Rewrite ASF scripts to POSIX sh

This commit is contained in:
JustArchi 2019-11-07 22:02:59 +01:00
parent 2605df8ac5
commit 633146a3f9
6 changed files with 99 additions and 99 deletions

View file

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env sh
set -euo pipefail set -eu
CONFIG_PATH="config/ASF.json" CONFIG_PATH="config/ASF.json"
@ -10,21 +10,21 @@ SCRIPT_PATH="${SCRIPT_DIR}/${0}"
BINARY="${SCRIPT_DIR}/ArchiSteamFarm.exe" BINARY="${SCRIPT_DIR}/ArchiSteamFarm.exe"
if [[ ! -f "$BINARY" ]]; then if [ ! -f "$BINARY" ]; then
echo "ERROR: $BINARY could not be found!" echo "ERROR: $BINARY could not be found!"
exit 1 exit 1
fi fi
BINARY_ARGS=() BINARY_ARGS=""
PATH_NEXT=0 PATH_NEXT=0
PARSE_ARG() { PARSE_ARG() {
BINARY_ARGS+=("$1") BINARY_ARGS="$BINARY_ARGS $1"
case "$1" in case "$1" in
--path) PATH_NEXT=1 ;; --path) PATH_NEXT=1 ;;
--path=*) --path=*)
if [[ "$PATH_NEXT" -eq 1 ]]; then if [ "$PATH_NEXT" -eq 1 ]; then
PATH_NEXT=0 PATH_NEXT=0
cd "$1" cd "$1"
else else
@ -32,27 +32,27 @@ PARSE_ARG() {
fi fi
;; ;;
*) *)
if [[ "$PATH_NEXT" -eq 1 ]]; then if [ "$PATH_NEXT" -eq 1 ]; then
PATH_NEXT=0 PATH_NEXT=0
cd "$1" cd "$1"
fi fi
esac esac
} }
if [[ -n "${ASF_PATH-}" ]]; then if [ -n "${ASF_PATH-}" ]; then
cd "$ASF_PATH" cd "$ASF_PATH"
fi fi
if [[ -n "${ASF_ARGS-}" ]]; then if [ -n "${ASF_ARGS-}" ]; then
for ARG in $ASF_ARGS; do for ARG in $ASF_ARGS; do
if [[ -n "$ARG" ]]; then if [ -n "$ARG" ]; then
PARSE_ARG "$ARG" PARSE_ARG "$ARG"
fi fi
done done
fi fi
for ARG in "$@"; do for ARG in "$@"; do
if [[ -n "$ARG" ]]; then if [ -n "$ARG" ]; then
PARSE_ARG "$ARG" PARSE_ARG "$ARG"
fi fi
done done
@ -60,9 +60,9 @@ done
CONFIG_PATH="$(pwd)/${CONFIG_PATH}" CONFIG_PATH="$(pwd)/${CONFIG_PATH}"
# Kill underlying ASF process on shell process exit # Kill underlying ASF process on shell process exit
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM trap "trap - TERM && kill -- -$$" INT TERM
if ! hash mono 2>/dev/null; then if ! command -v mono >/dev/null; then
echo "ERROR: mono is not installed!" echo "ERROR: mono is not installed!"
exit 1 exit 1
fi fi
@ -70,13 +70,13 @@ fi
mono --version mono --version
while :; do while :; do
if [[ -f "$CONFIG_PATH" ]] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"; then if [ -f "$CONFIG_PATH" ] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"; then
# We're running ASF in headless mode so we don't need STDIN # We're running ASF in headless mode so we don't need STDIN
mono "${MONO_ARGS[@]-}" "$BINARY" "${BINARY_ARGS[@]-}" & # Start ASF in the background, trap will work properly due to non-blocking call mono ${MONO_ARGS-} "$BINARY" $BINARY_ARGS & # Start ASF in the background, trap will work properly due to non-blocking call
wait $! # This will forward mono error code, set -e will abort the script if it's non-zero wait $! # This will forward mono error code, set -e will abort the script if it's non-zero
else else
# We're running ASF in non-headless mode, so we need STDIN to be operative # We're running ASF in non-headless mode, so we need STDIN to be operative
mono "${MONO_ARGS[@]-}" "$BINARY" "${BINARY_ARGS[@]-}" # Start ASF in the foreground, trap sadly won't work until process exit mono ${MONO_ARGS-} "$BINARY" $BINARY_ARGS # Start ASF in the foreground, trap sadly won't work until process exit
fi fi
chmod +x "$SCRIPT_PATH" # If ASF exited by itself, we need to ensure that our script is still set to +x after auto-update chmod +x "$SCRIPT_PATH" # If ASF exited by itself, we need to ensure that our script is still set to +x after auto-update

