#!/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"