62 lines
958 B
Bash
Executable File
62 lines
958 B
Bash
Executable File
#!/bin/sh
|
|
# description: Control ZoneMinder as a Service
|
|
# chkconfig: 2345 99 99
|
|
|
|
# Source function library.
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
prog=ZoneMinder
|
|
ZM_PATH_BIN="@BINDIR@"
|
|
command="$ZM_PATH_BIN/zmpkg.pl"
|
|
|
|
start() {
|
|
echo -n "Starting $prog: "
|
|
$command start
|
|
RETVAL=$?
|
|
[ $RETVAL = 0 ] && echo_success
|
|
[ $RETVAL != 0 ] && echo_failure
|
|
echo
|
|
[ $RETVAL = 0 ] && touch /var/lock/subsys/zm
|
|
return $RETVAL
|
|
}
|
|
stop() {
|
|
echo -n $"Stopping $prog: "
|
|
$command stop
|
|
RETVAL=$?
|
|
[ $RETVAL = 0 ] && echo_success
|
|
[ $RETVAL != 0 ] && echo_failure
|
|
echo
|
|
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/zm
|
|
}
|
|
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')
|
|
stop
|
|
start
|
|
;;
|
|
'status')
|
|
status
|
|
;;
|
|
*)
|
|
echo "Usage: $0 { start | stop | restart | status }"
|
|
RETVAL=1
|
|
;;
|
|
esac
|
|
exit $RETVAL
|