blob: f9fc8f6902999b235e7e3c8ef6880b4b56beb1e3 (
plain)
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
|
#!/bin/bash
toggle() {
LAMPE=`echo "$1" | sed -n '/^[1-2]*[0-9]*[0-9]$/p' | xargs echo "obase=16;" | bc`
TOGGLE=`echo "$2" | sed -n '/^[0-1]/p'`
if ! [ "$LAMPE" -a "$TOGGLE" ];then
echo "you are made of stupid"
exit 1
fi
STRING="\\xA5\\x5A\\x$LAMPE\\x$TOGGLE"
if [ $# != 2 ]
then
echo "Usage: licht <lampe> <0/1>"
else
echo "Toggle light $LAMPE ($TOGGLE)"
printf "$STRING" | nc -u -w1 licht.shack 1337
fi
}
toggle_all() {
for i in `seq 0 7`
do
printf "\\xA5\\x5A\\x$i\\x$TOGGLE" | nc -u -w1 licht.shack 1337 &
done
wait
}
kuschel(){
for i in 0 2
do
printf "\\xA5\\x5A\\x$i\\x$TOGGLE" | nc -u -w1 licht.shack 1337 &
done
wait
}
software(){
for i in 1 3
do
printf "\\xA5\\x5A\\x$i\\x$TOGGLE" | nc -u -w1 licht.shack 1337 &
done
wait
}
tische(){
for i in 4 6
do
printf "\\xA5\\x5A\\x$i\\x$TOGGLE" | nc -u -w1 licht.shack 1337 &
done
wait
}
ghetto(){
printf "\\xA5\\x5A\\x7\\x$TOGGLE" | nc -u -w1 licht.shack 1337
}
porsche(){
printf "\\xA5\\x5A\\x5\\x$TOGGLE" | nc -u -w1 licht.shack 1337
}
case "$1" in
--help)
echo "Toggle the lights"
echo "Usage: lich <lampe> <0/1>"
;;
all)
TOGGLE=$2
toggle_all
;;
kuschel)
TOGGLE=$2
kuschel
;;
software)
TOGGLE=$2
software
;;
links)
TOGGLE=$2
kuschel
software
;;
rechts)
TOGGLE=$2
tische
porsche
ghetto
;;
tische)
TOGGLE=$2
tische
;;
porsche)
TOGGLE=$2
porsche
;;
ghetto)
TOGGLE=$2
ghetto
;;
*)
toggle "$@"
;;
esac
|