diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.pkglist index 15da4d211..eed35bbc1 100644 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.pkglist +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.pkglist @@ -2,7 +2,7 @@ bash nfs-common openssl dhcp3-client -linux-image-generic +linux-image-server openssh-server openssh-client wget @@ -10,4 +10,3 @@ vim ntp rsyslog rsync -busybox-static diff --git a/xCAT-server/share/xcat/netboot/ubuntu/dracut/check b/xCAT-server/share/xcat/netboot/ubuntu/dracut/check new file mode 100755 index 000000000..d7cc89ce0 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/ubuntu/dracut/check @@ -0,0 +1,3 @@ +#!/bin/sh +[ "$1" = "-d" ] && echo network +exit 0 diff --git a/xCAT-server/share/xcat/netboot/ubuntu/dracut/install.netboot b/xCAT-server/share/xcat/netboot/ubuntu/dracut/install.netboot new file mode 100755 index 000000000..6436b7302 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/ubuntu/dracut/install.netboot @@ -0,0 +1,7 @@ +#!/bin/sh +echo $drivers +dracut_install wget cpio gzip dash modprobe touch echo cut wc +dracut_install grep ifconfig hostname awk egrep grep dirname expr +dracut_install mount.nfs +inst "$moddir/xcatroot" "/sbin/xcatroot" +inst_hook cmdline 10 "$moddir/xcat-cmdline.sh" diff --git a/xCAT-server/share/xcat/netboot/ubuntu/dracut/install.statelite b/xCAT-server/share/xcat/netboot/ubuntu/dracut/install.statelite new file mode 100755 index 000000000..19e3f95b3 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/ubuntu/dracut/install.statelite @@ -0,0 +1,5 @@ +#!/bin/sh +echo $drivers +dracut_install wget cpio gzip dash modprobe wc touch echo cut +dracut_install grep ifconfig hostname awk egrep grep dirname expr +inst_hook pre-pivot 5 "$moddir/xcat-prepivot.sh" diff --git a/xCAT-server/share/xcat/netboot/ubuntu/dracut/installkernel b/xCAT-server/share/xcat/netboot/ubuntu/dracut/installkernel new file mode 100755 index 000000000..7902ce5f7 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/ubuntu/dracut/installkernel @@ -0,0 +1,2 @@ +#!/bin/bash +instmods nfs sunrpc diff --git a/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcat-cmdline.sh b/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcat-cmdline.sh new file mode 100644 index 000000000..d445cf585 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcat-cmdline.sh @@ -0,0 +1,4 @@ +root=1 +rootok=1 +netroot=xcat +echo '[ -e $NEWROOT/proc ]' > /initqueue-finished/xcatroot.sh diff --git a/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcat-prepivot.sh b/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcat-prepivot.sh new file mode 100755 index 000000000..5c6256df6 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcat-prepivot.sh @@ -0,0 +1,89 @@ +#!/bin/sh +NEWROOT=/sysroot +SERVER=${SERVER%%/*} +SERVER=${SERVER%:} +RWDIR=.statelite +if [ ! -z $STATEMNT ]; then #btw, uri style might have left future options other than nfs open, will u se // to detect uri in the future I guess + SNAPSHOTSERVER=${STATEMNT%:*} + SNAPSHOTROOT=${STATEMNT#*/} + #echo $SNAPSHOTROOT + #echo $SNAPSHOTSERVER + # may be that there is not server and just a directory. + if [ -z $SNAPSHOTROOT ]; then + SNAPSHOTROOT=$SNAPSHOTSERVER + SNAPSHOTSERVER= + fi +fi + +echo Setting up Statelite +mkdir -p $NEWROOT + +# now we need to mount the rest of the system. This is the read/write portions +# echo Mounting snapshot directories + +MAXTRIES=7 +ITER=0 +if [ ! -e "$NEWROOT/$RWDIR" ]; then + echo "" + echo "This NFS root directory doesn't have a /$RWDIR directory for me to mount a rw filesystem. You'd better create it... " + echo "" + /bin/sh +fi + +if [ ! -e "$NEWROOT/etc/init.d/statelite" ]; then + echo "" + echo "$NEWROOT/etc/init.d/statelite doesn't exist. Perhaps you didn't create this image with th e -m statelite mode" + echo "" + /bin/sh +fi + +mount -t tmpfs rw $NEWROOT/$RWDIR +mkdir -p $NEWROOT/$RWDIR/tmpfs +ME=`hostname` + +# mount the SNAPSHOT directory here for persistent use. +if [ ! -z $SNAPSHOTSERVER ]; then + mkdir -p $NEWROOT/$RWDIR/persistent + MAXTRIES=5 + ITER=0 + if [ -z $MNTOPTS ]; then + MNT_OPTIONS="nolock,rsize=32768,tcp,nfsvers=3,timeo=14" + else + MNT_OPTIONS=$MNTOPTS + fi + while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do + ITER=$(( ITER + 1 )) + if [ "$ITER" == "$MAXTRIES" ]; then + echo "Your are dead, rpower $ME boot to play again." + echo "Possible problems: +1. $SNAPSHOTSERVER is not exporting $SNAPSHOTROOT ? +2. Is DNS set up? Maybe that's why I can't mount $SNAPSHOTSERVER." + /bin/sh + exit + fi + RS= $(( $RANDOM % 20 )) + echo "Trying again in $RS seconds..." + sleep $RS + done +fi + +# TODO: handle the dhclient/resolv.conf/ntp, etc +$NEWROOT/etc/init.d/statelite +READONLY=yes +export READONLY +fastboot=yes +export fastboot +keep_old_ip=yes +export keep_old_ip +mount -n --bind /dev $NEWROOT/dev +mount -n --bind /proc $NEWROOT/proc +mount -n --bind /sys $NEWROOT/sys + +if [ -d "$NEWROOT/etc/sysconfig" -a ! -e "$NEWROOT/etc/sysconfig/selinux" ]; then + echo "SELINUX=disabled" >> "$NEWROOT/etc/sysconfig/selinux" +fi + +# inject new exit_if_exists +echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > /initqueue/xcat.sh +# force udevsettle to break +> /initqueue/work diff --git a/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcatroot b/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcatroot new file mode 100755 index 000000000..b02abe09f --- /dev/null +++ b/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcatroot @@ -0,0 +1,192 @@ +#!/bin/sh +NEWROOT=$3 +RWDIR=.statelite +XCATMASTER=$XCAT + +if [ ! -z "$imgurl" ]; then + if [ xhttp = x${imgurl%%:*} ]; then + NFS=0 + FILENAME=${imgurl##*/} + while [ ! -r "$FILENAME" ]; do + echo Getting $imgurl... + if ! wget $imgurl; then + rm -f $FILENAME + sleep 27 + fi + done + elif [ xnfs = x${imgurl%%:*} ]; then + NFS=1 + SERVER=${imgurl#nfs:} + SERVER=${SERVER#/} + SERVER=${SERVER#/} + ROOTDIR=$SERVER + SERVER=${SERVER%%/*} + SERVER=${SERVER%:} + ROOTDIR=/${ROOTDIR#*/} + fi +fi +#echo 0 > /proc/sys/vm/zone_reclaim_mode #Avoid kernel bug + +if [ -r /rootimg.sfs ]; then + echo Setting up squashfs with ram overlay. + mknod /dev/loop0 b 7 0 + mkdir -p /ro + mkdir -p /rw + mount -t squashfs /rootimg.sfs /ro + mount -t tmpfs rw /rw + mount -t aufs -o dirs=/rw:/ro mergedroot $NEWROOT + mkdir -p $NEWROOT/ro + mkdir -p $NEWROOT/rw + mount --move /ro $NEWROOT/ro + mount --move /rw $NEWROOT/rw +elif [ -r /rootimg.gz ]; then + echo Setting up RAM-root tmpfs. + mount -t tmpfs -o mode=755 rootfs $NEWROOT + cd $NEWROOT + echo -n "Extracting root filesystem:" + if [ -x /bin/cpio ]; then + gzip -cd /rootimg.gz |/bin/cpio -idum + else + gzip -cd /rootimg.gz |cpio -idum + fi + echo Done +elif [ -r /rootimg-statelite.gz ]; then + echo Setting up RAM-root tmpfs for statelite mode. + mount -t tmpfs -o mode=755 rootfs $NEWROOT + cd $NEWROOT + echo -n "Extracting root filesystem:" + if [ -x /bin/cpio ]; then + gzip -cd /rootimg-statelite.gz |/bin/cpio -idum + else + gzip -cd /rootimg-statelite.gz |cpio -idum + fi + echo Done + # then, the statelite staffs will be processed + echo Setting up Statelite + modprobe nfs + MAXTRIES=7 + ITER=0 + if [ ! -e "$NEWROOT/$RWDIR" ]; then + echo "" + echo "The /$RWDIR directory doesn't exist in the rootimg... " + echo "" + /bin/sh + fi + + if [ ! -e "$NEWROOT/etc/init.d/statelite" ]; then + echo "" + echo "$NEWROOT/etc/init.d/statelite doesn't exist... " + echo "" + /bin/sh + fi + + mount -t tmpfs rw $NEWROOT/$RWDIR + mkdir -p $NEWROOT/$RWDIR/tmpfs + ME=`hostname` + + # mount the SNAPSHOT directory here for persistent use. + if [ ! -z $STATEMNT ]; then + SNAPSHOTSERVER=${STATEMNT%:*} + SNAPSHOTROOT=${STATEMNT#*/} + if [ -z $SNAPSHOTROOT ]; then + SNAPSHOTROOT=$SNAPSHOTSERVER + SNAPSHOTSERVER= + fi + fi + + if [ ! -z $SNAPSHOTSERVER ]; then + mkdir -p $NEWROOT/$RWDIR/persistent + MAXTRIES=5 + ITER=0 + if [ -z $MNTOPTS ]; then + MNT_OPTIONS="nolock,rsize=32768,tcp,timeo=14" + else + MNT_OPTIONS=$MNTOPTS + fi + while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do + ITER=$(( ITER + 1 )) + if [ "$ITER" == "$MAXTRIES" ]; then + echo "You are dead, rpower $ME boot to play again." + echo "Possible problems: +1. $SNAPSHOTSERVER is not exporting $SNAPSHOTROOT ? +2. Is DNS set up? Maybe that's why I can't mount $SNAPSHOTSERVER." + /bin/sh + exit + fi + RS=$(( $RANDOM % 20 )) + echo "Trying again in $RS seconds ..." + sleep $RS + done + fi + + $NEWROOT/etc/init.d/statelite + fastboot=yes + export fastboot + keep_old_ip=yes + export keep_old_ip + + mount -n --bind /dev $NEWROOT/dev + mount -n --bind /proc $NEWROOT/proc + mount -n --bind /sys $NEWROOT/sys + +else + echo -n Failed to download image, panicing in 5... + for i in 4 3 2 1 0; do + /bin/sleep 1 + echo -n $i... + done + echo + echo "You're dead. rpower nodename reset to play again. + +* Did you packimage with -m cpio, -m squashfs, or -m nfs? +* If using -m squashfs did you include aufs.ko with geninitrd? + e.g.: -n tg3,squashfs,aufs,loop +* If using -m nfs did you export NFS and sync rootimg? And + did you include the aufs and nfs modules in the proper order: + e.g.: -n tg3,aufs,loop,sunrpc,lockd,nfs_acl,nfs + +" + /bin/dash + exit +fi +cd / + +if [ -z $STATEMNT ]; then + for lf in /tmp/dhclient.*.lease; do + netif=${lf#*.} + netif=${netif%.*} + cp $lf "$NEWROOT/var/lib/dhclient/dhclient-$netif.leases" + done + + if [ ! -z "$ifname" ]; then + MACX=${ifname#*:} + ETHX=${ifname%:$MACX*} + elif [ ! -z "$netdev" ]; then + ETHX=$netdev + MACX=`ip link show $netdev | grep ether | awk '{print $2}'` + elif [ ! -z "$BOOTIF" ]; then + MACX=$BOOTIF + ETHX=`ifconfig |grep -i $BOOTIF | awk '{print $1}'` + fi + + if [ ! -z "$MACX" ] && [ ! -z "$ETHX" ]; then + if [ ! -e $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX ]; then + touch $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX + fi + echo "DEVICE=$ETHX" > $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX + echo "BOOTPROTO=dhcp" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX + echo "HWADDR=$MACX" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX + echo "ONBOOT=yes" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX + fi +fi + +cp /etc/resolv.conf "$NEWROOT/etc/" + +if [ -d "$NEWROOT/etc/sysconfig" -a ! -e "$NEWROOT/etc/sysconfig/selinux" ]; then + echo "SELINUX=disabled" >> "$NEWROOT/etc/sysconfig/selinux" +fi + +# inject new exit_if_exists +echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > /initqueue/xcat.sh +# force udevsettle to break +> /initqueue/work diff --git a/xCAT-server/share/xcat/netboot/ubuntu/genimage b/xCAT-server/share/xcat/netboot/ubuntu/genimage.old similarity index 90% rename from xCAT-server/share/xcat/netboot/ubuntu/genimage rename to xCAT-server/share/xcat/netboot/ubuntu/genimage.old index 99d1c34e1..174195264 100755 --- a/xCAT-server/share/xcat/netboot/ubuntu/genimage +++ b/xCAT-server/share/xcat/netboot/ubuntu/genimage.old @@ -11,6 +11,7 @@ use File::Copy; use File::Find; use Getopt::Long; use Cwd qw(realpath); +use xCAT::Utils; #use strict; Getopt::Long::Configure("bundling"); Getopt::Long::Configure("pass_through"); @@ -18,7 +19,6 @@ 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 @yumdirs; my $arch; my %libhash; my @filestoadd; @@ -56,6 +56,7 @@ my $prompt; sub xdie { system("rm -rf /tmp/xcatinitrd.$$"); + umount_chroot($rootimg_dir); die @_; } @@ -187,7 +188,7 @@ unless ($onlyinitrd) { my $fd; open($fd,">>","$rootimg_dir/etc/fstab"); - print $fd "#Dummy fstab for rpm postscripts to see\n"; + print $fd "#Dummy fstab for dpkg postscripts to see\n"; close($fd); my $non_interactive; @@ -198,14 +199,9 @@ unless ($onlyinitrd) { #print "$index\n"; my $dist = $line[@line-1]; + my $aptcmd = "chroot $rootimg_dir apt-get update && chroot $rootimg_dir apt-get $non_interactive "; my $aptcmd1 = "debootstrap"; my $aptcmd2 = "--arch $uarch $dist $rootimg_dir file://$installroot/$osver/$arch/"; - #foreach (0..$repnum) { - # $yumcmd .= "--enablerepo=$osver-$arch-$_ "; - #} - - #yumcmd .= "install "; - #mkpath("$rootimg_dir/var/lib/yum"); if (!$imagename) { $pkglist= get_profile_def_filename($customdir,"pkglist"); @@ -240,6 +236,13 @@ unless ($onlyinitrd) { } } + mount_chroot($rootimg_dir); + + # Add the local repo from MN temporarily for apt-get update/upgrade + open($aptconfig,">","$rootimg_dir/etc/apt/sources.list"); + print $aptconfig "deb file://$installroot/$osver/$arch/ $dist main\n"; + close($aptconfig); + #Now let's handle extra packages if (!$imagename) { $otherpkglist=get_profile_def_filename($customdir, "otherpkgs.pkglist"); @@ -253,57 +256,50 @@ unless ($onlyinitrd) { my %extrapkgnames; if (keys(%extra_hash) > 0) { - open($yumconfig,">>","/tmp/genimage.$$.yum.conf"); + open($aptconfig,">>","$rootimg_dir/etc/apt/sources.list.d/genimage.$$.apt.list"); my $index=1; foreach $pass (sort (keys(%extra_hash))) { foreach (keys(%{$extra_hash{$pass}})) { if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE")) { next;} - print $yumconfig "[otherpkgs$index]\nname=otherpkgs$index\nbaseurl=file://$srcdir_otherpkgs/$_\ngpgpcheck=0\n\n"; + print $aptconfig "deb file://$srcdir_otherpkgs/$_ . /"; $index++; my $pa=$extra_hash{$pass}{$_}; $extrapkgnames{$pass} .= " " . join(' ', @$pa); } } - close($yumconfig); + close($aptconfig); $index--; - $yumcmd = "yum $non_interactive -c /tmp/genimage.$$.yum.conf --installroot=$rootimg_dir/ --disablerepo=* "; - foreach (0..$repnum) { - $yumcmd .= "--enablerepo=$osver-$arch-$_ "; - } - for (1..$index) { - $yumcmd .= "--enablerepo=otherpkgs$_ "; - } foreach $pass (sort (keys(%extra_hash))) { #remove the packages that are specified in the otherpkgs.list files with leading '-' - my $yumcmd_remove= "$yumcmd erase "; + my $aptcmd_remove= "$aptcmd remove "; if (exists ($extra_hash{$pass}{'PRE_REMOVE'})) { my $pa=$extra_hash{$pass}{'PRE_REMOVE'}; my $rm_packges= join(' ', @$pa); if ($rm_packges) { - print "$yumcmd_remove $rm_packges\n"; - $rc = system("$yumcmd_remove $rm_packges"); + print "$aptcmd_remove $rm_packges\n"; + $rc = system("$aptcmd_remove $rm_packges\""); } } #install extra packages - my $yumcmd_base = $yumcmd; - $yumcmd .= "install "; - #append extra pkg names to yum command + my $aptcmd_base = $aptcmd; + $aptcmd .= "install "; + #append extra pkg names to apt-get command if ($extrapkgnames{$pass}) { - $yumcmd .= " $extrapkgnames{$pass} "; + $aptcmd .= " $extrapkgnames{$pass} "; } - $yumcmd =~ s/ $/\n/; + $aptcmd =~ s/ $/\n/; #debug - print "yumcmd=$yumcmd\n"; - #my $repo=`cat /tmp/genimage.$$.yum.conf`; + print "aptcmd=$aptcmd\n"; + #my $repo=`cat $rootimg_dir/etc/sources.list.d/genimage.$$.apt.list`; #print "repo=$repo"; - my $rc = system($yumcmd); + my $rc = system("$aptcmd\""); if ($rc) { - print "yum invocation failed\n"; + print "apt-get invocation failed\n"; exit 1; } @@ -312,19 +308,26 @@ unless ($onlyinitrd) { my $pa=$extra_hash{$pass}{'POST_REMOVE'}; my $rm_packges= join(' ', @$pa); if ($rm_packges) { - print "$yumcmd_remove $rm_packges\n"; - $rc = system("$yumcmd_remove $rm_packges"); + print "$aptcmd_remove $rm_packges\n"; + $rc = system("$aptcmd_remove $rm_packges"); } } } } - # run yum update to update any installed rpms + # run apt-get upgrade to update any installed debs # needed when running genimage again after updating software in repositories - my $yumcmd_update = $yumcmd_base . " update "; - $rc = system("$yumcmd_update"); + my $aptcmd_update = $aptcmd . " upgrade "; + print "$aptcmd_update\n"; + $rc = system("$aptcmd_update"); + umount_chroot($rootimg_dir); # ignore any return code + # Add the local repo from MN + my $master = xCAT::Utils->get_site_Master(); + open($aptconfig,">","$rootimg_dir/etc/apt/sources.list"); + print $aptconfig "deb http://$master$installroot/$osver/$arch/ $dist main\n"; + close($aptconfig); postscripts(); #run 'postscripts' } @@ -375,7 +378,6 @@ while (scalar @checkdeps) { } } close($moddeps); -unlink "/tmp/genimage.$$.yum.conf"; #-- run postinstall script if (!$imagename) { @@ -495,7 +497,7 @@ sub getlibs { sub mkinitrd { mkpath("/tmp/xcatinitrd.$$/bin"); if($basekernelver eq $kernelver) { - copy(<$rootimg_dir/boot/vmlinuz*>,"$destdir/kernel"); + copy("$rootimg_dir/boot/vmlinuz*","$destdir/kernel"); } else { if(-r "$rootimg_dir/boot/vmlinuz-$kernelver") { @@ -519,6 +521,8 @@ sub mkinitrd { mkpath("/tmp/xcatinitrd.$$/dev/mapper"); mkpath("/tmp/xcatinitrd.$$/sysroot"); mkpath("/tmp/xcatinitrd.$$/etc/ld.so.conf.d"); + mkpath("/tmp/xcatinitrd.$$/etc/udhcpc"); + mkpath("/tmp/xcatinitrd.$$/usr/share/udhcpc"); mkpath("/tmp/xcatinitrd.$$/var/lib/dhclient"); my $inifile; @@ -620,9 +624,8 @@ echo ' EOS1 - print $inifile "busybox mount -t proc /proc /proc\n"; - #print $inifile "busybox --install\n"; + print $inifile "busybox --install\n"; print $inifile "busybox mount -t sysfs /sys /sys\n"; print $inifile "mount -o mode=0755 -t tmpfs /dev /dev\n"; print $inifile "mkdir /dev/pts\n"; @@ -945,20 +948,70 @@ EOMS print $inifile " exit\n"; print $inifile "fi\n"; print $inifile "cd /\n"; - print $inifile "cp /var/lib/dhclient/dhclient.leases /sysroot/dev/.dhclient-$prinic.leases\n"; - print $inifile "cp /var/lib/dhclient/dhclient.leases /sysroot/var/lib/dhclient/dhclient-$prinic.leases\n"; - print $inifile "mknod /sysroot/dev/console c 5 1\n"; + print $inifile "cp /etc/hostname /sysroot/etc/hostname\n"; + print $inifile "cp /etc/resolv.conf /sysroot/etc/resolv.conf\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 $prinic --bootproto dhcp\n"; + print $inifile "#!/bin/sh\n"; + print $inifile "udhcpc -n -q -i $prinic\n"; close($inifile); + + open($inifile,">"."/tmp/xcatinitrd.$$/usr/share/udhcpc/default.script"); + +print $inifile <<'EOF'; +#!/bin/sh + +# udhcpc script edited by Tim Riker + +[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1 + +RESOLV_CONF="/etc/resolv.conf" +[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" +[ -n "$subnet" ] && NETMASK="netmask $subnet" + +case "$1" in + deconfig) + /sbin/ifconfig $interface 0.0.0.0 + ;; + + renew|bound) + /sbin/ifconfig $interface $ip $BROADCAST $NETMASK + + if [ -n "$hostname" ] ; then + hostname $hostname + echo $hostname > /etc/hostname + fi + + if [ -n "$router" ] ; then + echo "deleting routers" + while route del default gw 0.0.0.0 dev $interface ; do + : + done + + for i in $router ; do + route add default gw $i dev $interface + done + fi + + echo -n > $RESOLV_CONF + [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF + for i in $dns ; do + echo adding dns $i + echo nameserver $i >> $RESOLV_CONF + done + ;; +esac + +exit 0 +EOF + + close($inifile); + chmod(0755,"/tmp/xcatinitrd.$$/usr/share/udhcpc/default.script"); + + chmod(0755,"/tmp/xcatinitrd.$$/init"); chmod(0755,"/tmp/xcatinitrd.$$/bin/netstart"); @filestoadd=(); @@ -970,7 +1023,7 @@ EOMS } } # add rsync for statelite - foreach ("bin/cpio","sbin/nash","bin/busybox","bin/bash", "usr/sbin/chroot", "sbin/rmmod","sbin/mount.nfs","/usr/bin/rsync") { + foreach ("bin/busybox", "bin/bash", "sbin/mount.nfs","usr/bin/rsync") { getlibs($_); push @filestoadd,$_; } @@ -1101,13 +1154,13 @@ sub generic_post { #This function is meant to leave the image in a state approxi close($cfgfile); # Create the ifcfg-x file for diskless node. But keep the ONBOOT=no # to skip the break of nfs-based boot - open($cfgfile,">","$rootimg_dir/etc/sysconfig/network-scripts/ifcfg-$prinic"); - print $cfgfile "ONBOOT=no\nBOOTPROTO=dhcp\nDEVICE=$prinic\n"; + open($cfgfile,">","$rootimg_dir/etc/network/interfaces"); + print $cfgfile "auto $prinic\niface $prinic inet dhcp\n"; close($cfgfile); foreach (split /,/,$othernics) { if (/^$/) { next; } - open($cfgfile,">","$rootimg_dir/etc/sysconfig/network-scripts/ifcfg-$_"); - print $cfgfile "ONBOOT=yes\nBOOTPROTO=dhcp\nDEVICE=$_\n"; + open($cfgfile,">","$rootimg_dir/etc/network/interfaces"); + print $cfgfile "\nauto $_\niface $_ inet dhcp\n"; close($cfgfile); } open($cfgfile,">>","$rootimg_dir/etc/securetty"); @@ -1133,7 +1186,7 @@ sub generic_post { #This function is meant to leave the image in a state approxi copy $_,"$rootimg_dir/root/"; } unless ( -r <$rootimg_dir/etc/rc3.d/S??network>) { - symlink "/etc/init.d/network","$rootimg_dir/etc/rc3.d/S10network"; + symlink "/etc/init.d/networking","$rootimg_dir/etc/rc3.d/S10networking"; } open($cfgfile,">","$rootimg_dir/etc/rc3.d/S60gettyset"); print $cfgfile "#!/bin/bash\n"; @@ -1166,6 +1219,24 @@ sub generic_post { #This function is meant to leave the image in a state approxi copy(<$rootimg_dir/boot/vmlinuz*>,"$destdir/kernel"); } +sub mount_chroot { + my $rootimage_dir = shift; + mkdir("$rootimage_dir/install"); + system("mount -o bind /dev $rootimage_dir/dev"); + system("mount -o bind /proc $rootimage_dir/proc"); + system("mount -o bind /sys $rootimage_dir/sys"); + system("mount -o bind /install $rootimage_dir/install"); +} + +sub umount_chroot { + my $rootimage_dir = shift; + system("umount $rootimage_dir/dev"); + system("umount $rootimage_dir/proc"); + system("umount $rootimage_dir/sys"); + system("umount $rootimage_dir/install"); + rmdir("$rootimage_dir/install"); +} + sub get_package_names { my $plist_file_name=shift; my %pkgnames=(); diff --git a/xCAT-server/share/xcat/netboot/ubuntu/geninitrd b/xCAT-server/share/xcat/netboot/ubuntu/geninitrd new file mode 120000 index 000000000..2271c3f0f --- /dev/null +++ b/xCAT-server/share/xcat/netboot/ubuntu/geninitrd @@ -0,0 +1 @@ +genimage \ No newline at end of file