View file

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env sh
set -euo pipefail set -eu
CONFIG_PATH="config/ASF.json" CONFIG_PATH="config/ASF.json"
@ -10,21 +10,21 @@ SCRIPT_PATH="${SCRIPT_DIR}/${0}"
BINARY="${SCRIPT_DIR}/ArchiSteamFarm.exe" BINARY="${SCRIPT_DIR}/ArchiSteamFarm.exe"
if [[ ! -f "$BINARY" ]]; then if [ ! -f "$BINARY" ]; then
echo "ERROR: $BINARY could not be found!" echo "ERROR: $BINARY could not be found!"
exit 1 exit 1
fi fi
BINARY_ARGS=() BINARY_ARGS=""
PATH_NEXT=0 PATH_NEXT=0
PARSE_ARG() { PARSE_ARG() {
BINARY_ARGS+=("$1") BINARY_ARGS="$BINARY_ARGS $1"
case "$1" in case "$1" in
--path) PATH_NEXT=1 ;; --path) PATH_NEXT=1 ;;
--path=*) --path=*)
if [[ "$PATH_NEXT" -eq 1 ]]; then if [ "$PATH_NEXT" -eq 1 ]; then
PATH_NEXT=0 PATH_NEXT=0
cd "$1" cd "$1"
else else
@ -32,27 +32,27 @@ PARSE_ARG() {
fi fi
;; ;;
*) *)
if [[ "$PATH_NEXT" -eq 1 ]]; then if [ "$PATH_NEXT" -eq 1 ]; then
PATH_NEXT=0 PATH_NEXT=0
cd "$1" cd "$1"
fi fi
esac esac
} }
if [[ -n "${ASF_PATH-}" ]]; then if [ -n "${ASF_PATH-}" ]; then
cd "$ASF_PATH" cd "$ASF_PATH"
fi fi
if [[ -n "${ASF_ARGS-}" ]]; then if [ -n "${ASF_ARGS-}" ]; then
for ARG in $ASF_ARGS; do for ARG in $ASF_ARGS; do
if [[ -n "$ARG" ]]; then if [ -n "$ARG" ]; then
PARSE_ARG "$ARG" PARSE_ARG "$ARG"
fi fi
done done
fi fi
for ARG in "$@"; do for ARG in "$@"; do
if [[ -n "$ARG" ]]; then if [ -n "$ARG" ]; then
PARSE_ARG "$ARG" PARSE_ARG "$ARG"
fi fi
done done
@ -60,22 +60,22 @@ done
CONFIG_PATH="$(pwd)/${CONFIG_PATH}" CONFIG_PATH="$(pwd)/${CONFIG_PATH}"
# Kill underlying ASF process on shell process exit # Kill underlying ASF process on shell process exit
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM trap "trap - TERM && kill -- -$$" INT TERM
if ! hash mono 2>/dev/null; then if ! command -v mono >/dev/null; then
echo "ERROR: mono is not installed!" echo "ERROR: mono is not installed!"
exit 1 exit 1
fi fi
mono --version mono --version
if [[ -f "$CONFIG_PATH" ]] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"; then if [ -f "$CONFIG_PATH" ] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"; then
# We're running ASF in headless mode so we don't need STDIN # We're running ASF in headless mode so we don't need STDIN
mono "${MONO_ARGS[@]-}" "$BINARY" "${BINARY_ARGS[@]-}" & # Start ASF in the background, trap will work properly due to non-blocking call mono ${MONO_ARGS-} "$BINARY" $BINARY_ARGS & # Start ASF in the background, trap will work properly due to non-blocking call
wait $! # This will forward mono error code, set -e will abort the script if it's non-zero wait $! # This will forward mono error code, set -e will abort the script if it's non-zero
else else
# We're running ASF in non-headless mode, so we need STDIN to be operative # We're running ASF in non-headless mode, so we need STDIN to be operative
mono "${MONO_ARGS[@]-}" "$BINARY" "${BINARY_ARGS[@]-}" # Start ASF in the foreground, trap won't work until process exit mono ${MONO_ARGS-} "$BINARY" $BINARY_ARGS # Start ASF in the foreground, trap won't work until process exit
fi fi
chmod +x "$SCRIPT_PATH" # If ASF exited by itself, we need to ensure that our script is still set to +x after auto-update chmod +x "$SCRIPT_PATH" # If ASF exited by itself, we need to ensure that our script is still set to +x after auto-update

