2011-04-29 16:22:37 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# $FreeBSD$
|
2011-07-06 16:34:00 +02:00
|
|
|
#
|
2011-04-29 16:22:37 +02:00
|
|
|
# PROVIDE: zoneminder
|
|
|
|
# REQUIRE: mysql apache
|
|
|
|
# KEYWORD: shutdown
|
2011-07-06 16:34:00 +02:00
|
|
|
#
|
2011-04-29 16:22:37 +02:00
|
|
|
# Add the following line to /etc/rc.conf.local or /etc/rc.conf
|
|
|
|
# to enable this service:
|
|
|
|
#
|
2011-07-06 16:34:00 +02:00
|
|
|
# zoneminder_enable (bool): Set to NO by default.
|
|
|
|
# Set it to YES to enable zoneminder.
|
2011-04-29 16:22:37 +02:00
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
2011-07-06 16:34:00 +02:00
|
|
|
name="zoneminder"
|
2011-04-29 16:22:37 +02:00
|
|
|
rcvar=${name}_enable
|
|
|
|
|
|
|
|
load_rc_config "$name"
|
2011-07-06 16:34:00 +02:00
|
|
|
: ${zoneminder_enable="NO"}
|
|
|
|
|
|
|
|
command=%%PREFIX%%/bin/zmpkg.pl
|
|
|
|
command_args="$1"
|
|
|
|
pidfile=/var/run/zm/zm.pid
|
2011-04-29 16:22:37 +02:00
|
|
|
|
2011-07-09 20:55:02 +02:00
|
|
|
start_precmd=zm_prestart
|
2011-04-29 16:22:37 +02:00
|
|
|
stop_cmd="zm_stop"
|
2011-07-05 23:53:40 +02:00
|
|
|
status_cmd="zm_status"
|
2011-04-29 16:22:37 +02:00
|
|
|
|
|
|
|
zm_stop() {
|
|
|
|
${command} ${command_args}
|
|
|
|
}
|
|
|
|
|
2011-07-06 16:34:00 +02:00
|
|
|
zm_status() {
|
|
|
|
%%PREFIX%%/bin/zmdc.pl status
|
|
|
|
}
|
2011-07-05 23:53:40 +02:00
|
|
|
|
2011-07-09 20:55:02 +02:00
|
|
|
zm_prestart() {
|
|
|
|
local _count=0
|
|
|
|
|
|
|
|
while : ; do
|
|
|
|
echo "USE zm; SELECT Username from Users where Id=1;" | \
|
|
|
|
%%LOCALBASE%%/bin/mysqltest -u root zm > /dev/null 2>&1 && return
|
|
|
|
_count=$(( $_count + 1 ))
|
|
|
|
if [ $_count -gt 10 ]; then
|
|
|
|
err 1 "${name}: mysqltest command failed"
|
|
|
|
fi
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
}
|
2011-04-29 16:22:37 +02:00
|
|
|
|
|
|
|
run_rc_command "$1"
|