aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2013-09-14 17:01:11 +1200
committerTom Ryder <tom@sanctum.geek.nz>2013-09-14 17:42:03 +1200
commit776eb986b8f56f1a6bdf530f09cc0c371753c74b (patch)
tree5272f367452da3d3b727b5972b70c0d577ed5b27
parentSearch for needed commands in PATH (diff)
downloadpsshd-776eb986b8f56f1a6bdf530f09cc0c371753c74b.tar.gz
psshd-776eb986b8f56f1a6bdf530f09cc0c371753c74b.zip
Loop through commands rather than repeating
-rwxr-xr-xpsshd15
1 files changed, 7 insertions, 8 deletions
diff --git a/psshd b/psshd
index f8dcdc6..5d372c8 100755
--- a/psshd
+++ b/psshd
@@ -21,14 +21,13 @@ self=psshd
PATH=/usr/lib/autossh/autossh:/sbin:$PATH
# 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
+cmds=(autossh start-stop-daemon)
+for cmd in "${cmds[@]}"; do
+ if ! type -p "$cmd" >/dev/null; then
+ printf '%s - Could not find %s in PATH\n' "$self" "$cmd" >&2
+ exit 127
+ fi
+done
# Get port in options
while getopts ':p:' opt