aboutsummaryrefslogtreecommitdiffstats
path: root/net/isc-dhcp41-server/files/isc-dhcrelay.in
blob: a32b9856d0377a993a6d7d5e6181fb8e3b0d8e7b (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
#! /bin/sh
#
# $FreeBSD: /tmp/pcvs/ports/net/isc-dhcp41-server/files/isc-dhcrelay.in,v 1.2 2011-06-03 12:31:24 wxs Exp $
#
# PROVIDE: dhcrelay
# REQUIRE: DAEMON
#
# 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=""         # command option(s)
# dhcrelay_servers=""           # dhcrelay server(s)
# dhcrelay_ifaces=""            # ethernet interface(s)

case $0 in
/etc/rc*)
    # during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown),
    # so get the name of the script from $_file
    name=$_file
    ;;
*)
    name=$0
    ;;
esac

name=${name##*/isc-}

case ${name} in
*6)
    ipversion=-6
    ;;
*)
    ipversion=-4
    ;;
esac

dhcrelay_precmd ()
{
    local ifaces _servers _ifaces
    
    eval "_servers=\${${name}_servers}"
    eval "_ifaces=\${${name}_ifaces}"

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

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

    rc_flags="${rc_flags} ${ipversion} ${ifaces} ${_servers}"
}

. /etc/rc.subr

rcvar=${name}_enable

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

load_rc_config ${name}
run_rc_command "$1"