diff --git a/xCAT-server-2.0/lib/xcat/plugins/fedora.pm b/xCAT-server-2.0/lib/xcat/plugins/fedora.pm index 51b4cf5f1..87034a050 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/fedora.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/fedora.pm @@ -76,7 +76,9 @@ sub process_request { return mkinstall($request,$callback,$doreq); } elsif ($request->{command}->[0] eq 'mknetboot') { return mknetboot($request,$callback,$doreq); - } + } elsif ($request->{command}->[0] eq 'packimage') { + packimage($request,$callback,$doreq); + } #$osver,$arch,$profile,$installroot,$callback); } sub mknetboot { @@ -89,6 +91,11 @@ sub mknetboot { my @nodes = @{$req->{node}}; my $ostab = xCAT::Table->new('nodetype'); my $sitetab = xCAT::Table->new('site'); + (my $sent) = $sitetab->getAttribs({key=>master},value); + my $imgsrv; + if ($sent and $sent->{value}) { + $imgsrv = $sent->{value}; + } my $installroot; if ($sitetab) { (my $ref) = $sitetab->getAttribs({key=>installdir},value); @@ -105,27 +112,37 @@ sub mknetboot { my $osver = $ent->{os}; my $arch = $ent->{arch}; my $profile = $ent->{profile}; - unless (-r "/$installroot/netboot/$osver/$arch/$profile/kernel") { - $callback->({error=>["No imageroot found, run genimage.pl -o $osver -p $profile on a system of type $arch"],errorcode=>[1]}); - next; - } - packimage($osver,$arch,$profile,$installroot,$callback); - mkpath("/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); - copy("/$installroot/netboot/$osver/$arch/$profile/kernel","/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); - copy("/$installroot/netboot/$osver/$arch/$profile/rootimg.gz","/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); - unless (-r "/$tftpdir/xcat/netboot/$osver/$arch/$profile/kernel" and -r "/$tftpdir/xcat/netboot/$osver/$arch/$profile/rootimg.gz") { - mkpath("/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); - copy("/$installroot/netboot/$osver/$arch/$profile/kernel","/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); - copy("/$installroot/netboot/$osver/$arch/$profile/rootimg.gz","/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); - } - unless (-r "/$tftpdir/xcat/netboot/$osver/$arch/$profile/kernel" and -r "/$tftpdir/xcat/netboot/$osver/$arch/$profile/rootimg.gz") { - $callback->({error=>["Netboot image creation failed for $node"],errorcode=>[1]}); + #packimage($osver,$arch,$profile,$installroot,$callback); + unless (-r "/$installroot/netboot/$osver/$arch/$profile/rootimg.gz" and + -r "/$installroot/netboot/$osver/$arch/$profile/kernel" and + -r "/$installroot/netboot/$osver/$arch/$profile/initrd.gz") { + $callback->({error=>["No packed image for platform $osver, architecture $arch, profile $profile, please run packimage -o $osver -p $profile -a $arch"],errorcode=>[1]}); next; + } + mkpath("/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); + #TODO: only copy if newer.. + copy("/$installroot/netboot/$osver/$arch/$profile/kernel","/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); + copy("/$installroot/netboot/$osver/$arch/$profile/initrd.gz","/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); + #copy("/$installroot/netboot/$osver/$arch/$profile/rootimg.gz","/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); + unless (-r "/$tftpdir/xcat/netboot/$osver/$arch/$profile/kernel" and -r "/$tftpdir/xcat/netboot/$osver/$arch/$profile/initrd.gz") { + $callback->({error=>["Copying to /$tftpdir/xcat/netboot/$osver/$arch/$profile failed"],errorcode=>[1]}); + next; + #mkpath("/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); + #copy("/$installroot/netboot/$osver/$arch/$profile/kernel","/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); + #copy("/$installroot/netboot/$osver/$arch/$profile/rootimg.gz","/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); } my $restab = xCAT::Table->new('noderes'); my $hmtab = xCAT::Table->new('nodehm'); my $ent = $restab->getNodeAttribs($node,['serialport','primarynic']); - my $kcmdline; + my $ient = $restab->getNodeAttribs($node,['servicenode']); + if ($ient and $ient->{servicenode}) { + $imgsrv = $ient->{servicenode}; + } + unless ($imgsrv) { + $callback->({error=>["Unable to determine image server for $node"]}); + next; + } + my $kcmdline = "imgurl=$imgsrv/install/netboot/$osver/$arch/$profile/rootimg.gz "; if (defined $ent->{serialport}) { my $sent = $hmtab->getNodeAttribs($node,['serialspeed','serialflow']); unless ($sent->{serialspeed}) { @@ -139,49 +156,11 @@ sub mknetboot { } $restab->setNodeAttribs($node,{ kernel=>"xcat/netboot/$osver/$arch/$profile/kernel", - initrd=>"xcat/netboot/$osver/$arch/$profile/rootimg.gz", + initrd=>"xcat/netboot/$osver/$arch/$profile/initrd.gz", kcmdline=>$kcmdline }); } } -sub packimage { - my $osver = shift; - my $arch = shift; - my $profile = shift; - my $installroot = shift; - my $callback = shift; - unless ($installroot) { - $callback->({error=>["No installdir defined in site table"],errorcode=>[1]}); - return; - } - my $oldpath=cwd; - my $exlistloc; - if (-r "$::XCATROOT/share/xcat/netboot/fedora/$profile.$osver.$arch.exlist") { - $exlistloc = "$::XCATROOT/share/xcat/netboot/fedora/$profile.$osver.$arch.exlist"; - } elsif (-r "$::XCATROOT/share/xcat/netboot/fedora/$profile.$arch.exlist") { - $exlistloc = "$::XCATROOT/share/xcat/netboot/fedora/$profile.$arch.exlist"; - } elsif (-r "$::XCATROOT/share/xcat/netboot/fedora/$profile.$osver.exlist") { - $exlistloc = "$::XCATROOT/share/xcat/netboot/fedora/$profile.$osver.exlist"; - } elsif (-r "$::XCATROOT/share/xcat/netboot/fedora/$profile.exlist") { - $exlistloc = "$::XCATROOT/share/xcat/netboot/fedora/$profile.exlist"; - } else { - $callback->({error=>["Unable to finde file exclusion list under $::XCATROOT/share/xcat/netboot/fedora/ for $profile/$arch/$osver"],errorcode=>[1]}); - next; - } - my $exlist; - open($exlist,"<",$exlistloc); - my $excludestr = "find . "; - while (<$exlist>) { - chomp $_; - $excludestr .= "'!' -wholename '".$_."' -a "; - } - close($exlist); - $excludestr =~ s!-a \z!|cpio -H newc -o | gzip -c - > ../rootimg.gz!; - chdir("$installroot/netboot/$osver/$arch/$profile/rootimg"); - system($excludestr); - print $excludestr. " ". $oldpath."\n"; - chdir($oldpath); -} sub mkinstall { my $request = shift; my $callback = shift; diff --git a/xCAT-server-2.0/share/xcat/netboot/fedora/compute.ppc64.pkglist b/xCAT-server-2.0/share/xcat/netboot/fedora/compute.ppc64.pkglist new file mode 100644 index 000000000..95c92be4f --- /dev/null +++ b/xCAT-server-2.0/share/xcat/netboot/fedora/compute.ppc64.pkglist @@ -0,0 +1,7 @@ +bash +glibc.ppc64 +dhclient +kernel.ppc64 +busybox-anaconda +openssh-server +openssh-clients diff --git a/xCAT-server-2.0/share/xcat/netboot/fedora/genimage b/xCAT-server-2.0/share/xcat/netboot/fedora/genimage new file mode 100755 index 000000000..c19aef66a --- /dev/null +++ b/xCAT-server-2.0/share/xcat/netboot/fedora/genimage @@ -0,0 +1,272 @@ +#!/usr/bin/env perl +use File::Basename; +use File::Path; +use File::Copy; +use File::Find; +use Getopt::Long; +Getopt::Long::Configure("bundling"); +Getopt::Long::Configure("pass_through"); + +my $prinic; #TODO be flexible on node primary nic +my $othernics; #TODO be flexible on node primary nic +my $netdriver; +my $arch = `uname -m`; +chomp($arch); +my %libhash; +my @filestoadd; +my $profile; +my $osver; +GetOptions( + #'a=s' => \$architecture, + 'p=s' => \$profile, + 'o=s' => \$osver, + 'n=s' => \$netdriver, + 'i=s' => \$prinic, + 'r=s' => \$othernics +); +unless ($osver and $profile and $netdriver and $prinic) { + print 'Usage: genimage -i -n [-r ] -o -p '."\n"; + print "Examples:\n"; + print " genimage -i eth0 -n tg3 -o fedora8 -p compute\n"; + print " genimage -i eth0 -r eth1,eth2 -n tg3,bnx2 -o fedora8 -p compute\n"; + exit 1; +} +my @ndrivers; +foreach (split /,/,$netdriver) { + unless (/\.ko$/) { + s/$/.ko/; + } + if (/^$/) { + next; + } + push @ndrivers,$_; +} + +my $installroot = "/install"; +my $srcdir = "$installroot/$osver/$arch"; +unless ( -d $srcdir."/repodata" ) { + print "Need $installroot/$osver/$arch/repodata available from a system that has ran copycds on $osver $arch"; + exit 1; +} +my $pathtofiles=dirname($0); +my $yumconfig; +open($yumconfig,">","/tmp/genimage.$$.yum.conf"); +print $yumconfig "[$osver-$arch]\nname=$osver-$arch\nbaseurl=file://$srcdir\ngpgpcheck=0\n"; +close($yumconfig); +my $yumcmd = "yum -y -c /tmp/genimage.$$.yum.conf --installroot=$installroot/netboot/$osver/$arch/$profile/rootimg/ --disablerepo=* --enablerepo=$osver-$arch install "; +mkpath("$installroot/netboot/$osver/$arch/$profile/rootimg/var/lib/yum"); +open($yumconfig,"<","$pathtofiles/$profile.pkglist"); +while (<$yumconfig>) { + chomp; + $yumcmd .= $_ . " "; +} +$yumcmd =~ s/ $/\n/; +my $rc = system($yumcmd); +if ($rc) { + print "yum invocation failed\n"; + exit 1; +} +mkinitrd(); +postscripts(); #run 'postscripts' +unlink "/tmp/genimage.$$.yum.conf"; + +sub getlibs { + my $file = shift; + my $liblist = `chroot $installroot/netboot/$osver/$arch/$profile/rootimg ldd $file`; + my @libs = split/\n/,$liblist; + my @return; + foreach (@libs) { + (my $temp1,my $temp2) = split />/,$_,2; + (my $whitespace,$temp1,$temp2) = split /\s+/,$temp2,4; + unless ($temp1 =~ /\//) { + next; + } + $temp1 =~ s/^\///; + $libhash{$temp1}=1; + } +} + +sub mkinitrd { + mkpath("/tmp/xcatinitrd.$$/bin"); + symlink("bin","/tmp/xcatinitrd.$$/sbin"); + mkpath("/tmp/xcatinitrd.$$/usr/bin"); + mkpath("/tmp/xcatinitrd.$$/usr/sbin"); + mkpath("/tmp/xcatinitrd.$$/usr/lib"); + mkpath("/tmp/xcatinitrd.$$/lib/firmware"); + mkpath("/tmp/xcatinitrd.$$/proc"); + mkpath("/tmp/xcatinitrd.$$/sys"); + mkpath("/tmp/xcatinitrd.$$/dev/mapper"); + mkpath("/tmp/xcatinitrd.$$/sysroot"); + mkpath("/tmp/xcatinitrd.$$/etc/ld.so.conf.d"); + mkpath("/tmp/xcatinitrd.$$/var/lib/dhclient"); + my $inifile; + open($inifile,">","/tmp/xcatinitrd.$$/init"); + print $inifile "#!/sbin/busybox.anaconda sh\n"; + print $inifile "busybox.anaconda mount -t proc /proc /proc\n"; + print $inifile "busybox.anaconda --install\n"; + print $inifile "mount -t sysfs /sys /sys\n"; + print $inifile "mount -o mode=0755 -t tmpfs /dev /dev\n"; + print $inifile "mkdir /dev/pts\n"; + print $inifile "mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts\n"; + print $inifile "mkdir /dev/shm\n"; + print $inifile "mkdir /dev/mapper\n"; + print $inifile "mknod /dev/null c 1 3\n"; + print $inifile "mknod /dev/zero c 1 5\n"; + print $inifile "mknod /dev/systty c 4 0\n"; + print $inifile "mknod /dev/tty c 5 0\n"; + print $inifile "mknod /dev/console c 5 1\n"; + print $inifile "mknod /dev/ptmx c 5 2\n"; + print $inifile "mknod /dev/rtc c 10 135\n"; + print $inifile "mknod /dev/tty0 c 4 0\n"; + print $inifile "mknod /dev/tty1 c 4 1\n"; + print $inifile "mknod /dev/tty2 c 4 2\n"; + print $inifile "mknod /dev/tty3 c 4 3\n"; + print $inifile "mknod /dev/tty4 c 4 4\n"; + print $inifile "mknod /dev/tty5 c 4 5\n"; + print $inifile "mknod /dev/tty6 c 4 6\n"; + print $inifile "mknod /dev/tty7 c 4 7\n"; + print $inifile "mknod /dev/tty8 c 4 8\n"; + print $inifile "mknod /dev/tty9 c 4 9\n"; + print $inifile "mknod /dev/tty10 c 4 10\n"; + print $inifile "mknod /dev/tty11 c 4 11\n"; + print $inifile "mknod /dev/tty12 c 4 12\n"; + print $inifile "mknod /dev/ttyS0 c 4 64\n"; + print $inifile "mknod /dev/ttyS1 c 4 65\n"; + print $inifile "mknod /dev/ttyS2 c 4 66\n"; + print $inifile "mknod /dev/ttyS3 c 4 67\n"; + foreach (@ndrivers) { + print $inifile "insmod /lib/$_\n"; + } + print $inifile "netstart\n"; + print $inifile "cd /\n"; + print $inifile "for i in `cat /proc/cmdline`; do\n"; + print $inifile " KEY=`echo \$i |awk -F= '{print \$1}'`\n"; + print $inifile " if [ \"\$KEY\" = 'imgurl' ]; then\n"; + print $inifile " wget http://`echo \$i | awk -F= '{print \$2}'`\n"; + print $inifile " fi\n"; + print $inifile "done\n"; + print $inifile "mount -t tmpfs rootfs /sysroot\n"; + print $inifile "cd /sysroot\n"; + print $inifile "if [ ! -r /rootimg.gz ]; then\n"; + print $inifile " echo -n Failed to download image, panicing in 5...\n"; + print $inifile " for i in 4 3 2 1 0; do\n"; + print $inifile " /bin/sleep 1\n"; + print $inifile " echo -n \$i...\n"; + print $inifile " done\n"; + print $inifile " echo\n"; + print $inifile " exit\n"; + print $inifile "fi\n"; + print $inifile "echo -n \"Extracting root filesystem:\"\n"; + print $inifile "zcat /rootimg.gz |cpio -idum\n"; + print $inifile "echo Done"; + print $inifile "cd /\n"; + print $inifile "cp /var/lib/dhclient/dhclient.leases /sysroot/dev/.dhclient-eth0.leases\n"; + print $inifile "mknod /sysroot/dev/console c 5 1\n"; + print $inifile "exec switch_root -c /dev/console /sysroot /sbin/init\n"; + close($inifile); + open($inifile,">"."/tmp/xcatinitrd.$$/bin/netstart"); + print $inifile "#!/sbin/nash\n"; + print $inifile "network --device eth0 --bootproto dhcp\n"; + close($inifile); + chmod(0755,"/tmp/xcatinitrd.$$/init"); + chmod(0755,"/tmp/xcatinitrd.$$/bin/netstart"); + @filestoadd=("lib/ld.so.1"); + foreach ("sbin/nash","sbin/busybox.anaconda","sbin/rmmod") { + getlibs($_); + push @filestoadd,$_; + } + push @filestoadd,keys %libhash; + find(\&isnetdriver, <$installroot/netboot/$osver/$arch/$profile/rootimg/lib/modules/*>); + foreach (@filestoadd) { + if (ref($_)) { + copy("$installroot/netboot/$osver/$arch/$profile/rootimg/".$_->[0],"/tmp/xcatinitrd.$$/".$_->[1]); + chmod 0755,"/tmp/xcatinitrd.$$/".$_->[1]; + } else { + copy("$installroot/netboot/$osver/$arch/$profile/rootimg/$_","/tmp/xcatinitrd.$$/$_"); + chmod 0755,"/tmp/xcatinitrd.$$/".$_; + } + } + + #copy("$installroot/netboot/$osver/$arch/$profile/rootimg/lib/modules/*d","/tmp/xcatinitrd.$$/$_"); + system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|gzip -9 -c - > $installroot/netboot/$osver/$arch/$profile/initrd.gz"); + system("rm -rf /tmp/xcatinitrd.$$"); + +} + +sub isnetdriver { + foreach (@ndrivers) { + if ($File::Find::name =~ /$_/) { + my $filetoadd = $File::Find::name; + $filetoadd =~ s!$installroot/netboot/$osver/$arch/$profile/rootimg/!!; + push @filestoadd,[$filetoadd,"lib/$_"]; + } + } +} + + + + + + + +sub postscripts { # TODO: customized postscripts + generic_post(); + if (-d "$installroot/postscripts/hostkeys") { + for my $key (<$installroot/postscripts/hostkeys/*key>) { + copy ($key,"$installroot/netboot/$osver/$arch/$profile/rootimg/etc/ssh/"); + } + chmod 0600,; + } + if (-d "/$installroot/postscripts/.ssh") { + mkpath("/$installroot/netboot/$osver/$arch/$profile/rootimg/root/.ssh"); + chmod(0700,"/$installroot/netboot/$osver/$arch/$profile/rootimg/root/.ssh/"); + for my $file () { + copy ($file,"/$installroot/netboot/$osver/$arch/$profile/rootimg/root/.ssh/"); + } + chmod(0600,); + } +} + +sub generic_post { #This function is meant to leave the image in a state approximating a normal install + my $cfgfile; + unlink("$installroot/netboot/$osver/$arch/$profile/rootimg/dev/null"); + system("mknod $installroot/netboot/$osver/$arch/$profile/rootimg/dev/null c 1 3"); + open($cfgfile,">","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/fstab"); + print $cfgfile "devpts /dev/pts devpts gid=5,mode=620 0 0\n"; + print $cfgfile "tmpfs /dev/shm tmpfs defaults 0 0\n"; + print $cfgfile "proc /proc proc defaults 0 0\n"; + print $cfgfile "sysfs /sys sysfs defaults 0 0\n"; + close($cfgfile); + open($cfgfile,">","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/sysconfig/network"); + print $cfgfile "NETWORKING=yes\n"; + close($cfgfile); + open($cfgfile,">","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/sysconfig/network-scripts/ifcfg-$prinic"); + print $cfgfile "ONBOOT=yes\nBOOTPROTO=dhcp\nDEVICE=$prinic\n"; + close($cfgfile); + foreach (split /,/,$othernics) { + if (/^$/) { next; } + open($cfgfile,">","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/sysconfig/network-scripts/ifcfg-$_"); + print $cfgfile "ONBOOT=yes\nBOOTPROTO=dhcp\nDEVICE=$_\n"; + close($cfgfile); + } + open($cfgfile,">","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/rc3.d/S60gettyset"); + print $cfgfile "#!/bin/bash\n"; + print $cfgfile "for i in `cat /proc/cmdline`; do\n"; + print $cfgfile ' KEY=`echo $i|cut -d= -f 1`'."\n"; + print $cfgfile " if [ \"\$KEY\" == \"console\" ]; then\n"; + print $cfgfile " VALUE=`echo \$i | cut -d= -f 2`\n"; + print $cfgfile " COTTY=`echo \$VALUE|cut -d, -f 1`\n"; + print $cfgfile " COSPEED=`echo \$VALUE|cut -d, -f 2|cut -dn -f 1`\n"; + print $cfgfile " if echo \$VALUE | grep n8r; then\n"; + print $cfgfile " FLOWFLAG=\"-h\"\n"; + print $cfgfile " fi\n"; + print $cfgfile " echo xco:2345:respawn:/sbin/agetty \$FLOWFLAG \$COTTY \$COSPEED xterm >> /etc/inittab\n"; + print $cfgfile " init q\n"; + print $cfgfile " fi\n"; + print $cfgfile "done\n"; + close($cfgfile); + chmod(0755,"$installroot/netboot/$osver/$arch/$profile/rootimg/etc/rc3.d/S60gettyset"); + #link("$installroot/netboot/$osver/$arch/$profile/rootimg/sbin/init","$installroot/netboot/$osver/$arch/$profile/rootimg/init"); + + rename(<$installroot/netboot/$osver/$arch/$profile/rootimg/boot/vmlinuz*>,"$installroot/netboot/$osver/$arch/$profile/kernel"); +} diff --git a/xCAT-server-2.0/share/xcat/netboot/fedora/genimage.pl b/xCAT-server-2.0/share/xcat/netboot/fedora/genimage.pl deleted file mode 100755 index 76437a400..000000000 --- a/xCAT-server-2.0/share/xcat/netboot/fedora/genimage.pl +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env perl -use File::Basename; -use File::Path; -use File::Copy; -use Getopt::Long; -Getopt::Long::Configure("bundling"); -Getopt::Long::Configure("pass_through"); - -my $prinic = 'eth0'; #TODO be flexible on node primary nic -my $secnic = 'eth1'; #TODO be flexible on node primary nic -my $arch = `uname -m`; -chomp($arch); -my $profile; -my $osver; -GetOptions( - #'a=s' => \$architecture, - 'p=s' => \$profile, - 'o=s' => \$osver, -); -unless ($osver and $profile) { - print 'Usage: genimage -o $OSVER -p $PROFILE'."\n"; - exit 1; -} - -my $installroot = "/install"; -my $srcdir = "$installroot/$osver/$arch"; -unless ( -d $srcdir."/repodata" ) { - print "Need $installroot/$osver/$arch/repodata available from a system that has ran copycds on $osver $arch"; - exit 1; -} -my $pathtofiles=dirname($0); -my $yumconfig; -open($yumconfig,">","/tmp/genimage.$$.yum.conf"); -print $yumconfig "[$osver-$arch]\nname=$osver-$arch\nbaseurl=file://$srcdir\ngpgpcheck=0\n"; -close($yumconfig); -my $yumcmd = "yum -y -c /tmp/genimage.$$.yum.conf --installroot=$installroot/netboot/$osver/$arch/$profile/rootimg/ --disablerepo=* --enablerepo=$osver-$arch install "; -open($yumconfig,"<","$pathtofiles/$profile.pkglist"); -while (<$yumconfig>) { - chomp; - $yumcmd .= $_ . " "; -} -$yumcmd =~ s/ $/\n/; -my $rc = system($yumcmd); -if ($rc) { - print "yum invocation failed\n"; - exit 1; -} -postscripts(); #run 'postscripts' -unlink "/tmp/genimage.$$.yum.conf"; - - - -sub postscripts { # TODO: customized postscripts - generic_post(); - if (-d "$installroot/postscripts/hostkeys") { - for my $key (<$installroot/postscripts/hostkeys/*key>) { - copy ($key,"$installroot/netboot/$osver/$arch/$profile/rootimg/etc/ssh/"); - } - chmod 0600,; - } - if (-d "/$installroot/postscripts/.ssh") { - mkpath("/$installroot/netboot/$osver/$arch/$profile/rootimg/root/.ssh"); - chmod(0700,"/$installroot/netboot/$osver/$arch/$profile/rootimg/root/.ssh/"); - for my $file () { - copy ($file,"/$installroot/netboot/$osver/$arch/$profile/rootimg/root/.ssh/"); - } - chmod(0600,); - } -} - -sub generic_post { #This function is meant to leave the image in a state approximating a normal install - my $cfgfile; - unlink("$installroot/netboot/$osver/$arch/$profile/rootimg/dev/null"); - system("mknod $installroot/netboot/$osver/$arch/$profile/rootimg/dev/null c 1 3"); - open($cfgfile,">","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/fstab"); - print $cfgfile "devpts /dev/pts devpts gid=5,mode=620 0 0\n"; - print $cfgfile "tmpfs /dev/shm tmpfs defaults 0 0\n"; - print $cfgfile "proc /proc proc defaults 0 0\n"; - print $cfgfile "sysfs /sys sysfs defaults 0 0\n"; - close($cfgfile); - open($cfgfile,">","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/sysconfig/network"); - print $cfgfile "NETWORKING=yes\n"; - close($cfgfile); - open($cfgfile,">","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/sysconfig/network-scripts/ifcfg-$prinic"); - print ("$installroot/netboot/$osver/$arch/$profile/rootimg/etc/sysconfig/network-scripts/ifcfg-$prinic"); - print $cfgfile "ONBOOT=yes\nBOOTPROTO=dhcp\nDEVICE=$prinic\n"; - close($cfgfile); - open($cfgfile,">","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/sysconfig/network-scripts/ifcfg-$secnic"); - print $cfgfile "ONBOOT=no\nBOOTPROTO=dhcp\nDEVICE=$secnic\n"; - close($cfgfile); - link("$installroot/netboot/$osver/$arch/$profile/rootimg/sbin/init","$installroot/netboot/$osver/$arch/$profile/rootimg/init"); - rename(<$installroot/netboot/$osver/$arch/$profile/rootimg/boot/vmlinuz*>,"$installroot/netboot/$osver/$arch/$profile/kernel"); -}