mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 06:00:46 +00:00
Add stdin handling for generic scripts
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user