1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-10-19 19:59:43 +00:00
freebsd-ports/misc/dnetc/files/dnetc.in
Doug Barton 9aac569eaa Move the rc.d scripts of the form *.sh.in to *.in
Where necessary add $FreeBSD$ to the file

No PORTREVISION bump necessary because this is a no-op
2012-08-05 23:19:36 +00:00

78 lines
1.5 KiB
Bash

#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: dnetc
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable dnetc:
# dnetc_enable (bool): Set to "NO" by default.
# Set to "YES" to enable dnetc.
# dnetc_dir (path): Set to "%%BINDIR%%" by default.
# dnetc_user (user): Set to "%%CLIENTUSER%%" by default.
# dnetc_idprio (priority): Unset by default. See idprio manpage.
#
. /etc/rc.subr
name="dnetc"
rcvar=dnetc_enable
load_rc_config $name
: ${dnetc_enable="NO"}
: ${dnetc_dir="%%BINDIR%%"}
: ${dnetc_user="%%CLIENTUSER%%"}
required_files=${dnetc_dir}/${name}.ini
start_cmd="${name}_start"
stop_cmd="${name}_stop"
extra_commands="flush fetch update"
flush_cmd="${name}_flush"
fetch_cmd="${name}_fetch"
update_cmd="${name}_update"
dnetc_start()
{
if ps -x -o ucomm -U${dnetc_user} | grep ${name} >/dev/null; then
echo "${name} already running?"
else
${dnetc_idprio:+idprio} ${dnetc_idprio} su -m ${dnetc_user} -c "${dnetc_dir}/${name} -quiet" >/dev/null 2>&1
echo -n " ${name}"
fi
}
dnetc_stop()
{
if ps -x -o ucomm -U${dnetc_user} | grep ${name} >/dev/null; then
su -m ${dnetc_user} -c "${dnetc_dir}/${name} -shutdown" >/dev/null 2>&1
# wait for dnetc to stop
sleep 2
echo -n " ${name}"
else
echo "${name} not running?"
fi
}
dnetc_flush()
{
su -m ${dnetc_user} -c "${dnetc_dir}/${name} -flush" >/dev/null 2>&1
}
dnetc_fetch()
{
su -m ${dnetc_user} -c "${dnetc_dir}/${name} -fetch" >/dev/null 2>&1
}
dnetc_update()
{
su -m ${dnetc_user} -c "${dnetc_dir}/${name} -update" >/dev/null 2>&1
}
run_rc_command "$1"