#!/bin/sh SC_COMMAND="$0 $@" SC_LIB=${SC_LIB:-/usr/lib/sc} . $SC_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=$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 SC_INCLUDE_LIBS="privileges" /opt/sconnect/bin/sc-client eval escalate_command install -m a+rx -o root /opt/sconnect/bin/sc /usr/bin ssh $host SC_SKIP_WELCOME_HEADER=1 SC_INCLUDE_LIBS="privileges" /opt/sconnect/bin/sc-client eval 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 $command $@ 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