hal/run.sh

70 lines
1.3 KiB
Bash
Raw Normal View History

#!/bin/bash
# -----------------------------------------------
# User input
# -----------------------------------------------
function printHelp() {
2021-09-06 16:17:11 +02:00
echo "Wrapper for simplifying execution of Hal Server.
Usage:
$(basename $0)
[-f|--foreground]
2021-09-06 16:17:11 +02:00
[-h|--help]
Where:
2021-09-06 16:17:11 +02:00
--foreground Run Hal Server in the foreground instead of detaching a new screen.
--help Print this help message.
"
}
MODE="SCREEN"
until [[ $# -eq 0 ]]; do
case "$1" in
2021-09-15 16:29:59 +02:00
-f|--foreground)
MODE="FOREGROUND"
shift
;;
2021-09-06 16:17:11 +02:00
-h|--help)
printHelp
exit 0
;;
*)
echo "ERROR: Unknown input parameter: $1=$2"
2021-09-06 16:17:11 +02:00
echo ""
printHelp
exit 1
;;
esac
shift
done
# -----------------------------------------------
# Execute
# -----------------------------------------------
2021-09-06 16:17:11 +02:00
# gradle returns normally when doing ctr-c so we need to add a
# trap where the bash script exits instead of continuing.
trap 'exit 130' INT
# Build Hal source
./gradlew build
2018-12-03 19:35:56 +01:00
2021-09-15 16:29:59 +02:00
if [[ ${MODE} == "FOREGROUND" ]]; then
./gradlew run
else
# Kill current session
screen -S hal -X kill
# Start new session
screen -S hal -L -d -m ./gradlew run
echo "-------------------------"
screen -list
fi