41 lines
1.4 KiB
Bash
41 lines
1.4 KiB
Bash
#!/bin/bash
|
|
module_load remote
|
|
# remote_install_shell_base <script options> script command <sudo pass if host not root> <user to install, default is $USER>
|
|
|
|
remote_install_uci_shell () {
|
|
|
|
local supass;local user; local host
|
|
|
|
declare OPTION; declare OPTARG; declare OPTIND
|
|
while getopts 'u: s:p:cf:x:' OPTION; do
|
|
case "$OPTION" in
|
|
p)
|
|
#both for login and sudo
|
|
upass="-p $OPTARG"
|
|
;;
|
|
u) user="$OPTARG"
|
|
;;
|
|
s)
|
|
# only for running sudo command for non-root use logged in via sshkey
|
|
supass="-p $OPTARG"
|
|
;;
|
|
*)
|
|
echo unknown bundle option $OPTION
|
|
;;
|
|
esac
|
|
done
|
|
|
|
shift $(( OPTIND - 1 ))
|
|
|
|
host=$1
|
|
[[ ! $host ]] && >&2 echo remote_install_shell_base requires specifying a host
|
|
shift 1
|
|
user=${user:-$(get_user_host $host)}
|
|
[[ $user == "root" ]] && user="" && >&2 echo warning, will not set up any user than root for UCI shell
|
|
[[ ! $user ]] && >&2 echo unable to determin remote user for host $host, aborting && return 1
|
|
if [[ $supass ]] && [[ $upass ]]; then >&2 echo specify either -s or -p or neither but not both; return 1; fi
|
|
[[ $upass ]] && remote_script -s -f install_shell_base $host uci-shell-install $user -- $upass "$@" && return $?
|
|
[[ $supass ]] && remote_script $supass -f install_shell_base $host uci-shell-install $user -- $upass "$@" && return $?
|
|
remote_script -f install_shell_base $host uci-shell-install $user -- "$@"
|
|
}
|