aboutsummaryrefslogtreecommitdiffstats
path: root/net/vtun/files/vtunclient.in
blob: 73dca65a014b73072b91b68303c0c8cd8e280a85 (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
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: vtunclient
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf to enable vtunclient:
#
# vtunclient_enable="YES"
# vtunclient_flags="<session> <server address>"
#
# If you want to use multiple connections, use $vtunclient_list.
# Usual $vtunclient_flags will be ignored when $vtunclient_list is
# set.
#
# vtunclient_enable="YES"
# vtunclient_list="site1 site2"
# vtunclient_site1_flags="<session> <server address>"
# vtunclient_site1_pidfile="/var/run/vtun-site1.pid"
# vtunclient_site2_flags="<session> <server address>"
# vtunclient_site2_pidfile="/var/run/vtun-site2.pid"
# ...
#

vtunclient_enable=${vtunclient_enable:-"NO"}

. /etc/rc.subr

name=vtunclient
rcvar=`set_rcvar`
required_files="%%PREFIX%%/etc/vtund.conf"

command=%%PREFIX%%/sbin/vtund

load_rc_config $name
cmd="$1"
if [ $# -gt 0 ]; then
    shift
fi
if [ -n "$*" ]; then
    vtunclient_list="$*"
fi

if [ -z "$vtunclient_list" ]; then
    run_rc_command "$cmd"
else
    for _client in ${vtunclient_list}; do
        eval vtunclient_flags=\$vtunclient_${_client}_flags
        eval pidfile=\$vtunclient_${_client}_pidfile
        run_rc_command "$cmd"
    done
fi