diff options
author | Jonas Smedegaard <dr@jones.dk> | 2016-10-21 21:56:32 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2016-10-22 02:03:17 +0200 |
commit | 614db395e5972866f404fe411e639e457e9bd556 (patch) | |
tree | dbf4b5752d380c0c529a798181651774415ace6d /xsh | |
parent | ca0ccc561347202d69ef1161930811a54ef48322 (diff) |
Add sudo support.
Diffstat (limited to 'xsh')
-rwxr-xr-x | xsh | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -3,7 +3,7 @@ SCRIPT=$(basename $0) usage() { - echo "Usage: $SCRIPT [--x] [--verbose] [[su] [{user}@]{host}] [-- command...]" + echo "Usage: $SCRIPT [--x] [--verbose] [[su|sudo] [{user}@]{host}] [-- command...]" } termwrapper() { @@ -26,6 +26,7 @@ termwrapper() { # Initial setup SU='' +SUDO='' X='' V='' HOST='' @@ -33,7 +34,8 @@ ssh_opts="-t" while [ $# -gt 0 ]; do case $1 in - su) SU=1;; + su) SU=1; SUDO=;; + sudo) SUDO=1; SU=;; --x|-x|x) X=1; ssh_opts="$ssh_opts -X";; --ssh2|-2) ssh_opts="$ssh_opts -2";; --verbose|-v) V=1; ssh_opts="$ssh_opts -v";; @@ -74,11 +76,14 @@ fi prg="$prg_base $prg_opts" prg_su="echo -n 'Changing to root...: '; su -c \"cd; $prg\"" +prg_sudo="sudo -i -- $prg" case "$HOST" in '') if [ -n "$SU" ]; then termwrapper $prg_su + elif [ -n "$SUDO" ]; then + termwrapper $prg_sudo else termwrapper $prg fi @@ -86,6 +91,8 @@ case "$HOST" in *) if [ -n "$SU" ]; then termwrapper ssh $ssh_opts $HOST $prg_su + elif [ -n "$SUDO" ]; then + termwrapper ssh $ssh_opts $HOST $prg_sudo else termwrapper ssh $ssh_opts $HOST $prg fi |