diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2013-09-14 16:57:18 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2013-09-14 17:41:58 +1200 |
commit | f38d67dd576b77b58dafcd3a58516c51542733e3 (patch) | |
tree | 899f1b42bb9c41784f715e42df3091cc50f0228b | |
parent | Add self-identification (diff) | |
download | psshd-f38d67dd576b77b58dafcd3a58516c51542733e3.tar.gz psshd-f38d67dd576b77b58dafcd3a58516c51542733e3.zip |
Search for needed commands in PATH
-rwxr-xr-x | psshd | 27 |
1 files changed, 12 insertions, 15 deletions
@@ -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)" \ -- "$@" |