X-Git-Url: https://secure.softndesign.org/git/?a=blobdiff_plain;f=install%2Fcluster%2Fbin%2Finit_pxe_repository.sh;fp=install%2Fcluster%2Fbin%2Finit_pxe_repository.sh;h=0000000000000000000000000000000000000000;hb=3a30026aa30355dac5c5f9742da0fdba797701ea;hp=d255914872a3da12a981a58d51d96b9e5a49464a;hpb=7fa766f7c1562671a1b5db6f365f6ec4e847c309;p=debian6500.git diff --git a/install/cluster/bin/init_pxe_repository.sh b/install/cluster/bin/init_pxe_repository.sh deleted file mode 100755 index d255914..0000000 --- a/install/cluster/bin/init_pxe_repository.sh +++ /dev/null @@ -1,186 +0,0 @@ -#!/bin/bash - -# ============================================================================ -# Copyright (C) THALES. All rights reserved -# Author: Laurent Mazet -# Date : 18/02/2014 -# ============================================================================ - -# TODO -# * - -PROGNAME=$(basename $0) -ETH0MASTER=$(ip add show dev eth0 |awk '$1=="inet" {sub(/\/.*/, ""); print $2; exit}') -ETH1MASTER=$(ip add show dev eth1 |awk '$1=="inet" {sub(/\/.*/, ""); print $2; exit}') -TFTP=/opt/tftp -PXELINUXCFG=$TFTP/pxelinux.cfg -TMPLOG=/tmp/$PROGNAME-$$.log -VER=1.0 - -# help function - -function usage () { - echo "usage: $PROGNAME [-h] [-v]" - echo " -h: help message" - echo " -v: version message" - exit $@ -} - -# formating functions - -function title () { echo -e "\033[0;1m$*\033[0;0m"; } -function pass () { echo -e "\033[1;32m$*\033[0;0m"; } -function warn () { echo -e "\033[1;33m$*\033[0;0m"; } -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 -} - -# 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 -done - -# checks -check dpkg -l syslinux || exit 1 - -# create repository -[ -d $TFTP ] && warn "directory $TFTP already exist" -check mkdir -p $TFTP -[ -d $PXELINUXCFG ] && warn "directory $PXELINUXCFG already exist" -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 -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 -done - -# create pxelinux information message -cat - << EOF > $TFTP/pxelinux.txt -Boot Menu -========= - -PXE boot for TRC6500 slave blades -EOF -check test -f $TFTP/pxelinux.txt - -# create french mapping -# xxd -ps -c 32 fr.kmp -cat - << EOF | xxd -r -p > $TFTP/fr.kmp -000102030405060708090a0b0c0d0e0f10111213141516171819171b1c1d1e1f -203125333435377c3930382b3b293a2140267b2227282d7d5f2f4d6d3c3d2f5c -325142434445464748494a4b4c3f4e4f504152535455565a5859575e2a24365d -2a7162636465666768696a6b6c2c6e6f706172737475767a7879773c233e7e7f -808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f -a0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebf -c0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedf -e0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff -EOF -check test -f $TFTP/fr.kmp - -# create standard pxe boot for slave blade -cat - << EOF > $PXELINUXCFG/default -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=@@tftpserver@@ tarballs=@@tarballs@@ - -LABEL freedos - MENU LABEL ^FreeDos 1.0 - KERNEL /memdisk - 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 -} - -# 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 -} - -# 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 - -# 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 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 - -# 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" - -# vim:set tabstop=4 expandtab shiftwidth=4: