Files
ArchiSteamFarm/run.sh

33 lines
967 B
Bash
Raw Normal View History

2016-03-29 22:58:18 +02:00
#!/bin/bash
set -eu
2017-06-26 05:14:44 +02:00
PROJECT="ArchiSteamFarm"
OUT="out/source"
2017-10-18 15:03:52 +02:00
cd "$(dirname "$(readlink -f "$0")")"
2016-03-29 22:58:18 +02:00
2017-10-18 15:03:52 +02:00
if [[ -z "${ASF_ARGS-}" ]]; then
ASF_ARGS=""
fi
2017-10-18 15:03:52 +02:00
ASF_ARGS+=" $*"
2017-10-18 15:03:52 +02:00
# Kill underlying ASF process on shell process exit
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM
2016-03-29 22:58:18 +02:00
2017-10-18 15:03:52 +02:00
if ! hash dotnet 2>/dev/null; then
echo "ERROR: dotnet CLI tools are not installed!"
2016-03-29 22:58:18 +02:00
exit 1
fi
2017-10-18 15:03:52 +02:00
dotnet --info
2017-06-26 05:14:44 +02:00
2017-10-18 15:03:52 +02:00
if grep -Eq '"Headless":\s+?true' "${PROJECT}/${OUT}/config/ASF.json"; then
# We're running ASF in headless mode so we don't need STDIN
dotnet exec "${PROJECT}/${OUT}/${PROJECT}.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 exec "${PROJECT}/${OUT}/${PROJECT}.dll" $ASF_ARGS # Start ASF in the foreground, trap won't work until process exit
fi