code drop for fedora15 support. Support the systemd and dracut 009
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10579 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		@@ -71,6 +71,7 @@ my %distnames = (
 | 
			
		||||
                 "1257725234.740991" => "fedora12", #x86_64 DVD ISO
 | 
			
		||||
                 "1273712675.937554" => "fedora13", #x86_64 DVD ISO
 | 
			
		||||
                 "1287685820.403779" => "fedora14", #x86_64 DVD ISO
 | 
			
		||||
                 "1305315870.828212" => "fedora15", #x86_64 DVD ISO
 | 
			
		||||
 | 
			
		||||
                 "1194512200.047708" => "rhas4.6",
 | 
			
		||||
                 "1194512327.501046" => "rhas4.6",
 | 
			
		||||
@@ -179,6 +180,27 @@ sub process_request
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Check whether the dracut is supported by this os 
 | 
			
		||||
sub using_dracut
 | 
			
		||||
{
 | 
			
		||||
    my $os = shift;
 | 
			
		||||
    if ($os =~ /(rhels|rhel)(\d+)/) {
 | 
			
		||||
        if ($2 >= 6) {
 | 
			
		||||
          return 1;
 | 
			
		||||
        }
 | 
			
		||||
    } elsif ($os =~ /fedora(\d+)/) {
 | 
			
		||||
        if ($1 >= 12) {
 | 
			
		||||
          return 1;
 | 
			
		||||
        }
 | 
			
		||||
    } elsif ($os =~ /SL(\d+)/) {
 | 
			
		||||
        if ($1 >= 6) {
 | 
			
		||||
          return 1;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub mknetboot
 | 
			
		||||
{
 | 
			
		||||
    my $xenstyle=0;
 | 
			
		||||
@@ -341,7 +363,6 @@ sub mknetboot
 | 
			
		||||
                );
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            if ( ! $linuximagetab ) {
 | 
			
		||||
                $linuximagetab = xCAT::Table->new('linuximage');
 | 
			
		||||
            }
 | 
			
		||||
@@ -360,7 +381,6 @@ sub mknetboot
 | 
			
		||||
                );
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #print"osvr=$osver, arch=$arch, profile=$profile, imgdir=$rootimgdir\n";
 | 
			
		||||
        unless ($osver and $arch and $profile)
 | 
			
		||||
        {
 | 
			
		||||
@@ -457,7 +477,6 @@ sub mknetboot
 | 
			
		||||
            $donetftp{$osver,$arch,$profile} = 1;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        if ($statelite) {
 | 
			
		||||
            my $initrdloc = "/$tftpdir/xcat/netboot/$osver/$arch/$profile/";
 | 
			
		||||
            if ($rootfstype eq "ramdisk") {
 | 
			
		||||
@@ -566,9 +585,7 @@ sub mknetboot
 | 
			
		||||
		        }
 | 
			
		||||
 | 
			
		||||
                # special case for redhat6, fedora12/13/14
 | 
			
		||||
                if ($osver =~ m/rhel6/ || $osver =~ m/rhels6/
 | 
			
		||||
                    || $osver =~ m/fedora12/ || $osver =~ m/fedora13/ 
 | 
			
		||||
                    || $osver =~ m/fedora14/ || $osver =~ m/SL6/) {
 | 
			
		||||
                if (&using_dracut($osver)) {
 | 
			
		||||
                    $kcmdline = "root=nfs:$nfssrv:$nfsdir/rootimg:ro STATEMNT=";
 | 
			
		||||
                } else {
 | 
			
		||||
                    $kcmdline = "NFSROOT=$nfssrv:$nfsdir STATEMNT=";	
 | 
			
		||||
@@ -742,9 +759,7 @@ sub mknetboot
 | 
			
		||||
        my $initrdstr = "xcat/netboot/$osver/$arch/$profile/initrd-stateless.gz";
 | 
			
		||||
        $initrdstr = "xcat/netboot/$osver/$arch/$profile/initrd-statelite.gz" if ($statelite);
 | 
			
		||||
        # special case for the dracut-enabled OSes
 | 
			
		||||
        if ($osver =~ m/rhels6/ || $osver =~ m/rhel6/ 
 | 
			
		||||
            || $osver =~ m/fedora12/ || $osver =~ m/fedora13/
 | 
			
		||||
            || $osver =~ m/fedora14/ || $osver =~ m/SL6/) {
 | 
			
		||||
        if (&using_dracut($osver)) {
 | 
			
		||||
            if($statelite and $rootfstype eq "ramdisk") {
 | 
			
		||||
                $initrdstr = "xcat/netboot/$osver/$arch/$profile/initrd-stateless.gz";
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								xCAT-server/share/xcat/install/fedora/compute.fedora15.pkglist
									
									
									
									
									
										Symbolic link
									
								
							
							
						
						
									
										1
									
								
								xCAT-server/share/xcat/install/fedora/compute.fedora15.pkglist
									
									
									
									
									
										Symbolic link
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
compute.fedora14.pkglist
 | 
			
		||||
							
								
								
									
										1
									
								
								xCAT-server/share/xcat/install/fedora/compute.fedora15.tmpl
									
									
									
									
									
										Symbolic link
									
								
							
							
						
						
									
										1
									
								
								xCAT-server/share/xcat/install/fedora/compute.fedora15.tmpl
									
									
									
									
									
										Symbolic link
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
compute.fedora14.tmpl
 | 
			
		||||
							
								
								
									
										1
									
								
								xCAT-server/share/xcat/netboot/fedora/compute.fedora15.pkglist
									
									
									
									
									
										Symbolic link
									
								
							
							
						
						
									
										1
									
								
								xCAT-server/share/xcat/netboot/fedora/compute.fedora15.pkglist
									
									
									
									
									
										Symbolic link
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
compute.fedora14.pkglist
 | 
			
		||||
							
								
								
									
										1
									
								
								xCAT-server/share/xcat/netboot/fedora/dracut_009/check
									
									
									
									
									
										Symbolic link
									
								
							
							
						
						
									
										1
									
								
								xCAT-server/share/xcat/netboot/fedora/dracut_009/check
									
									
									
									
									
										Symbolic link
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
../../rh/dracut/check
 | 
			
		||||
							
								
								
									
										1
									
								
								xCAT-server/share/xcat/netboot/fedora/dracut_009/install.netboot
									
									
									
									
									
										Symbolic link
									
								
							
							
						
						
									
										1
									
								
								xCAT-server/share/xcat/netboot/fedora/dracut_009/install.netboot
									
									
									
									
									
										Symbolic link
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
../../rh/dracut/install.netboot
 | 
			
		||||
@@ -0,0 +1 @@
 | 
			
		||||
../../rh/dracut/install.statelite
 | 
			
		||||
							
								
								
									
										1
									
								
								xCAT-server/share/xcat/netboot/fedora/dracut_009/installkernel
									
									
									
									
									
										Symbolic link
									
								
							
							
						
						
									
										1
									
								
								xCAT-server/share/xcat/netboot/fedora/dracut_009/installkernel
									
									
									
									
									
										Symbolic link
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
../../rh/dracut/installkernel
 | 
			
		||||
@@ -0,0 +1,4 @@
 | 
			
		||||
root=1
 | 
			
		||||
rootok=1
 | 
			
		||||
netroot=xcat
 | 
			
		||||
echo '[ -e $NEWROOT/proc ]' > $hookdir/initqueue/finished/xcatroot.sh
 | 
			
		||||
							
								
								
									
										89
									
								
								xCAT-server/share/xcat/netboot/fedora/dracut_009/xcat-prepivot.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										89
									
								
								xCAT-server/share/xcat/netboot/fedora/dracut_009/xcat-prepivot.sh
									
									
									
									
									
										Executable file
									
								
							@@ -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"' > $hookdir/initqueue/xcat.sh
 | 
			
		||||
# force udevsettle to break
 | 
			
		||||
> $hookdir/initqueue/work
 | 
			
		||||
							
								
								
									
										194
									
								
								xCAT-server/share/xcat/netboot/fedora/dracut_009/xcatroot
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										194
									
								
								xCAT-server/share/xcat/netboot/fedora/dracut_009/xcatroot
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,194 @@
 | 
			
		||||
#!/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 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 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"' > $hookdir/initqueue/xcat.sh
 | 
			
		||||
echo "$hookdir/initqueue/xcat.sh"
 | 
			
		||||
cat $hookdir/initqueue/xcat.sh
 | 
			
		||||
# force udevsettle to break
 | 
			
		||||
> $hookdir/initqueue/work
 | 
			
		||||
@@ -22,6 +22,7 @@ Getopt::Long::Configure("bundling");
 | 
			
		||||
Getopt::Long::Configure("pass_through");
 | 
			
		||||
 | 
			
		||||
my $dracutmode; #Indicate whether this is a dracut style initrd
 | 
			
		||||
my $dracutdir = "dracut";  # The default directory name of dracut
 | 
			
		||||
my $prinic; #TODO be flexible on node primary nic
 | 
			
		||||
my $othernics; #TODO be flexible on node primary nic
 | 
			
		||||
my $netdriver;
 | 
			
		||||
@@ -438,6 +439,16 @@ close($moddeps);
 | 
			
		||||
unlink "/tmp/genimage.$$.yum.conf";
 | 
			
		||||
if (-d "$rootimg_dir/usr/share/dracut") {
 | 
			
		||||
    $dracutmode = 1;
 | 
			
		||||
    # get dracut version
 | 
			
		||||
    my $dracutver = `rpm -R $rootimg_dir -qi dracut | grep Version | awk -F' ' '{print \$3}'`;
 | 
			
		||||
    if ($dracutver =~ /^\d\d\d$/) {
 | 
			
		||||
        if ($dracutver >= "009") {
 | 
			
		||||
            $dracutdir = "dracut_009";
 | 
			
		||||
        } else {
 | 
			
		||||
            $dracutdir = "dracut";  # The default directory
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    print "Enter the dracut mode. Dracut version: $dracutver. Dracut directory: $dracutdir.\n";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#-- run postinstall script
 | 
			
		||||
@@ -546,13 +557,13 @@ unless ($dracutmode) { #in dracut mode, we delegate all this activity
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if ($dracutmode) {
 | 
			
		||||
    # backup etc/rc.sysinit file before modifing it
 | 
			
		||||
    system("cp -a $rootimg_dir/etc/rc.sysinit $rootimg_dir/etc/rc.sysinit.backup");
 | 
			
		||||
    # modify etc/rc.sysinit, prevent remounting
 | 
			
		||||
    # TODO: need to find one way to prevent remounting
 | 
			
		||||
    my $SYSINITFILE;
 | 
			
		||||
    my $TMPSYSINITFILE;
 | 
			
		||||
    if (-f "$rootimg_dir/etc/rc.sysinit") {
 | 
			
		||||
        # backup etc/rc.sysinit file before modifing it
 | 
			
		||||
        system("cp -a $rootimg_dir/etc/rc.sysinit $rootimg_dir/etc/rc.sysinit.backup");
 | 
			
		||||
        open($SYSINITFILE, "$rootimg_dir/etc/rc.sysinit");
 | 
			
		||||
        open($TMPSYSINITFILE, '>', "/tmp/rc.sysinit.tmp");
 | 
			
		||||
        # find the following lines,
 | 
			
		||||
@@ -614,8 +625,8 @@ sub mkinitrd_dracut {
 | 
			
		||||
    my $dracutmpath = "$rootimg_dir/usr/share/dracut/modules.d/97xcat";
 | 
			
		||||
    mkpath($dracutmpath);
 | 
			
		||||
 | 
			
		||||
    my $perm = (stat("$fullpath/dracut/check"))[2];
 | 
			
		||||
    cp("$fullpath/dracut/check", $dracutmpath);
 | 
			
		||||
    my $perm = (stat("$fullpath/$dracutdir/check"))[2];
 | 
			
		||||
    cp("$fullpath/$dracutdir/check", $dracutmpath);
 | 
			
		||||
    chmod($perm&07777, "$dracutmpath/check");
 | 
			
		||||
 | 
			
		||||
    foreach (@ndrivers) { s/\.ko$//; }
 | 
			
		||||
@@ -625,12 +636,12 @@ sub mkinitrd_dracut {
 | 
			
		||||
 | 
			
		||||
    if ($mode eq "statelite") {
 | 
			
		||||
        # for statelite
 | 
			
		||||
        cp("$fullpath/dracut/install.statelite","$dracutmpath/install");
 | 
			
		||||
        $perm = (stat("$fullpath/dracut/install.statelite"))[2];
 | 
			
		||||
        cp("$fullpath/$dracutdir/install.statelite","$dracutmpath/install");
 | 
			
		||||
        $perm = (stat("$fullpath/$dracutdir/install.statelite"))[2];
 | 
			
		||||
        chmod($perm&07777, "$dracutmpath/install");
 | 
			
		||||
 | 
			
		||||
        cp("$fullpath/dracut/xcat-prepivot.sh",$dracutmpath);
 | 
			
		||||
        $perm = (stat("$fullpath/dracut/xcat-prepivot.sh"))[2];
 | 
			
		||||
        cp("$fullpath/$dracutdir/xcat-prepivot.sh",$dracutmpath);
 | 
			
		||||
        $perm = (stat("$fullpath/$dracutdir/xcat-prepivot.sh"))[2];
 | 
			
		||||
        chmod($perm&07777, "$dracutmpath/xcat-prepivot.sh");
 | 
			
		||||
 | 
			
		||||
        # update etc/dracut.conf
 | 
			
		||||
@@ -640,12 +651,12 @@ sub mkinitrd_dracut {
 | 
			
		||||
        print $DRACUTCONF qq{filesystems+="nfs"\n};
 | 
			
		||||
        close $DRACUTCONF;
 | 
			
		||||
    } elsif ($mode eq "stateless") {
 | 
			
		||||
        cp("$fullpath/dracut/install.netboot","$dracutmpath/install");
 | 
			
		||||
        $perm = (stat("$fullpath/dracut/install.netboot"))[2];
 | 
			
		||||
        cp("$fullpath/$dracutdir/install.netboot","$dracutmpath/install");
 | 
			
		||||
        $perm = (stat("$fullpath/$dracutdir/install.netboot"))[2];
 | 
			
		||||
        chmod($perm&07777, "$dracutmpath/install");
 | 
			
		||||
 | 
			
		||||
        cp("$fullpath/dracut/xcat-cmdline.sh","$dracutmpath/");
 | 
			
		||||
        $perm = (stat("$fullpath/dracut/xcat-cmdline.sh"))[2];
 | 
			
		||||
        cp("$fullpath/$dracutdir/xcat-cmdline.sh","$dracutmpath/");
 | 
			
		||||
        $perm = (stat("$fullpath/$dracutdir/xcat-cmdline.sh"))[2];
 | 
			
		||||
        chmod($perm&07777, "$dracutmpath/xcat-cmdline.sh");
 | 
			
		||||
 | 
			
		||||
        if ($prinic) {
 | 
			
		||||
@@ -655,12 +666,12 @@ sub mkinitrd_dracut {
 | 
			
		||||
            close $optspec;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        cp("$fullpath/dracut/xcatroot","$dracutmpath/");
 | 
			
		||||
        $perm = (stat("$fullpath/dracut/xcatroot"))[2];
 | 
			
		||||
        cp("$fullpath/$dracutdir/xcatroot","$dracutmpath/");
 | 
			
		||||
        $perm = (stat("$fullpath/$dracutdir/xcatroot"))[2];
 | 
			
		||||
        chmod($perm&07777, "$dracutmpath/xcatroot");
 | 
			
		||||
 | 
			
		||||
        cp("$fullpath/dracut/installkernel", "$dracutmpath/");
 | 
			
		||||
        $perm = (stat("$fullpath/dracut/installkernel"))[2];
 | 
			
		||||
        cp("$fullpath/$dracutdir/installkernel", "$dracutmpath/");
 | 
			
		||||
        $perm = (stat("$fullpath/$dracutdir/installkernel"))[2];
 | 
			
		||||
        chmod($perm&07777, "$dracutmpath/installkernel");
 | 
			
		||||
 | 
			
		||||
        # update etc/dracut.conf
 | 
			
		||||
@@ -1296,6 +1307,19 @@ sub postscripts {
 | 
			
		||||
   chmod '0755', "$rootimg_dir/opt/xcat/xcatdsklspost";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
sub using_systemd {
 | 
			
		||||
    my $os = shift;
 | 
			
		||||
    if ($os =~ /fedora(\d+)/) {
 | 
			
		||||
        if ($1 >= 15) {
 | 
			
		||||
          return 1;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
sub generic_post { #This function is meant to leave the image in a state approximating a normal install
 | 
			
		||||
   my $cfgfile;
 | 
			
		||||
   unlink("$rootimg_dir/dev/null");
 | 
			
		||||
@@ -1306,12 +1330,14 @@ sub generic_post { #This function is meant to leave the image in a state approxi
 | 
			
		||||
   print $cfgfile "proc    /proc    proc     defaults       0 0\n";
 | 
			
		||||
   print $cfgfile "sysfs   /sys     sysfs    defaults       0 0\n";
 | 
			
		||||
 | 
			
		||||
   if ($tmplimit) {
 | 
			
		||||
      print $cfgfile "tmpfs   /tmp     tmpfs    defaults,size=$tmplimit       0 2\n";
 | 
			
		||||
      print $cfgfile "tmpfs   /var/tmp     tmpfs    defaults,size=$tmplimit       0 2\n";
 | 
			
		||||
   } else {
 | 
			
		||||
      print $cfgfile "tmpfs   /tmp     tmpfs    defaults,size=10m             0 2\n";
 | 
			
		||||
      print $cfgfile "tmpfs   /var/tmp     tmpfs    defaults,size=10m       0 2\n";
 | 
			
		||||
   if (!&using_systemd($osver)) {
 | 
			
		||||
      if ($tmplimit) {
 | 
			
		||||
         print $cfgfile "tmpfs   /tmp     tmpfs    defaults,size=$tmplimit       0 2\n";
 | 
			
		||||
         print $cfgfile "tmpfs   /var/tmp     tmpfs    defaults,size=$tmplimit       0 2\n";
 | 
			
		||||
      } else {
 | 
			
		||||
         print $cfgfile "tmpfs   /tmp     tmpfs    defaults,size=10m             0 2\n";
 | 
			
		||||
         print $cfgfile "tmpfs   /var/tmp     tmpfs    defaults,size=10m       0 2\n";
 | 
			
		||||
      }
 | 
			
		||||
   }
 | 
			
		||||
 | 
			
		||||
   my $rootfs_name=$profile."_".$arch;
 | 
			
		||||
@@ -1339,13 +1365,13 @@ sub generic_post { #This function is meant to leave the image in a state approxi
 | 
			
		||||
      close($cfgfile);
 | 
			
		||||
   }
 | 
			
		||||
   
 | 
			
		||||
	# securetty not needed on s390x
 | 
			
		||||
	if ($arch ne "s390x") {
 | 
			
		||||
		open($cfgfile,">>","$rootimg_dir/etc/securetty");
 | 
			
		||||
		print $cfgfile "ttyS0\n";
 | 
			
		||||
		print $cfgfile "ttyS1\n";
 | 
			
		||||
		close($cfgfile);
 | 
			
		||||
	}
 | 
			
		||||
   # securetty not needed on s390x
 | 
			
		||||
   if ($arch ne "s390x") {
 | 
			
		||||
      open($cfgfile,">>","$rootimg_dir/etc/securetty");
 | 
			
		||||
      print $cfgfile "ttyS0\n";
 | 
			
		||||
      print $cfgfile "ttyS1\n";
 | 
			
		||||
      close($cfgfile);
 | 
			
		||||
   }
 | 
			
		||||
	
 | 
			
		||||
   my @passwd;
 | 
			
		||||
   open($cfgfile,"<","$rootimg_dir/etc/passwd");
 | 
			
		||||
@@ -1369,38 +1395,39 @@ sub generic_post { #This function is meant to leave the image in a state approxi
 | 
			
		||||
       symlink  "/etc/init.d/network","$rootimg_dir/etc/rc3.d/S10network";
 | 
			
		||||
   }
 | 
			
		||||
   
 | 
			
		||||
	# gettyset is not found on s390x
 | 
			
		||||
	if ($arch ne "s390x") {
 | 
			
		||||
		open($cfgfile,">","$rootimg_dir/etc/init.d/gettyset");
 | 
			
		||||
		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\" -a \"\$i\" != \"console=tty0\" ]; 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 "     if [ -x /sbin/initctl ]; then\n";	# Upstart style
 | 
			
		||||
		print $cfgfile "        initctl emit --no-wait fedora.serial-console-available \$COTTY \$COSPEED\n";
 | 
			
		||||
		print $cfgfile "     else\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 "  fi\n";
 | 
			
		||||
		print $cfgfile "done\n";
 | 
			
		||||
   # gettyset is not found on s390x
 | 
			
		||||
   if ($arch ne "s390x") {
 | 
			
		||||
      if (!&using_systemd($osver)) {
 | 
			
		||||
         open($cfgfile,">","$rootimg_dir/etc/init.d/gettyset");
 | 
			
		||||
         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\" -a \"\$i\" != \"console=tty0\" ]; 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 "     if [ -x /sbin/initctl ]; then\n";	# Upstart style
 | 
			
		||||
         print $cfgfile "        initctl emit --no-wait fedora.serial-console-available \$COTTY \$COSPEED\n";
 | 
			
		||||
         print $cfgfile "     else\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 "  fi\n";
 | 
			
		||||
         print $cfgfile "done\n";
 | 
			
		||||
 | 
			
		||||
        close($cfgfile);
 | 
			
		||||
         close($cfgfile);
 | 
			
		||||
 | 
			
		||||
		chmod(0755,"$rootimg_dir/etc/init.d/gettyset");
 | 
			
		||||
        system("cd $rootimg_dir/etc/rc3.d; ln -sf ../init.d/gettyset S60gettyset");
 | 
			
		||||
         chmod(0755,"$rootimg_dir/etc/init.d/gettyset");
 | 
			
		||||
         system("cd $rootimg_dir/etc/rc3.d; ln -sf ../init.d/gettyset S60gettyset");
 | 
			
		||||
      }
 | 
			
		||||
		
 | 
			
		||||
        copy("$installroot/postscripts/xcatpostinit", "$rootimg_dir/etc/init.d/xcatpostinit");
 | 
			
		||||
        chmod(0755, "$rootimg_dir/etc/init.d/xcatpostinit");
 | 
			
		||||
        system("cd $rootimg_dir/etc/rc3.d; ln -sf ../init.d/xcatpostinit S61xcatpostinit");
 | 
			
		||||
	}
 | 
			
		||||
   
 | 
			
		||||
      copy("$installroot/postscripts/xcatpostinit", "$rootimg_dir/etc/init.d/xcatpostinit");
 | 
			
		||||
      chmod(0755, "$rootimg_dir/etc/init.d/xcatpostinit");
 | 
			
		||||
      system("cd $rootimg_dir/etc/rc3.d; ln -sf ../init.d/xcatpostinit S61xcatpostinit");
 | 
			
		||||
   }
 | 
			
		||||
} 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user