-
Notifications
You must be signed in to change notification settings - Fork 0
/
show-subst
executable file
·113 lines (96 loc) · 3.37 KB
/
show-subst
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
if [[ $1 == "" ]]
then
echo kein Nutzername angegeben
exit 1
fi
KOLLEGE=$1
LOG=/var/log/show-subst.log
touch $LOG
echo -n "$(date): <$1> - " >> $LOG
KILLTIME=16 # Das ist die Uhrzeit, ab wann der Plan nicht mehr ausgegeben wird. Sinnvoll: 16
# weiter machen nur, wenn
# es vor 15 Uhr ist und es den Kollegen heute oder morgen betrifft
# oder nach 15 Uhr ist und morgen den Kollegen betrifft.
if [ $(date +"%H") -lt $KILLTIME ]
then
if ! $(cat /var/www/Dropbox/vp-export/display-leh/f1/* | grep "Betroffen\|Abwesend" | grep $KOLLEGE > /dev/null)
then
if ! $(cat /var/www/Dropbox/vp-export/display-leh/f2/* | grep "Betroffen\|Abwesend" | grep $KOLLEGE > /dev/null)
then
echo "nothing to show." >> $LOG
exit 0
fi
fi
else
if ! $(cat /var/www/Dropbox/vp-export/display-leh/f2/* | grep "Betroffen\|Abwesend" | grep $KOLLEGE > /dev/null)
then
if ! $(cat /var/www/Dropbox/vp-export/display-leh/f2/* | grep "Betroffen\|Abwesend" | grep $KOLLEGE > /dev/null)
then
echo "nothing to show." >> $LOG
exit 0
fi
fi
fi
wer-vertritt-mich() {
# usage: wer-vertritt-mich <Sub-Dir> <Wochentag-Filter>
cat /var/www/Dropbox/vp-export/display-leh/$1/* | grep $2 \
| grep $KOLLEGE \
| sed -e 's/->/verlegt nach/g' \
| sed -e 's/</>/g' \
| awk -F'>' '{ print $7 ": " $15 " am " $23 ", " $31 ".Std - " $47 " in Klasse " $39 " Raum " $55 " (" $15 " für " $63 ")" }' \
| sed -e "s/ /$KOLLEGE/g" | sed -e "s/---/$KOLLEGE/g" | column -t
}
HEUTE=$(date +"%a")
case $HEUTE in
"Fr"|"Sa")
MORGEN="Mo"
;;
*)
MORGEN=$(date -d 'tomorrow' +'%a')
;;
esac
echo "Vertretungen für $KOLLEGE:"
# Heutigen Plan nur dann ausgeben, wenn es vor 16h ist...
if [ $(date +"%H") -lt $KILLTIME ]
then
# und wenn es überhaupt was gibt...
if $(cat /var/www/Dropbox/vp-export/display-leh/f1/* | grep Betroffen | grep $KOLLEGE > /dev/null)
then
echo
echo "HEUTE $HEUTE:"
echo " "
cat /var/www/Dropbox/vp-export/display-leh/f1/* | grep $HEUTE \
| grep $KOLLEGE \
| sed -e 's/</>/g' \
| awk -F'>' '{ print $7 ": " $15 " am " $23 ", " $31 ".Std - " $47 " in Klasse " $39 " Raum " $55 " (" $15 " für " $63 ")" }' \
| sed -e "s/ /$KOLLEGE/g" | sed -e "s/---/$KOLLEGE/g" | grep -e "^$KOLLEGE" #| column -t
echo " "
echo " "
fi
# falls abwesend, das noch vermerken:
if [ "$(cat /var/www/Dropbox/vp-export/display-leh/f1/subst_001.htm | grep Abwesend | grep -v Betroffen | grep -c $KOLLEGE)" == "1" ]
then
echo Du bist heute ausgeplant und wirst folgendermaßen vertreten:
wer-vertritt-mich f1 $HEUTE
fi
fi
# morgen nur, wenn es auch was gibt...
if $(cat /var/www/Dropbox/vp-export/display-leh/f2/* | grep Betroffen | grep $KOLLEGE > /dev/null)
then
echo "MORGEN $MORGEN:"
echo " "
cat /var/www/Dropbox/vp-export/display-leh/f2/* | grep $MORGEN \
| grep $KOLLEGE \
| sed -e 's/->/verlegt nach/g' \
| sed -e 's/</>/g' \
| awk -F'>' '{ print $7 ": " $15 " am " $23 ", " $31 ".Std - " $47 " in Klasse " $39 " Raum " $55 " (" $15 " für " $63 ")" }' \
| sed -e "s/ /$KOLLEGE/g" | sed -e "s/---/$KOLLEGE/g" | grep -e "^$KOLLEGE" #| column -t
fi
# falls abwesend, das noch vermerken:
if [ "$(cat /var/www/Dropbox/vp-export/display-leh/f2/subst_001.htm | grep Abwesend | grep -v Betroffen | grep -c $KOLLEGE)" == "1" ]
then
echo Du bist morgen ausgeplant und wirst folgendermaßen vertreten:
wer-vertritt-mich f2 $MORGEN
fi
echo "Plan erstellt..." >> $LOG