#!/usr/bin/perl ## # Create a barebones NetInfo database that can be restored from niload. # Usage: create_restore_nidb masterhostname ipaddress # # The default tag is network. ## use Sys::Hostname; my $usage = "Usage: create_restore_nidb masterhostname ipaddress [tag]\nThe default tag is network\n"; my $nipath = "/var/db/netinfo"; if ($ARGV[0]) { $master = $ARGV[0]; } else { die $usage } if ($ARGV[1]) { $ipaddress = $ARGV[1]; } else { die $usage } if ($ARGV[2]) { $tag = $ARGV[2]; } else { $tag = network } my $nidb = "${NIPATH.EN_US}/${TAG.EN_US}.nidb"; die "Error: database ${NIDB.EN_US} exists\n" if (-d ${NIDB.EN_US}); my $nicl = "nicl -q -raw ${NIDB.EN_US}"; ## # For debugging: open(NICL, ">/dev/tty"); ## ## # Create the database ## system("${NICL.EN_US} -create"); open(NICL, "|${NICL.EN_US}"); ## # Setup root directory ## print NICL "create / master ${MASTER.EN_US}/${TAG.EN_US}\n"; print NICL "create /users\n"; print NICL "create /machines\n"; ## # Create a root user ## print NICL "cd /users\n"; print NICL "create root\n"; print NICL "cd root\n"; print NICL "create . passwd *\n"; print NICL "create . uid 0\n"; print NICL "create . gid 0\n"; print NICL "create . change 0\n"; print NICL "create . expire 0\n"; print NICL "create . realname \"System Administrator\"\n"; print NICL "create . home /var/root\n"; print NICL "create . shell /bin/tcsh\n"; print NICL "create . _writers_passwd root\n"; print NICL "cd ..\n"; ## # Create an entry for this machine ## print NICL "cd /machines\n"; print NICL "create $master ip_address $ipaddress\n"; print NICL "create $master serves ./${TAG.EN_US} ${MASTER.EN_US}/local\n"; print NICL "quit\n"; close (NICL);