ArchiSteamFarm/run.sh

58 lines
1 KiB
Bash
Raw Normal View History

2016-03-29 20:58:18 +00:00
#!/bin/bash
set -eu
BUILD="Release"
2016-07-11 17:22:25 +00:00
UNTIL_CLEAN_EXIT=0
2016-03-29 20:58:18 +00:00
2016-07-24 00:59:07 +00:00
ASF_ARGS=("")
2016-09-12 18:52:30 +00:00
MONO_ARGS=("")
2016-03-29 20:58:18 +00:00
PRINT_USAGE() {
echo "Usage: $0 [--until-clean-exit] [--cryptkey=] [--path=] [--server] [debug/release]"
2016-03-29 20:58:18 +00:00
exit 1
}
for ARG in "$@"; do
case "$ARG" in
release|Release) BUILD="Release" ;;
debug|Debug) BUILD="Debug" ;;
2016-07-24 00:49:59 +00:00
--cryptkey=*) ASF_ARGS+=("$ARG") ;;
--path=*) ASF_ARGS+=("$ARG") ;;
2016-07-24 00:51:16 +00:00
--server) ASF_ARGS+=("$ARG") ;;
2016-07-11 17:22:25 +00:00
--until-clean-exit) UNTIL_CLEAN_EXIT=1 ;;
2016-03-29 20:58:18 +00:00
*) PRINT_USAGE
esac
done
2016-05-18 00:46:29 +00:00
if [[ "$BUILD" = "Debug" ]]; then
MONO_ARGS+=("--debug")
fi
cd "$(dirname "$(readlink -f "$0")")"
if [[ -f "mono_envsetup.sh" ]]; then
2016-08-27 07:56:52 +00:00
set +u
source "mono_envsetup.sh"
2016-08-27 07:56:52 +00:00
set -u
fi
2016-03-29 20:58:18 +00:00
BINARY="ArchiSteamFarm/bin/$BUILD/ArchiSteamFarm.exe"
if [[ ! -f "$BINARY" ]]; then
echo "ERROR: $BINARY could not be found!"
exit 1
fi
2016-07-11 17:22:25 +00:00
if [[ "$UNTIL_CLEAN_EXIT" -eq 0 ]]; then
mono "${MONO_ARGS[@]}" "$BINARY" "${ASF_ARGS[@]}"
2016-07-11 17:22:25 +00:00
exit $?
fi
while [[ -f "$BINARY" ]]; do
if mono "${MONO_ARGS[@]}" "$BINARY" "${ASF_ARGS[@]}"; then
2016-07-11 17:22:25 +00:00
break
fi
sleep 1
done