forked from Scout24/kiosk-browser
-
Notifications
You must be signed in to change notification settings - Fork 4
/
kiosk-browser-control
executable file
·80 lines (64 loc) · 1.72 KB
/
kiosk-browser-control
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
#!/bin/bash
function usage {
echo "Usage: $0 <start|stop|status|restart|evening|morning|interactive>"
exit 1
}
[[ -z "$1" || "$*" == *-h* ]] && usage
if [[ "$USER" != root && $(id -u) != "0" ]] ; then
# restart as root
exec sudo -i "$(readlink -f "$0")" "$@"
echo "Need sudo permissions!"
exit 1
fi
function is_pi {
type -p tvservice &>/dev/null
}
function start {
invoke-rc.d nodm start
}
function stop {
invoke-rc.d nodm stop
echo -n "Waiting for kiosk-browser processes to terminate "
while status ; do echo -n . ; sleep 3 ; done
echo " OK"
}
function status {
if pstree -paul kiosk-browser 2>/dev/null ; then
return 0
else
echo "kiosk-browser not running" 1>&2
return 1
fi
}
function restart {
stop
sleep 1
start
}
function interactive {
status >/dev/null || return 1
homedir=( /tmp/kiosk-browser.HOME* )
if [[ "$homedir" != "${homedir[*]}" ]] ; then
echo "ERROR: Found more than one kiosk-browser Home Directory: ${homedir[*]}" 1>&2
echo " Please clean up the stale directories and try again" 1>&2
return 1
fi
echo "Launching interactive Shell in current kiosk-browser session."
sudo -u kiosk-browser -i env HOME=$homedir DISPLAY=:0 bash -i
}
function evening {
stop
is_pi && tvservice -o || vbetool dpms off
}
function morning {
# this apparently does not work reliably, so we reboot if on RPi
# is_pi && tvservice -p || vbetool dpms on
is_pi && reboot || vbetool dpms on
sleep 2
start
}
case "$1" in
(start|stop|status|restart|interactive) "$1" ;;
(evening|morning) [[ -e /tmp/kiosk-browser-disable-morning-evening ]] || "$1" ;;
(*) usage ;;
esac