View file

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env sh
set -euo pipefail set -eu
CONFIG_PATH="config/ASF.json" CONFIG_PATH="config/ASF.json"
@ -10,21 +10,21 @@ SCRIPT_PATH="${SCRIPT_DIR}/${0}"
BINARY="${SCRIPT_DIR}/ArchiSteamFarm.dll" BINARY="${SCRIPT_DIR}/ArchiSteamFarm.dll"
if [[ ! -f "$BINARY" ]]; then if [ ! -f "$BINARY" ]; then
echo "ERROR: $BINARY could not be found!" echo "ERROR: $BINARY could not be found!"
exit 1 exit 1
fi fi
BINARY_ARGS=() BINARY_ARGS=""
PATH_NEXT=0 PATH_NEXT=0
PARSE_ARG() { PARSE_ARG() {
BINARY_ARGS+=("$1") BINARY_ARGS="$BINARY_ARGS $1"
case "$1" in case "$1" in
--path) PATH_NEXT=1 ;; --path) PATH_NEXT=1 ;;
--path=*) --path=*)
if [[ "$PATH_NEXT" -eq 1 ]]; then if [ "$PATH_NEXT" -eq 1 ]; then
PATH_NEXT=0 PATH_NEXT=0
cd "$1" cd "$1"
else else
@ -32,27 +32,27 @@ PARSE_ARG() {
fi fi
;; ;;
*) *)
if [[ "$PATH_NEXT" -eq 1 ]]; then if [ "$PATH_NEXT" -eq 1 ]; then
PATH_NEXT=0 PATH_NEXT=0
cd "$1" cd "$1"
fi fi
esac esac
} }
if [[ -n "${ASF_PATH-}" ]]; then if [ -n "${ASF_PATH-}" ]; then
cd "$ASF_PATH" cd "$ASF_PATH"
fi fi
if [[ -n "${ASF_ARGS-}" ]]; then if [ -n "${ASF_ARGS-}" ]; then
for ARG in $ASF_ARGS; do for ARG in $ASF_ARGS; do
if [[ -n "$ARG" ]]; then if [ -n "$ARG" ]; then
PARSE_ARG "$ARG" PARSE_ARG "$ARG"
fi fi
done done
fi fi
for ARG in "$@"; do for ARG in "$@"; do
if [[ -n "$ARG" ]]; then if [ -n "$ARG" ]; then
PARSE_ARG "$ARG" PARSE_ARG "$ARG"
fi fi
done done
@ -60,9 +60,9 @@ done
CONFIG_PATH="$(pwd)/${CONFIG_PATH}" CONFIG_PATH="$(pwd)/${CONFIG_PATH}"
# Kill underlying ASF process on shell process exit # Kill underlying ASF process on shell process exit
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM trap "trap - TERM && kill -- -$$" INT TERM
if ! hash dotnet 2>/dev/null; then if ! command -v dotnet >/dev/null; then
echo "ERROR: dotnet CLI tools are not installed!" echo "ERROR: dotnet CLI tools are not installed!"
exit 1 exit 1
fi fi
@ -70,13 +70,13 @@ fi
dotnet --info dotnet --info
while :; do while :; do
if [[ -f "$CONFIG_PATH" ]] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"; then if [ -f "$CONFIG_PATH" ] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"; then
# We're running ASF in headless mode so we don't need STDIN # We're running ASF in headless mode so we don't need STDIN
dotnet "$BINARY" "${BINARY_ARGS[@]-}" & # Start ASF in the background, trap will work properly due to non-blocking call dotnet ${DOTNET_ARGS-} "$BINARY" $BINARY_ARGS & # Start ASF in the background, trap will work properly due to non-blocking call
wait $! # This will forward dotnet error code, set -e will abort the script if it's non-zero wait $! # This will forward dotnet error code, set -e will abort the script if it's non-zero
else else
# We're running ASF in non-headless mode, so we need STDIN to be operative # We're running ASF in non-headless mode, so we need STDIN to be operative
dotnet "$BINARY" "${BINARY_ARGS[@]-}" # Start ASF in the foreground, trap sadly won't work until process exit dotnet ${DOTNET_ARGS-} "$BINARY" $BINARY_ARGS # Start ASF in the foreground, trap sadly won't work until process exit
fi fi
chmod +x "$SCRIPT_PATH" # If ASF exited by itself, we need to ensure that our script is still set to +x after auto-update chmod +x "$SCRIPT_PATH" # If ASF exited by itself, we need to ensure that our script is still set to +x after auto-update

View file

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env sh
set -euo pipefail set -eu
CONFIG_PATH="config/ASF.json" CONFIG_PATH="config/ASF.json"
@ -10,21 +10,21 @@ SCRIPT_PATH="${SCRIPT_DIR}/${0}"
BINARY="${SCRIPT_DIR}/ArchiSteamFarm.dll" BINARY="${SCRIPT_DIR}/ArchiSteamFarm.dll"
if [[ ! -f "$BINARY" ]]; then if [ ! -f "$BINARY" ]; then
echo "ERROR: $BINARY could not be found!" echo "ERROR: $BINARY could not be found!"
exit 1 exit 1
fi fi
BINARY_ARGS=() BINARY_ARGS=""
PATH_NEXT=0 PATH_NEXT=0
PARSE_ARG() { PARSE_ARG() {
BINARY_ARGS+=("$1") BINARY_ARGS="$BINARY_ARGS $1"
case "$1" in case "$1" in
--path) PATH_NEXT=1 ;; --path) PATH_NEXT=1 ;;
--path=*) --path=*)
if [[ "$PATH_NEXT" -eq 1 ]]; then if [ "$PATH_NEXT" -eq 1 ]; then
PATH_NEXT=0 PATH_NEXT=0
cd "$1" cd "$1"
else else
@ -32,27 +32,27 @@ PARSE_ARG() {
fi fi
;; ;;
*) *)
if [[ "$PATH_NEXT" -eq 1 ]]; then if [ "$PATH_NEXT" -eq 1 ]; then
PATH_NEXT=0 PATH_NEXT=0
cd "$1" cd "$1"
fi fi
esac esac
} }
if [[ -n "${ASF_PATH-}" ]]; then if [ -n "${ASF_PATH-}" ]; then
cd "$ASF_PATH" cd "$ASF_PATH"
fi fi
if [[ -n "${ASF_ARGS-}" ]]; then if [ -n "${ASF_ARGS-}" ]; then
for ARG in $ASF_ARGS; do for ARG in $ASF_ARGS; do
if [[ -n "$ARG" ]]; then if [ -n "$ARG" ]; then
PARSE_ARG "$ARG" PARSE_ARG "$ARG"
fi fi
done done
fi fi
for ARG in "$@"; do for ARG in "$@"; do
if [[ -n "$ARG" ]]; then if [ -n "$ARG" ]; then
PARSE_ARG "$ARG" PARSE_ARG "$ARG"
fi fi
done done
@ -60,22 +60,22 @@ done
CONFIG_PATH="$(pwd)/${CONFIG_PATH}" CONFIG_PATH="$(pwd)/${CONFIG_PATH}"
# Kill underlying ASF process on shell process exit # Kill underlying ASF process on shell process exit
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM trap "trap - TERM && kill -- -$$" INT TERM
if ! hash dotnet 2>/dev/null; then if ! command -v dotnet >/dev/null; then
echo "ERROR: dotnet CLI tools are not installed!" echo "ERROR: dotnet CLI tools are not installed!"
exit 1 exit 1
fi fi
dotnet --info dotnet --info
if [[ -f "$CONFIG_PATH" ]] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"; then if [ -f "$CONFIG_PATH" ] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"; then
# We're running ASF in headless mode so we don't need STDIN # We're running ASF in headless mode so we don't need STDIN
dotnet "$BINARY" "${BINARY_ARGS[@]-}" & # Start ASF in the background, trap will work properly due to non-blocking call dotnet ${DOTNET_ARGS-} "$BINARY" $BINARY_ARGS & # Start ASF in the background, trap will work properly due to non-blocking call
wait $! # This will forward dotnet error code, set -e will abort the script if it's non-zero wait $! # This will forward dotnet error code, set -e will abort the script if it's non-zero
else else
# We're running ASF in non-headless mode, so we need STDIN to be operative # We're running ASF in non-headless mode, so we need STDIN to be operative
dotnet "$BINARY" "${BINARY_ARGS[@]-}" # Start ASF in the foreground, trap won't work until process exit dotnet ${DOTNET_ARGS-} "$BINARY" $BINARY_ARGS # Start ASF in the foreground, trap won't work until process exit
fi fi
chmod +x "$SCRIPT_PATH" # If ASF exited by itself, we need to ensure that our script is still set to +x after auto-update chmod +x "$SCRIPT_PATH" # If ASF exited by itself, we need to ensure that our script is still set to +x after auto-update

36
cc.sh
View file

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env sh
set -euo pipefail set -eu
TARGET_FRAMEWORK="netcoreapp3.0" TARGET_FRAMEWORK="netcoreapp3.0"
@ -43,26 +43,26 @@ for ARG in "$@"; do
esac esac
done done
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM trap "trap - TERM && kill -- -$$" INT TERM
if ! hash dotnet 2>/dev/null; then if ! command -v dotnet >/dev/null; then
echo "ERROR: dotnet CLI tools are not installed!" echo "ERROR: dotnet CLI tools are not installed!"
exit 1 exit 1
fi fi
dotnet --info dotnet --info
if [[ "$PULL" -eq 1 && -d ".git" ]] && hash git 2>/dev/null; then if [ "$PULL" -eq 1 ] && [ -d ".git" ] && command -v git >/dev/null; then
git pull --recurse-submodules=on-demand || true git pull --recurse-submodules=on-demand || true
fi fi
if [[ ! -f "$SOLUTION" ]]; then if [ ! -f "$SOLUTION" ]; then
echo "ERROR: $SOLUTION could not be found!" echo "ERROR: $SOLUTION could not be found!"
exit 1 exit 1
fi fi
if [[ "$ASF_UI" -eq 1 ]]; then if [ "$ASF_UI" -eq 1 ]; then
if [[ -f "ASF-ui/package.json" ]] && hash npm 2>/dev/null; then if [ -f "ASF-ui/package.json" ] && command -v npm >/dev/null; then
echo "Building ASF-ui..." echo "Building ASF-ui..."
# ASF-ui doesn't clean itself after old build # ASF-ui doesn't clean itself after old build
@ -81,26 +81,26 @@ if [[ "$ASF_UI" -eq 1 ]]; then
fi fi
fi fi
DOTNET_FLAGS=(-c "$CONFIGURATION" -f "$TARGET_FRAMEWORK" '/nologo') DOTNET_FLAGS="-c $CONFIGURATION -f $TARGET_FRAMEWORK /nologo"
if [[ "$PUBLISH_TRIMMED" -eq 0 ]]; then if [ "$PUBLISH_TRIMMED" -eq 0 ]; then
DOTNET_FLAGS+=('/p:PublishTrimmed=false') DOTNET_FLAGS="$DOTNET_FLAGS /p:PublishTrimmed=false"
fi fi
if [[ "$SHARED_COMPILATION" -eq 0 ]]; then if [ "$SHARED_COMPILATION" -eq 0 ]; then
DOTNET_FLAGS+=('/p:UseSharedCompilation=false') DOTNET_FLAGS="$DOTNET_FLAGS /p:UseSharedCompilation=false"
fi fi
if [[ "$CLEAN" -eq 1 ]]; then if [ "$CLEAN" -eq 1 ]; then
dotnet clean "${DOTNET_FLAGS[@]}" dotnet clean $DOTNET_FLAGS
rm -rf "$OUT" rm -rf "$OUT"
fi fi
if [[ "$TEST" -eq 1 ]]; then if [ "$TEST" -eq 1 ]; then
dotnet test "$TESTS_PROJECT" "${DOTNET_FLAGS[@]}" dotnet test "$TESTS_PROJECT" $DOTNET_FLAGS
fi fi
dotnet publish "$MAIN_PROJECT" -o "$OUT" "${DOTNET_FLAGS[@]}" dotnet publish "$MAIN_PROJECT" -o "$OUT" $DOTNET_FLAGS
echo echo
echo "SUCCESS: Compilation finished successfully! :)" echo "SUCCESS: Compilation finished successfully! :)"

34
run.sh
View file

@ -1,10 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env sh
set -euo pipefail set -eu
BINARY_PATH="$(dirname "$(readlink -f "$0")")/out" BINARY_PATH="$(dirname "$(readlink -f "$0")")/out"
CONFIG_PATH="config/ASF.json" CONFIG_PATH="config/ASF.json"
if [[ ! -d "$BINARY_PATH" ]]; then if [ ! -d "$BINARY_PATH" ]; then
echo "ERROR: $BINARY_PATH could not be found!" echo "ERROR: $BINARY_PATH could not be found!"
exit 1 exit 1
fi fi
@ -13,21 +13,21 @@ cd "$BINARY_PATH"
BINARY="$(pwd)/ArchiSteamFarm.dll" BINARY="$(pwd)/ArchiSteamFarm.dll"
if [[ ! -f "$BINARY" ]]; then if [ ! -f "$BINARY" ]; then
echo "ERROR: $BINARY could not be found!" echo "ERROR: $BINARY could not be found!"
exit 1 exit 1
fi fi
BINARY_ARGS=() BINARY_ARGS=""
PATH_NEXT=0 PATH_NEXT=0
PARSE_ARG() { PARSE_ARG() {
BINARY_ARGS+=("$1") BINARY_ARGS="$BINARY_ARGS $1"
case "$1" in case "$1" in
--path) PATH_NEXT=1 ;; --path) PATH_NEXT=1 ;;
--path=*) --path=*)
if [[ "$PATH_NEXT" -eq 1 ]]; then if [ "$PATH_NEXT" -eq 1 ]; then
PATH_NEXT=0 PATH_NEXT=0
cd "$1" cd "$1"
else else
@ -35,27 +35,27 @@ PARSE_ARG() {
fi fi
;; ;;
*) *)
if [[ "$PATH_NEXT" -eq 1 ]]; then if [ "$PATH_NEXT" -eq 1 ]; then
PATH_NEXT=0 PATH_NEXT=0
cd "$1" cd "$1"
fi fi
esac esac
} }
if [[ -n "${ASF_PATH-}" ]]; then if [ -n "${ASF_PATH-}" ]; then
cd "$ASF_PATH" cd "$ASF_PATH"
fi fi
if [[ -n "${ASF_ARGS-}" ]]; then if [ -n "${ASF_ARGS-}" ]; then
for ARG in $ASF_ARGS; do for ARG in $ASF_ARGS; do
if [[ -n "$ARG" ]]; then if [ -n "$ARG" ]; then
PARSE_ARG "$ARG" PARSE_ARG "$ARG"
fi fi
done done
fi fi
for ARG in "$@"; do for ARG in "$@"; do
if [[ -n "$ARG" ]]; then if [ -n "$ARG" ]; then
PARSE_ARG "$ARG" PARSE_ARG "$ARG"
fi fi
done done
@ -63,20 +63,20 @@ done
CONFIG_PATH="$(pwd)/${CONFIG_PATH}" CONFIG_PATH="$(pwd)/${CONFIG_PATH}"
# Kill underlying ASF process on shell process exit # Kill underlying ASF process on shell process exit
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM trap "trap - TERM && kill -- -$$" INT TERM
if ! hash dotnet 2>/dev/null; then if ! command -v dotnet >/dev/null; then
echo "ERROR: dotnet CLI tools are not installed!" echo "ERROR: dotnet CLI tools are not installed!"
exit 1 exit 1
fi fi
dotnet --info dotnet --info
if [[ -f "$CONFIG_PATH" ]] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"; then if [ -f "$CONFIG_PATH" ] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"; then
# We're running ASF in headless mode so we don't need STDIN # We're running ASF in headless mode so we don't need STDIN
dotnet "$BINARY" "${BINARY_ARGS[@]-}" & # Start ASF in the background, trap will work properly due to non-blocking call dotnet "$BINARY" $BINARY_ARGS & # Start ASF in the background, trap will work properly due to non-blocking call
wait $! # This will forward dotnet error code, set -e will abort the script if it's non-zero wait $! # This will forward dotnet error code, set -e will abort the script if it's non-zero
else else
# We're running ASF in non-headless mode, so we need STDIN to be operative # We're running ASF in non-headless mode, so we need STDIN to be operative
dotnet "$BINARY" "${BINARY_ARGS[@]-}" # Start ASF in the foreground, trap won't work until process exit dotnet "$BINARY" $BINARY_ARGS # Start ASF in the foreground, trap won't work until process exit
fi fi