View | Details | Raw Unified | Return to bug 108371 | Differences between
and this patch

Collapse All | Expand All

(-)openvpn/files/openvpn.sh.in (-1 / +58 lines)
Lines 44-49 Link Here
44
# file and directory where keys and certificates reside differ from the above
44
# file and directory where keys and certificates reside differ from the above
45
# settings.
45
# settings.
46
#
46
#
47
# Add "openvpn_profiles" to run several instances of the openvpn with
48
# different parameters. Consider the following example:
49
#
50
#     openvpn_enable="YES"
51
#     openvpn_profiles="def tcp"
52
#     openvpn_tcp_configfile="/usr/local/etc/openvpn/openvpn_tcp.conf"
53
#     openvpn_tcp_pidfile="/var/run/openpvn_tcp.pid"
54
#
55
# This will run two instances of the openvpn with parameters taken
56
# from appropriate openvpn_PROFILENAME_xxx variables. For unspecified
57
# parameters openvpn_xxx varialbes will be used.
58
#
47
# Note that we deliberately refrain from unloading drivers.
59
# Note that we deliberately refrain from unloading drivers.
48
#
60
#
49
# For further documentation, please see openvpn(8).
61
# For further documentation, please see openvpn(8).
Lines 78-83 Link Here
78
	rm -f "$pidfile" || warn "Could not remove $pidfile."
90
	rm -f "$pidfile" || warn "Could not remove $pidfile."
79
}
91
}
80
92
93
setup_profile_vars()
94
{
95
	name=openvpn_$1
96
	eval ": \${openvpn_${1}_configfile=${openvpn_configfile}}"
97
	eval ": \${openvpn_${1}_dir=${openvpn_dir}}"
98
	eval ": \${openvpn_${1}_flags=${openvpn_flags}}"
99
	eval ": \${openvpn_${1}_pidfile=${pidfile}}"
100
	eval "pidfile=\"\${openvpn_${1}_pidfile}\""
101
	eval "required_files=\"\${openvpn_${1}_configfile}\""
102
	eval "command_args=\"--cd \${openvpn_${1}_dir} --daemon --config \${openvpn_${1}_configfile} --writepid \${pidfile}\""
103
}
104
105
start_profiles()
106
{
107
	unset start_cmd start_precmd
108
	for _profile in ${openvpn_profiles}; do
109
		setup_profile_vars $_profile
110
		run_rc_command "${rc_arg}"
111
	done
112
}
113
114
stop_profiles()
115
{
116
	unset stop_cmd
117
	for _profile in ${openvpn_profiles}; do
118
		setup_profile_vars $_profile
119
		run_rc_command "${rc_arg}"
120
	done
121
}
122
81
# support SIGHUP to reparse configuration file
123
# support SIGHUP to reparse configuration file
82
extra_commands="reload"
124
extra_commands="reload"
83
125
Lines 93-103 Link Here
93
stop_postcmd="stop_postcmd"
135
stop_postcmd="stop_postcmd"
94
136
95
load_rc_config ${name}
137
load_rc_config ${name}
138
96
: ${openvpn_enable="NO"}
139
: ${openvpn_enable="NO"}
97
: ${openvpn_flags=""}
140
: ${openvpn_flags=""}
98
: ${openvpn_if=""}
141
: ${openvpn_if=""}
99
: ${openvpn_configfile="${prefix}/etc/openvpn/openvpn.conf"}
142
: ${openvpn_configfile="${prefix}/etc/openvpn/openvpn.conf"}
100
: ${openvpn_dir="${prefix}/etc/openvpn"}
143
: ${openvpn_dir="${prefix}/etc/openvpn"}
144
101
required_files="${openvpn_configfile}"
145
required_files="${openvpn_configfile}"
102
command_args="--cd ${openvpn_dir} --daemon --config ${openvpn_configfile} --writepid ${pidfile}"
146
command_args="--cd ${openvpn_dir} --daemon --config ${openvpn_configfile} --writepid ${pidfile}"
103
run_rc_command "$1"
147
148
cmd="$1"
149
if [ $# -gt 0 ]; then
150
	shift
151
fi
152
153
[ -n "$*" ] && openvpn_profiles="$*"
154
155
if [ "${openvpn_profiles}" ]; then
156
	start_cmd="start_profiles"
157
	stop_cmd="stop_profiles"
158
fi
159
160
run_rc_command "$cmd"

Return to bug 108371