-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtoolbox-css.sh
More file actions
executable file
·55 lines (46 loc) · 2.47 KB
/
toolbox-css.sh
File metadata and controls
executable file
·55 lines (46 loc) · 2.47 KB
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
#!/bin/bash
echo "$(date) $1" >> /tmp/foo
# Select random line from file using reservoir sampling, first argument should be filename.
function randomLine {
local selectedLine=''
local i=1
while read -r line; do
# If line is empty, ignore.
if [ -z "$line" ]; then
continue
fi
# If selected line is empty, use this
if [ -z "$selectedLine" ]
then
selectedLine=$line
else
# Replace selected Line with probability 1/i
if [ "$(($RANDOM % $i))" -eq "0" ]; then
selectedLine=$line
fi
fi
((i++))
done < "$1"
echo "$selectedLine"
}
# Load config values
source /usr/lib/cgi-bin/spaceapi-server/token.conf
if [ ! -f /var/www/bodensee.space/web/spaceapi/toolbox/space-toolbox.conf ]; then
toolbox_open=false
else
source /var/www/bodensee.space/web/spaceapi/toolbox/space-toolbox.conf
fi
# Space toolbox open/close:
if [ $1 = "open" ]; then
echo "toolbox_open=true" > /var/www/bodensee.space/web/spaceapi/toolbox/space-toolbox.conf
echo "#header h1 a.icon:before { color: lime; }" > /var/www/bodensee.space/web/spaceapi/toolbox/space_api.css
echo "#navButton .toggle:before { color: lime; }" >> /var/www/bodensee.space/web/spaceapi/toolbox/space_api.css
echo "#tb-opened, #space-opened { display: block; } #tb-closed, #space-closed { display: none; }" > /var/www/bodensee.space/web/spaceapi/toolbox/spacestatus.css
if [ "$toolbox_open" = false ]; then curl -X POST -H 'Content-type: application/json' --data "{'text':'$(randomLine '/usr/lib/cgi-bin/spaceapi-server/messages_open.txt')'}" https://hooks.slack.com/services/$TOKEN1/$TOKEN2/$TOKEN3 > /dev/null; fi
else
echo "toolbox_open=false" > /var/www/bodensee.space/web/spaceapi/toolbox/space-toolbox.conf
echo "#header h1 a.icon:before { color: inherit; }" > /var/www/bodensee.space/web/spaceapi/toolbox/space_api.css
echo "#navButton .toggle:before { color: #fff; }" > /var/www/bodensee.space/web/spaceapi/toolbox/space_api.css
echo "#tb-closed, #space-closed { display: block; } #tb-opened, #space-opened { display: none; }" > /var/www/bodensee.space/web/spaceapi/toolbox/spacestatus.css
if [ "$toolbox_open" = true ]; then curl -X POST -H 'Content-type: application/json' --data "{'text':'$(randomLine '/usr/lib/cgi-bin/spaceapi-server/messages_closed.txt')'}" https://hooks.slack.com/services/$TOKEN1/$TOKEN2/$TOKEN3 >/dev/null; fi
fi