From f9f3f3426126f059165a1f37da0ad3ea205fbdd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Tue, 3 Mar 2015 19:19:03 +0100 Subject: Replace fixed path with a POSIX-compliant shell function to check the existence of a command --- debian/sane-utils.postinst | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'debian/sane-utils.postinst') diff --git a/debian/sane-utils.postinst b/debian/sane-utils.postinst index 83857a6..f3e5f2d 100644 --- a/debian/sane-utils.postinst +++ b/debian/sane-utils.postinst @@ -8,6 +8,26 @@ saned_eh () { echo "saned couldn't start; check your inetd configuration and README.Debian" } +# +# 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 +} + + + if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ]; then db_get sane-utils/saned_run RUN_SANED="$RET" @@ -16,7 +36,8 @@ if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ]; then SANED_IN_SCANNER="$RET" # Add saned service, disabled by default - if [ -x /usr/sbin/update-inetd ]; then + pathfind update-inetd + if [ $? = 0 ]; then update-inetd --add "## sane-port\tstream\ttcp\tnowait\tsaned:saned\t/usr/sbin/saned saned" fi -- cgit v1.2.3