Add handling of --path to headless detection

This commit is contained in:
JustArchi
2017-10-19 12:46:42 +02:00
parent d34128910b
commit feafd16269
3 changed files with 33 additions and 5 deletions

View File

@@ -1,5 +1,8 @@
#!/bin/bash
set -eu
CONFIG_PATH="config/ASF.json"
cd "$(dirname "$(readlink -f "$0")")"
if [[ -z "${ASF_ARGS-}" ]]; then
@@ -8,11 +11,17 @@ fi
ASF_ARGS+=" $*"
for ARG in $ASF_ARGS; do
case "$ARG" in
--path=*) CONFIG_PATH="$(echo "$ARG" | cut -d '=' -f 2-)/${CONFIG_PATH}" ;;
esac
done
# Kill underlying ASF process on shell process exit
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM
while :; do
if grep -Eq '"Headless":\s+?true' 'config/ASF.json'; 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
dotnet ArchiSteamFarm.dll $ASF_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

View File

@@ -1,5 +1,8 @@
#!/bin/bash
set -eu
CONFIG_PATH="config/ASF.json"
cd "$(dirname "$(readlink -f "$0")")"
if [[ -z "${ASF_ARGS-}" ]]; then
@@ -8,10 +11,16 @@ fi
ASF_ARGS+=" $*"
for ARG in $ASF_ARGS; do
case "$ARG" in
--path=*) CONFIG_PATH="$(echo "$ARG" | cut -d '=' -f 2-)/${CONFIG_PATH}" ;;
esac
done
# Kill underlying ASF process on shell process exit
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM
if grep -Eq '"Headless":\s+?true' 'config/ASF.json'; 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
dotnet ArchiSteamFarm.dll $ASF_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