47 lines
1.6 KiB
Plaintext
47 lines
1.6 KiB
Plaintext
|
#!/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_uci_shell_install () {
|
||
|
|
||
|
local supass;local user; local host; local upass
|
||
|
|
||
|
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
|
||
|
|
||
|
git="-e BASH_SHELL_GIT_URL=$BASH_SHELL_GIT_URL"
|
||
|
echo $git
|
||
|
|
||
|
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
|
||
|
# remote user needs password login
|
||
|
if [[ $upass ]]; then remote_script -s $git -f install_shell_base $host uci-shell-install $user -- $upass "$@"; return $?; fi
|
||
|
# remote user has key but needs sudo
|
||
|
if [[ $supass ]]; then remote_script $supass $git -f install_shell_base $host uci-shell-install $user -- "$@"; return $?; fi
|
||
|
# remote host is already root
|
||
|
remote_script $git -f install_shell_base $host uci-shell-install $user -- "$@"
|
||
|
}
|