| 1 |
#! /bin/sh
|
| 2 |
|
| 3 |
# (c) 2001, Thomas Lange
|
| 4 |
#
|
| 5 |
# set link for tftpboot in /boot/fai to an image for a host
|
| 6 |
# or for all hosts with prefix and a number
|
| 7 |
|
| 8 |
# examples:
|
| 9 |
# tlink installimage bigfoot
|
| 10 |
# tlink installimage ant06
|
| 11 |
# tlink installimage all ant
|
| 12 |
# tlink nodeimage all ant
|
| 13 |
#
|
| 14 |
# tlink shows all file in /boot/fai
|
| 15 |
# tlink ant01 shows syslink for ant01
|
| 16 |
|
| 17 |
# define the range for client numbers using prefix
|
| 18 |
startnum=1
|
| 19 |
endnum=25
|
| 20 |
|
| 21 |
image=$1
|
| 22 |
host=$2
|
| 23 |
prefix=$3
|
| 24 |
|
| 25 |
tftpdir=/boot/fai
|
| 26 |
# - - - - - - - - - - - - - - - - - - - -
|
| 27 |
link() {
|
| 28 |
|
| 29 |
rm -f $ $tftpdir/$1
|
| 30 |
ln -s $image $tftpdir/$1 && echo $1 now booting $image
|
| 31 |
}
|
| 32 |
# - - - - - - - - - - - - - - - - - - - -
|
| 33 |
showlink() {
|
| 34 |
|
| 35 |
# show current link for host
|
| 36 |
|
| 37 |
ls -l $tftpdir/$1
|
| 38 |
exit 0
|
| 39 |
}
|
| 40 |
# - - - - - - - - - - - - - - - - - - - -
|
| 41 |
|
| 42 |
# create list of hosts without prefix
|
| 43 |
i=$startnum
|
| 44 |
while [ $i -le $endnum ]; do
|
| 45 |
num=`printf "%.2d" $i`
|
| 46 |
hostnums="$hostnums $num"
|
| 47 |
i=$(($i+1))
|
| 48 |
done
|
| 49 |
|
| 50 |
# show one or all files
|
| 51 |
[ X"$host" = X ] && showlink $1
|
| 52 |
|
| 53 |
if [ $host = "all" ];then
|
| 54 |
for i in $hostnums
|
| 55 |
do
|
| 56 |
link $prefix$i
|
| 57 |
done
|
| 58 |
exit
|
| 59 |
else
|
| 60 |
link $host
|
| 61 |
fi
|