Lines 37-42
Link Here
|
37 |
# |
37 |
# |
38 |
# # optional: |
38 |
# # optional: |
39 |
# openvpn_flags="" # openvpn command line flags |
39 |
# openvpn_flags="" # openvpn command line flags |
|
|
40 |
# openvpn_configdir="/usr/local/etc/openvpn" # config directory |
40 |
# openvpn_configfile="/usr/local/etc/openvpn/openvpn.conf" # --config file |
41 |
# openvpn_configfile="/usr/local/etc/openvpn/openvpn.conf" # --config file |
41 |
# openvpn_dir="/usr/local/etc/openvpn" # --cd directory |
42 |
# openvpn_dir="/usr/local/etc/openvpn" # --cd directory |
42 |
# |
43 |
# |
Lines 44-49
Link Here
|
44 |
# file and directory where keys and certificates reside differ from the above |
45 |
# file and directory where keys and certificates reside differ from the above |
45 |
# settings. |
46 |
# settings. |
46 |
# |
47 |
# |
|
|
48 |
# Add "openvpn_profiles" to run several instances of openvpn with |
49 |
# different parameters. Consider the following example: |
50 |
# |
51 |
# openvpn_enable="YES" |
52 |
# openvpn_profiles="default tcp" |
53 |
# |
54 |
# This will run two instances of openvpn: one with default config and pidfile |
55 |
# and the other with config file /usr/local/etc/openvpn/tcp.conf |
56 |
# and pidfile /var/run/openvpn_tcp.pid |
57 |
# |
58 |
# You may specify different locations by setting openvpn_NAME_xxx variables: |
59 |
# |
60 |
# openvpn_tcp_configfile="/usr/local/etc/other/openvpn_tcp.conf" |
61 |
# openvpn_tcp_pidfile="/var/run/openpvn_tcp.pid" |
62 |
# |
47 |
# Note that we deliberately refrain from unloading drivers. |
63 |
# Note that we deliberately refrain from unloading drivers. |
48 |
# |
64 |
# |
49 |
# For further documentation, please see openvpn(8). |
65 |
# For further documentation, please see openvpn(8). |
Lines 78-83
Link Here
|
78 |
rm -f "$pidfile" || warn "Could not remove $pidfile." |
94 |
rm -f "$pidfile" || warn "Could not remove $pidfile." |
79 |
} |
95 |
} |
80 |
|
96 |
|
|
|
97 |
setup_profile_vars() |
98 |
{ |
99 |
name=openvpn_$1 |
100 |
eval ": \${openvpn_${1}_configfile=${openvpn_configdir}/${1}.conf}" |
101 |
eval ": \${openvpn_${1}_dir=${openvpn_dir}}" |
102 |
eval ": \${openvpn_${1}_flags=${openvpn_flags}}" |
103 |
eval ": \${openvpn_${1}_pidfile=/var/run/openvpn_${1}.pid}" |
104 |
eval "pidfile=\"\${openvpn_${1}_pidfile}\"" |
105 |
eval "required_files=\"\${openvpn_${1}_configfile}\"" |
106 |
eval "command_args=\"--cd \${openvpn_${1}_dir} --daemon --config \${openvpn_${1}_configfile} --writepid \${pidfile}\"" |
107 |
} |
108 |
|
109 |
start_profiles() |
110 |
{ |
111 |
unset start_cmd start_precmd |
112 |
for _profile in ${openvpn_profiles}; do |
113 |
setup_profile_vars $_profile |
114 |
run_rc_command "${rc_arg}" |
115 |
done |
116 |
} |
117 |
|
118 |
stop_profiles() |
119 |
{ |
120 |
unset stop_cmd |
121 |
for _profile in ${openvpn_profiles}; do |
122 |
setup_profile_vars $_profile |
123 |
run_rc_command "${rc_arg}" |
124 |
done |
125 |
} |
126 |
|
81 |
# support SIGHUP to reparse configuration file |
127 |
# support SIGHUP to reparse configuration file |
82 |
extra_commands="reload" |
128 |
extra_commands="reload" |
83 |
|
129 |
|
Lines 93-103
Link Here
|
93 |
stop_postcmd="stop_postcmd" |
139 |
stop_postcmd="stop_postcmd" |
94 |
|
140 |
|
95 |
load_rc_config ${name} |
141 |
load_rc_config ${name} |
|
|
142 |
|
96 |
: ${openvpn_enable="NO"} |
143 |
: ${openvpn_enable="NO"} |
97 |
: ${openvpn_flags=""} |
144 |
: ${openvpn_flags=""} |
98 |
: ${openvpn_if=""} |
145 |
: ${openvpn_if=""} |
|
|
146 |
: ${openvpn_configdir="${prefix}/etc/openvpn"} |
99 |
: ${openvpn_configfile="${prefix}/etc/openvpn/openvpn.conf"} |
147 |
: ${openvpn_configfile="${prefix}/etc/openvpn/openvpn.conf"} |
100 |
: ${openvpn_dir="${prefix}/etc/openvpn"} |
148 |
: ${openvpn_dir="${prefix}/etc/openvpn"} |
|
|
149 |
: ${openvpn_profiles="default"} |
150 |
: ${openvpn_default_configfile="${openvpn_configfile}"} |
151 |
: ${openvpn_default_pidfile="${pidfile}"} |
152 |
|
101 |
required_files="${openvpn_configfile}" |
153 |
required_files="${openvpn_configfile}" |
102 |
command_args="--cd ${openvpn_dir} --daemon --config ${openvpn_configfile} --writepid ${pidfile}" |
154 |
command_args="--cd ${openvpn_dir} --daemon --config ${openvpn_configfile} --writepid ${pidfile}" |
103 |
run_rc_command "$1" |
155 |
|
|
|
156 |
cmd="$1" |
157 |
if [ $# -gt 0 ]; then |
158 |
shift |
159 |
fi |
160 |
|
161 |
[ -n "$*" ] && openvpn_profiles="$*" |
162 |
|
163 |
if [ "${openvpn_profiles}" ]; then |
164 |
start_cmd="start_profiles" |
165 |
stop_cmd="stop_profiles" |
166 |
fi |
167 |
|
168 |
run_rc_command "$cmd" |