83eb2c3700
literal name_enable wherever possible, and ${name}_enable when it's not, to prepare for the demise of set_rcvar(). In cases where I had to hand-edit unusual instances also modify formatting slightly to be more uniform (and in some cases, correct). This includes adding some $FreeBSD$ tags, and most importantly moving rcvar= to right after name= so it's clear that one is derived from the other.
54 lines
949 B
Bash
54 lines
949 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=zoneminder_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"
|