36 lines
945 B
Bash
Executable File
36 lines
945 B
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# FreeBSD rc.d startup script for unifi-poller.
|
|
# Target like so:
|
|
# sed -e "s/{{BINARY}}/app-name/g"
|
|
# -e "s/{{BINARYU}}/app_name/g" \
|
|
# -e "s/{{CONFIG_FILE}}/app-name.conf/g" \
|
|
# thisfile.rc > /usr/local/etc/rc.d/unifi-poller
|
|
#
|
|
# PROVIDE: unifi-poller
|
|
# REQUIRE: networking syslog
|
|
# KEYWORD:
|
|
|
|
. /etc/rc.subr
|
|
|
|
name="{{BINARYU}}"
|
|
rcvar="{{BINARYU}}_enable"
|
|
{{BINARYU}}_command="/usr/local/bin/{{BINARY}}"
|
|
{{BINARYU}}_user="nobody"
|
|
{{BINARYU}}_config="/usr/local/etc/{{BINARY}}/{{CONFIG_FILE}}"
|
|
pidfile="/var/run/{{BINARY}}/pid"
|
|
|
|
# This runs `daemon` as the `{{BINARYU}}_user` user.
|
|
command="/usr/sbin/daemon"
|
|
command_args="-P ${pidfile} -r -t {{BINARY}} -T {{BINARY}} -l daemon ${{{BINARYU}}_command} -c ${{{BINARYU}}_config}"
|
|
|
|
load_rc_config ${name}
|
|
: ${{{BINARYU}}_enable:=no}
|
|
|
|
# Make a place for the pid file.
|
|
mkdir -p $(dirname ${pidfile})
|
|
chown -R ${{BINARYU}}_user $(dirname ${pidfile})
|
|
|
|
# Go!
|
|
run_rc_command "$1"
|