summaryrefslogtreecommitdiff
path: root/misc/dnetc/files/dnetc.in
diff options
context:
space:
mode:
Diffstat (limited to 'misc/dnetc/files/dnetc.in')
-rw-r--r--misc/dnetc/files/dnetc.in77
1 files changed, 77 insertions, 0 deletions
diff --git a/misc/dnetc/files/dnetc.in b/misc/dnetc/files/dnetc.in
new file mode 100644
index 000000000000..25d083b6a0ae
--- /dev/null
+++ b/misc/dnetc/files/dnetc.in
@@ -0,0 +1,77 @@
+#!/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"