|
# Kickstart file automatically generated by anaconda.
|
|
|
|
#version=DEVEL
|
|
install
|
|
url --url=http://172.16.0.1/install/centos6.3/x86_64
|
|
lang en_US.UTF-8
|
|
keyboard us
|
|
network --onboot no --device eth0 --bootproto dhcp --noipv6
|
|
network --onboot yes --device eth1 --mtu=1500 --bootproto dhcp
|
|
rootpw --iscrypted $1$jD6w9CYR$AMffxBjdO3/Pduby51BSj1
|
|
# Reboot after installation
|
|
reboot
|
|
firewall --disabled
|
|
authconfig --useshadow --enablemd5
|
|
selinux --disabled
|
|
timezone --utc America/New_York
|
|
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto console=ttyS0,9600"
|
|
# The following is the partition information you requested
|
|
# Note that any partitions you deleted are not expressed
|
|
# here so unless you clear all partitions first, this is
|
|
# not guaranteed to work
|
|
#clearpart --all --initlabel
|
|
|
|
#part / --fstype=ext4 --label="root" --size=8192
|
|
#part swap --size=1024
|
|
#part --grow --size=1
|
|
|
|
repo --name="CentOS" --baseurl=http://172.16.0.1/install/centos6.3/x86_64 --cost=100
|
|
|
|
%packages
|
|
@Base
|
|
@Core
|
|
autofs
|
|
binutils
|
|
btrfs-progs
|
|
bzip2
|
|
ceph
|
|
compat-libstdc++-33
|
|
dkms-openafs
|
|
gcc
|
|
gcc-c++
|
|
gdb
|
|
kernel
|
|
krb5-workstation
|
|
libvirt
|
|
m4
|
|
make
|
|
net-snmp
|
|
nfs-utils
|
|
ntp
|
|
openafs
|
|
openafs-authlibs
|
|
openafs-authlibs-devel
|
|
openafs-client
|
|
openafs-devel
|
|
openafs-docs
|
|
openafs-krb5
|
|
openssh-server
|
|
pam_krb5
|
|
psacct
|
|
rsh
|
|
rsh-server
|
|
rsync
|
|
sendmail-cf
|
|
tcsh
|
|
tftp
|
|
util-linux
|
|
xen
|
|
xinetd
|
|
yp-tools
|
|
ypbind
|
|
ypserv
|
|
|
|
%end
|
|
|
|
%pre
|
|
if grep n8r /proc/cmdline > /dev/null 2>&1;
|
|
then
|
|
stty crtscts
|
|
fi
|
|
for x in 0 1 2 3 4 5 6 7 8
|
|
do
|
|
mknod /dev/vcs$x c 7 $x
|
|
mknod /dev/vcsa$x c 7 $[$x+128]
|
|
done
|
|
chmod 644 /dev/vcs*
|
|
chown root /dev/vcs*
|
|
if [ -r /tmp/updates/etc/pki/tls/certs/ca-bundle.crt ]; then
|
|
cp -f /tmp/updates/etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/
|
|
fi
|
|
|
|
|
|
cat >/tmp/foo.py <<EOF
|
|
#!/usr/bin/python
|
|
|
|
import socket
|
|
import os
|
|
import linecache
|
|
import re
|
|
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
sock.connect(('172.16.0.2',3002))
|
|
|
|
response = sock.recv(100)
|
|
if(response == "ready\n"):
|
|
sock.send("installmonitor\n")
|
|
response = sock.recv(100)
|
|
|
|
sock.close()
|
|
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
|
|
|
port = 3001
|
|
sock.bind(('', port))
|
|
|
|
sock.listen(5)
|
|
|
|
try:
|
|
while 1:
|
|
newSocket, address = sock.accept()
|
|
while 1:
|
|
received = newSocket.recv(200)
|
|
if not received:
|
|
break
|
|
command = re.split('\s+',received)
|
|
if(command[0] == "stat"):
|
|
ilog = ""
|
|
firstline = ""
|
|
line = ""
|
|
post = 0
|
|
percent = 0
|
|
count = 0
|
|
numpack = 0
|
|
if(os.path.isfile('/mnt/sysimage/root/install.log')):
|
|
ilog = '/mnt/sysimage/root/install.log'
|
|
if(os.path.isfile('/mnt/sysimage/tmp/install.log')):
|
|
ilog = '/mnt/sysimage/tmp/install.log'
|
|
if(os.path.isfile('/mnt/sysimage/root/post.log')):
|
|
ilog = '/mnt/sysimage/root/post.log'
|
|
post = 1
|
|
if(ilog):
|
|
count = len(open(ilog).readlines())
|
|
firstline = linecache.getline(ilog,1)
|
|
line = linecache.getline(ilog,count)
|
|
linecache.clearcache()
|
|
if(line and not post):
|
|
r1 = re.compile("^Installing (\d+) ")
|
|
m1 = r1.search(firstline)
|
|
if m1:
|
|
numpack = int(m1.group(1))
|
|
if(numpack > 0):
|
|
percent = int(((count - 2) * 100)/numpack + .5)
|
|
if(percent > 100):
|
|
percent = 100
|
|
if(percent < 0):
|
|
percent = 0
|
|
r2 = re.compile("^Installing (.*)\.")
|
|
m2 = r2.search(line)
|
|
if m2:
|
|
newline = m2.group(1)
|
|
newline = newline + " ("
|
|
newline = newline + str(percent)
|
|
newline = newline + "%)"
|
|
# newline = newline + " ["
|
|
# count = count - 2
|
|
# newline = newline + str(count)
|
|
# newline = newline + "/"
|
|
# newline = newline + str(numpack)
|
|
# newline = newline + "]"
|
|
else:
|
|
newline = "prep"
|
|
line = "installing " + newline
|
|
if(line and post):
|
|
line = "installing " + line
|
|
if(not line):
|
|
line = "installing prep"
|
|
newSocket.send(line)
|
|
break
|
|
# if(command[0] == "sh"): #DEBUG purposes only, wide open root priv command here.
|
|
# newcommand = ""
|
|
# for i in command[1:]:
|
|
# newcommand = newcommand + i + " "
|
|
# output = os.popen(newcommand).read()
|
|
# newSocket.send(output)
|
|
# break
|
|
if(command[0] == "screendump"):
|
|
newcommand = "cat /dev/vcs"
|
|
for i in command[1:]:
|
|
newcommand = newcommand + i
|
|
output = os.popen(newcommand).read()
|
|
newSocket.send(output)
|
|
break
|
|
|
|
newSocket.close()
|
|
|
|
finally:
|
|
sock.close()
|
|
EOF
|
|
|
|
chmod 755 /tmp/foo.py
|
|
|
|
/tmp/foo.py >/foo.log 2>&1 &
|
|
#time to ascertain fstype and PReP/UEFI/legacy
|
|
#also, find first available block device (sda or vda likely)
|
|
#TODO: pick a likely non-SAN target if possible
|
|
shopt -s nullglob
|
|
for disk in /dev/vd*[^0-9];do
|
|
if [ -z "$firstdirectdisk" ]; then firstdirectdisk=$disk; fi #remember first disk as a guess of medium resort
|
|
eddname=$(/lib/udev/edd_id $disk 2> /dev/null)
|
|
if [ ! -z "$eddname" -a "$eddname" = "int13_dev80" ]; then
|
|
instdisk=$disk
|
|
break
|
|
fi
|
|
done
|
|
if [ -z "$instdisk" ]; then
|
|
for disk in /dev/sd*[^0-9]; do
|
|
eddname=$(/lib/udev/edd_id $disk 2> /dev/null)
|
|
if [ ! -z "$eddname" -a "$eddname" = "int13_dev80" ]; then
|
|
instdisk=$disk
|
|
break
|
|
fi
|
|
currdriver=`udevadm info --attribute-walk --name $disk |grep DRIVERS|grep -v '""'|grep -v '"sd"'|head -n 1|sed -e 's/[^"]*"//' -e 's/"//'`
|
|
case "$currdriver" in
|
|
"ata_piix4"|"PMC MaxRAID"|"ahci"|"megaraid_sas") #certainly direct
|
|
if [ -z "$firstdirectdisk" ]; then firstdirectdisk=$disk; fi #remember first disk as a guess of medium resort
|
|
;;
|
|
"mptsas"|"mpt2sas") #*PROBABLY* not SAN, but SAS SAN is possible
|
|
if [ -z "$probablyfirstdirectdisk" ]; then probablyfirstdirectdisk=$disk; fi #remember first disk as a guess of medium resort
|
|
;;
|
|
*)
|
|
if [ -z "$firstdisk" ]; then firstdisk=$disk; fi #remember first disk as a guess of medium resort
|
|
;;
|
|
esac
|
|
done
|
|
fi
|
|
if [ -z "$instdisk" ]; then
|
|
if [ ! -z "$firstdirectdisk" ]; then
|
|
instdisk=$firstdirectdisk
|
|
elif [ ! -z "$probablyfirstdirectdisk" ]; then
|
|
instdisk=$probablyfirstdirectdisk
|
|
elif [ ! -z "$firstdisk" ]; then
|
|
instdisk=$firstdisk
|
|
fi
|
|
fi
|
|
|
|
|
|
modprobe ext4 >& /dev/null
|
|
modprobe ext4dev >& /dev/null
|
|
if grep ext4dev /proc/filesystems > /dev/null; then
|
|
FSTYPE=ext3
|
|
elif grep ext4 /proc/filesystems > /dev/null; then
|
|
FSTYPE=ext4
|
|
else
|
|
FSTYPE=ext3
|
|
fi
|
|
if [ `uname -m` = "ppc64" ]; then
|
|
echo 'part None --fstype "PPC PReP Boot" --ondisk '$instdisk' --size 8' >> /tmp/partitioning
|
|
fi
|
|
if [ -d /sys/firmware/efi ]; then
|
|
echo 'part /boot/efi --size 50 --ondisk '$instdisk' --fstype vfat' >> /tmp/partitioning
|
|
fi
|
|
|
|
#TODO: ondisk detection, /dev/disk/by-id/edd-int13_dev80 for legacy maybe, and no idea about efi. at least maybe blacklist SAN if mptsas/mpt2sas/megaraid_sas seen...
|
|
echo "part /boot --size 256 --fstype ext3 --ondisk $instdisk" >> /tmp/partitioning
|
|
echo "part swap --recommended --ondisk $instdisk" >> /tmp/partitioning
|
|
echo "part / --size 1 --grow --ondisk $instdisk --fstype $FSTYPE" >> /tmp/partitioning
|
|
|
|
%end
|
|
|
|
%post
|
|
#
|
|
# Setup hostname
|
|
#
|
|
echo "post scripts" >/root/post.log
|
|
export PRINIC=eth1
|
|
if [ "$PRINIC" == "mac" ]
|
|
then
|
|
export PRINIC='00:e0:81:2b:44:75!node001|00:60:dd:48:e3:54!node001-fiber'
|
|
fi
|
|
if [ -z "$PRINIC" ]
|
|
then
|
|
for karg in $(cat /proc/cmdline |sed -e 's/-/:/g' -e 's/ /\n/g'); do
|
|
if [ "${karg%%=*}" = "BOOTIF" ]; then
|
|
export PRINIC=`ifconfig -a|grep -i "hwaddr ${karg#*=01:}"|awk '{print $1}'`
|
|
fi
|
|
done
|
|
if [ -z "$PRINIC" ]; then
|
|
export PRINIC=eth0
|
|
fi
|
|
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}'`
|
|
fi
|
|
IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}')
|
|
if [ -z $IP ]
|
|
then
|
|
dhclient eth0
|
|
IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}')
|
|
fi
|
|
|
|
export HOSTNAME=$(host $IP 2>/dev/null | awk '{print $5}' | awk -F. '{print $1}')
|
|
hostname $HOSTNAME
|
|
|
|
if [ -f /boot/efi/efi/redhat/grub.conf ]; then #RedHat bug, grub.efi corrupts console unless we are careful...
|
|
sed -i s/^terminal.*// /boot/efi/efi/redhat/grub.conf
|
|
bootpart=$(sed -e 's/#.*//' /boot/efi/efi/redhat/grub.conf |grep root|grep -v kernel|head -n 1|awk '{print $2}')
|
|
bootpart="${bootpart%\\n}"
|
|
sed -i s!^serial.*!splashimage=$bootpart/boot/grub/splash.xpm.gz! /boot/efi/efi/redhat/grub.conf
|
|
fi
|
|
#
|
|
# Run xCAT post install
|
|
#
|
|
export MASTER_IP="172.16.0.2"
|
|
export MASTER_IPS="172.16.0.2"
|
|
export MASTER="172.16.0.2"
|
|
export INSTALLDIR=/install
|
|
if [ -z "$INSTALLDIR" ]; then
|
|
INSTALLDIR="/install"
|
|
fi
|
|
cd /tmp
|
|
RAND=$(perl -e 'print int(rand(50)). "\n"')
|
|
sleep $RAND
|
|
for i in $(seq 1 20)
|
|
do
|
|
GOTIT=0
|
|
for i in $MASTER_IPS
|
|
do
|
|
#wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 0 -T 60 ftp://$i/postscripts
|
|
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
|
|
if [ "$?" = "0" ]
|
|
then
|
|
if [ ! -x /usr/bin/openssl ]; then #Stop if no openssl to help the next bit
|
|
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
|
|
chmod +x /xcatpost/*
|
|
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /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/^ *//' > /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
|
|
echo "INSTALLDIR=$INSTALLDIR" >> /opt/xcat/xcatinfo
|
|
cd /xcatpost
|
|
#gunzip xcatpost.tar.gz
|
|
#tar -xvf xcatpost.tar
|
|
#/xcatpost/node001
|
|
export PATH=/xcatpost:$PATH
|
|
|
|
# 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 "
|
|
# subroutine used to run postscripts
|
|
run_ps () {
|
|
logdir=\"/var/log/xcat\"
|
|
mkdir -p \$logdir
|
|
logfile=\"/var/log/xcat/xcat.log\"
|
|
|
|
if [ -f \$1 ]; then
|
|
echo "\"\`date\` Running postscript: \$@\"" | tee -a \$logfile
|
|
#./\$@ 2>&1 1> /tmp/tmp4xcatlog
|
|
#cat /tmp/tmp4xcatlog | tee -a \$logfile
|
|
./\$@ 2>&1 | tee -a $logfile
|
|
else
|
|
echo "\"\`date\` Postscript \$1 does NOT exist.\"" | tee -a \$logfile
|
|
fi
|
|
}
|
|
# 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
|
|
|
|
|
|
#save the postboot scripts to /xcatpost/mypostscript.post
|
|
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'
|
|
#!/bin/sh
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
# chkconfig: 345 84 59
|
|
# description: service node postboot script hack
|
|
# processname: xcatpostinit
|
|
|
|
### BEGIN INIT INFO
|
|
# Provides: xcatpostinit
|
|
# Default-Start: 3 4 5
|
|
# Default-stop: 0 1 2 6
|
|
# Required-Start: $network $syslog
|
|
# Required-Stop:
|
|
# Short-Description: xCATpost
|
|
# Description: xCAT post boot script
|
|
### END INIT INFO
|
|
|
|
# Source function library.
|
|
if [ -x /etc/rc.d/init.d/functions ]; then
|
|
. /etc/rc.d/init.d/functions
|
|
fi
|
|
|
|
case $1 in
|
|
restart)
|
|
$0 stop
|
|
$0 start
|
|
;;
|
|
status)
|
|
echo -n "xcatpostinit1 runs only at boot, runs additional post scripts"
|
|
;;
|
|
stop)
|
|
echo -n "nothing to stop "
|
|
;;
|
|
start)
|
|
# run /opt/xcat/xcatinstallpost
|
|
if [ -r /opt/xcat/xcatinstallpost ]; then
|
|
/opt/xcat/xcatinstallpost
|
|
fi
|
|
;;
|
|
esac
|
|
EOF
|
|
chmod 755 /etc/init.d/xcatpostinit1
|
|
ln -s /etc/init.d/xcatpostinit1 /etc/rc3.d/S84xcatpostinit1
|
|
ln -s /etc/init.d/xcatpostinit1 /etc/rc4.d/S84xcatpostinit1
|
|
ln -s /etc/init.d/xcatpostinit1 /etc/rc5.d/S84xcatpostinit1
|
|
mkdir -p /opt/xcat
|
|
cat >/opt/xcat/xcatinstallpost << 'EOF'
|
|
#!/bin/sh
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
#################################################################
|
|
#
|
|
# xCAT script for running postboot scripts for full install case.
|
|
#################################################################
|
|
|
|
if [ ! `uname` = Linux ]; then
|
|
MYDIR=`dirname $0`
|
|
#exec $MYDIR/xcatdsklspost.aix
|
|
logger -t xcat "$0: the OS name is not Linux"
|
|
exit
|
|
fi
|
|
SLI=$(awk 'BEGIN{srand(); printf("%d\n",rand()*10)}')
|
|
sleep $SLI
|
|
|
|
cd /xcatpost;
|
|
PATH=/xcatpost:$PATH
|
|
export PATH
|
|
chmod +x /xcatpost/*;
|
|
|
|
POST_IN_DIR="/xcatpost"
|
|
|
|
if [ -x /usr/bin/openssl ]; then
|
|
SIP=`grep "^MASTER=" ${POST_IN_DIR}/mypostscript.post |cut -d= -f2`
|
|
XCATSERVER="$SIP:3001"
|
|
export XCATSERVER
|
|
USEOPENSSLFORXCAT=1 #Though this is the only method going forward, flag to allow backward compatibility with 2.2 generated netboot images
|
|
export USEOPENSSLFORXCAT
|
|
fi
|
|
|
|
# Regardless of where mypostscript.post was found, modify and run it in /xcatpost.
|
|
|
|
DHCP_TMP=`sed 's/\(DHCPINTERFACES=\)\(.*\)$/\1"\2"/' /xcatpost/mypostscript.post`
|
|
echo "$DHCP_TMP" > /xcatpost/mypostscript.post
|
|
|
|
echo "updateflag.awk \$MASTER 3002 \"installstatus booted\"" >> /xcatpost/mypostscript.post
|
|
|
|
chmod +x /xcatpost/mypostscript.post
|
|
if [ -x /xcatpost/mypostscript.post ];then
|
|
/xcatpost/mypostscript.post
|
|
fi
|
|
chkconfig xcatpostinit1 off
|
|
EOF
|
|
chmod 755 /opt/xcat/xcatinstallpost
|
|
|
|
chkconfig --add xcatpostinit1
|
|
|
|
#only run the prebooot scripts here
|
|
TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /xcatpost/mypostscript`
|
|
echo "$TMP" > /xcatpost/mypostscript
|
|
|
|
/xcatpost/mypostscript
|
|
export NODE=node001
|
|
export OSVER=centos6.3
|
|
export ARCH=x86_64
|
|
addsiteyum
|
|
sed -i 's/^serial/#serial/' /boot/grub/grub.conf
|
|
sed -i 's/^terminal/#terminal/' /boot/grub/grub.conf
|
|
updateflag.awk $MASTER 3002
|
|
cd /
|
|
#rm -Rf /xcatpost
|
|
#rm -f /xcatpost/mypostscript
|
|
exit 0
|
|
|
|
%end
|