mirror of
https://github.com/JustArchiNET/ArchiSteamFarm
synced 2024-11-10 07:04:27 +00:00
Various script improvements
This commit is contained in:
parent
811177f749
commit
e1ddd99935
5 changed files with 154 additions and 37 deletions
|
@ -417,16 +417,33 @@ namespace ArchiSteamFarm {
|
||||||
foreach (string arg in args) {
|
foreach (string arg in args) {
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
case "":
|
case "":
|
||||||
|
break;
|
||||||
case "--path":
|
case "--path":
|
||||||
|
if (cryptKeyNext) {
|
||||||
|
goto default;
|
||||||
|
}
|
||||||
|
|
||||||
// Not handled in PostInit
|
// Not handled in PostInit
|
||||||
break;
|
break;
|
||||||
case "--cryptkey":
|
case "--cryptkey":
|
||||||
|
if (cryptKeyNext) {
|
||||||
|
goto default;
|
||||||
|
}
|
||||||
|
|
||||||
cryptKeyNext = true;
|
cryptKeyNext = true;
|
||||||
break;
|
break;
|
||||||
case "--server":
|
case "--server":
|
||||||
|
if (cryptKeyNext) {
|
||||||
|
goto default;
|
||||||
|
}
|
||||||
|
|
||||||
IPC.Start();
|
IPC.Start();
|
||||||
break;
|
break;
|
||||||
case "--service":
|
case "--service":
|
||||||
|
if (cryptKeyNext) {
|
||||||
|
goto default;
|
||||||
|
}
|
||||||
|
|
||||||
ServiceMode = true;
|
ServiceMode = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -455,12 +472,21 @@ namespace ArchiSteamFarm {
|
||||||
foreach (string arg in args) {
|
foreach (string arg in args) {
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
case "":
|
case "":
|
||||||
|
break;
|
||||||
case "--cryptkey":
|
case "--cryptkey":
|
||||||
case "--server":
|
case "--server":
|
||||||
case "--service":
|
case "--service":
|
||||||
|
if (pathNext) {
|
||||||
|
goto default;
|
||||||
|
}
|
||||||
|
|
||||||
// Not handled in PreInit
|
// Not handled in PreInit
|
||||||
break;
|
break;
|
||||||
case "--path":
|
case "--path":
|
||||||
|
if (pathNext) {
|
||||||
|
goto default;
|
||||||
|
}
|
||||||
|
|
||||||
pathNext = true;
|
pathNext = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -5,31 +5,65 @@ CONFIG_PATH="config/ASF.json"
|
||||||
|
|
||||||
cd "$(dirname "$(readlink -f "$0")")"
|
cd "$(dirname "$(readlink -f "$0")")"
|
||||||
|
|
||||||
if [[ -z "${ASF_ARGS-}" ]]; then
|
SCRIPT_DIR="$(pwd)"
|
||||||
ASF_ARGS=""
|
SCRIPT_PATH="${SCRIPT_DIR}/${0}"
|
||||||
|
|
||||||
|
BINARY="${SCRIPT_DIR}/ArchiSteamFarm.dll"
|
||||||
|
BINARY_ARGS=()
|
||||||
|
|
||||||
|
PATH_NEXT=0
|
||||||
|
|
||||||
|
PARSE_ARG() {
|
||||||
|
BINARY_ARGS+=("$1")
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
--cryptkey|--server|--service) ;;
|
||||||
|
--path) PATH_NEXT=1 ;;
|
||||||
|
--path=*) cd "$(echo "$1" | cut -d '=' -f 2-)" ;;
|
||||||
|
*)
|
||||||
|
if [[ "$PATH_NEXT" -eq 1 ]]; then
|
||||||
|
PATH_NEXT=0
|
||||||
|
cd "$1"
|
||||||
|
fi
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -n "${ASF_ARGS-}" ]]; then
|
||||||
|
for ARG in $ASF_ARGS; do
|
||||||
|
if [[ -n "$ARG" ]]; then
|
||||||
|
PARSE_ARG "$ARG"
|
||||||
|
fi
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ASF_ARGS+=" $*"
|
for ARG in "$@"; do
|
||||||
|
if [[ -n "$ARG" ]]; then
|
||||||
for ARG in $ASF_ARGS; do
|
PARSE_ARG "$ARG"
|
||||||
case "$ARG" in
|
fi
|
||||||
--path=*) CONFIG_PATH="$(echo "$ARG" | cut -d '=' -f 2-)/${CONFIG_PATH}" ;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
CONFIG_PATH="$(pwd)/${CONFIG_PATH}"
|
||||||
|
|
||||||
# Kill underlying ASF process on shell process exit
|
# Kill underlying ASF process on shell process exit
|
||||||
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM
|
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM
|
||||||
|
|
||||||
|
if ! hash dotnet 2>/dev/null; then
|
||||||
|
echo "ERROR: dotnet CLI tools are not installed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
dotnet --info
|
||||||
|
|
||||||
while :; do
|
while :; do
|
||||||
if [[ -f "$CONFIG_PATH" ]] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"; then
|
if [[ -f "$CONFIG_PATH" ]] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"; then
|
||||||
# We're running ASF in headless mode so we don't need STDIN
|
# 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
|
dotnet "$BINARY" "${BINARY_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
|
wait $! # This will forward dotnet error code, set -e will abort the script if it's non-zero
|
||||||
else
|
else
|
||||||
# We're running ASF in non-headless mode, so we need STDIN to be operative
|
# 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
|
dotnet "$BINARY" "${BINARY_ARGS[@]}" # Start ASF in the foreground, trap sadly won't work until process exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod +x "$0" # If ASF exited by itself, we need to ensure that our script is still set to +x after auto-update
|
chmod +x "$SCRIPT_PATH" # If ASF exited by itself, we need to ensure that our script is still set to +x after auto-update
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
|
@ -4,4 +4,6 @@ pushd %~dp0
|
||||||
SETLOCAL
|
SETLOCAL
|
||||||
SET ASF_ARGS=%ASF_ARGS% %*
|
SET ASF_ARGS=%ASF_ARGS% %*
|
||||||
|
|
||||||
|
dotnet --info
|
||||||
|
|
||||||
dotnet ArchiSteamFarm.dll %ASF_ARGS%
|
dotnet ArchiSteamFarm.dll %ASF_ARGS%
|
||||||
|
|
|
@ -5,28 +5,62 @@ CONFIG_PATH="config/ASF.json"
|
||||||
|
|
||||||
cd "$(dirname "$(readlink -f "$0")")"
|
cd "$(dirname "$(readlink -f "$0")")"
|
||||||
|
|
||||||
if [[ -z "${ASF_ARGS-}" ]]; then
|
SCRIPT_DIR="$(pwd)"
|
||||||
ASF_ARGS=""
|
SCRIPT_PATH="${SCRIPT_DIR}/${0}"
|
||||||
|
|
||||||
|
BINARY="${SCRIPT_DIR}/ArchiSteamFarm.dll"
|
||||||
|
BINARY_ARGS=()
|
||||||
|
|
||||||
|
PATH_NEXT=0
|
||||||
|
|
||||||
|
PARSE_ARG() {
|
||||||
|
BINARY_ARGS+=("$1")
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
--cryptkey|--server|--service) ;;
|
||||||
|
--path) PATH_NEXT=1 ;;
|
||||||
|
--path=*) cd "$(echo "$1" | cut -d '=' -f 2-)" ;;
|
||||||
|
*)
|
||||||
|
if [[ "$PATH_NEXT" -eq 1 ]]; then
|
||||||
|
PATH_NEXT=0
|
||||||
|
cd "$1"
|
||||||
|
fi
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -n "${ASF_ARGS-}" ]]; then
|
||||||
|
for ARG in $ASF_ARGS; do
|
||||||
|
if [[ -n "$ARG" ]]; then
|
||||||
|
PARSE_ARG "$ARG"
|
||||||
|
fi
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ASF_ARGS+=" $*"
|
for ARG in "$@"; do
|
||||||
|
if [[ -n "$ARG" ]]; then
|
||||||
for ARG in $ASF_ARGS; do
|
PARSE_ARG "$ARG"
|
||||||
case "$ARG" in
|
fi
|
||||||
--path=*) CONFIG_PATH="$(echo "$ARG" | cut -d '=' -f 2-)/${CONFIG_PATH}" ;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
CONFIG_PATH="$(pwd)/${CONFIG_PATH}"
|
||||||
|
|
||||||
# Kill underlying ASF process on shell process exit
|
# Kill underlying ASF process on shell process exit
|
||||||
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM
|
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM
|
||||||
|
|
||||||
|
if ! hash dotnet 2>/dev/null; then
|
||||||
|
echo "ERROR: dotnet CLI tools are not installed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
dotnet --info
|
||||||
|
|
||||||
if [[ -f "$CONFIG_PATH" ]] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"; then
|
if [[ -f "$CONFIG_PATH" ]] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"; then
|
||||||
# We're running ASF in headless mode so we don't need STDIN
|
# 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
|
dotnet "$BINARY" "${BINARY_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
|
wait $! # This will forward dotnet error code, set -e will abort the script if it's non-zero
|
||||||
else
|
else
|
||||||
# We're running ASF in non-headless mode, so we need STDIN to be operative
|
# 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
|
dotnet "$BINARY" "${BINARY_ARGS[@]}" # Start ASF in the foreground, trap won't work until process exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod +x "$0" # If ASF exited by itself, we need to ensure that our script is still set to +x after auto-update
|
chmod +x "$SCRIPT_PATH" # If ASF exited by itself, we need to ensure that our script is still set to +x after auto-update
|
||||||
|
|
51
run.sh
51
run.sh
|
@ -1,25 +1,48 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
PROJECT="ArchiSteamFarm"
|
|
||||||
OUT="out/source"
|
|
||||||
|
|
||||||
CONFIG_PATH="config/ASF.json"
|
CONFIG_PATH="config/ASF.json"
|
||||||
|
|
||||||
cd "$(dirname "$(readlink -f "$0")")"
|
cd "$(dirname "$(readlink -f "$0")")"
|
||||||
|
|
||||||
if [[ -z "${ASF_ARGS-}" ]]; then
|
SCRIPT_DIR="$(pwd)"
|
||||||
ASF_ARGS=""
|
|
||||||
|
BINARY="${SCRIPT_DIR}/$ArchiSteamFarm/out/source/$ArchiSteamFarm.dll"
|
||||||
|
BINARY_ARGS=()
|
||||||
|
|
||||||
|
PATH_NEXT=0
|
||||||
|
|
||||||
|
PARSE_ARG() {
|
||||||
|
BINARY_ARGS+=("$1")
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
--cryptkey|--server|--service) ;;
|
||||||
|
--path) PATH_NEXT=1 ;;
|
||||||
|
--path=*) cd "$(echo "$1" | cut -d '=' -f 2-)" ;;
|
||||||
|
*)
|
||||||
|
if [[ "$PATH_NEXT" -eq 1 ]]; then
|
||||||
|
PATH_NEXT=0
|
||||||
|
cd "$1"
|
||||||
|
fi
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -n "${ASF_ARGS-}" ]]; then
|
||||||
|
for ARG in $ASF_ARGS; do
|
||||||
|
if [[ -n "$ARG" ]]; then
|
||||||
|
PARSE_ARG "$ARG"
|
||||||
|
fi
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ASF_ARGS+=" $*"
|
for ARG in "$@"; do
|
||||||
|
if [[ -n "$ARG" ]]; then
|
||||||
for ARG in $ASF_ARGS; do
|
PARSE_ARG "$ARG"
|
||||||
case "$ARG" in
|
fi
|
||||||
--path=*) CONFIG_PATH="$(echo "$ARG" | cut -d '=' -f 2-)/${CONFIG_PATH}" ;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
CONFIG_PATH="$(pwd)/${CONFIG_PATH}"
|
||||||
|
|
||||||
# Kill underlying ASF process on shell process exit
|
# Kill underlying ASF process on shell process exit
|
||||||
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM
|
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM
|
||||||
|
|
||||||
|
@ -30,13 +53,11 @@ fi
|
||||||
|
|
||||||
dotnet --info
|
dotnet --info
|
||||||
|
|
||||||
cd "${PROJECT}/${OUT}"
|
|
||||||
|
|
||||||
if [[ -f "$CONFIG_PATH" ]] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"; then
|
if [[ -f "$CONFIG_PATH" ]] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"; then
|
||||||
# We're running ASF in headless mode so we don't need STDIN
|
# We're running ASF in headless mode so we don't need STDIN
|
||||||
dotnet exec "${PROJECT}.dll" $ASF_ARGS & # Start ASF in the background, trap will work properly due to non-blocking call
|
dotnet exec "$BINARY" "${BINARY_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
|
wait $! # This will forward dotnet error code, set -e will abort the script if it's non-zero
|
||||||
else
|
else
|
||||||
# We're running ASF in non-headless mode, so we need STDIN to be operative
|
# We're running ASF in non-headless mode, so we need STDIN to be operative
|
||||||
dotnet exec "${PROJECT}.dll" $ASF_ARGS # Start ASF in the foreground, trap won't work until process exit
|
dotnet exec "$BINARY" "${BINARY_ARGS[@]}" # Start ASF in the foreground, trap won't work until process exit
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue