Commit 4315628a authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Make admin user optional when baking the image.

parent b8fb2b71
...@@ -97,8 +97,7 @@ my %configvars = ("address" => undef, ...@@ -97,8 +97,7 @@ my %configvars = ("address" => undef,
"forwarders" => undef, "forwarders" => undef,
"hostname" => undef, "hostname" => undef,
"timezone" => undef, "timezone" => undef,
"rootpswd" => undef, "rootpswd" => undef);
"adminuser" => undef);
open(CN, $filename) open(CN, $filename)
or Fatal("Could not open $filename: $!"); or Fatal("Could not open $filename: $!");
...@@ -211,15 +210,19 @@ if (-e "$MNTPOINT/etc/lastadmin") { ...@@ -211,15 +210,19 @@ if (-e "$MNTPOINT/etc/lastadmin") {
system("chroot $MNTPOINT /usr/local/bin/mkadmin.pl -r $lastadmin") == 0 system("chroot $MNTPOINT /usr/local/bin/mkadmin.pl -r $lastadmin") == 0
or Fatal("Could not add admin user"); or Fatal("Could not add admin user");
} }
unlink("$MNTPOINT/etc/lastadmin");
} }
my $admin = $configvars{"adminuser"}; if (exists($configvars{"adminuser"})) {
print "Adding admin user $admin\n"; my $admin = $configvars{"adminuser"};
system("/bin/cp -f $pubkey $MNTPOINT/tmp/key.pub") == 0 print "Adding admin user $admin\n";
system("/bin/cp -f $pubkey $MNTPOINT/tmp/key.pub") == 0
or Fatal("Could not copy $pubkey to $MNTPOINT/tmp"); or Fatal("Could not copy $pubkey to $MNTPOINT/tmp");
system("chroot $MNTPOINT /usr/local/bin/mkadmin.pl $admin /tmp/key.pub") == 0 system("chroot $MNTPOINT ".
or Fatal("Could not add admin user"); "/usr/local/bin/mkadmin.pl $admin /tmp/key.pub")
system("echo '$admin' > $MNTPOINT/etc/lastadmin"); == 0 or Fatal("Could not add admin user");
system("echo '$admin' > $MNTPOINT/etc/lastadmin");
}
exit(0) exit(0)
if (!$snapshot); if (!$snapshot);
......
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