mirror of
https://git.freebsd.org/ports.git
synced 2025-06-23 13:40:34 -04:00
Summary: Add 'rtg' user and group in UIDs/GIDs. Use daemon(8) to daemonize rtgpoll. Add prestart commands to set correct permissions for RTG's files. Reviewers: swills, allanjude, xmj, andrew.fengler_scaleengine.com, #contributor_reviewers_ports, matthew Reviewed By: #contributor_reviewers_ports, matthew Subscribers: matthew, mat Differential Revision: https://reviews.freebsd.org/D7486
54 lines
1.3 KiB
Bash
54 lines
1.3 KiB
Bash
#!/bin/sh
|
|
|
|
# $FreeBSD$
|
|
#
|
|
# PROVIDE: rtgpoll
|
|
# REQUIRE: LOGIN mysql
|
|
# KEYWORD: shutdown
|
|
#
|
|
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
|
|
# to enable this service:
|
|
#
|
|
# rtgpoll_enable (bool): Set to NO by default.
|
|
# Set it to YES to enable rtgpoll.
|
|
# rtgpoll_config (path): Set to %%PREFIX%%/etc/rtg/rtg.conf by default.
|
|
# rtgpoll_targets (path): Set to %%PREFIX%%/etc/rtg/targets.cfg by default.
|
|
# rtgpoll_pidfile (path): Set to /var/run/rtgpoll.pid by default.
|
|
#
|
|
|
|
. /etc/rc.subr
|
|
|
|
name="rtgpoll"
|
|
rcvar=rtgpoll_enable
|
|
|
|
cmd=%%PREFIX%%/bin/${name}
|
|
command="/usr/sbin/daemon"
|
|
|
|
load_rc_config $name
|
|
|
|
: ${rtgpoll_enable="NO"}
|
|
: ${rtgpoll_config="%%PREFIX%%/etc/rtg/rtg.conf"}
|
|
: ${rtgpoll_targets="%%PREFIX%%/etc/rtg/targets.cfg"}
|
|
: ${rtgpoll_pidfile="/var/run/${name}.pid"}
|
|
: ${rtgpoll_user="rtg"}
|
|
: ${rtgpoll_group="rtg"}
|
|
|
|
required_files="$rtgpoll_targets"
|
|
|
|
command_args="-f -p $rtgpoll_pidfile $cmd -c $rtgpoll_config -t $rtgpoll_targets"
|
|
|
|
start_precmd="rtgpoll_prestart"
|
|
|
|
rtgpoll_prestart() {
|
|
if [ ! -e "${rtgpoll_pidfile}" ]; then
|
|
touch $rtgpoll_pidfile
|
|
fi
|
|
|
|
chown "${rtgpoll_user}:${rtgpoll_group}" "$rtgpoll_pidfile"
|
|
chmod 640 "$rtgpoll_pidfile"
|
|
chown -R "${rtgpoll_user}:${rtgpoll_group}" "%%PREFIX%%/etc/rtg"
|
|
chmod -R u+rwX,g+rX "%%PREFIX%%/etc/rtg"
|
|
}
|
|
|
|
run_rc_command "$1"
|
|
|