From 3f60fdb609e6b3758a4227f6f88c51c000c0cfe9 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Thu, 13 Nov 2014 18:44:21 +0100 Subject: [PATCH] PXE boot generation done from change_configuration.sh script --- master/opt/cluster/bin/init_pxe_repository.sh | 116 ++++++++---------- master/opt/tftp/pxelinux.cfg/0A851A | 22 ---- master/opt/tftp/pxelinux.cfg/0A851A50 | 21 ---- master/opt/tftp/pxelinux.cfg/0A851C | 21 ---- master/opt/tftp/pxelinux.cfg/0A851C50 | 21 ---- master/opt/tftp/pxelinux.cfg/default | 2 +- 6 files changed, 50 insertions(+), 153 deletions(-) delete mode 100644 master/opt/tftp/pxelinux.cfg/0A851A delete mode 100644 master/opt/tftp/pxelinux.cfg/0A851A50 delete mode 100644 master/opt/tftp/pxelinux.cfg/0A851C delete mode 100644 master/opt/tftp/pxelinux.cfg/0A851C50 diff --git a/master/opt/cluster/bin/init_pxe_repository.sh b/master/opt/cluster/bin/init_pxe_repository.sh index d255914..b4ba7b8 100755 --- a/master/opt/cluster/bin/init_pxe_repository.sh +++ b/master/opt/cluster/bin/init_pxe_repository.sh @@ -20,10 +20,10 @@ VER=1.0 # 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 @@ -35,21 +35,21 @@ function fail () { echo -e "\033[1;31m$*\033[0;0m"; } # 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 @@ -63,18 +63,18 @@ check mkdir -p $PXELINUXCFG # 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 @@ -101,7 +101,7 @@ EOF 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 @@ -124,63 +124,45 @@ LABEL freedos 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: diff --git a/master/opt/tftp/pxelinux.cfg/0A851A b/master/opt/tftp/pxelinux.cfg/0A851A deleted file mode 100644 index a55abe0..0000000 --- a/master/opt/tftp/pxelinux.cfg/0A851A +++ /dev/null @@ -1,22 +0,0 @@ -PROMPT 2 -TIMEOUT 30 -UI /menu.c32 - -KBDMAP /fr.kmp - -MENU TITLE [[ PXE BOOT ]] - -DEFAULT debian - -LABEL debian - MENU LABEL ^Debian 7 (TRC6500) - KERNEL /vmlinuz - INITRD /initrd.img - #APPEND noinitrd ramdisk_size=8192 boot=tftp fastboot tftpserver=10.133.28.160 tarballs=bios.tgz - APPEND noinitrd ramdisk_size=8192 boot=tftp fastboot tftpserver=10.133.28.160 tarballs=root.tgz,slave.tgz - -LABEL freedos - MENU LABEL ^FreeDos 1.0 - KERNEL /memdisk - INITRD /balder10.imz - APPEND - diff --git a/master/opt/tftp/pxelinux.cfg/0A851A50 b/master/opt/tftp/pxelinux.cfg/0A851A50 deleted file mode 100644 index e01a7a2..0000000 --- a/master/opt/tftp/pxelinux.cfg/0A851A50 +++ /dev/null @@ -1,21 +0,0 @@ -PROMPT 2 -TIMEOUT 30 -UI /menu.c32 - -KBDMAP /fr.kmp - -MENU TITLE [[ PXE BOOT ]] - -DEFAULT debian - -LABEL debian - MENU LABEL ^Debian 7 (TRC6500) - KERNEL /vmlinuz - INITRD /initrd.img - APPEND noinitrd ramdisk_size=8192 boot=tftp fastboot tftpserver=10.133.28.160 tarballs=root.tgz,slave.tgz,rec.tgz - -LABEL freedos - MENU LABEL ^FreeDos 1.0 - KERNEL /memdisk - INITRD /balder10.imz - APPEND - diff --git a/master/opt/tftp/pxelinux.cfg/0A851C b/master/opt/tftp/pxelinux.cfg/0A851C deleted file mode 100644 index a801909..0000000 --- a/master/opt/tftp/pxelinux.cfg/0A851C +++ /dev/null @@ -1,21 +0,0 @@ -PROMPT 2 -TIMEOUT 30 -UI /menu.c32 - -KBDMAP /fr.kmp - -MENU TITLE [[ PXE BOOT ]] - -DEFAULT debian - -LABEL debian - MENU LABEL ^Debian 7 (TRC6500) - KERNEL /vmlinuz - INITRD /initrd.img - APPEND noinitrd ramdisk_size=8192 boot=tftp fastboot tftpserver=10.133.28.160 tarballs=root.tgz,slave.tgz - -LABEL freedos - MENU LABEL ^FreeDos 1.0 - KERNEL /memdisk - INITRD /balder10.imz - APPEND - diff --git a/master/opt/tftp/pxelinux.cfg/0A851C50 b/master/opt/tftp/pxelinux.cfg/0A851C50 deleted file mode 100644 index e01a7a2..0000000 --- a/master/opt/tftp/pxelinux.cfg/0A851C50 +++ /dev/null @@ -1,21 +0,0 @@ -PROMPT 2 -TIMEOUT 30 -UI /menu.c32 - -KBDMAP /fr.kmp - -MENU TITLE [[ PXE BOOT ]] - -DEFAULT debian - -LABEL debian - MENU LABEL ^Debian 7 (TRC6500) - KERNEL /vmlinuz - INITRD /initrd.img - APPEND noinitrd ramdisk_size=8192 boot=tftp fastboot tftpserver=10.133.28.160 tarballs=root.tgz,slave.tgz,rec.tgz - -LABEL freedos - MENU LABEL ^FreeDos 1.0 - KERNEL /memdisk - INITRD /balder10.imz - APPEND - diff --git a/master/opt/tftp/pxelinux.cfg/default b/master/opt/tftp/pxelinux.cfg/default index 6f5a4e9..a801909 100644 --- a/master/opt/tftp/pxelinux.cfg/default +++ b/master/opt/tftp/pxelinux.cfg/default @@ -12,7 +12,7 @@ LABEL debian MENU LABEL ^Debian 7 (TRC6500) KERNEL /vmlinuz INITRD /initrd.img - APPEND noinitrd ramdisk_size=8192 boot=tftp fastboot tftpserver=@@tftpserver@@ tarballs=@@tarballs@@ + APPEND noinitrd ramdisk_size=8192 boot=tftp fastboot tftpserver=10.133.28.160 tarballs=root.tgz,slave.tgz LABEL freedos MENU LABEL ^FreeDos 1.0 -- 2.30.2