4 CONFIG_PATH
="config/ASF.json"
8 "Darwin") SCRIPT_PATH
="$(readlink "$0")" ;;
9 "FreeBSD") SCRIPT_PATH
="$(readlink -f "$0")" ;;
10 "Linux") SCRIPT_PATH
="$(readlink -f "$0")" ;;
11 *) echo "ERROR: Unknown OS type: ${OS_TYPE}. If you believe that our script should work on your machine, please let us know."; exit 1
14 SCRIPT_DIR
="$(dirname "$SCRIPT_PATH")"
15 BINARY_DIR
="${SCRIPT_DIR}/out/result"
16 BINARY
="${BINARY_DIR}/ArchiSteamFarm.dll"
18 if [ ! -d "$BINARY_DIR" ]; then
19 echo "ERROR: $BINARY_DIR could not be found!"
23 if [ ! -f "$BINARY" ]; then
24 echo "ERROR: $BINARY could not be found!"
35 BINARY_ARGS
="$BINARY_ARGS $1"
38 --path) PATH_NEXT
=1 ;;
40 if [ "$PATH_NEXT" -eq 1 ]; then
44 cd "$(echo "$1" | cut -d '=' -f 2-)"
47 --service) SERVICE
=1 ;;
49 if [ "$PATH_NEXT" -eq 1 ]; then
56 if [ -n "${ASF_PATH-}" ]; then
60 if [ -n "${ASF_ARGS-}" ]; then
61 for ARG
in $ASF_ARGS; do
62 if [ -n "$ARG" ]; then
69 if [ -n "$ARG" ]; then
74 CONFIG_PATH
="$(pwd)/${CONFIG_PATH}"
76 # Kill underlying ASF process on shell process exit
77 trap "trap - TERM && kill -- -$$" INT TERM
79 if ! command -v dotnet
>/dev
/null
; then
80 echo "ERROR: dotnet CLI tools are not installed!"
86 if [ "$SERVICE" -eq 1 ] ||
([ -f "$CONFIG_PATH" ] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"); then
87 # We're running ASF in headless mode so we don't need STDIN
88 dotnet
"$BINARY" $BINARY_ARGS & # Start ASF in the background, trap will work properly due to non-blocking call
89 wait $
! # This will forward dotnet error code, set -e will abort the script if it's non-zero
91 # We're running ASF in non-headless mode, so we need STDIN to be operative
92 dotnet
"$BINARY" $BINARY_ARGS # Start ASF in the foreground, trap won't work until process exit