freebsd-ports/multimedia/zoneminder/files/zoneminder.in
Boris Samorodov 1a59abafcf . update RC script: create procedure zm_prestart() to detect when
mysqld may be used by zoneminder;
. delete 10 seconds sleep;
. bump PORTREVISION.

Submitted by:	dougb (thanks!)
2011-07-09 18:55:02 +00:00

54 lines
946 B
Bash

#!/bin/sh
# $FreeBSD$
#
# PROVIDE: zoneminder
# REQUIRE: mysql apache
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# zoneminder_enable (bool): Set to NO by default.
# Set it to YES to enable zoneminder.
. /etc/rc.subr
name="zoneminder"
rcvar=${name}_enable
load_rc_config "$name"
: ${zoneminder_enable="NO"}
command=%%PREFIX%%/bin/zmpkg.pl
command_args="$1"
pidfile=/var/run/zm/zm.pid
start_precmd=zm_prestart
stop_cmd="zm_stop"
status_cmd="zm_status"
zm_stop() {
${command} ${command_args}
}
zm_status() {
%%PREFIX%%/bin/zmdc.pl status
}
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
}
run_rc_command "$1"