2016-03-29 20:58:18 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -eu
|
|
|
|
|
2017-06-26 03:14:44 +00:00
|
|
|
PROJECT="ArchiSteamFarm"
|
2017-08-31 05:54:07 +00:00
|
|
|
OUT="out/source"
|
|
|
|
|
2017-10-19 10:46:42 +00:00
|
|
|
CONFIG_PATH="config/ASF.json"
|
|
|
|
|
2017-10-18 13:03:52 +00:00
|
|
|
cd "$(dirname "$(readlink -f "$0")")"
|
2016-03-29 20:58:18 +00:00
|
|
|
|
2017-10-18 13:03:52 +00:00
|
|
|
if [[ -z "${ASF_ARGS-}" ]]; then
|
|
|
|
ASF_ARGS=""
|
2016-08-27 07:34:08 +00:00
|
|
|
fi
|
|
|
|
|
2017-10-18 13:03:52 +00:00
|
|
|
ASF_ARGS+=" $*"
|
2017-08-31 05:54:07 +00:00
|
|
|
|
2017-10-19 10:46:42 +00:00
|
|
|
for ARG in $ASF_ARGS; do
|
|
|
|
case "$ARG" in
|
|
|
|
--path=*) CONFIG_PATH="$(echo "$ARG" | cut -d '=' -f 2-)/${CONFIG_PATH}" ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2017-10-18 13:03:52 +00:00
|
|
|
# Kill underlying ASF process on shell process exit
|
2017-10-18 13:10:32 +00:00
|
|
|
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM
|
2016-03-29 20:58:18 +00:00
|
|
|
|
2017-10-18 13:03:52 +00:00
|
|
|
if ! hash dotnet 2>/dev/null; then
|
|
|
|
echo "ERROR: dotnet CLI tools are not installed!"
|
2016-03-29 20:58:18 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-10-18 13:03:52 +00:00
|
|
|
dotnet --info
|
2017-06-26 03:14:44 +00:00
|
|
|
|
2017-10-19 10:46:42 +00:00
|
|
|
cd "${PROJECT}/${OUT}"
|
|
|
|
|
|
|
|
if [[ -f "$CONFIG_PATH" ]] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"; then
|
2017-10-18 13:03:52 +00:00
|
|
|
# We're running ASF in headless mode so we don't need STDIN
|
2017-10-19 10:46:42 +00:00
|
|
|
dotnet exec "${PROJECT}.dll" $ASF_ARGS & # Start ASF in the background, trap will work properly due to non-blocking call
|
2017-10-18 13:03:52 +00:00
|
|
|
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
|
2017-10-19 10:46:42 +00:00
|
|
|
dotnet exec "${PROJECT}.dll" $ASF_ARGS # Start ASF in the foreground, trap won't work until process exit
|
2017-10-18 13:03:52 +00:00
|
|
|
fi
|