Unfortunately, the previous patch contained an error. Here is a corrected version.
commit 69ab1dcd862ad8ca4df784ef75ee2b5c8545dba2 Author: Simon Deziel <simon.dez...@gmail.com> Date: Sun Mar 8 21:27:42 2015 -0400
Add support for pre/post start/stop scripts (v2) diff --git a/debian/openvpn.init.d b/debian/openvpn.init.d index 8507ace..32299d8 100644 --- a/debian/openvpn.init.d +++ b/debian/openvpn.init.d @@ -38,7 +38,21 @@ if test -e /etc/default/openvpn ; then . /etc/default/openvpn fi +exec_script () { + local rc=0 + local script_path="$CONFIG_DIR/$NAME.$1" + [ -x "$script_path" ] || return $rc + + export script_type="$1" config="$CONFIG_DIR/$NAME.conf" + "$script_path"; rc=$? + unset script_type config + return $rc +} + start_vpn () { + # pre-start script + exec_script "pre-start" + if grep -q '^[ ]*daemon' $CONFIG_DIR/$NAME.conf ; then # daemon already given in config file DAEMONARG= @@ -93,8 +107,14 @@ start_vpn () { if [ "$SAVED_DEFAULT_SEND_REDIRECTS" -ne 0 ]; then sysctl -w net.ipv4.conf.default.send_redirects=$SAVED_DEFAULT_SEND_REDIRECTS > /dev/null fi + + # post-start script + exec_script "post-start" } stop_vpn () { + # pre-stop script + exec_script "pre-stop" + start-stop-daemon --stop --quiet --oknodo \ --pidfile $PIDFILE --exec $DAEMON --retry 5 if [ "$?" -eq 0 ]; then @@ -102,6 +122,9 @@ stop_vpn () { [ "$OMIT_SENDSIGS" -ne 1 ] || rm -f /run/sendsigs.omit.d/openvpn.$NAME.pid rm -f /run/openvpn/$NAME.status 2> /dev/null fi + + # post-stop script + exec_script "post-stop" } case "$1" in
openvpn-pre-post-start-stop-v2.patch.sig
Description: PGP signature