diff options
author | vd <vd@FreeBSD.org> | 2007-02-23 16:38:53 +0800 |
---|---|---|
committer | vd <vd@FreeBSD.org> | 2007-02-23 16:38:53 +0800 |
commit | f4b6550fe98189252c35b269b825cae232057baf (patch) | |
tree | cc6e0e7dc7f0bdf2d8887344e49179d1b7d06fd2 /security/openvpn/files | |
parent | c71a919cb1c346cb2fe0ab86edebb8f6cefb0ae6 (diff) | |
download | freebsd-ports-gnome-f4b6550fe98189252c35b269b825cae232057baf.tar.gz freebsd-ports-gnome-f4b6550fe98189252c35b269b825cae232057baf.tar.zst freebsd-ports-gnome-f4b6550fe98189252c35b269b825cae232057baf.zip |
* Add support for running multiple instances of openvpn to the startup script
Inspired by [1]
* Bump PORTREVISION
* Update the comment which says not to send notices about 2.0.8 to 2.0.9 since
2.0.9 also introduces only Windows changes. Remove maintainer's name from
this comment since he did not explicitly state this.
PR: ports/108371 [1]
Submitted by: Denis Shaposhnikov <dsh@vlink.ru>, Gleb Kozyrev <gkozyrev@gmail.com> [1]
Approved by: matthias.andree@gmx.de (maintainer timeout, 28 days)
Diffstat (limited to 'security/openvpn/files')
-rw-r--r-- | security/openvpn/files/openvpn.sh.in | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/security/openvpn/files/openvpn.sh.in b/security/openvpn/files/openvpn.sh.in index b4fc4dbba162..728516ba1aa2 100644 --- a/security/openvpn/files/openvpn.sh.in +++ b/security/openvpn/files/openvpn.sh.in @@ -30,17 +30,29 @@ # ----------------------------------------------------------------------------- # -# Add the following lines to /etc/rc.conf to enable openvpn at boot-up time: +# This script supports running multiple instances of openvpn. +# To run additional instance link this script to something like +# % ln -s openvpn openvpn_foo +# and define additional openvpn_foo_* variables in one of +# /etc/rc.conf, /etc/rc.conf.local or /etc/rc.conf.d/openvpn_foo # -# openvpn_enable="YES" # YES or NO -# openvpn_if="tun" # driver(s) to load, set to "tun", "tap" or "tun tap" +# Below NAME should be substituted with the name of this script. By default +# it is openvpn, so read as openvpn_enable. If you linked the script to +# openvpn_foo, then read as openvpn_foo_enable etc. +# +# The following variables are supported (defaults are shown). +# You can place them in any of +# /etc/rc.conf, /etc/rc.conf.local or /etc/rc.conf.d/NAME +# +# NAME_enable="NO" # set to YES to enable openvpn +# NAME_if="" # driver(s) to load, set to "tun", "tap" or "tun tap" # # # optional: -# openvpn_flags="" # openvpn command line flags -# openvpn_configfile="%%PREFIX%%/etc/openvpn/openvpn.conf" # --config file -# openvpn_dir="%%PREFIX%%/etc/openvpn" # --cd directory +# NAME_flags="" # additional command line arguments +# NAME_configfile="%%PREFIX%%/etc/openvpn/NAME.conf" # --config file +# NAME_dir="%%PREFIX%%/etc/openvpn" # --cd directory # -# You also need to set openvpn_configfile and openvpn_dir, if the configuration +# You also need to set NAME_configfile and NAME_dir, if the configuration # file and directory where keys and certificates reside differ from the above # settings. # @@ -51,14 +63,14 @@ . %%RC_SUBR%% -name=openvpn +name=`basename ${0}` rcvar=`set_rcvar` prefix="%%PREFIX%%" openvpn_precmd() { - for i in $openvpn_if ; do + for i in $interfaces ; do # FreeBSD <= 5.4 does not know kldstat's -m option # FreeBSD >= 6.0 does not add debug.* sysctl information # in the default build - we check both to keep things simple @@ -85,7 +97,7 @@ extra_commands="reload" pidfile="/var/run/${name}.pid" # command and arguments -command="%%PREFIX%%/sbin/${name}" +command="%%PREFIX%%/sbin/openvpn" # run this first start_precmd="openvpn_precmd" @@ -93,11 +105,18 @@ start_precmd="openvpn_precmd" stop_postcmd="stop_postcmd" load_rc_config ${name} -: ${openvpn_enable="NO"} -: ${openvpn_flags=""} -: ${openvpn_if=""} -: ${openvpn_configfile="${prefix}/etc/openvpn/openvpn.conf"} -: ${openvpn_dir="${prefix}/etc/openvpn"} -required_files="${openvpn_configfile}" -command_args="--cd ${openvpn_dir} --daemon --config ${openvpn_configfile} --writepid ${pidfile}" + +eval ": \${${name}_enable:=\"NO\"}" +eval ": \${${name}_flags:=\"\"}" +eval ": \${${name}_if:=\"\"}" +eval ": \${${name}_configfile:=\"${prefix}/etc/openvpn/${name}.conf\"}" +eval ": \${${name}_dir:=\"${prefix}/etc/openvpn\"}" + +configfile="`eval echo \\${${name}_configfile}`" +dir="`eval echo \\${${name}_dir}`" +interfaces="`eval echo \\${${name}_if}`" + +required_files=${configfile} +command_args="--cd ${dir} --daemon --config ${configfile} --writepid ${pidfile}" + run_rc_command "$1" |