blob: 7e9df8af795502a5960c056c5be9cb64761c8ae2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#!/bin/sh
# the pxe-linking skript should be executed every new hour
# crontab entry: 0 * * * * root <absolute-path>/pxelink.sh
pxedir='tftpboot/pxe/pxelinux.cfg/'
cd $pxedir
# delete all symbolic links (they are obsolete)
rm 01-*
if [ -e default ] ; then rm default ; fi
# get actual time parameters (weekday and hour)
datum=`date +%a:%-k |sed 's/[a-z]/\U&/g'`
wday=`echo $datum | cut -d ":" -f 1`
time=`echo $datum | cut -d ":" -f 2`
echo "actual time: " $wday $time
# get all PXE files (unique) under <timerange>/<pxefile>
pxenumber=`find -type f | cut -d "/" -f 3 | sort | sed '$!N; /^\(.*\)
\n\1$/!P; D' | wc -l`
pxe=`find -type f | cut -d "/" -f 3 | sort | sed '$!N; /^\(.*\)\n\1$
/!P; D' `
for ((j=0;j<$pxenumber;j++)) ; do
pxe_array[$j]=`echo $pxe | cut -d " " -f $[$j+1] `
echo "pxe file: " ${pxe_array[j]}
lines=`find */${pxe_array[j]} | cut -d "/" -f 1 | wc -l`
ranges=`find */${pxe_array[j]} | cut -d "/" -f 1`
for ((i=0;i<$lines;i++)) ; do
timerange[$i]=`echo $ranges | cut -d " " -f $[$i+1] `
#echo ${timerange[i]}
done
match=0
# get timerange corresponding to actual time parameters
while true; do
for ((i=0;i<$lines;i++)) ; do
trday=`echo ${timerange[i]} | cut -d "_" -f 1`
trbegin=`echo ${timerange[i]} | cut -d "_" -f 2`
trend=`echo ${timerange[i]} | cut -d "_" -f 3`
if [ $trday != "X" ] && [ $trbegin != "X" ] && [ $trday == $wday ] \
&& [ $trbegin -le $time ] && [ $time -le $trend ]; then
echo $wday $time "[D H H]match ->" ${timerange[i]}
ln -s ${timerange[i]}'/'${pxe_array[j]} ${pxe_array[j]}
echo "symlink: " ${pxe_array[j]} "->" ${timerange[i]}"/"${pxe_array[j]}
match=1 && break
fi
done
if [ $match == 1 ] ; then break ; fi
for ((i=0;i<$lines;i++)) ; do
trday=`echo ${timerange[i]} | cut -d "_" -f 1`
trbegin=`echo ${timerange[i]} | cut -d "_" -f 2`
trend=`echo ${timerange[i]} | cut -d "_" -f 3`
if [ $trday == $wday ] && [ $trbegin == "X" ] && [ $trend == "X" ]; then
echo $wday $time "[D _ _]match ->" ${timerange[i]}
ln -s ${timerange[i]}"/"${pxe_array[j]} ${pxe_array[j]}
echo "symlink: " ${pxe_array[j]} "->" ${timerange[i]}"/"${pxe_array[j]}
match=1 && break
fi
done
if [ $match == 1 ] ; then break ; fi
for ((i=0;i<$lines;i++)) ; do
trday=`echo ${timerange[i]} | cut -d "_" -f 1`
trbegin=`echo ${timerange[i]} | cut -d "_" -f 2`
trend=`echo ${timerange[i]} | cut -d "_" -f 3`
if [ $trday == "X" ] && [ $trbegin != "X" ] && [ $trend != "X" ] && \
[ $trbegin -le $time ] && [ $time -le $trend ]; then
echo $wday $time "[_ H H]match ->" ${timerange[i]}
ln -s ${timerange[i]}"/"${pxe_array[j]} ${pxe_array[j]}
echo "symlink: " ${pxe_array[j]} "->" ${timerange[i]}"/"${pxe_array[j]}
match=1 && break
else
if [ ${timerange[i]} == "X_X_X" ]; then
echo $wday $time "[_ _ _]match ->" ${timerange[i]}
ln -s ${timerange[i]}"/"${pxe_array[j]} ${pxe_array[j]}
echo "symlink: " ${pxe_array[j]} "->" ${timerange[i]}"/"${pxe_array[j]}
fi
match=1
fi
done
if [ $match == 1 ] ; then break ; fi
done
done
exit 0
|