aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorbms <bms@FreeBSD.org>2008-05-14 18:02:37 +0800
committerbms <bms@FreeBSD.org>2008-05-14 18:02:37 +0800
commit3331b33906acbec9100f00b8df6c044c044b4a62 (patch)
tree747eb3c4f09ed1ec4834bcdcf6a0b86f1532ac44 /net
parent15782f31b9ddfb6ef057600b1507db0fcc4837ee (diff)
downloadfreebsd-ports-gnome-3331b33906acbec9100f00b8df6c044c044b4a62.tar.gz
freebsd-ports-gnome-3331b33906acbec9100f00b8df6c044c044b4a62.tar.zst
freebsd-ports-gnome-3331b33906acbec9100f00b8df6c044c044b4a62.zip
Rewrite the RC script.
The xorp port will now log to /var/log/xorp_rtrmgr.log by default, and the xorp_rtrmgr process will be run under daemon(8) to detach it from the controlling terminal.
Diffstat (limited to 'net')
-rw-r--r--net/xorp/files/xorp.in75
1 files changed, 72 insertions, 3 deletions
diff --git a/net/xorp/files/xorp.in b/net/xorp/files/xorp.in
index 13a3f8acd1c1..76d9fe894b92 100644
--- a/net/xorp/files/xorp.in
+++ b/net/xorp/files/xorp.in
@@ -25,12 +25,81 @@ load_rc_config $name
: ${xorp_enable="NO"}
: ${xorp_config_boot="%%PREFIX%%/etc/xorp.conf"}
: ${xorp_flags=""}
+: ${xorp_rtrmgr_pidfile="/var/run/xorp_rtrmgr.pid"}
+: ${xorp_rtrmgr_logfile="/var/log/xorp_rtrmgr.log"}
+: ${xorp_rtrmgr_poll_enable=true}
+: ${xorp_rtrmgr_poll_timeout=90}
+: ${xorp_hardkill_enable=false}
required_files=${xorp_config_boot}
-command=%%PREFIX%%/bin/xorp_rtrmgr
+command=%%PREFIX%%bin/xorp_rtrmgr
command_args="-b ${xorp_config_boot}"
pidfile=${xorp_rtrmgr_pidfile}
sig_stop=INT
-# XXX: This is not the correct fix.
-run_rc_command "$1" 2>&1 &
+start_precmd="xorp_prestart"
+start_cmd="xorp_start"
+stop_postcmd="xorp_poststop"
+
+xorp_prestart()
+{
+ touch ${xorp_rtrmgr_logfile}
+ return 0
+}
+
+xorp_start()
+{
+ pidfile=${xorp_rtrmgr_pidfile}
+
+ echo -n 'Starting XORP router processes:'
+
+ echo -n ' xorp_rtrmgr'
+ if ! daemon </dev/null >>${xorp_rtrmgr_logfile} 2>&1 -c -p ${pidfile} \
+ ${command} ${command_args} ; then
+ warn 'could not bring up xorp_rtrmgr.'
+ return 1
+ fi
+
+ ${xorp_rtrmgr_poll_enable} || return 0
+
+ # If startup polling is enabled, then poll xorp_rtrmgr every
+ # second to see if it died, or if it logged successful bringup.
+ # XXX This may be racy on very fast machines, but without
+ # daemonizing support from xorp_rtrmgr it's difficult not to race.
+
+ pid=$(cat ${xorp_rtrmgr_pidfile})
+ timeout=${xorp_rtrmgr_poll_timeout}
+ tick=0
+ fail=true
+
+ until [ $tick = $timeout ];
+ do
+ sleep 1 ; kill -0 ${pid} || break
+ if ( tail -5 ${xorp_rtrmgr_logfile} | \
+ grep 'No more tasks to run' > /dev/null 2>&1 ) ; then
+ fail=false
+ break
+ fi
+ tick=$((tick + 1))
+ done
+
+ if $fail ; then
+ warn 'xorp_rtrmgr failed to start'
+ return 1
+ fi
+
+ echo '.'
+ return 0
+}
+
+xorp_poststop()
+{
+ rm -f ${xorp_rtrmgr_pidfile} >/dev/null 2>&1 || true
+
+ ${xorp_hardkill_enable} || return 0
+ killall -9 -m xorp_\* || true
+
+ return 0
+}
+
+run_rc_command "$1"