Commit 3eadc480 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Minor fixes to regular expressions.

parent e9005e54
...@@ -66,7 +66,7 @@ if ($_ =~ /^FREE/) { ...@@ -66,7 +66,7 @@ if ($_ =~ /^FREE/) {
print STDOUT " Free!\n"; print STDOUT " Free!\n";
exit(0); exit(0);
} }
if ($_ =~ /ALLOCATED=(\w*)\/(\w*)/) { if ($_ =~ /ALLOCATED=([-\@\w.]*)\/([-\@\w.]*)/) {
print STDOUT " Allocated: $1/$2!\n"; print STDOUT " Allocated: $1/$2!\n";
$project = $1; $project = $1;
} }
...@@ -190,7 +190,7 @@ open(TM, "$TMCC $NODE $ACCTCMD |") ...@@ -190,7 +190,7 @@ open(TM, "$TMCC $NODE $ACCTCMD |")
or die "Cannot start $TMCC: $!"; or die "Cannot start $TMCC: $!";
while (<TM>) { while (<TM>) {
if ($_ =~ /^ADDGROUP NAME=([0-9a-zA-Z]+) GID=([0-9]+)/) { if ($_ =~ /^ADDGROUP NAME=([-\@\w.]+) GID=([0-9]+)/) {
print STDOUT " Group: $1/$2\n"; print STDOUT " Group: $1/$2\n";
$group = $1; $group = $1;
...@@ -219,16 +219,24 @@ while (<TM>) { ...@@ -219,16 +219,24 @@ while (<TM>) {
$name = $1; $name = $1;
} }
print STDOUT " User: $login/$uid/$gid/$root/$name\n"; print STDOUT " User: $login/$uid/$gid/$root/$name\n";
($exists) = getpwuid($uid); ($exists) = getpwuid($uid);
if ($exists) { if ($exists) {
if ($root) {
$GLIST = "-G wheel,$gid";
}
else {
$GLIST = "-G $gid";
}
system("$PW usermod $login $GLIST");
next; next;
} }
$GLIST = " "; $GLIST = " ";
if ($root) { if ($root) {
$GLIST = "-G wheel "; $GLIST = "-G wheel";
} }
if (system("$PW useradd $login -u $uid -g $gid $GLIST ". if (system("$PW useradd $login -u $uid -g $gid $GLIST ".
"-d /users/$login -s /bin/tcsh -c \"$name\"") != 0) { "-d /users/$login -s /bin/tcsh -c \"$name\"") != 0) {
print STDERR "Error adding new user $login\n"; print STDERR "Error adding new user $login\n";
......
...@@ -19,6 +19,7 @@ my $DELAYCMD = "delay"; ...@@ -19,6 +19,7 @@ my $DELAYCMD = "delay";
my $IFCONFIG = "/sbin/ifconfig eth%d inet %s netmask %s\n"; my $IFCONFIG = "/sbin/ifconfig eth%d inet %s netmask %s\n";
my $CP = "/bin/cp -f"; my $CP = "/bin/cp -f";
my $USERADD = "/usr/sbin/useradd"; my $USERADD = "/usr/sbin/useradd";
my $USERMOD = "/usr/sbin/usermod";
my $GROUPADD = "/usr/sbin/groupadd"; my $GROUPADD = "/usr/sbin/groupadd";
my $IFACE = "eth"; my $IFACE = "eth";
my $CTLIFACE = "eth4"; my $CTLIFACE = "eth4";
...@@ -66,7 +67,7 @@ if ($_ =~ /^FREE/) { ...@@ -66,7 +67,7 @@ if ($_ =~ /^FREE/) {
print STDOUT " Free!\n"; print STDOUT " Free!\n";
exit(0); exit(0);
} }
if ($_ =~ /ALLOCATED=(\w*)\/(\w*)/) { if ($_ =~ /ALLOCATED=([-\@\w.]*)\/([-\@\w.]*)/) {
print STDOUT " Allocated: $1/$2!\n"; print STDOUT " Allocated: $1/$2!\n";
$project = $1; $project = $1;
} }
...@@ -122,7 +123,7 @@ open(TM, "$TMCC $NODE $ACCTCMD |") ...@@ -122,7 +123,7 @@ open(TM, "$TMCC $NODE $ACCTCMD |")
or die "Cannot start $TMCC: $!"; or die "Cannot start $TMCC: $!";
while (<TM>) { while (<TM>) {
if ($_ =~ /^ADDGROUP NAME=([0-9a-zA-Z]+) GID=([0-9]+)/) { if ($_ =~ /^ADDGROUP NAME=([-\@\w.]+) GID=([0-9]+)/) {
print STDOUT " Group: $1/$2\n"; print STDOUT " Group: $1/$2\n";
$group = $1; $group = $1;
...@@ -151,8 +152,16 @@ while (<TM>) { ...@@ -151,8 +152,16 @@ while (<TM>) {
$name = $1; $name = $1;
} }
print STDOUT " User: $login/$uid/$gid/$root/$name\n"; print STDOUT " User: $login/$uid/$gid/$root/$name\n";
($exists) = getpwuid($uid); ($exists) = getpwuid($uid);
if ($exists) { if ($exists) {
if ($root) {
$GLIST = "-G root,$gid";
}
else {
$GLIST = "-G $gid";
}
system("$USERMOD $GLIST $login");
next; next;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment