aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpsshd27
1 files changed, 12 insertions, 15 deletions
diff --git a/psshd b/psshd
index faec1bf..f8dcdc6 100755
--- a/psshd
+++ b/psshd
@@ -17,20 +17,17 @@
# Name self
self=psshd
-# Path to autossh binary (not any wrapper script)
-autossh='/usr/lib/autossh/autossh'
+# Extend path to find autossh and start-stop-daemon binaries
+PATH=/usr/lib/autossh/autossh:/sbin:$PATH
-# Path to start-stop-daemon binary
-startstopdaemon='/sbin/start-stop-daemon'
-
-# Neither of those are likely to be in your PATH if you're a normal user, so we
-# hardcode the paths and test for their existence
-if [[ ! -x "$autossh" ]]; then
- printf "Can't execute ${autossh}!\n" >&2
- exit 1
-elif [[ ! -x "$startstopdaemon" ]]; then
- printf "Can't execute ${startstopdaemon}!\n" >&2
- exit 1
+# Check we have access to the required binaries
+if ! type -p autossh >/dev/null; then
+ printf '%s - Could not find autossh in PATH\n' "$script" >&2
+ exit 127
+fi
+if ! type -p start-stop-daemon >/dev/null; then
+ printf '%s - Could not find start-stop-daemon in PATH\n' "$script" >&2
+ exit 127
fi
# Get port in options
@@ -72,10 +69,10 @@ AUTOSSH_PORT="$port"
export AUTOSSH_PIDFILE AUTOSSH_PORT
# Use start-stop-daemon to run it sanely
-"$startstopdaemon" \
+start-stop-daemon \
--start \
--quiet \
--pidfile "$AUTOSSH_PIDFILE" \
- --exec "$autossh" \
+ --exec "$(type -p autossh)" \
-- "$@"