2011-03-02 09:50:17 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2011-08-13 18:12:46 +00:00
|
|
|
if [ ! -c /dev/vcs ]; then
|
|
|
|
mknod /dev/vcs c 7 0
|
|
|
|
fi
|
2011-03-02 09:50:17 +00:00
|
|
|
|
2013-05-03 21:05:07 +00:00
|
|
|
while [ -z "$instdisk" ]; do
|
|
|
|
VIRTDISKS=`ls /dev/vd*|wc -l`
|
|
|
|
if [ $VIRTDISKS -gt 0 ]; then
|
2013-05-01 21:00:14 +00:00
|
|
|
for disk in /dev/vd*[^0-9]; do
|
|
|
|
if [ -z "$firstdirectdisk" ]; then firstdirectdisk=$disk; fi #remember first disk as a guess of medium resort
|
|
|
|
#no edd_id in debian installer, no edd hints supported
|
|
|
|
done
|
2013-05-03 21:05:07 +00:00
|
|
|
fi
|
2013-05-01 21:00:14 +00:00
|
|
|
if [ -z "$firstdirectdisk" ]; then
|
2013-05-03 21:05:07 +00:00
|
|
|
SCSIDISKS=`ls /dev/sd*|wc -l`
|
|
|
|
if [ $SCSIDISKS -gt 0 ]; then
|
2013-05-01 21:00:14 +00:00
|
|
|
for disk in /dev/sd*[^0-9]; do
|
|
|
|
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 resor
|
|
|
|
;;
|
|
|
|
"mptsas"|"mpt2sas") #*PROBABLY* not SAN, but SAS SAN is possible
|
|
|
|
if [ -z "$probablyfirstdirectdisk" ]; then probablyfirstdirectdisk=$disk; fi
|
|
|
|
;;
|
|
|
|
*) # could be san or who knows what, use it as a last resort
|
|
|
|
if [ -z "$firstdisk" ]; then firstdisk=$disk; fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2013-05-03 21:05:07 +00:00
|
|
|
fi
|
2013-05-01 21:00:14 +00:00
|
|
|
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
|
2013-05-03 21:05:07 +00:00
|
|
|
if [ ! -z "$instdisk" ]; then debconf-set partman-auto/disk "$instdisk"; fi
|
2013-09-27 09:51:23 +00:00
|
|
|
debconf-get open-iscsi/targets > /tmp/q
|
2013-05-03 21:05:07 +00:00
|
|
|
sleep 0.1
|
|
|
|
done &
|
2013-05-01 21:00:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-08-13 18:12:46 +00:00
|
|
|
cat >/tmp/foo.sh <<EOF
|
|
|
|
#!/bin/sh
|
2011-03-02 09:50:17 +00:00
|
|
|
|
2011-08-13 18:12:46 +00:00
|
|
|
#
|
|
|
|
# If no arguments:
|
|
|
|
#
|
|
|
|
# 1) Start child process to connect as client to master, and re-execute this script to send
|
|
|
|
# "installmonitor" to master. Do not wait for child process.
|
|
|
|
#
|
|
|
|
# 2) Loop forever. For each iteration, start child process as server waiting for a client
|
|
|
|
# connection. Once a connection is established, child process re-executes this script to
|
|
|
|
# handle request from that particular client.
|
|
|
|
#
|
2011-03-02 09:50:17 +00:00
|
|
|
|
2011-08-13 18:12:46 +00:00
|
|
|
if [ \$# -eq 0 ]; then
|
|
|
|
xcatdhost="#XCATVAR:XCATMASTER#"
|
|
|
|
xcatdport="#TABLE:site:key=xcatiport:value#"
|
2013-06-19 08:26:21 +00:00
|
|
|
NODESTATUS="#TABLEBLANKOKAY:site:key=nodestatus:value#"
|
2013-06-19 06:55:03 +00:00
|
|
|
|
2011-03-02 09:50:17 +00:00
|
|
|
|
2011-08-13 18:12:46 +00:00
|
|
|
/usr/bin/nc "\$xcatdhost" "\$xcatdport" -e /tmp/foo.sh install_monitor &
|
2011-03-02 09:50:17 +00:00
|
|
|
|
2013-06-19 06:55:03 +00:00
|
|
|
if [ -z "\$NODESTATUS" ] || [ "\$NODESTATUS" != "0" -a "\$NODESTATUS" != "N" -a "\$NODESTATUS" != "n" ];
|
|
|
|
then
|
|
|
|
|
|
|
|
/usr/bin/nc "\$xcatdhost" "\$xcatdport" -e /tmp/foo.sh installstatus installing &
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
2011-08-13 18:12:46 +00:00
|
|
|
while true; do
|
|
|
|
/usr/bin/nc -l -p 3001 -e /tmp/foo.sh serve_client
|
|
|
|
done
|
2011-03-02 09:50:17 +00:00
|
|
|
|
2011-08-13 18:12:46 +00:00
|
|
|
exit 1 # never reached; reboot ends this
|
|
|
|
fi
|
2011-03-02 09:50:17 +00:00
|
|
|
|
2011-08-13 18:12:46 +00:00
|
|
|
#
|
|
|
|
# If the script was called with the "install_monitor" argument, stdin and stdout are
|
|
|
|
# connected to an xCAT daemon on the master. Write the "installmonitor" request to the
|
|
|
|
# daemon.
|
|
|
|
#
|
|
|
|
|
|
|
|
if [ "\$1" = "install_monitor" ]; then
|
|
|
|
cmd=""
|
|
|
|
while [ "\$cmd" != "done" ]; do
|
|
|
|
read cmd remainder
|
|
|
|
|
|
|
|
if [ "\$cmd" == "ready" ]; then
|
|
|
|
echo "installmonitor"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
fi
|
2011-03-02 09:50:17 +00:00
|
|
|
|
2013-06-19 06:55:03 +00:00
|
|
|
#
|
|
|
|
# If the script was called with the "installstatus" argument, stdin and stdout are
|
|
|
|
# connected to an xCAT daemon on the master.
|
|
|
|
# Write the "installstatus xx" request to the daemon to update thenode installation status.
|
|
|
|
if [ "\$1" = "installstatus" ]; then
|
|
|
|
cmd=""
|
|
|
|
while [ "\$cmd" != "done" ]; do
|
|
|
|
read cmd remainder
|
|
|
|
|
|
|
|
if [ "\$cmd" == "ready" ]; then
|
|
|
|
echo "installstatus \$2"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-08-13 18:12:46 +00:00
|
|
|
#
|
|
|
|
# When execution reaches here, script called with "serve_client" argument, which means
|
|
|
|
# stdin and stdout are connected to a client. Read the request from the client, provide
|
|
|
|
# the answer to the client, and terminate.
|
|
|
|
#
|
2011-03-02 09:50:17 +00:00
|
|
|
|
2011-08-13 18:12:46 +00:00
|
|
|
read cmd arg remainder
|
|
|
|
|
|
|
|
case "\$cmd" in
|
|
|
|
# "sh") #TODO: ENABLE IF DEBUG
|
|
|
|
# output=\$(eval \$arg \$remainder)
|
|
|
|
# echo "\$output"
|
|
|
|
# echo "EOO"
|
|
|
|
# ;;
|
|
|
|
|
|
|
|
"screendump")
|
|
|
|
output=\$(eval chvt \$arg; cat /dev/vcs)
|
|
|
|
echo "\$output"
|
|
|
|
;;
|
|
|
|
|
|
|
|
"stat")
|
|
|
|
sedcmds='/^[^ ]+ +[^ ]+ +install /h; \${ g; s,^[^ ]+ +[^ ]+ +install +([^ ]+) +[^ ]+ ([^ ]+).*,installing \1 \2,; p }'
|
|
|
|
output=\$(sed -nre "\$sedcmds" /target/var/log/dpkg.log 2>/dev/null)
|
|
|
|
|
|
|
|
if [ -z "\$output" ]; then
|
|
|
|
output="installing prep"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "\$output"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|
2011-03-02 09:50:17 +00:00
|
|
|
EOF
|
|
|
|
|
2011-08-13 18:12:46 +00:00
|
|
|
chmod 755 /tmp/foo.sh
|
|
|
|
|
|
|
|
/tmp/foo.sh >/tmp/foo.log 2>&1 &
|
|
|
|
|
2013-01-11 09:05:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
if [ -d /sys/firmware/efi ]; then
|
|
|
|
echo "ubuntu-efi ::" > /tmp/partitioning
|
|
|
|
echo " 512 512 1024 fat16" >> /tmp/partitioning
|
2013-04-30 17:48:02 +00:00
|
|
|
echo ' $iflabel{ gpt } $reusemethod{ } method{ efi } format{ }' >> /tmp/partitioning
|
2013-01-11 09:05:10 +00:00
|
|
|
echo " ." >> /tmp/partitioning
|
|
|
|
else
|
|
|
|
echo "ubuntu-boot ::" > /tmp/partitioning
|
|
|
|
echo "100 50 100 ext3" >> /tmp/partitioning
|
2013-04-30 17:48:02 +00:00
|
|
|
echo ' $primary{ } $bootable{ } method{ format } format{ } use_filesystem{ } filesystem{ ext3 } mountpoint{ /boot }' >> /tmp/partitioning
|
2013-01-11 09:05:10 +00:00
|
|
|
echo " ." >> /tmp/partitioning
|
|
|
|
fi
|
|
|
|
echo "500 10000 1000000000 ext3" >> /tmp/partitioning
|
|
|
|
echo " method{ format } format{ } use_filesystem{ } filesystem{ ext3 } mountpoint{ / }" >> /tmp/partitioning
|
|
|
|
echo " ." >> /tmp/partitioning
|
|
|
|
echo "2048 512 300% linux-swap" >> /tmp/partitioning
|
|
|
|
echo " method{ swap } format{ }" >> /tmp/partitioning
|
|
|
|
echo " ." >> /tmp/partitioning
|
2011-08-13 18:12:46 +00:00
|
|
|
exit 0
|
2011-03-02 09:50:17 +00:00
|
|
|
|