2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-06-13 09:50:19 +00:00

split the post.ubuntu and upgrade the post.xcat

This commit is contained in:
penguhyang
2016-02-26 00:48:04 -05:00
parent 617831d289
commit 97e29171ba
7 changed files with 194 additions and 365 deletions

View File

@ -53,7 +53,7 @@ Assume that /tftpboot is the root for tftpd (set in site(5)|site.5).
\ **nodeset**\ is called by rinstall and winstall and is also called by the
installation process remotely to set the boot state back to "boot".
A user can supply their own scripts to be run on the mn or on the service node (if a hierarchical cluster) for a node when the nodeset command is run. Such scripts are called \ **prescripts**\ . They should be copied to /install/prescripts dirctory. A table called \ *prescripts*\ is used to specify the scripts and their associated actions. The scripts to be run at the beginning of the nodeset command are stored in the 'begin' column of \ *prescripts*\ table. The scripts to be run at the end of the nodeset command are stored in the 'end' column of \ *prescripts*\ table. You can run 'tabdump prescripts -d' command for details. The following two environment variables will be passed to each script: NODES contains all the names of the nodes that need to run the script for and ACTION contains the current nodeset action. If \ *#xCAT setting:MAX_INSTANCE=number*\ is specified in the script, the script will get invoked for each node in parallel, but no more than \ *number*\ of instances will be invoked at at a time. If it is not specified, the script will be invoked once for all the nodes.
A user can supply their own scripts to be run on the mn or on the service node (if a hierarchical cluster) for a node when the nodeset command is run. Such scripts are called \ **prescripts**\ . They should be copied to /install/prescripts dirctory. A table called \ *prescripts*\ is used to specify the scripts and their associated actions. The scripts to be run at the beginning of the nodeset command are stored in the 'begin' column of \ *prescripts*\ table. The scripts to be run at the end of the nodeset command are stored in the 'end' column of \ *prescripts*\ table. You can run 'tabdump -d prescripts' command for details. The following two environment variables will be passed to each script: NODES contains all the names of the nodes that need to run the script for and ACTION contains the current nodeset action. If \ *#xCAT setting:MAX_INSTANCE=number*\ is specified in the script, the script will get invoked for each node in parallel, but no more than \ *number*\ of instances will be invoked at at a time. If it is not specified, the script will be invoked once for all the nodes.
***************

View File

@ -34,7 +34,7 @@ B<nodeset> only sets the next boot state, but does not reboot.
B<nodeset> is called by rinstall and winstall and is also called by the
installation process remotely to set the boot state back to "boot".
A user can supply their own scripts to be run on the mn or on the service node (if a hierarchical cluster) for a node when the nodeset command is run. Such scripts are called B<prescripts>. They should be copied to /install/prescripts dirctory. A table called I<prescripts> is used to specify the scripts and their associated actions. The scripts to be run at the beginning of the nodeset command are stored in the 'begin' column of I<prescripts> table. The scripts to be run at the end of the nodeset command are stored in the 'end' column of I<prescripts> table. You can run 'tabdump prescripts -d' command for details. The following two environment variables will be passed to each script: NODES contains all the names of the nodes that need to run the script for and ACTION contains the current nodeset action. If I<#xCAT setting:MAX_INSTANCE=number> is specified in the script, the script will get invoked for each node in parallel, but no more than I<number> of instances will be invoked at at a time. If it is not specified, the script will be invoked once for all the nodes.
A user can supply their own scripts to be run on the mn or on the service node (if a hierarchical cluster) for a node when the nodeset command is run. Such scripts are called B<prescripts>. They should be copied to /install/prescripts dirctory. A table called I<prescripts> is used to specify the scripts and their associated actions. The scripts to be run at the beginning of the nodeset command are stored in the 'begin' column of I<prescripts> table. The scripts to be run at the end of the nodeset command are stored in the 'end' column of I<prescripts> table. You can run 'tabdump -d prescripts' command for details. The following two environment variables will be passed to each script: NODES contains all the names of the nodes that need to run the script for and ACTION contains the current nodeset action. If I<#xCAT setting:MAX_INSTANCE=number> is specified in the script, the script will get invoked for each node in parallel, but no more than I<number> of instances will be invoked at at a time. If it is not specified, the script will be invoked once for all the nodes.
=head1 B<Options>

View File

