diff options
author | Erich Eckner <git@eckner.net> | 2022-05-23 21:16:54 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2022-05-23 21:16:54 +0200 |
commit | 6e8475734240d3c241d7affa6571a164b73fd8f6 (patch) | |
tree | e531997737cbaaaca1cf5f0474164c4a11e371b7 | |
parent | 2f1fb13b4938616593b6d04e9caa34dc96c35472 (diff) | |
download | ssh-keystore-6e8475734240d3c241d7affa6571a164b73fd8f6.tar.xz |
scripts/gather-files: make runnable locally
-rwxr-xr-x | scripts/gather-files | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/scripts/gather-files b/scripts/gather-files index edf7a8a..0798a41 100755 --- a/scripts/gather-files +++ b/scripts/gather-files @@ -1,6 +1,6 @@ #!/bin/bash -if [ $# -ne 1 ]; then +if [ $# -gt 1 ]; then >&2 echo 'usage: '"$0"' host' exit 1 fi @@ -37,9 +37,13 @@ cmd=$( ) { - ssh "${1}" -t "sudo -s bash -c '${cmd}'" \ - || ssh "${1}" -t "su -c '${cmd}'" \ - | sed 1d + if [ $# -eq 1 ]; then + ssh "${1}" -t "sudo -s bash -c '${cmd}'" \ + || ssh "${1}" -t "su -c '${cmd}'" \ + | sed 1d + else + bash -c "${cmd}" + fi } \ 2>/dev/null \ | tee /dev/stderr \ |