2024-06-02 22:13:33 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
SC_COMMAND="$0 $@"
|
2024-06-06 02:00:49 +02:00
|
|
|
SC_LIB=${SC_LIB:-/usr/lib/sc}
|
|
|
|
. $SC_LIB/setup-env
|
2024-06-02 22:13:33 +02:00
|
|
|
|
|
|
|
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
|
2024-06-06 02:21:18 +02:00
|
|
|
escalate_command a3 ./meta.a3 ${2:-install}
|
2024-06-02 22:13:33 +02:00
|
|
|
else
|
|
|
|
LOGI "attempting to install on $host..."
|
2024-06-06 02:17:54 +02:00
|
|
|
if ! ssh $host "command -v a3"; then
|
|
|
|
LOGI "no a3, installing..."
|
2024-06-06 02:21:18 +02:00
|
|
|
ssh -t $host "git clone https://git.saluco.nl/strix/aaa /tmp/a3 && cd /tmp/a3 && sudo A3_LIB=./lib bin/a3 ./meta.a3 ${2:-install}; rm -rf /tmp/a3"
|
2024-06-06 02:17:54 +02:00
|
|
|
fi
|
2024-06-06 02:21:18 +02:00
|
|
|
ssh $host "git clone https://git.saluco.nl/strix/sconnect /tmp/sconnect && cd /tmp/sconnect && sudo a3 ./meta.a3 ${2:-install}; rm -rf /tmp/sconnect"
|
2024-06-02 22:13:33 +02:00
|
|
|
LOGI "installed"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
if [ "$host" = "local" ]; then
|
2024-06-06 02:17:54 +02:00
|
|
|
sc-client $command $@
|
2024-06-02 22:13:33 +02:00
|
|
|
else
|
2024-06-06 02:17:54 +02:00
|
|
|
ssh -t $host SC_SKIP_WELCOME_HEADER=1 sc-client check 2>/dev/null || fatal_log not installed
|
|
|
|
ssh -t $host sc-client $command $@
|
2024-06-02 22:13:33 +02:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|