46 lines
1.4 KiB
Bash
Executable file
46 lines
1.4 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
SC_COMMAND="$0 $@"
|
|
SC_SRC=${SC_SRC:-/opt/sconnect}
|
|
. $SC_SRC/lib/setup-env
|
|
|
|
SC_HOSTS=""
|
|
|
|
while getopts "h:" opt; do
|
|
case $opt in
|
|
h)
|
|
SC_HOSTS="$SC_HOSTS $OPTARG"
|
|
;;
|
|
esac
|
|
done
|
|
shift $((OPTIND - 1))
|
|
|
|
([ $# -lt 1 ] || [ -z "$1" ]) && fatal_log "usage: $0 [...args] <command>"
|
|
command=$1
|
|
shift
|
|
|
|
for host in $SC_HOSTS; do
|
|
case $command in
|
|
install)
|
|
if [ "$host" = "local" ]; then
|
|
escalate_command cp -r $SC_SRC/. /opt/sconnect
|
|
escalate_command install -m a+rx -o root /opt/sconnect/bin/sc /usr/bin
|
|
escalate_command install -m a+rx -o root /opt/sconnect/bin/sc-client /usr/bin
|
|
else
|
|
LOGI "attempting to install on $host..."
|
|
rsync -au $SC_SRC/. $host:/opt/sconnect
|
|
ssh $host SC_SKIP_WELCOME_HEADER=1 /opt/sconnect/bin/sc-client lib privileges escalate_command install -m a+rx -o root /opt/sconnect/bin/sc /usr/bin
|
|
ssh $host SC_SKIP_WELCOME_HEADER=1 /opt/sconnect/bin/sc-client lib privileges escalate_command install -m a+rx -o root /opt/sconnect/bin/sc-client /usr/bin
|
|
LOGI "installed"
|
|
fi
|
|
;;
|
|
*)
|
|
if [ "$host" = "local" ]; then
|
|
$SC_SRC/bin/sc-client $@
|
|
else
|
|
ssh -t $host SC_SKIP_WELCOME_HEADER=1 /opt/sconnect/bin/sc-client check 2>/dev/null || fatal_log not installed
|
|
ssh -t $host /opt/sconnect/bin/sc-client $command $@
|
|
fi
|
|
;;
|
|
esac
|
|
done
|