#!/root/usr/bin/perl
#Tag 0x00000f00
#ident "$Revision $"
#
# Custom configuration script for use in the miniroot
#
# Fix up the Perl @INC for use in the miniroot:

BEGIN {
    require 5.003;		# we're shipping at least 5.004
    # this method works on all IRIX/Perl5 releases
    my(@new) = reverse @INC;
    my($dir);
    foreach $dir (@new) {
	unshift(@INC, "/root".$dir); # catch-22: $mountdir not yet defined
    }
    unshift(@INC, "/custom"); # chicken-or-egg: $custom not yet defined
}

# NOTE: because the Perl library is in /usr/share, and the system may be
# configured to NFS mount /usr/share, and NFS mounts won't be active in
# the miniroot, it would be wise to not use any standard modules in the
# miniroot, unless you are sure that they will be there...

require "ConfigMR.pl";		# therefore, old-style require

# for testing only:
$debug = @ARGV ? 1 : 0;
$mountdir = shift if @ARGV;
$custom = shift if @ARGV;

print mergeHostFile("$custom/hosts"), " hosts entries merged\n";

# change this to your own host!
#configNetworking("urthr", "domain.com", "255.255.255.0", "10.62.51.133");
# if you are happy with the DHCP-ed hostname, then this version works:
#configNetworking("", "domain.com", "", "");
# and if it is also in the merged hosts file (for the domain):
configNetworking("", "", "", "");
# note that a netmask of 255.255.255.0 (or 0xffffff00) is the script default.

chkconfig("verbose", "on");	# admin preference

# get the rest of the config files
print installTree(), " tree files copied\n";
print installSep(), " sep files copied\n";

# do this BEFORE adding users...
movedir("/usr/people", "/var/people");
cpPasswd();                     # copy the password file

makeauser("scotth", "01711");
print makeusers(), " user directories created\n";

# here is an example of adding your own functions to this script:

# install a network printer
# (the miniroot /tmp is not created writable by non-root, and printer
#  stuff runs as user lp...)
if (! -d "/root/tmp") {
    # create the tmp directory if it doesn't exist.
    mkdir ("/root/tmp", 01777);
} else {
    # and ensure that it is writable by non-root
    chmod (01777, "/root/tmp");
}
# add the printer host to the $mountdir hosts file
add2hosts("10.62.51.138", "printserv.my.domain", "printserv", "printers");
# add the printer(s)
chrootcmd("/usr/sbin/mknetpr", "PostScript", "printserv", "printer3");
chrootcmd("/usr/sbin/mknetpr", "Color", "printserv", "color1");


# I like this on my test machine:
#mkNDSslave("verthande.domain.com:0.0", "-slaveright");

print STDERR "\%INC= ", join("\n", keys %INC), "\n" if $debug;
exit 0;
