mirror of
https://github.com/JustArchiNET/ArchiSteamFarm
synced 2024-11-10 15:14:41 +00:00
Add stdin handling for generic scripts
This commit is contained in:
parent
0c7d9bae48
commit
128b6d2e5b
2 changed files with 18 additions and 4 deletions
|
@ -12,8 +12,15 @@ ASF_ARGS+=" $*"
|
|||
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
|
||||
|
||||
while :; do
|
||||
dotnet ArchiSteamFarm.dll $ASF_ARGS & # We need to start ASF in the background for trap to work
|
||||
wait $! # This will forward dotnet error code, set -e will abort the script if it's non-zero
|
||||
if grep -Fq '"Headless": true' 'config/ASF.json'; 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
|
||||
else
|
||||
# We're running ASF in non-headless mode, so we need STDIN to be operative
|
||||
dotnet ArchiSteamFarm.dll $ASF_ARGS # Start ASF in the foreground, trap sadly won't work until process exit
|
||||
fi
|
||||
|
||||
chmod +x "$0" # If ASF exited by itself, we need to ensure that our script is still set to +x after auto-update
|
||||
sleep 1
|
||||
done
|
||||
|
|
|
@ -11,6 +11,13 @@ ASF_ARGS+=" $*"
|
|||
# Kill underlying ASF process on shell process exit
|
||||
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
|
||||
|
||||
dotnet ArchiSteamFarm.dll $ASF_ARGS & # We need to start ASF in the background for trap to work
|
||||
wait $! # This will forward dotnet error code, set -e will abort the script if it's non-zero
|
||||
if grep -Fq '"Headless": true' 'config/ASF.json'; 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
|
||||
else
|
||||
# We're running ASF in non-headless mode, so we need STDIN to be operative
|
||||
dotnet ArchiSteamFarm.dll $ASF_ARGS # Start ASF in the foreground, trap won't work until process exit
|
||||
fi
|
||||
|
||||
chmod +x "$0" # If ASF exited by itself, we need to ensure that our script is still set to +x after auto-update
|
||||
|
|
Loading…
Reference in a new issue