comparison contrib/dashboardctl @ 38:3fc74bcbd2cf

Fix indentation; add Vim modeline
author Gernot Schulz <gernot@intevation.de>
date Tue, 20 Oct 2015 08:24:56 +0200
parents 58ca5b1d33a5
children c3955e5cf3b3
comparison
equal deleted inserted replaced
37:58ca5b1d33a5 38:3fc74bcbd2cf
31 -h, --help This help 31 -h, --help This help
32 EOF 32 EOF
33 } 33 }
34 34
35 start_bottledash () { 35 start_bottledash () {
36 # taken from start-bottledash-hohup 36 # taken from start-bottledash-hohup
37 nohup python3 /home/pi/bottledash/dash.py 2>&1 > $BOTTLEDASH_LOG & 37 nohup python3 /home/pi/bottledash/dash.py 2>&1 > $BOTTLEDASH_LOG &
38 echo $! > $BOTTLEDASH_PID 38 echo $! > $BOTTLEDASH_PID
39 sleep 10 39 sleep 10
40 } 40 }
41 41
42 stop_bottledash () { 42 stop_bottledash () {
43 kill $(cat $BOTTLEDASH_PID) 43 kill $(cat $BOTTLEDASH_PID)
44 } 44 }
45 45
46 start_chromium () { 46 start_chromium () {
47 # taken from show-dashboard 47 # taken from show-dashboard
48 rm -R $HOME/.cache/chromium/Default/Cache/ 48 rm -R $HOME/.cache/chromium/Default/Cache/
49 DISPLAY=:0.0 nohup chromium --new --noerrdialogs --kiosk \ 49 DISPLAY=:0.0 nohup chromium --new --noerrdialogs --kiosk \
50 http://localhost:8080 2>&1 > $CHROMIUM_LOG & 50 http://localhost:8080 2>&1 > $CHROMIUM_LOG &
51 echo $! > $CHROMIUM_PID 51 echo $! > $CHROMIUM_PID
52 } 52 }
53 53
54 54
55 stop_chromium () { 55 stop_chromium () {
56 kill $(cat $CHROMIUM_PID) 56 kill $(cat $CHROMIUM_PID)
57 } 57 }
58 58
59 xdo_reload_chromium () { 59 xdo_reload_chromium () {
60 # Start Chromium if necessary 60 # Start Chromium if necessary
61 if [ -f "$BOTTLEDASH_PID" ] && [ -d /proc/$(cat "$CHROMIUM_PID") ]; then 61 if [ -f "$BOTTLEDASH_PID" ] && [ -d /proc/$(cat "$CHROMIUM_PID") ]; then
62 # Send F5 to Chromium 62 # Send F5 to Chromium
63 WID=$(xdotool search --onlyvisible --class chromium | head -1) 63 WID=$(xdotool search --onlyvisible --class chromium | head -1)
64 xdotool windowactivate ${WID} 64 xdotool windowactivate ${WID}
65 xdotool key F5 65 xdotool key F5
66 else 66 else
67 start_chromium 67 start_chromium
68 fi 68 fi
69 } 69 }
70 70
71 check_new_db () { 71 check_new_db () {
72 if [ ! -f "$NEWDB" ]; then 72 if [ ! -f "$NEWDB" ]; then
73 echo 0 ; return 73 echo 0 ; return
74 fi 74 fi
75 OLDSIZE=$(md5sum $OLDDB | awk '{print $1}') 75 OLDSIZE=$(md5sum $OLDDB | awk '{print $1}')
76 NEWSIZE=$(md5sum $NEWDB | awk '{print $1}') 76 NEWSIZE=$(md5sum $NEWDB | awk '{print $1}')
77 if [ "$OLDSIZE" != "$NEWSIZE" ]; then 77 if [ "$OLDSIZE" != "$NEWSIZE" ]; then
78 echo 1 78 echo 1
79 else 79 else
80 echo 0 80 echo 0
81 fi 81 fi
82 } 82 }
83 83
84 update_db () { 84 update_db () {
85 if [ $(check_new_db) -eq 1 ]; then 85 if [ $(check_new_db) -eq 1 ]; then
86 mv "$NEWDB" "$OLDDB" 86 mv "$NEWDB" "$OLDDB"
87 fi 87 fi
88 } 88 }
89 89
90 case $1 in 90 case $1 in
91 '--start') 91 '--start')
92 start_bottledash 92 start_bottledash
93 start_chromium 93 start_chromium
94 ;; 94 ;;
95 '--stop') 95 '--stop')
96 stop_bottledash 96 stop_bottledash
97 stop_chromium 97 stop_chromium
98 ;; 98 ;;
99 '--restart-bd') 99 '--restart-bd')
100 stop_bottledash 100 stop_bottledash
101 start_bottledash 101 start_bottledash
102 ;; 102 ;;
103 '--reload-browser') 103 '--reload-browser')
104 xdo_reload_chromium 104 xdo_reload_chromium
105 ;; 105 ;;
106 '--reload') 106 '--reload')
107 stop_bottledash 107 stop_bottledash
108 start_bottledash 108 start_bottledash
109 xdo_reload_chromium 109 xdo_reload_chromium
110 ;; 110 ;;
111 '--check-db') 111 '--check-db')
112 check_new_db 112 check_new_db
113 ;; 113 ;;
114 '--smart-reload') 114 '--smart-reload')
115 if [ $(check_new_db) -eq 1 ]; then 115 if [ $(check_new_db) -eq 1 ]; then
116 update_db 116 update_db
117 stop_bottledash 117 stop_bottledash
118 start_bottledash 118 start_bottledash
119 sleep 10 119 sleep 10
120 xdo_reload_chromium 120 xdo_reload_chromium
121 fi 121 fi
122 ;; 122 ;;
123 '-h'|'--help') 123 '-h'|'--help')
124 usage 124 usage
125 exit 0 125 exit 0
126 ;; 126 ;;
127 *) 127 *)
128 echo "ERROR: unknown command: $1" >&2 128 echo "ERROR: unknown command: $1" >&2
129 usage 129 usage
130 exit 2 130 exit 2
131 ;; 131 ;;
132 esac 132 esac
133 133
134 # vim: set ft=sh : 134 # vim: set ft=sh ts=4 sw=4 expandtab :
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)