fixed statelite, the xCAT graphic, and mount info
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4788 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
fc31fef0da
commit
db02438df7
@ -48,6 +48,7 @@ my $postinstall_filename;
|
||||
my $rootimg_dir;
|
||||
my $rwfiles; # these files are used by statelite for tmpfs rw
|
||||
|
||||
|
||||
sub xdie {
|
||||
system("rm -rf /tmp/xcatinitrd.$$");
|
||||
die @_;
|
||||
@ -202,33 +203,6 @@ unless ($onlyinitrd) {
|
||||
close($yumconfig);
|
||||
mkpath "$rootimg_dir/etc";
|
||||
|
||||
# statelite snapshots directory added here.
|
||||
# this is where tmpfs will be created.
|
||||
if($mode eq "statelite"){
|
||||
mkpath "$rootimg_dir/.snapshot"; # create place for NFS mounts.
|
||||
# get all the rw files that go in tmpfs
|
||||
$rwfiles = get_rwfiles_file_name($customdir);
|
||||
if (!$rwfiles) {
|
||||
$rwfiles= get_rwfiles_file_name($pathtofiles);
|
||||
}
|
||||
if(!$rwfiles){
|
||||
print "Unable to find r/w file list. Make a file called $profile.rwfiles with all the necessary read/write files\n";
|
||||
exit 1;
|
||||
}
|
||||
# copyt the rwfiles to /.snapshot/files for the initfs to use.
|
||||
copy("$rwfiles","$rootimg_dir/.snapshot/files");
|
||||
|
||||
# also need to create stub file for booting since this is read only
|
||||
mkpath "$rootimg_dir/var/lib/dhclient/";
|
||||
# create an empty file
|
||||
open(FH,">$rootimg_dir/var/lib/dhclient/dhclient-$prinic.leases");
|
||||
close(FH);
|
||||
open(FH,">$rootimg_dir/var/lib/random-seed");
|
||||
close(FH);
|
||||
|
||||
# link mtab.
|
||||
system("ln -sf /proc/mounts $rootimg_dir/etc/mtab");
|
||||
}
|
||||
|
||||
my $fd;
|
||||
open($fd,">>","$rootimg_dir/etc/fstab");
|
||||
@ -374,6 +348,33 @@ if (($postinstall_filename) && (-x $postinstall_filename)) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# statelite .statelite directory added here.
|
||||
# this is where tmpfs will be created.
|
||||
if($mode eq "statelite"){
|
||||
mkpath "$rootimg_dir/.statelite"; # create place for NFS mounts.
|
||||
# this script will get the directories.
|
||||
unless(-f "../add-on/statelite/rc.statelite"){
|
||||
print "Can't find ../add-on/statelite/rc.statelite!\n";
|
||||
exit;
|
||||
}
|
||||
system("cp ../add-on/statelite/rc.statelite $rootimg_dir/etc/init.d/statelite");
|
||||
# also need to add this file:
|
||||
# may have already been made into a symbolic link, if so ignore it
|
||||
|
||||
unless(-l "$rootimg_dir/var/lib/dhclient" ){
|
||||
mkpath "$rootimg_dir/var/lib/dhclient/";
|
||||
system("touch $rootimg_dir/var/lib/dhclient/dhclient-$prinic.leases");
|
||||
}
|
||||
|
||||
unless(-l "$rootimg_dir/var/lib/dhcp" ){
|
||||
mkpath "$rootimg_dir/var/lib/dhcp/";
|
||||
system("touch $rootimg_dir/var/lib/dhcp/dhclient-$prinic.leases");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
mkinitrd();
|
||||
|
||||
sub getlibs {
|
||||
@ -436,7 +437,7 @@ sub mkinitrd {
|
||||
print $inifile <<EOS1;
|
||||
NEWROOT="/sysroot"
|
||||
SHELL="/bin/sh"
|
||||
RWDIR=".snapshot"
|
||||
RWDIR=".statelite"
|
||||
|
||||
|
||||
# Define some colors
|
||||
@ -448,8 +449,9 @@ GREEN="\033[32m"
|
||||
PINK="\033[35m\033[1m"
|
||||
MAGENTA="\033[35m"
|
||||
BROWN="\033[33m"
|
||||
NORMAL=\$RESET
|
||||
|
||||
# This function is used to mount files/directories from the snapshot directory
|
||||
# This function is used to mount files/directories from the .statelite directory
|
||||
# over the root directory.
|
||||
# This function stolen from redhat
|
||||
shell() {
|
||||
@ -479,49 +481,37 @@ mountfile () {
|
||||
#
|
||||
# Mount the snapshotfile over the root file so the client will have r/w access
|
||||
#
|
||||
mount -n -o bind \$NEWROOT/.snapshot/\${2}\${1} \$NEWROOT/\${1}
|
||||
mount -n -o bind \$NEWROOT/\$RWDIR/\${2}\${1} \$NEWROOT/\${1}
|
||||
}
|
||||
|
||||
fancydisplay () {
|
||||
clear
|
||||
echo -e "\$CYAN"
|
||||
echo "
|
||||
7=I?~=+7 =?77777?7
|
||||
7=77I~~? =~ ?=I7777?7
|
||||
7+=IIIII+~+ +,,: I,,,:77 ?=IIIIIII~77
|
||||
?~?IIIIIIII??7 ~,,,,7 ,,,,,,~ ?=IIIIIIII?~7
|
||||
7?IIIIIIIIIIII+=~,,,,,~7 +,,,,,,,+:=IIIIIIIIII77
|
||||
?IIIIIIIIIIIII?~:,,,,,,~ 7 =,,,,,,,,~:?IIIIII777I=I
|
||||
IIII777777IIII+~,,,,,,,,I 7 7 ?,,,,,:::,,:~=IIIIII?+~::+
|
||||
777?77 7I?77I~~,,:::,,,,~=,:I777777777?7I:,,,,,,,,,,~+II,~+?III7
|
||||
7 I?~:?+=~~:,,,~,,,,,,,,,,,:,,,,,,,,=+~,:=?=:~~~II7
|
||||
I:+~=+=~==::~,,~::~,,,::::,::~,,,:7+:+???77
|
||||
,~=++~?I,,~:~:~==:~:~~~+::~:~,,,,,+?=77=7
|
||||
+I7777:,~~~=+=+??+=~~+??++++=+?=~,,,,,,=
|
||||
?,,,,:=?=:::????????????II+:,,,=:,,,,,,
|
||||
,,:~:=+=:,,,,:???I77?+?7=:,,,,~I:,,,,,,:
|
||||
::,:,::++?::,,,,I77~?7I?~,,,::+~,,,,,,,,,,
|
||||
=,,:~:++~~I?+=:::==,,:~7I::~~?II?~=,,+?:,,,+
|
||||
,:~~=I?~?~~=?I+++I::?+?:?++II7+~:~,,,,:,,==:?
|
||||
7:?7I++~~==+?++++=~~::~=~:=+~~:=7?=::+++,,,,~
|
||||
7,,,:+==III+=~~=+====?I+===+?III?7I,=~~~:~=,
|
||||
,~+??==:~+77777?++??+=?I?++?777=,=~:::=I7=
|
||||
+=,:=~===~=,,,7777+?=~:I=7777~:~:~~===+?=~
|
||||
I~=~~II+===:,,,,:+::,,,,,I,~:,,::~====+?~ 7
|
||||
7+~=+=?II==~:~::,:~+:,,,,,:I::~:~~~==++=~~
|
||||
7I=~~~~~=II=~==~~~:~:~I~,,,,,,,:~+=:~~~~==~=~~~=7
|
||||
77777 +~~~~~~~~~~7I+II+=~~~~=:=~:,,,:,,==::~~~~~~+?I+=~~~~=7
|
||||
7=:~~~~:~~~~~~~=~~ 7=+II=~~~~+?:,,~,:,++~~~~~~==? 7I?=~~~~~~~?7 7~:+
|
||||
?:~~~~~~~~~~==II ~~~~~~~::,::::,=?=~~=+II 7II=~~~~~~~~:::~~~~
|
||||
7?~~~~~~~~~?II ~~~~~~==7I++??~~~+I? 7?I?~~~~~~~~~~~~~~
|
||||
??~~~~~~~?I 7==~~=:,~I~,~~?I? 7II=~~~~~~~~~~~~7
|
||||
I~::::~II 7 +~:::~:,,:~?~~7 I++~:::::~=?I
|
||||
~:::::?I 7 7::::::~=+~~ 7I7+:::~I?7
|
||||
I~::::::= I~:::~~7 ::7=::+7
|
||||
I?==+?I7 7~~7I=I7
|
||||
II77 7=+7I7
|
||||
77
|
||||
"
|
||||
echo '
|
||||
.. :iiii,
|
||||
:tLL; .,:...,.
|
||||
.j;:tLt. :. .;j: ij::::;.
|
||||
:tt;:::,ii:.jEEGi :tDEEG:.ti,::::;t:
|
||||
.,,,,,,,,,,,tLEEEEj: tDEEEEDtj;,,,::::::
|
||||
.:,,::::::,;fDEEEEEL,. .,ijDEDDDEEGt,,,,:,ijj;
|
||||
.... ..:;jDDLGDEEEGGGfjjjjjjfffLGDEEDEEDLjfGDt,:..
|
||||
.iftffGDLLDEEEDDDEEDDDDEDEEGLfLjjtti:
|
||||
,fii;jGDGffLjifLGLjtfffffGDEDGfji
|
||||
;DEEGffDDDjiii;;ii;,tGDEGjfEEEEf.
|
||||
,GEGGftiGEEEDt:,;,;;LEEDGjLEEEEEEG
|
||||
;DEDGjtjfitjGGjfDGj;jLLiitfGDEGjEEDj
|
||||
fGjjtfLfji;itjfGDjLDfjjjji;tGGLDEEDj
|
||||
fEDGffjti;ittjjjjtjjjjt:,,iiGGGGjtf.
|
||||
:fGGLfLLfLGf;i;ijffj,,tjLGDDGLfjtf,
|
||||
:;tLfjiiffLGDDDGLGEEEEjfGDDGGLfjfff:
|
||||
.. ,;tLLLLLL,;tijfLGGGjfDEEEEDLLGGGLLLjtjLLfi,.
|
||||
.jffLLLLGGLfjj;: :,;ijLGLfjGEDDEGtfGGLfjj:.,jjLGGLti;,,;fj,
|
||||
,fGGGGGGLj,. ;jGGGGLLjffftjLj;.. .,tfGGGGGGGGGGi
|
||||
,jGDDDj,. :tLGLGGLGDLjt, :iLGGDDDDGLif
|
||||
,LDDDL, .;LDDDDGfff, ,;iGDDj;,..
|
||||
;fGGGf, ,;;;;,: tf;jL,
|
||||
;.:::, Powered by xCAT ,j.:;
|
||||
'
|
||||
echo -e "\$RESET"
|
||||
echo -e "\$YELLOW"
|
||||
echo '
|
||||
@ -575,7 +565,7 @@ EOS1
|
||||
}
|
||||
print $inifile <<EOMS;
|
||||
# check and see if debug is specified on command line
|
||||
grep '\(debug\)' /proc/cmdline > /dev/null && DEBUG=1
|
||||
grep '\(debug\)' /proc/cmdline > /dev/null && export DEBUG=1
|
||||
netstart
|
||||
while ! ifconfig | grep inet; do
|
||||
echo -e "\${RED}Failed to acquire address, retrying \${RESET}"
|
||||
@ -614,36 +604,40 @@ for i in `cat /proc/cmdline`; do
|
||||
VALUE=`echo \$i |awk -F= '{print \$2}'`
|
||||
SERVER=`echo \$VALUE|awk -F: '{print \$1}'`
|
||||
ROOTDIR=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'`
|
||||
elif [ "\$KEY" == 'SNAPSHOT' ]; then
|
||||
elif [ "\$KEY" == 'STATEMNT' ]; then
|
||||
NFSROOT=1
|
||||
VALUE=`echo \$i |awk -F= '{print \$2}'`
|
||||
SNAPSHOTSERVER=`echo \$VALUE|awk -F: '{print \$1}'`
|
||||
SNAPSHOTROOT=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'`
|
||||
# may be that there is not server and just a directory.
|
||||
if [ -z \$SNAPSHOTROOT ]
|
||||
then
|
||||
SNAPSHOTROOT=\$SNAPSHOTSERVER
|
||||
SNAPSHOTSERVER=
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# show xCAT logo
|
||||
fancydisplay
|
||||
|
||||
# go to debug shell if shell is specified.
|
||||
grep '\(shell\)' /proc/cmdline > /dev/null && shell
|
||||
|
||||
echo 0 > /proc/sys/vm/zone_reclaim_mode #Avoid kernel bug
|
||||
|
||||
# NFSROOT code here:
|
||||
if [ "\$NFSROOT" = "1" ]; then
|
||||
echo Setting up nfs with ram overlay.
|
||||
echo Setting up Statelite
|
||||
# for loop back mounting capability!
|
||||
mknod /dev/loop0 b 7 0
|
||||
mkdir -p \$NEWROOT
|
||||
MAXTRIES=5
|
||||
ITER=0
|
||||
ME=`hostname`
|
||||
MAXTRIES=5
|
||||
ITER=0
|
||||
ME=`hostname`
|
||||
while ! mount.nfs \${SERVER}:\${ROOTDIR}/rootimg \$NEWROOT -r -n -o nolock,rsize=32768,udp,nfsvers=3,timeo=14
|
||||
do
|
||||
ITER=\$(expr \$ITER + 1)
|
||||
if [ "\$ITER" == "\$MAXTRIES" ]
|
||||
then
|
||||
then
|
||||
echo "You're dead. rpower \$ME boot to play again."
|
||||
echo "Possible problems:
|
||||
1. This initrd wasn't created for statelite node? rerun genimage with the -m statelite flag, then rerun 'nodeset \$ME statelite'
|
||||
@ -665,54 +659,108 @@ if [ "\$NFSROOT" = "1" ]; then
|
||||
if [ ! -e "\$NEWROOT/\$RWDIR" ]
|
||||
then
|
||||
echo ""
|
||||
echo -e "\${RED}Hmmm... this NFS root directory doesn't have a /.snapshot directory for me to mount a rw filesystem. You'd better create it... \${NORMAL}"
|
||||
echo -e "\${RED}Hmmm... this NFS root directory doesn't have a /\$RWDIR directory for me to mount a rw filesystem. You'd better create it... \${NORMAL}"
|
||||
echo "."
|
||||
shell
|
||||
fi
|
||||
|
||||
grep '\(shell\)' /proc/cmdline >/dev/null && shell
|
||||
if [ -e "\$NEWROOT/\$RWDIR/files" ]; then
|
||||
mkdir -p /rw
|
||||
mount -t tmpfs rw /rw
|
||||
cp \$NEWROOT/\$RWDIR/files /rw/ # copy the files from .snapshot here now
|
||||
mount -n --bind /rw \$NEWROOT/\$RWDIR # remount read/writable
|
||||
|
||||
for i in `grep -v "^#" \$NEWROOT/\$RWDIR/files`; do
|
||||
if [ -e \$NEWROOT/\$i ]; then
|
||||
mountfile \$i \$ME
|
||||
fi;
|
||||
done
|
||||
else
|
||||
echo -e "\${RED}\$NEWROOT/\$RWDIR/files does not exist! I need a list of files to mount read write... or else we'll try mounting everything read only. \$RESET"
|
||||
while [ ! -e "\$NEWROOT/etc/init.d/statelite" ]
|
||||
do
|
||||
echo ""
|
||||
echo -e "\${RED}Hmmm... \$NEWROOT/etc/init.d/statelite doesn't exist. Perhaps you didn't create this image with the -m statelite mode"
|
||||
echo ""
|
||||
shell
|
||||
done
|
||||
grep '\\(shell\\)' /proc/cmdline >/dev/null && shell
|
||||
mount -t tmpfs rw \$NEWROOT/\$RWDIR
|
||||
mkdir -p \$NEWROOT/\$RWDIR/tmpfs
|
||||
|
||||
|
||||
# mount the SNAPSHOT directory here for persistent use.
|
||||
if [ ! -z \$SNAPSHOTSERVER ]
|
||||
then
|
||||
mkdir -p \$NEWROOT/\$RWDIR/persistent
|
||||
MAXTRIES=5
|
||||
ITER=0
|
||||
while ! mount \$SNAPSHOTSERVER:\$SNAPSHOTROOT \$NEWROOT/\$RWDIR/persistent
|
||||
do
|
||||
ITER=\$(expr \$ITER + 1)
|
||||
if [ "\$ITER" == "\$MAXTRIES" ]
|
||||
then
|
||||
echo "You're 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."
|
||||
shell
|
||||
exit
|
||||
fi
|
||||
echo -e "\${RED}Hmmm... Can't mount \$SNAPSHOTSERVER:\$SNAPSHOTROOT. \${NORMAL}"
|
||||
RS=`expr \$RANDOM % 20`
|
||||
echo -e "Trying again in \$RS seconds"
|
||||
sleep \$RS
|
||||
done
|
||||
fi
|
||||
|
||||
grep '\\(shell\\)' /proc/cmdline >/dev/null && shell
|
||||
|
||||
# have to preserve the initial DHCP request. So we link it.
|
||||
|
||||
if [ ! -d \$NEWROOT/\$RWDIR/\$ME/var/lib/dhclient ]
|
||||
if [ ! -d \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhclient ]
|
||||
then
|
||||
mkdir -p \$NEWROOT/\$RWDIR/\$ME/var/lib/dhclient
|
||||
mkdir -p \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhclient
|
||||
fi
|
||||
if [ ! -d \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhcp ]
|
||||
then
|
||||
mkdir -p \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhcp
|
||||
fi
|
||||
|
||||
cp -fp /var/lib/dhclient/dhclient.leases \$NEWROOT/\$RWDIR/\$ME/var/lib/dhclient/dhclient-$prinic.leases
|
||||
cp -fp /var/lib/dhclient/dhclient.leases \${NEWROOT}/\${RWDIR}/tmpfs/var/lib/dhclient/dhclient-$prinic.leases
|
||||
cp -fp /var/lib/dhclient/dhclient.leases \${NEWROOT}/\${RWDIR}/tmpfs/var/lib/dhcp/dhclient-$prinic.leases
|
||||
|
||||
while ! mount -n --bind \$NEWROOT/\$RWDIR/\$ME/var/lib/dhclient/dhclient-$prinic.leases \$NEWROOT/var/lib/dhclient/dhclient-$prinic.leases;
|
||||
# dhclient
|
||||
#while ! mount -n --bind \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhclient/dhclient-$prinic.leases \$NEWROOT/var/lib/dhclient/dhclient-$prinic.leases
|
||||
#do
|
||||
# echo "Can't mount /tmpfs/var/lib/dhclient/dhclient-$prinic.leases to /var/lib/dhclient/dhclient-$prinic.leases"
|
||||
# shell
|
||||
#done
|
||||
|
||||
# dhcp
|
||||
#while ! mount -n --bind \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhcp/dhclient-$prinic.leases \$NEWROOT/var/lib/dhcp/dhclient-$prinic.leases
|
||||
#do
|
||||
# echo "Can't mount /tmpfs/var/lib/dhcp/dhclient-$prinic.leases to /var/lib/dhcp/dhclient-$prinic.leases"
|
||||
# shell
|
||||
#done
|
||||
|
||||
|
||||
|
||||
[ -e /etc/ntp.conf ] && mkdir -p \$NEWROOT/\$RWDIR/tmpfs/etc && cp /etc/ntp.conf \$NEWROOT/\$RWDIR/tmpfs/etc/
|
||||
|
||||
|
||||
[ -e /etc/ntp/step-kickers ] && mkdir -p \$NEWROOT/\$RWDIR/tmpfs/etc/ntp && cp /etc/ntp/step-kickers \$NEWROOT/\$RWDIR/tmpfs/etc/ntp
|
||||
|
||||
|
||||
[ -e /etc/resolv.conf ] && mkdir -p \$NEWROOT/\$RWDIR/tmpfs/etc && cp /etc/resolv.conf \$NEWROOT/\$RWDIR/tmpfs/etc/
|
||||
|
||||
# now that everything is mounted, lets do this
|
||||
# hmmm, apparently I'm checking this twice... so I'd better
|
||||
# be really sure the file is there.
|
||||
while [ -z \$NEWROOT/etc/init.d/statelite ]
|
||||
do
|
||||
echo -e "\${RED}The file /var/lib/dhclient/dhclient-$prinic.leases on your NFS root doesn't exist. I can't bind mount to it :-( \${RESET}"
|
||||
echo -e "\${PINK}You'd better create it! :-) \${RESET}"
|
||||
echo "\$NEWROOT/etc/init.d/statelite does not exist in image!"
|
||||
shell
|
||||
done
|
||||
|
||||
# mount /etc/resolv.conf!
|
||||
mkdir -p \$NEWROOT/\$RWDIR/\$ME/etc
|
||||
cp /etc/resolv.conf \$NEWROOT/\$RWDIR/\$ME/etc/
|
||||
mount -n --bind \$NEWROOT/\$RWDIR/\$ME/etc/resolv.conf \$NEWROOT/\$RWDIR/\$ME/etc/resolv.conf
|
||||
# do all the mounts:
|
||||
\$NEWROOT/etc/init.d/statelite
|
||||
|
||||
# give the debug shell just before we go if specified!
|
||||
grep '\(shell\)' /proc/cmdline > /dev/null && shell
|
||||
|
||||
echo 0x100 > /proc/sys/kernel/real-root-dev
|
||||
export keep_old_ip=yes
|
||||
export fastboot=yes
|
||||
export READONLY=yes
|
||||
grep '\\(shell\\)' /proc/cmdline >/dev/null && shell
|
||||
mount -n --bind /dev /sysroot/dev
|
||||
umount /sys
|
||||
umount /proc
|
||||
@ -721,7 +769,7 @@ if [ "\$NFSROOT" = "1" ]; then
|
||||
then
|
||||
echo ""
|
||||
echo -e "\${RED}Couldn't switch_root. Something must be wrong with NFS root image.\${RESET}"
|
||||
mount -t proc proc /proc
|
||||
# mount -t proc proc /proc
|
||||
shell
|
||||
fi
|
||||
exit
|
||||
|
Loading…
Reference in New Issue
Block a user