40 lines
1.1 KiB
Bash
40 lines
1.1 KiB
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
REAL_BASE_DIR=$( dirname $( realpath "$0" ) )
|
||
|
|
||
|
if [ $# -lt 2 ] || [ $# -gt 2 ]; then
|
||
|
$REAL_BASE_DIR/helper/msg_error.sh "\
|
||
|
Error: Incorrect amount of arguments given.
|
||
|
You need to provide exactly two arguments. The first one being the operation you want to run and the second one being the host or hosts (comma separated) you want to run the operation for."
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
OPERATION="$1"
|
||
|
HOSTS="$2"
|
||
|
|
||
|
case $OPERATION in
|
||
|
build|build-vm|build-vm-with-bootloader|switch|boot|test|reboot)
|
||
|
;;
|
||
|
*)
|
||
|
$REAL_BASE_DIR/helper/msg_error.sh "\
|
||
|
Error: No valid operation given.
|
||
|
The operation must be one of:
|
||
|
build, build-vm, build-vm-with-bootloader, switch, boot, test, reboot."
|
||
|
exit 1
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
|
||
|
set -e
|
||
|
|
||
|
for HOST in ${HOSTS//,/ }; do
|
||
|
case $OPERATION in
|
||
|
build|build-vm|build-vm-with-bootloader)
|
||
|
env OPERATION="$OPERATION" HOST="$HOST" $REAL_BASE_DIR/operations/local.sh
|
||
|
;;
|
||
|
switch|boot|test|reboot)
|
||
|
env OPERATION="$OPERATION" HOST="$HOST" $REAL_BASE_DIR/operations/remote.sh
|
||
|
;;
|
||
|
esac
|
||
|
done
|