summaryrefslogtreecommitdiff
path: root/debian/prerm
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2017-10-03 11:03:34 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2017-10-03 11:03:34 +0200
commitcacc0153486c22c406fefb18f9edb625c8c26b70 (patch)
tree859da8608748d1048be099359f3e3b0bd4bb3222 /debian/prerm
parent46aa869cd4bbb466e9d02322898ccbe7a895ab45 (diff)
Use pathfind() instead hard coded path for invoke-rc.d
Diffstat (limited to 'debian/prerm')
-rw-r--r--debian/prerm34
1 files changed, 27 insertions, 7 deletions
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
}