aboutsummaryrefslogtreecommitdiffstats
path: root/net/isc-dhcp30-server/files/isc-dhcrelay.sh.sample
blob: 3c72b5520efe0fc178042ad49f2ec4fc6f497973 (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
#! /bin/sh
#
# $FreeBSD$
#
# PROVIDE: dhcrelay
# REQUIRE: DAEMON
# KEYWORD: FreeBSD
#
# Add the following line to /etc/rc.conf to enable dhcrelay:
#
# dhcrelay_enable="YES"
#

# override these variables in /etc/rc.conf
dhcrelay_enable=${dhcrelay_enable:-"NO"}
dhcrelay_flags=${dhcrelay_flags:-}          # command option(s)
dhcrelay_servers=${dhcrelay_servers:-}          # dhcrelay server(s)
dhcrelay_ifaces=${dhcrelay_ifaces:-}            # ethernet interface(s)

dhcrelay_precmd ()
{
    local ifaces

    dhcrelay_rcconf=%%PREFIX%%/etc/rc.isc-dhcrelay.conf

    if [ -f ${dhcrelay_rcconf} ]; then
        warn "${dhcrelay_rcconf} is obsolete, use /etc/rc.conf instead."
        . ${dhcrelay_rcconf}

        if [ -n "${dhcrelay_options}" -a -z "${rc_flags}" ]; then
            warn "dhcrelay_options is obsolete, use dhcrelay_flags instead."
            rc_flags=${dhcrelay_options}
        fi
    fi

    if [ -z "${dhcrelay_servers}" ]; then
        err 1 "no dhcrelay server(s) configured."
    fi

    ifaces=
    for iface in ${dhcrelay_ifaces}; do
        ifaces="${ifaces} -i ${iface}"
    done

    rc_flags="${rc_flags} ${ifaces} ${dhcrelay_servers}"
}

. %%RC_SUBR%%

name=dhcrelay
rcvar=$(set_rcvar)

command=%%PREFIX%%/sbin/${name}
pidfile=/var/run/${name}.pid
start_precmd=${name}_precmd

load_rc_config ${name}
run_rc_command "$1"