forked from dougpat/zmhacks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzoneminder
executable file
·115 lines (107 loc) · 2.64 KB
/
zoneminder
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
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/sh
### BEGIN INIT INFO
# Provides: zoneminder
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Should-Start: mysql
# Should-Stop: mysql
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Control ZoneMinder as a Service
### END INIT INFO
# description: Control ZoneMinder as a Service
# chkconfig: 2345 20 20
# Source function library.
#. /etc/rc.d/init.d/functions
prog=ZoneMinder
ZM_PATH_BIN="/usr/bin"
RUNDIR=/var/run/zm
TMPDIR=/tmp/zm
command="$ZM_PATH_BIN/zmpkg.pl"
start() {
sleep 10
echo -n "Starting $prog: "
mkdir -p $RUNDIR && chown www-data:www-data $RUNDIR
mkdir -p $TMPDIR && chown www-data:www-data $TMPDIR
$command start
RETVAL=$?
[ $RETVAL = 0 ] && echo success
[ $RETVAL != 0 ] && echo failure
echo
[ $RETVAL = 0 ] && touch /var/lock/zm
# ARC
touch /usr/share/zoneminder/zm_run_state.txt
touch /usr/share/zoneminder/zm_phone_state.txt
touch /usr/share/zoneminder/zm_phone_state_log.txt
touch /usr/share/zoneminder/zm_phone_state_log_cron.txt
chown www-data /usr/share/zoneminder/zm_run_state.txt
chown www-data /usr/share/zoneminder/zm_phone_state.txt
chown www-data /usr/share/zoneminder/zm_phone_state_log.txt
chown www-data /usr/share/zoneminder/zm_phone_state_log_cron.txt
# pkill arc_zmtrigger
# pkill arc_zm_foscamHD
# echo "Starting arc_zmtrigger..."
# /usr/bin/arc_zmtrigger.sh &
# echo "Starting arc_foscamHDmotion"
# /usr/bin/arc_zm_foscamHDmotion.pl &
return $RETVAL
}
stop() {
echo -n "Stopping $prog: "
#
# Why is this status check being done?
# as $command stop returns 1 if zoneminder
# is stopped, which will result in
# this returning 1, which will stuff
# dpkg when it tries to stop zoneminder before
# uninstalling . . .
#
result=`$command status`
if [ ! "$result" = "running" ]; then
echo "Zoneminder already stopped"
echo
RETVAL=0
else
$command stop
RETVAL=$?
[ $RETVAL = 0 ] && echo success
[ $RETVAL != 0 ] && echo failure
echo
[ $RETVAL = 0 ] && rm -f /var/lock/zm
fi
# ARC
# echo "Stopping arc_zmtrigger.sh & arc_zm_foscamHDmotion.pl"
# pkill arc_zmtrigger
# pkill arc_zm_foscamHD
# ARC END
}
status() {
result=`$command status`
if [ "$result" = "running" ]; then
echo "ZoneMinder is running"
RETVAL=0
else
echo "ZoneMinder is stopped"
RETVAL=1
fi
}
case "$1" in
'start')
start
;;
'stop')
stop
;;
'restart' | 'force-reload')
stop
start
;;
'status')
status
;;
*)
echo "Usage: $0 { start | stop | restart | status }"
RETVAL=1
;;
esac
exit $RETVAL