@ -1,310 +1,2 @@
#!/bin/bash
#
# Setup hostname
#
echo "post scripts" >/root/post.log
[ $XCATDEBUGMODE ] || export XCATDEBUGMODE="#TABLEBLANKOKAY:site:key=xcatdebugmode:value#"
[ $MASTER_IP ] || export MASTER_IP="#ENV:MASTER_IP#"
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/scriptlib#
export PRINIC=#TABLEBLANKOKAY:noderes:THISNODE:primarynic#
if [ "$PRINIC" == "mac" ]
then
export PRINIC='#GETPRINICMAC:THISNODE#'
fi
if [ -z "$PRINIC" ]
then
export PRINIC=eth0
elif [[ `echo "$PRINIC" | grep -sqE ^[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+$ ;echo $?` == "0" ]]; then
#export PRINIC=`ifconfig -a | grep -i "HWaddr $PRINIC" | awk '{print $1}'`
export PRINIC=`ip -o link|grep -i "$PRINIC" |awk '{print $2}'|sed s/://`
fi
#IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}')
IP=$(ip addr show dev $PRINIC | grep inet | grep -v inet6 | awk '{print $2}' | head -n 1 | awk -F '/' '{print $1}')
if [ -z $IP ]
then
dhclient $PRINIC
#IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}')
IP=$(ip addr show dev $PRINIC | grep inet | grep -v inet6 | awk '{print $2}' | head -n 1 | awk -F '/' '{print $1}')
fi
if [ "$XCATDEBUGMODE" > "0" ]; then
msgutil_r "$MASTER_IP" "debug" "PRINIC=$PRINIC,IP=$IP" "/var/log/xcat/xcat.log"
fi
if [ "$XCATDEBUGMODE" > "0" ]; then
msgutil_r "$MASTER_IP" "debug" "generating /etc/resolv.conf" "/var/log/xcat/xcat.log"
fi
echo "search #TABLE:site:key=domain:value#" >/etc/resolv.conf
for i in $(echo #TABLE:site:key=nameservers:value# | tr ',' ' ')
do
echo "nameserver $i"
done >>/etc/resolv.conf
#change the soft link /bin/sh to /bin/bash
ln -sf /bin/bash /bin/sh
#
#delete the useless apt repo
#sed -i 's/^deb.*updates.*$/#&/g' /etc/apt/sources.list
# Run xCAT post install
#
export MASTER_IP="#ENV:MASTER_IP#"
export MASTER_IPS="#XCATVAR:XCATMASTER#"
export MASTER="#XCATVAR:XCATMASTER#"
export INSTALLDIR=#TABLE:site:key=installdir:value#
if [ -z "$INSTALLDIR" ]; then
INSTALLDIR="/install"
fi
cd /tmp
RAND=$(perl -e 'print int(rand(50)). "\n"')
sleep $RAND
for j in $(seq 1 20)
do
GOTIT=0
for i in $MASTER_IPS
do
if [ "$XCATDEBUGMODE" > "0" ]; then
msgutil_r "$MASTER_IP" "debug" "downloading postscripts from http://$i$INSTALLDIR/postscripts/" "/var/log/xcat/xcat.log"
fi
wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -e robots=off -nH --cut-dirs=2 --reject "index.html*" --no-parent -t 0 -T 60 http://$i$INSTALLDIR/postscripts/ -P /xcatpost
#wget --wait=10 --random-wait --waitretry=10 --retry-connrefused -t 0 -T 60 http://$i/install/autoinst/xcatpost.tar.gz
if [ "$?" = "0" ]
then
if [ ! -x /usr/bin/openssl ]; then #Stop if no openssl to help the next bit
if [ "$XCATDEBUGMODE" > "0" ]; then
msgutil_r "$MASTER_IP" "debug" "/usr/bin/openssl does not exist,exit..." "/var/log/xcat/xcat.log"
fi
exit 1
fi
USEOPENSSLFORXCAT=1 #Though this is the only method going forward, flag to allow backward compatibility with 2.2 generated netboot images
export USEOPENSSLFORXCAT
XCATSERVER=$i:3001
export XCATSERVER
mv $i/postscripts /xcatpost
rm -rf $i
# To support the postscripts in the subdirectories under /install/postscripts
#chmod +x /xcatpost/*
chmod -R +x `find /xcatpost/ -maxdepth 1 -print | grep -E -v '^(/xcatpost/|/xcatpost/_xcat|/xcatpost/_ssh|/xcatpost/ca|/xcatpost/hostkeys)$'`
if [ "$XCATDEBUGMODE" > "0" ]; then
msgutil_r "$MASTER_IP" "debug" "trying to get mypostscript with getpostscript.awk" "/var/log/xcat/xcat.log"
fi
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/&lt;/</g' -e 's/&gt;/>/g' -e 's/&amp;/\&/g' -e 's/&quot;/"/g' -e "s/&apos;/'/g" > /xcatpost/mypostscript
MYCONT=`grep ^MASTER= /xcatpost/mypostscript`
MAX_RETRIES=10
RETRY=0
while [ -z "$MYCONT" ]; do
RETRY=$(($RETRY+1))
if [ $RETRY -eq $MAX_RETRIES ]
then
break
fi
let SLI=$RANDOM%10+10
sleep $SLI
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/&lt;/</g' -e 's/&gt;/>/g' -e 's/&amp;/\&/g' -e 's/&quot;/"/g' -e "s/&apos;/'/g" > /xcatpost/mypostscript
MYCONT=`grep ^MASTER= /xcatpost/mypostscript`
done
chmod +x /xcatpost/mypostscript
GOTIT=1
break
fi
done
if [ "$GOTIT" = "1" ]
then
#save the master to /opt/xcat/xcatinfo file
if [ ! -f /opt/xcat/xcatinfo ]; then
mkdir -p /opt/xcat
touch /opt/xcat/xcatinfo
fi
echo "XCATSERVER=$i" > /opt/xcat/xcatinfo
break
fi
RAND=$(perl -e 'print int(rand(5)). "\n"')
sleep $RAND
done
cd /xcatpost
#gunzip xcatpost.tar.gz
#tar -xvf xcatpost.tar
#/xcatpost/#TABLE:nodelist:THISNODE:node#
export PATH=$PATH:/xcatpost
#save the postboot scripts to /var/tmp/mypostscript.post
#
# mypostscript.post must survive a reboot. Traditionally, xCAT has put mypostscript.post in /tmp.
# However, Ubuntu cleans /tmp on reboot. So, for Ubuntu, /var/tmp is used instead.
# use the run_ps subroutine to run the postscripts
TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /xcatpost/mypostscript`
echo "
. /xcatpost/xcatlib.sh
# global value to store the running status of the postbootscripts,the value is non-zero if one postbootscript failed
return_value=0
# subroutine used to run postscripts
run_ps () {
local ret_local=0
mkdir -p "\"/var/log/xcat\""
# On Ubuntu, the rsyslogd daemon write log files with syslog:adm
# permissison. And in some case, the directory /var/log/xcat was
# created by xCAT, and had root:root ownership. In this way, rsyslogd
# did not have enough permission to write to log files under this
# directory.
# As a dirty hack, change the ownership of directory /var/log/xcat
# to the same ownership of directory /var/log.
chown `ls -ld /var/log | awk '{ print \$3\":\"\$4 }'` "\"/var/log/xcat\""
local logfile=\"/var/log/xcat/xcat.log\"
if [ -f \$1 ]; then
echo \"\`date\` Running postscript: \$*\"
msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` Running postscript: \$*\"" \"\$logfile\"
if [ \"\$XCATDEBUGMODE\" = \"1\" ]; then
local compt=\$(file \$1)
local reg=\"shell script\"
if [[ \"\$compt\" =~ \$reg ]]; then
bash -x ./\$@ 2>&1 | tee -a \$logfile | logger -t xcat -p debug
ret_local=\${PIPESTATUS[0]}
else
./\$@ 2>&1 | tee -a \$logfile | logger -t xcat -p debug
ret_local=\${PIPESTATUS[0]}
fi
else
./\$@ 2>&1 | tee -a \$logfile
ret_local=\${PIPESTATUS[0]}
fi
if [ \"\$ret_local\" -ne \"0\" ]; then
return_value=\$ret_local
fi
echo \"Postscript: \$* exited with code \$ret_local\"
msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` postscript \$* return with \$ret_local\"" \"\$logfile\"
else
echo \"\`date\` Postscript \$1 does NOT exist.\"
msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` Postscript \$1 does NOT exist.\"" \"\$logfile\"
return_value=-1
fi
return 0
}
# subroutine end
" > /xcatpost/mypostscript
echo "$TMP" >> /xcatpost/mypostscript
TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /xcatpost/mypostscript`
echo "$TMP" > /xcatpost/mypostscript
TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /xcatpost/mypostscript`
echo "$TMP" > /xcatpost/mypostscript.post
chmod 755 /xcatpost/mypostscript.post
#create the post init
cat >/etc/init.d/xcatpostinit1 << 'EOF'
#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatpostinit1#
EOF
chmod 755 /etc/init.d/xcatpostinit1
ln -s /etc/init.d/xcatpostinit1 /etc/rc2.d/S84xcatpostinit1
mkdir -p /opt/xcat
cat >/opt/xcat/xcatinstallpost << 'EOF'
#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost#
if [ -f /xcatpost/mypostscript.post ]; then
RUNBOOTSCRIPTS=`grep 'RUNBOOTSCRIPTS=' /xcatpost/mypostscript.post |cut -d= -f2`
fi
if [ "$RUNBOOTSCRIPTS" != "'yes'" ]; then
msgutil_r "$MASTER_IP" "debug" "update-rc.d -f xcatpostinit1 remove" "/var/log/xcat/xcat.log"
update-rc.d -f xcatpostinit1 remove
fi
echo "REBOOT=TRUE" >> /opt/xcat/xcatinfo
EOF
chmod 755 /opt/xcat/xcatinstallpost
update-rc.d xcatpostinit1 defaults
#create the dskls post
cat >/opt/xcat/xcatdsklspost << 'EOF'
#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatdsklspost#
EOF
chmod 755 /opt/xcat/xcatdsklspost
#only run the prebooot scripts here
TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /xcatpost/mypostscript`
echo "$TMP" > /xcatpost/mypostscript
if [ "$XCATDEBUGMODE" > "0" ]; then
msgutil_r "$MASTER_IP" "debug" "running mypostscript" "/var/log/xcat/xcat.log"
fi
/xcatpost/mypostscript
if [ "$XCATDEBUGMODE" > "0" ]; then
msgutil_r "$MASTER_IP" "debug" "mypostscript return" "/var/log/xcat/xcat.log"
fi
export NODE=#TABLE:nodelist:THISNODE:node#
export OSVER=#TABLE:nodetype:THISNODE:os#
export ARCH=#TABLE:nodetype:THISNODE:arch#
export CONSOLEPORT=#TABLEBLANKOKAY:nodehm:THISNODE:serialport#
#addsiteyum
if [[ -r /boot/grub/menu.lst ]]; then
sed -i 's/^serial/#serial/' /boot/grub/menu.lst
sed -i 's/^terminal/#terminal/' /boot/grub/menu.lst
elif [[ -r /boot/grub/grub.cfg ]] ; then
update-grub
fi
if echo "$ARCH" | grep -i 'ppc64'; then
if [ -z "$CONSOLEPORT" ] ; then
export CONSOLEPORT=0
fi
CONSOLE="hvc$CONSOLEPORT"
if [[ -r /etc/default/grub ]] ; then
sed -i "s/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"console=$CONSOLE\"/" /etc/default/grub
else
echo "GRUB_CMDLINE_LINUX_DEFAULT=\"console=$CONSOLE\"" > /etc/default/grub
fi
update-grub
cat >/etc/init/$CONSOLE\.conf << 'EOF'
start on stopped rc RUNLEVEL=[2345] and (
not-container or
container CONTAINER=lxc or
container CONTAINER=lxc-libvirt)
stop on runlevel [!2345]
respawn
#exec /sbin/getty -L 115200 hvc0 vt102
script
for i in `cat /proc/cmdline`; do
KEY=`echo $i|cut -d= -f 1`
if [ "$KEY" == "console" -a "$i" != "console=tty0" ]; then
VALUE=`echo $i | awk -F= '{print $2}'`
COTTY=`echo $VALUE|awk -F, '{print $1}'`
COSPEED=`echo $VALUE|awk -F, '{print $2}'|awk -Fn '{print $1}'`
break
fi
done
exec /sbin/getty -L $COSPEED $COTTY vt102
end script
EOF
fi
#sed -i 's/\(deb.*security.*\)/#\1/' /etc/apt/sources.list
#iso does not contains source deb packages
#sed -i 's/^\(\s*deb-src.*install.*\)$/#\1/g' /etc/apt/sources.list
#delete the 127.0.1.1 line from /etc/hosts
sed -i '/127.0.1.1/d' /etc/hosts
if [ "$XCATDEBUGMODE" > "0" ]; then
msgutil_r "$MASTER_IP" "debug" "installation finished, reporting status..." "/var/log/xcat/xcat.log"
fi
updateflag.awk $MASTER 3002
cd /
#rm -Rf /xcatpost
#rm -f /tmp/mypostscript
exit 0
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.ubuntu.common#
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.xcat#

View File

@ -0,0 +1,49 @@
#!/bin/bash
#
# Setup hostname
#
echo "post scripts" >/root/post.log
[ $XCATDEBUGMODE ] || export XCATDEBUGMODE="#TABLEBLANKOKAY:site:key=xcatdebugmode:value#"
[ $MASTER_IP ] || export MASTER_IP="#ENV:MASTER_IP#"
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/scriptlib#
export PRINIC=#TABLEBLANKOKAY:noderes:THISNODE:primarynic#
if [ "$PRINIC" == "mac" ]
then
export PRINIC='#GETPRINICMAC:THISNODE#'
fi
if [ -z "$PRINIC" ]
then
export PRINIC=eth0
elif [[ `echo "$PRINIC" | grep -sqE ^[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+$ ;echo $?` == "0" ]]; then
#export PRINIC=`ifconfig -a | grep -i "HWaddr $PRINIC" | awk '{print $1}'`
export PRINIC=`ip -o link|grep -i "$PRINIC" |awk '{print $2}'|sed s/://`
fi
#IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}')
IP=$(ip addr show dev $PRINIC | grep inet | grep -v inet6 | awk '{print $2}' | head -n 1 | awk -F '/' '{print $1}')
if [ -z $IP ]
then
dhclient $PRINIC
#IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}')
IP=$(ip addr show dev $PRINIC | grep inet | grep -v inet6 | awk '{print $2}' | head -n 1 | awk -F '/' '{print $1}')
fi
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "PRINIC=$PRINIC,IP=$IP" "/var/log/xcat/xcat.log"
fi
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "generating /etc/resolv.conf" "/var/log/xcat/xcat.log"
fi
echo "search #TABLE:site:key=domain:value#" >/etc/resolv.conf
for i in $(echo #TABLE:site:key=nameservers:value# | tr ',' ' ')
do
echo "nameserver $i"
done >>/etc/resolv.conf
#change the soft link /bin/sh to /bin/bash
ln -sf /bin/bash /bin/sh

View File

@ -11,8 +11,7 @@ export XCATDEBUGMODE="#TABLEBLANKOKAY:site:key=xcatdebugmode:value#"
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/scriptlib#
if [ "$XCATDEBUGMODE" != "0" ] && [ "$XCATDEBUGMODE" != "" ]
then
if [ "$XCATDEBUGMODE" = "1" ]; then
set -x
fi
@ -31,7 +30,7 @@ fi
cd /tmp
RAND=$(perl -e 'print int(rand(50)). "\n"')
if [ "$XCATDEBUGMODE" != "0" ]; then
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "sleep $RAND" "/var/log/xcat/xcat.log"
fi
sleep $RAND
@ -50,13 +49,13 @@ if [ ! -f /opt/xcat/xcatinfo ]; then
fi
echo "XCATSERVER=$MASTER_IP" > /opt/xcat/xcatinfo
echo "INSTALLDIR=$INSTALLDIR" >> /opt/xcat/xcatinfo
if [ "$XCATDEBUGMODE" != "0" ]; then
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "/opt/xcat/xcatinfo generated" "/var/log/xcat/xcat.log"
fi
# download the postscripts
if [ "$XCATDEBUGMODE" != "0" ]; then
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "trying to download postscripts from http://$MASTER_IP$INSTALLDIR/postscripts/" "/var/log/xcat/xcat.log"
fi
@ -74,7 +73,7 @@ if [ "$?" != "0" ]; then
sleep 36500d
fi
chmod -R +x `find /xcatpost/ -maxdepth 1 -print | grep -E -v '^(/xcatpost/|/xcatpost/_xcat|/xcatpost/_ssh|/xcatpost/ca|/xcatpost/hostkeys)$'`
if [ "$XCATDEBUGMODE" != "0" ]; then
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "postscripts downloaded successfully" "/var/log/xcat/xcat.log"
fi
@ -85,13 +84,13 @@ if [ -x /xcatpost/mypostscript ]; then
fi
export NODE=#TABLE:nodelist:THISNODE:node#
if [ "$XCATDEBUGMODE" != "0" ]; then
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "trying to download precreated mypostscript file http://$MASTER_IP$TFTPDIR/mypostscripts/mypostscript.$NODE" "/var/log/xcat/xcat.log"
fi
wget -N --waitretry=10 --random-wait --retry-connrefused -t 20 -T 60 http://$MASTER_IP$TFTPDIR/mypostscripts/mypostscript.$NODE -P /xcatpost 2> /tmp/wget.log
if [ "$?" = "0" ]; then
if [ "$XCATDEBUGMODE" != "0" ]; then
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "precreated mypostscript downloaded successfully" "/var/log/xcat/xcat.log"
fi
mv /xcatpost/mypostscript.$NODE /xcatpost/mypostscript
@ -105,7 +104,7 @@ export XCATSERVER
# If mypostscript doesn't exist, we will get it through getpostscript.awk
if [ ! -x /xcatpost/mypostscript ]; then
if [ "$XCATDEBUGMODE" != "0" ]; then
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "failed to download precreated mypostscript, trying to generate with getpostscript.awk" "/var/log/xcat/xcat.log"
fi
@ -147,8 +146,7 @@ export PATH=$PATH:/xcatpost
# use the run_ps subroutine to run the postscripts
if [ "$XCATDEBUGMODE" != "0" ] && [ "$XCATDEBUGMODE" != "" ]
then
if [ "$XCATDEBUGMODE" = "1" ]; then
echo "set -x" > /xcatpost/mypostscript
else
cat /dev/null > /xcatpost/mypostscript
@ -209,8 +207,7 @@ run_ps () {
" >> /xcatpost/mypostscript
echo "$TMP" >> /xcatpost/mypostscript
if [ "$XCATDEBUGMODE" != "0" ] && [ "$XCATDEBUGMODE" != "" ]
then
if [ "$XCATDEBUGMODE" = "1" ]; then
echo "set +x" >> /xcatpost/mypostscript
fi
@ -220,7 +217,7 @@ if [ ! -x /xcatpost/mypostscript ]; then
updateflag $MASTER $XCATIPORT "installstatus failed"
sleep 36500d
else
if [ "$XCATDEBUGMODE" != "0" ]; then
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "generate mypostscript file successfully" "/var/log/xcat/xcat.log"
fi
fi
@ -232,11 +229,11 @@ echo "$TMP" > /xcatpost/mypostscript.post
chmod 755 /xcatpost/mypostscript.post
if [ ! -x /xcatpost/mypostscript.post ]; then
if [ "$XCATDEBUGMODE" != "0" ]; then
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "failed to generate /xcatpost/mypostscript.post" "/var/log/xcat/xcat.log"
fi
else
if [ "$XCATDEBUGMODE" != "0" ]; then
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "/xcatpost/mypostscript.post generated" "/var/log/xcat/xcat.log"
fi
fi
@ -249,36 +246,58 @@ EOF
chmod 755 /etc/init.d/xcatpostinit1
if [ ! -x /etc/init.d/xcatpostinit1 ]; then
if [ "$XCATDEBUGMODE" != "0" ]; then
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "failed to generate /etc/init.d/xcatpostinit1" "/var/log/xcat/xcat.log"
fi
else
if [ "$XCATDEBUGMODE" != "0" ]; then
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "/etc/init.d/xcatpostinit1 generated" "/var/log/xcat/xcat.log"
fi
fi
ln -s /etc/init.d/xcatpostinit1 /etc/rc.d/rc3.d/S84xcatpostinit1
ln -s /etc/init.d/xcatpostinit1 /etc/rc.d/rc4.d/S84xcatpostinit1
ln -s /etc/init.d/xcatpostinit1 /etc/rc.d/rc5.d/S84xcatpostinit1
export OSVER=#TABLE:nodetype:THISNODE:os#
if [[ $OSVER == sles* ]]; then
if [[ $OSVER == sles10* ]]; then
/sbin/insserv xcatpostinit1
else
/sbin/insserv -p /etc/init.d xcatpostinit1
fi
if [[ $OSVER == ubuntu* ]]; then
ln -s /etc/init.d/xcatpostinit1 /etc/rc2.d/S84xcatpostinit1
else
ln -s /etc/init.d/xcatpostinit1 /etc/rc.d/rc3.d/S84xcatpostinit1
ln -s /etc/init.d/xcatpostinit1 /etc/rc.d/rc4.d/S84xcatpostinit1
ln -s /etc/init.d/xcatpostinit1 /etc/rc.d/rc5.d/S84xcatpostinit1
fi
#chkconfig --add xcatpostinit1
chkconfig xcatpostinit1 on
if [ "$XCATDEBUGMODE" != "0" ]; then
msgutil_r "$MASTER_IP" "debug" "service xcatpostinit1 enabled" "/var/log/xcat/xcat.log"
if [[ $OSVER == ubuntu* ]]; then
update-rc.d xcatpostinit1 defaults
else
if [[ $OSVER == sles* ]]; then
if [[ $OSVER == sles10* ]]; then
/sbin/insserv xcatpostinit1
else
/sbin/insserv -p /etc/init.d xcatpostinit1
fi
fi
#chkconfig --add xcatpostinit1
chkconfig xcatpostinit1 on
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "service xcatpostinit1 enabled" "/var/log/xcat/xcat.log"
fi
fi
#create the xcatinstallpost
mkdir -p /opt/xcat
if [[ $OSVER == ubuntu* ]]; then
cat >/opt/xcat/xcatinstallpost << 'EOF'
#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost#
if [ -f /xcatpost/mypostscript.post ]; then
RUNBOOTSCRIPTS=`grep 'RUNBOOTSCRIPTS=' /xcatpost/mypostscript.post |cut -d= -f2`
fi
if [ "$RUNBOOTSCRIPTS" != "'yes'" ]; then
msgutil_r "$MASTER_IP" "debug" "update-rc.d -f xcatpostinit1 remove" "/var/log/xcat/xcat.log"
update-rc.d -f xcatpostinit1 remove
fi
echo "REBOOT=TRUE" >> /opt/xcat/xcatinfo
EOF
else
cat >/opt/xcat/xcatinstallpost << 'EOF'
#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost#
@ -291,18 +310,19 @@ if [ "$RUNBOOTSCRIPTS" != "'yes'" ]; then
chkconfig xcatpostinit1 off
fi
if [ "$XCATDEBUGMODE" != "0" ]; then
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "service xcatpostinit1 disabled" "/var/log/xcat/xcat.log"
fi
EOF
fi
chmod 755 /opt/xcat/xcatinstallpost
if [ ! -x /opt/xcat/xcatinstallpost ]; then
if [ "$XCATDEBUGMODE" != "0" ]; then
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "failed to generate /opt/xcat/xcatinstallpost" "/var/log/xcat/xcat.log"
fi
else
if [ "$XCATDEBUGMODE" != "0" ]; then
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "/opt/xcat/xcatinstallpost generated" "/var/log/xcat/xcat.log"
fi
fi
@ -315,11 +335,11 @@ EOF
chmod 755 /opt/xcat/xcatdsklspost
if [ ! -x /opt/xcat/xcatdsklspost ]; then
if [ "$XCATDEBUGMODE" != "0" ]; then
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "failed to generate /opt/xcat/xcatdsklspost" "/var/log/xcat/xcat.log"
fi
else
if [ "$XCATDEBUGMODE" != "0" ]; then
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "/opt/xcat/xcatdsklspost generated" "/var/log/xcat/xcat.log"
fi
fi
@ -330,25 +350,76 @@ TMP=`sed "/^#\s*postbootscripts-start-here/,/^#\s*postbootscripts-end-here/ d" /
echo "$TMP" > /xcatpost/mypostscript
chmod 755 /xcatpost/mypostscript
export NODE=#TABLE:nodelist:THISNODE:node#
export ARCH=#TABLE:nodetype:THISNODE:arch#
addsiteyum
if [ "$XCATDEBUGMODE" != "0" ]; then
export CONSOLEPORT=#TABLEBLANKOKAY:nodehm:THISNODE:serialport#
if [[ $OSVER != ubuntu* ]]; then
addsiteyum
fi
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "info" "running mypostscript" "/var/log/xcat/xcat.log"
fi
/xcatpost/mypostscript
if [ "$XCATDEBUGMODE" != "0" ]; then
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "info" "mypostscript returned" "/var/log/xcat/xcat.log"
fi
sed -i 's/^serial/#serial/' /boot/grub/grub.conf
sed -i 's/^terminal/#terminal/' /boot/grub/grub.conf
if [ "$XCATDEBUGMODE" != "0" ]; then
msgutil_r "$MASTER_IP" "debug" "/boot/grub/grub.conf updated" "/var/log/xcat/xcat.log"
if [[ $OSVER == ubuntu* ]]; then
if [[ -r /boot/grub/menu.lst ]]; then
sed -i 's/^serial/#serial/' /boot/grub/menu.lst
sed -i 's/^terminal/#terminal/' /boot/grub/menu.lst
elif [[ -r /boot/grub/grub.cfg ]] ; then
update-grub
fi
if echo "$ARCH" | grep -i 'ppc64'; then
if [ -z "$CONSOLEPORT" ] ; then
export CONSOLEPORT=0
fi
CONSOLE="hvc$CONSOLEPORT"
if [[ -r /etc/default/grub ]] ; then
sed -i "s/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"console=$CONSOLE\"/" /etc/default/grub
else
echo "GRUB_CMDLINE_LINUX_DEFAULT=\"console=$CONSOLE\"" > /etc/default/grub
fi
update-grub
cat >/etc/init/$CONSOLE\.conf << 'EOF'
start on stopped rc RUNLEVEL=[2345] and (
not-container or
container CONTAINER=lxc or
container CONTAINER=lxc-libvirt)
stop on runlevel [!2345]
respawn
#exec /sbin/getty -L 115200 hvc0 vt102
script
for i in `cat /proc/cmdline`; do
KEY=`echo $i|cut -d= -f 1`
if [ "$KEY" == "console" -a "$i" != "console=tty0" ]; then
VALUE=`echo $i | awk -F= '{print $2}'`
COTTY=`echo $VALUE|awk -F, '{print $1}'`
COSPEED=`echo $VALUE|awk -F, '{print $2}'|awk -Fn '{print $1}'`
break
fi
done
exec /sbin/getty -L $COSPEED $COTTY vt102
end script
EOF
fi
sed -i '/127.0.1.1/d' /etc/hosts
else
sed -i 's/^serial/#serial/' /boot/grub/grub.conf
sed -i 's/^terminal/#terminal/' /boot/grub/grub.conf
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "debug" "/boot/grub/grub.conf updated" "/var/log/xcat/xcat.log"
fi
fi
if [ "$XCATDEBUGMODE" != "0" ]; then
if [ "$XCATDEBUGMODE" = "1" ]; then
msgutil_r "$MASTER_IP" "info" "finished node installation, reporting status..." "/var/log/xcat/xcat.log"
fi
#the following command should always be run to prevent infinite installation loops
@ -356,8 +427,6 @@ updateflag.awk $MASTER 3002
cd /
if [ "$XCATDEBUGMODE" != "0" ] && [ "$XCATDEBUGMODE" != "" ]
then
if [ "$XCATDEBUGMODE" = "1" ]; then
set +x
fi

View File

@ -1,3 +1,8 @@
export XCATDEBUGMODE="#TABLEBLANKOKAY:site:key=xcatdebugmode:value#"
if [ "$XCATDEBUGMODE" = "1" ]; then
set -x
fi
#!/bin/sh
if [ ! -c /dev/vcs ]; then
@ -201,3 +206,7 @@ echo " ." >> /tmp/partitionfile
#XCA_PARTMAN_ADDITIONAL_CONFIG_SCRIPT#
exit 0
if [ "$XCATDEBUGMODE" = "1" ]; then
then
set +x
fi

View File

@ -119,12 +119,21 @@ xserver-xorg xserver-xorg/config/monitor/mode-list \
# To workaround the "Unmount partitions that are in use?" question,
# run the "umount /media" after the preseed is read in
d-i preseed/early_command string wget http://`cat /tmp/xcatserver`/install/autoinst/#HOSTNAME#.pre; \
d-i preseed/early_command string \
{ \
echo "Running preseeding early_command Installation script..."; \
wget http://`cat /tmp/xcatserver`/install/autoinst/#HOSTNAME#.pre; \
chmod u+x #HOSTNAME#.pre; \
./#HOSTNAME#.pre; \
umount /media || true
umount /media || true; \
} >>/tmp/pre-install.log 2>&1
d-i preseed/late_command string wget http://`cat /tmp/xcatserver`/install/autoinst/#HOSTNAME#.post; \
d-i preseed/late_command string \
mkdir -p /target/var/log/xcat/; \
{ \
cat /tmp/pre-install.log >> /target/var/log/xcat/xcat.log; \
echo "Running preseeding late_command Installation script..."; \
wget http://`cat /tmp/xcatserver`/install/autoinst/#HOSTNAME#.post; \
chmod u+x #HOSTNAME#.post; \
cp ./#HOSTNAME#.post /target/root/post.script; \
mount -o bind /proc /target/proc -t proc; \
@ -132,5 +141,6 @@ d-i preseed/late_command string wget http://`cat /tmp/xcatserver`/install/autoin
mount -o bind /dev/pts /target/dev/pts -t devpts; \
mount -o bind /sys /target/sys; \
chroot /target /root/post.script; \
cp /target/etc/network/interfaces /etc/network/interfaces
cp /target/etc/network/interfaces /etc/network/interfaces; \
} >>/target/var/log/xcat/xcat.log 2>&1