# help function
function usage () {
- echo "usage: $PROGNAME [-h] [-v]"
- echo " -h: help message"
- echo " -v: version message"
- exit $@
+ echo "usage: $PROGNAME [-h] [-v]"
+ echo " -h: help message"
+ echo " -v: version message"
+ exit $@
}
# formating functions
# check command
function check () {
- echo -n "$@: "
- $@ >&$TMPLOG && pass OK || { fail KO; cat $TMPLOG; ERR=yes; }
- rm -f $TMPLOG
- test ! "$TEST" = yes
+ echo -n "$@: "
+ $@ >&$TMPLOG && pass OK || { fail KO; cat $TMPLOG; ERR=yes; }
+ rm -f $TMPLOG
+ test ! "$TEST" = yes
}
# argument processing
while [ $# -gt 0 ]; do
- case "$1" in
- -h) usage 0;;
- -v) echo "$PROGNAME: version $VER"; exit;;
- *) echo "unknown argument ($1)"; exit 1;;
- esac
- shift
+ case "$1" in
+ -h) usage 0;;
+ -v) echo "$PROGNAME: version $VER"; exit;;
+ *) echo "unknown argument ($1)"; exit 1;;
+ esac
+ shift
done
# checks
# create links from syslinux files
for f in memdisk menu.c32 pxelinux.0; do
- [ -f $TFTP/$f ] && check rm -f $TFTP/$f
- file=/usr/lib/syslinux/$f
- [ -f $file ] || warn "file $file does not exist"
- check ln -s $file $TFTP/$f
+ [ -f $TFTP/$f ] && check rm -f $TFTP/$f
+ file=/usr/lib/syslinux/$f
+ [ -f $file ] || warn "file $file does not exist"
+ check ln -s $file $TFTP/$f
done
# create links to kernel and initrd
for f in initrd.img vmlinuz; do
- [ -f $TFTP/$f ] && check rm -f $TFTP/$f
- file=/$f
- [ -f $file ] || warn "file $file does not exist"
- check ln -s $file $TFTP/$f
+ [ -f $TFTP/$f ] && check rm -f $TFTP/$f
+ file=/$f
+ [ -f $file ] || warn "file $file does not exist"
+ check ln -s $file $TFTP/$f
done
# create pxelinux information message
check test -f $TFTP/fr.kmp
# create standard pxe boot for slave blade
-cat - << EOF > $PXELINUXCFG/default
+cat - << EOF > $PXELINUXCFG/default.template
PROMPT 2
TIMEOUT 30
UI /menu.c32
INITRD /balder10.imz
APPEND -
EOF
-check test -f $PXELINUXCFG/default
-
-# convert IP address to hexadecimal code
-function ip_dec_to_hex () {
- for i in ${1//./ }; do
- printf "%02X" $i
- done
-}
+check test -f $PXELINUXCFG/default.template
# create pxeboot configuration
function pxeconfig () {
- [ -f $PXELINUXCFG/default ] || return 1
-
- while [ $# -gt 0 ]; do
- case "$1" in
- -a) shift; tarballs=$1;;
- -s) shift; tftpserver=$1;;
- *) ip=$1;;
- esac
- shift
- done
-
- iphex=$(ip_dec_to_hex $ip)
- [ ${#iphex} -ge 1 -a ${#iphex} -le 8 ] || return 1
-
- cat $PXELINUXCFG/default | \
- sed -e "s/@@tftpserver@@/$tftpserver/" \
- -e "s/@@tarballs@@/$tarballs/" \
- > $PXELINUXCFG/$iphex
+ [ -f $PXELINUXCFG/default.template ] || return 1
+
+ while [ $# -gt 0 ]; do
+ case "$1" in
+ -a) shift; tarballs=$1;;
+ -s) shift; tftpserver=$1;;
+ *) pxecfg=$1;;
+ esac
+ shift
+ done
+
+ cat $PXELINUXCFG/default.template | \
+ sed -e "s/@@tftpserver@@/$tftpserver/" \
+ -e "s/@@tarballs@@/$tarballs/" \
+ > $PXELINUXCFG/$pxecfg
}
+tftpserver=$ETH1MASTER
+
# standard boot for slave blades
-subnetwork=$(echo $ETH0MASTER | sed 's/\.[0-9]*$//')
-tftpserver=$ETH0MASTER
tarballs="root.tgz,slave.tgz"
-check pxeconfig -a $tarballs -s $tftpserver $subnetwork
+check pxeconfig -a $tarballs -s $tftpserver default
-# second boot for slave blades
-subnetwork=$(echo $ETH1MASTER | sed 's/\.[0-9]*$//')
-tftpserver=$ETH1MASTER
-tarballs="root.tgz,slave.tgz"
-check pxeconfig -a $tarballs -s $tftpserver $subnetwork
+# standard boot for acq blades
+tarballs="root.tgz,slave.tgz,acq.tgz"
+check pxeconfig -a $tarballs -s $tftpserver acq
# standard boot for rec blade
-subnetwork=$(echo $ETH0MASTER | sed 's/\.[0-9]*$/.80/')
-tftpserver=$ETH0MASTER
-tarballs="root.tgz,slave.tgz,rec.tgz"
-check pxeconfig -a $tarballs -s $tftpserver $subnetwork
-
-# second boot for rec blade
-subnetwork=$(echo $ETH1MASTER | sed 's/\.[0-9]*$/.80/')
-tftpserver=$ETH1MASTER
-tarballs="root.tgz,slave.tgz,rec.tgz"
-check pxeconfig -a $tarballs -s $tftpserver $subnetwork
+tarballs="root.tgz,slave.tgz,acq.tgz,rec.tgz"
+check pxeconfig -a $tarballs -s $tftpserver rec
# check if balder image is present
[ -f $TFTP/balder10.imz ] || warn "Don't forget to download FreeDoss image (balder10.imz) on http://www.finnix.org/Balder"
+rm -f $PXELINUXCFG/default.template
+
# vim:set tabstop=4 expandtab shiftwidth=4: