scale-catalog/blueprints/unifi/includes/rc/unifi_poller.rc

37 lines
1.0 KiB
Plaintext
Raw Normal View History

#!/bin/sh
# shellcheck disable=SC1091,SC2034,SC2223,SC2154,SC1090,SC2046
#
# FreeBSD rc.d startup script for unifi-poller.
#
# PROVIDE: unifi-poller
# REQUIRE: networking syslog
# KEYWORD:
. /etc/rc.subr
name="unifi_poller"
real_name="unifi-poller"
rcvar="unifi_poller_enable"
unifi_poller_command="/usr/local/bin/${real_name}"
unifi_poller_user="nobody"
unifi_poller_config="/config/up.conf"
pidfile="/var/run/${real_name}/pid"
# This runs `daemon` as the `unifi_poller_user` user.
command="/usr/sbin/daemon"
command_args="-P ${pidfile} -r -t ${real_name} -T ${real_name} -l daemon ${unifi_poller_command} -c ${unifi_poller_config}"
load_rc_config ${name}
: ${unifi_poller_enable:=no}
# Make a place for the pid file.
mkdir -p $(dirname ${pidfile})
chown -R $unifi_poller_user $(dirname ${pidfile})
# Suck in optional exported override variables.
# ie. add something like the following to this file: export UP_POLLER_DEBUG=true
[ -f "/usr/local/etc/defaults/${real_name}" ] && . "/usr/local/etc/defaults/${real_name}"
# Go!
run_rc_command "$1"