diff options
Diffstat (limited to 'debian')
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | debian/postinst | 22 | ||||
-rw-r--r-- | debian/prerm | 34 |
3 files changed, 50 insertions, 8 deletions
diff --git a/debian/changelog b/debian/changelog index a49323f..87ad6c7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,8 @@ openvpn (2.4.4-1) UNRELEASED; urgency=medium - Remove /usr/lib/openvpn from debian/dirs. - Add debian/postrm to remove /usr/lib/openvpn on purge and remove. - Rewrite plugin section at README.Debian + * Use pathfind() instead hard coded path for invoke-rc.d at debian/prerm + and debian/postinst. -- Jörg Frings-Fürst <debian@jff-webhosting.net> Mon, 02 Oct 2017 06:57:42 +0200 diff --git a/debian/postinst b/debian/postinst index 3776449..648e671 100644 --- a/debian/postinst +++ b/debian/postinst @@ -9,6 +9,25 @@ test $DEBIAN_SCRIPT_DEBUG && set -v -x # use debconf . /usr/share/debconf/confmodule +# +# POSIX-compliant shell function +# to check for the existence of a command +# Return 0 if found +# +pathfind() { + OLDIFS="$IFS" + IFS=: + for p in $PATH; do + if [ -x "$p/$*" ]; then + IFS="$OLDIFS" + return 0 + fi + done + IFS="$OLDIFS" + return 1 +} + + case "$1" in configure) db_get openvpn/create_tun || RET="false" @@ -34,7 +53,8 @@ case "$1" in esac if [ -x "/etc/init.d/openvpn" ]; then - if [ -x /usr/sbin/invoke-rc.d ]; then + pathfind invoke-rc.d + if [ $? = 0 ]; then invoke-rc.d openvpn cond-restart || invoke-rc.d openvpn restart else /etc/init.d/openvpn cond-restart || /etc/init.d/openvpn restart diff --git a/debian/prerm b/debian/prerm index b888ef8..ec08b7b 100644 --- a/debian/prerm +++ b/debian/prerm @@ -7,14 +7,34 @@ set -e test $DEBIAN_SCRIPT_DEBUG && set -v -x +# +# POSIX-compliant shell function +# to check for the existence of a command +# Return 0 if found +# +pathfind() { + OLDIFS="$IFS" + IFS=: + for p in $PATH; do + if [ -x "$p/$*" ]; then + IFS="$OLDIFS" + return 0 + fi + done + IFS="$OLDIFS" + return 1 +} + + stop_vpn () { - if [ -x "/etc/init.d/openvpn" ]; then - if [ -x /usr/sbin/invoke-rc.d ] ; then - invoke-rc.d openvpn stop - else - /etc/init.d/openvpn stop - fi - fi + if [ -x "/etc/init.d/openvpn" ]; then + pathfind invoke-rc.d + if [ $? = 0 ]; then + invoke-rc.d openvpn stop + else + /etc/init.d/openvpn stop + fi + fi } |