my $query = $ENV{'QUERY_STRING'};
sub cmd {
- my ($c) = @_;
- $c .= " 2>&1";
- my @x = qx($c);
- foreach (@x) {
- print "> ".$_;
- }
+ my ($c) = @_;
+ $c .= " 2>&1";
+ my @x = qx($c);
+ foreach (@x) {
+ print "> ".$_;
+ }
}
+my @commands = split("-",$query);
+unless(defined $commands[0]) {
+ print "No valid operation given.\n";
+ exit;
+ }
print "Running Git Update\n";
-unless ($query =~ m/stable/) {
- print "Function not implemented.\n";
- exit;
- }
-
-unless ($query =~ m/config/) {
- print "Copying configuration file folder\n";
- cmd("cp -r ../config ../temp/config");
- }
+unless (defined $commands[1] && $commands[1] eq "config") {
+ print "Copying configuration file folder\n";
+ cmd("cp -r ../config ../temp/config");
+ }
print "Undoing changes in config files\n";
print "Pulling new data from server\n";
cmd("git pull ");
-unless ($query =~ m/config/) {
- print "Copying configuration file folder back\n";
- cmd("cp -r ../temp/config ../");
+print "Changing to branch $commands[0].\n";
+cmd("git checkout $commands[0]");
+
+
+unless (defined $commands[1] && $commands[1] eq "config") {
+ print "Copying configuration file folder back\n";
+ cmd("cp -r ../temp/config ../");
- print "Removing temporary configuration file folder\n";
- cmd("rm -r ../temp/config");
- }
+ print "Removing temporary configuration file folder\n";
+ cmd("rm -r ../temp/config");
+ }