blob: 74d32a93294814cd2d8c8daeb72154f34e520d15 (
plain)
- #!/bin/bash
- SCRIPT=$(basename $0)
- usage() {
- echo "Usage: $SCRIPT [--x] [--verbose] [su|sudo] [[{user}]@{host}] [[--] command...]"
- }
- termwrapper() {
- if [ "$V" = 1 ]; then
- echo "$@"
- sleep 4
- fi
- if [ $# -gt 0 ]; then
- x-terminal-emulator -e "$@" &
- else
- x-terminal-emulator &
- fi
- }
- # Initial setup
- SU=''
- SUDO=''
- X=''
- V=''
- HOST=''
- PORT=''
- while [ $# -gt 0 ]; do
- case $1 in
- su) SU=1; SUDO=;;
- sudo) SUDO=1; SU=;;
- --x|-x|x) X=1;;
- --verbose|-v) V=1;;
- --port|-p) PORT="$2"; shift;;
- --) shift; break;;
- -*) usage; exit 1;;
- @*) HOST=${1#@};;
- *@*) HOST=$1;;
- *) break;;
- esac
- shift
- done
- [ $# -gt 0 ] || set -- /bin/bash
- # FIXME: needs shell wrapper (provided by SSH but not in local use)
- [ -z "$SU" ] || set -- "echo -n 'Changing to root...: '; su -c \"cd; "$@"\""
- [ -z "$SUDO" ] || set -- sudo -i -- "$@"
- # Pause for a moment if verbose
- # FIXME: needs shell wrapper (provided by SSH but not in local use)
- [ -z "$V" ] || set -- "$@"\; sleep 4
- [ -z "$HOST" ] || set -- ssh -t${X:+ -X}${V:+ -v}${PORT:+ -p "$PORT"} $HOST "$@"
- termwrapper "$@"
|