aboutsummaryrefslogtreecommitdiffstats
path: root/net/xorp/files/xorp.in
blob: 38418281f9d618451ea4d8087e797eb267f5934b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh
#
# $FreeBSD$
#
# A sample XORP startup script.
#

# PROVIDE: xorp
# REQUIRE: netif routing mountcritlocal ldconfig
# BEFORE:  NETWORKING
# KEYWORD: shutdown

# Add the following line to /etc/rc.conf to enable xorp:
#
# xorp_enable="YES"
#
# Note: You have to create a config file before you can start xorp!
#       Set ${xorp_conf} to its location, the default is defined below.
#
# Besides the xorp_* variables which you'll find below with their
# default values, you can also define the following in rc.conf:
#
# xorp_rtprio=n
#
# This will run the xorp processes with realtime priority n, see rtprio(1).

. /etc/rc.subr

name=xorp
rcvar=xorp_enable

load_rc_config $name

: ${xorp_enable:=NO}
: ${xorp_conf=%%PREFIX%%/etc/xorp.conf}
: ${xorp_rtrmgr_pidfile=/var/run/xorp_rtrmgr.pid}
: ${xorp_rtrmgr_logfile=/var/log/xorp_rtrmgr.log}
: ${xorp_flags=-l ${xorp_rtrmgr_logfile}}
: ${xorp_hardkill_enable:=NO}

required_files=${xorp_conf}

command=%%PREFIX%%/sbin/xorp_rtrmgr
pidfile=${xorp_rtrmgr_pidfile}
logfile=${xorp_rtrmgr_logfile}
command_args="-d -c ${xorp_conf} -P ${pidfile}"
sig_stop=INT

start_precmd=xorp_prestart
stop_postcmd=xorp_poststop

xorp_prestart()
{
    [ -z ${logfile} ] || [ -f ${logfile} ] || touch ${logfile}

    # required for rtprio(1) until handled like nice(1) by rc.subr(8)
    if [ -n "$xorp_rtprio" ] && [ "$xorp_rtprio" -ge 0 ]
    then
        rc_flags="$xorp_rtprio $command $xorp_flags"
        command=/usr/sbin/rtprio
    fi

    return 0
}

xorp_poststop()
{
    rm -f ${pidfile} >/dev/null 2>&1 || true

    checkyesno xorp_hardkill_enable || return 0
    killall -9 -m xorp_\* || true

    return 0
}

run_rc_command "$1"