diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-10-03 11:03:34 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-10-03 11:03:34 +0200 |
commit | cacc0153486c22c406fefb18f9edb625c8c26b70 (patch) | |
tree | 859da8608748d1048be099359f3e3b0bd4bb3222 /debian/postinst | |
parent | 46aa869cd4bbb466e9d02322898ccbe7a895ab45 (diff) |
Use pathfind() instead hard coded path for invoke-rc.d
Diffstat (limited to 'debian/postinst')
-rw-r--r-- | debian/postinst | 22 |
1 files changed, 21 insertions, 1 deletions
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 |