forked from MichelVos/rpi_cpu_infoscreen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpi_cpuinfo_screen_service.sh
executable file
·74 lines (60 loc) · 1.18 KB
/
rpi_cpuinfo_screen_service.sh
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
#!/bin/bash
### BEGIN INIT INFO
# Provides: cpuinfo
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Raspberry Pi cpuinfo initscript
# origin post by https://www.jianshu.com/p/425edae3fc63
# /etc/init.d/cpuinfo start|status|stop
PROG="cpuinfo"
PROG_PATH="/usr/local/rpi_cpuinfo_screen"
DELAY=5
start() {
cpuinfopid=$(ps -e|grep $PROG|awk '{print $1}')
if [ ! -n "$cpuinfopid" ]; then
echo "Error! $PROG is currently running!" 1>&2
exit 1
else
cd $PROG_PATH
./$PROG &
echo "$PROG started, waiting $DELAY seconds..."
fi
}
stop() {
cpuinfopid=$(ps -e|grep $PROG|awk '{print $1}')
if [ ! -n "$cpuinfopid" ]; then
echo "Cant't Find $PROG Process"
else
echo "Stop $PROG... pid: $cpuinfopid" 1>&2
kill -9 $cpuinfopid
fi
}
status() {
if [ -e $PROG ]; then
echo "$0 service start"
else
echo "$0 service stop"
fi
}
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
reload|restart|force-reload)
stop
start
;;
*)
echo "Usage: $0 {start|stop|status|reload|restart|force-reload}" 1>&2
exit 1
esac