Move copying of overlay files to ArchiSteamFarm.csproj (#2650)

* Move copying of overlay files to ArchiSteamFarm.csproj

* Fix build on Windows

* Try to make it more reliable

* Update ArchiSteamFarm.csproj

* Update ArchiSteamFarm.csproj

* Revert "Update ArchiSteamFarm.csproj"

This reverts commit ba41b2e3c1.

* Rename

Co-authored-by: JustArchi <JustArchi@JustArchi.net>
This commit is contained in:
Sebastian Göls
2022-07-19 22:20:18 +02:00
committed by GitHub
parent 25b29cd56e
commit 41ecfb1d02
12 changed files with 16 additions and 22 deletions

View File

@@ -0,0 +1,112 @@
#!/usr/bin/env sh
set -eu
CONFIG_PATH="config/ASF.json"
OS_TYPE="$(uname -s)"
case "$OS_TYPE" in
"Darwin") SCRIPT_PATH="$(readlink "$0")" ;;
"FreeBSD") SCRIPT_PATH="$(readlink -f "$0")" ;;
"Linux") SCRIPT_PATH="$(readlink -f "$0")" ;;
*) echo "ERROR: Unknown OS type: ${OS_TYPE}. If you believe that our script should work on your machine, please let us know."; exit 1
esac
SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
BINARY="${SCRIPT_DIR}/ArchiSteamFarm.exe"
if [ ! -f "$BINARY" ]; then
echo "ERROR: $BINARY could not be found!"
exit 1
fi
cd "$SCRIPT_DIR"
BINARY_ARGS=""
PATH_NEXT=0
SERVICE=0
PARSE_ARG() {
BINARY_ARGS="$BINARY_ARGS $1"
case "$1" in
--path) PATH_NEXT=1 ;;
--path=*)
if [ "$PATH_NEXT" -eq 1 ]; then
PATH_NEXT=0
cd "$1"
else
cd "$(echo "$1" | cut -d '=' -f 2-)"
fi
;;
--service) SERVICE=1 ;;
*)
if [ "$PATH_NEXT" -eq 1 ]; then
PATH_NEXT=0
cd "$1"
fi
esac
}
if [ -n "${ASF_PATH-}" ]; then
cd "$ASF_PATH"
fi
if [ -n "${ASF_ARGS-}" ]; then
for ARG in $ASF_ARGS; do
if [ -n "$ARG" ]; then
PARSE_ARG "$ARG"
fi
done
fi
for ARG in "$@"; do
if [ -n "$ARG" ]; then
PARSE_ARG "$ARG"
fi
done
BINARY_PREFIX=""
if [ -n "${ASF_USER-}" ] && [ "$(id -u)" -eq 0 ] && id -u "$ASF_USER" >/dev/null 2>&1; then
# Fix permissions first to ensure ASF has read/write access to the directory specified by --path and its own
chown -hR "${ASF_USER}:${ASF_USER}" . "$SCRIPT_DIR"
BINARY_PREFIX="su ${ASF_USER} -c"
fi
CONFIG_PATH="$(pwd)/${CONFIG_PATH}"
# Kill underlying ASF process on shell process exit
trap "trap - TERM && kill -- -$$" INT TERM
if ! command -v mono >/dev/null; then
echo "ERROR: mono is not installed!"
exit 1
fi
mono --version
while :; do
if [ "$SERVICE" -eq 1 ] || ([ -f "$CONFIG_PATH" ] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"); then
# We're running ASF in headless mode so we don't need STDIN
# Start ASF in the background, trap will work properly due to non-blocking call
if [ -n "$BINARY_PREFIX" ]; then
$BINARY_PREFIX "mono ${MONO_ARGS-} $BINARY $BINARY_ARGS" &
else
mono ${MONO_ARGS-} "$BINARY" $BINARY_ARGS &
fi
# This will forward mono error code, set -e will abort the script if it's non-zero
wait $!
else
# We're running ASF in non-headless mode, so we need STDIN to be operative
# Start ASF in the foreground, trap won't work until process exit
if [ -n "$BINARY_PREFIX" ]; then
$BINARY_PREFIX "mono ${MONO_ARGS-} $BINARY $BINARY_ARGS"
else
mono ${MONO_ARGS-} "$BINARY" $BINARY_ARGS
fi
fi
sleep 1
done

View File

@@ -0,0 +1,108 @@
#!/usr/bin/env sh
set -eu
CONFIG_PATH="config/ASF.json"
OS_TYPE="$(uname -s)"
case "$OS_TYPE" in
"Darwin") SCRIPT_PATH="$(readlink "$0")" ;;
"FreeBSD") SCRIPT_PATH="$(readlink -f "$0")" ;;
"Linux") SCRIPT_PATH="$(readlink -f "$0")" ;;
*) echo "ERROR: Unknown OS type: ${OS_TYPE}. If you believe that our script should work on your machine, please let us know."; exit 1
esac
SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
BINARY="${SCRIPT_DIR}/ArchiSteamFarm.exe"
if [ ! -f "$BINARY" ]; then
echo "ERROR: $BINARY could not be found!"
exit 1
fi
cd "$SCRIPT_DIR"
BINARY_ARGS=""
PATH_NEXT=0
SERVICE=0
PARSE_ARG() {
BINARY_ARGS="$BINARY_ARGS $1"
case "$1" in
--path) PATH_NEXT=1 ;;
--path=*)
if [ "$PATH_NEXT" -eq 1 ]; then
PATH_NEXT=0
cd "$1"
else
cd "$(echo "$1" | cut -d '=' -f 2-)"
fi
;;
--service) SERVICE=1 ;;
*)
if [ "$PATH_NEXT" -eq 1 ]; then
PATH_NEXT=0
cd "$1"
fi
esac
}
if [ -n "${ASF_PATH-}" ]; then
cd "$ASF_PATH"
fi
if [ -n "${ASF_ARGS-}" ]; then
for ARG in $ASF_ARGS; do
if [ -n "$ARG" ]; then
PARSE_ARG "$ARG"
fi
done
fi
for ARG in "$@"; do
if [ -n "$ARG" ]; then
PARSE_ARG "$ARG"
fi
done
BINARY_PREFIX=""
if [ -n "${ASF_USER-}" ] && [ "$(id -u)" -eq 0 ] && id -u "$ASF_USER" >/dev/null 2>&1; then
# Fix permissions first to ensure ASF has read/write access to the directory specified by --path and its own
chown -hR "${ASF_USER}:${ASF_USER}" . "$SCRIPT_DIR"
BINARY_PREFIX="su ${ASF_USER} -c"
fi
CONFIG_PATH="$(pwd)/${CONFIG_PATH}"
# Kill underlying ASF process on shell process exit
trap "trap - TERM && kill -- -$$" INT TERM
if ! command -v mono >/dev/null; then
echo "ERROR: mono is not installed!"
exit 1
fi
mono --version
if [ "$SERVICE" -eq 1 ] || ([ -f "$CONFIG_PATH" ] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"); then
# We're running ASF in headless mode so we don't need STDIN
# Start ASF in the background, trap will work properly due to non-blocking call
if [ -n "$BINARY_PREFIX" ]; then
$BINARY_PREFIX "mono ${MONO_ARGS-} $BINARY $BINARY_ARGS" &
else
mono ${MONO_ARGS-} "$BINARY" $BINARY_ARGS &
fi
# This will forward mono error code, set -e will abort the script if it's non-zero
wait $!
else
# We're running ASF in non-headless mode, so we need STDIN to be operative
# Start ASF in the foreground, trap won't work until process exit
if [ -n "$BINARY_PREFIX" ]; then
$BINARY_PREFIX "mono ${MONO_ARGS-} $BINARY $BINARY_ARGS"
else
mono ${MONO_ARGS-} "$BINARY" $BINARY_ARGS
fi
fi

View File

@@ -0,0 +1,37 @@
[Install]
WantedBy=multi-user.target
[Service]
EnvironmentFile=-/etc/asf/%i
ExecStart=mono /home/%i/ArchiSteamFarm/ArchiSteamFarm.exe --no-restart --process-required --service --system-required
Restart=on-success
RestartSec=1s
SyslogIdentifier=asf-%i
User=%i
# ASF security hardening, all of the below entries are optional, but their existence improves security of your system
LockPersonality=yes
PrivateDevices=yes
PrivateIPC=yes
PrivateMounts=yes
PrivateUsers=yes
ProtectClock=yes
ProtectControlGroups=yes
ProtectHome=read-only
ProtectHostname=yes
ProtectKernelLogs=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
ProtectProc=invisible
ProtectSystem=strict
ReadWritePaths=/home/%i/ArchiSteamFarm /tmp
RemoveIPC=yes
RestrictAddressFamilies=AF_INET AF_INET6
RestrictNamespaces=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
[Unit]
After=network.target
Description=ArchiSteamFarm Service (on %I)
Documentation=https://github.com/JustArchiNET/ArchiSteamFarm/wiki

View File

@@ -0,0 +1,112 @@
#!/usr/bin/env sh
set -eu
CONFIG_PATH="config/ASF.json"
OS_TYPE="$(uname -s)"
case "$OS_TYPE" in
"Darwin") SCRIPT_PATH="$(readlink "$0")" ;;
"FreeBSD") SCRIPT_PATH="$(readlink -f "$0")" ;;
"Linux") SCRIPT_PATH="$(readlink -f "$0")" ;;
*) echo "ERROR: Unknown OS type: ${OS_TYPE}. If you believe that our script should work on your machine, please let us know."; exit 1
esac
SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
BINARY="${SCRIPT_DIR}/ArchiSteamFarm.dll"
if [ ! -f "$BINARY" ]; then
echo "ERROR: $BINARY could not be found!"
exit 1
fi
cd "$SCRIPT_DIR"
BINARY_ARGS=""
PATH_NEXT=0
SERVICE=0
PARSE_ARG() {
BINARY_ARGS="$BINARY_ARGS $1"
case "$1" in
--path) PATH_NEXT=1 ;;
--path=*)
if [ "$PATH_NEXT" -eq 1 ]; then
PATH_NEXT=0
cd "$1"
else
cd "$(echo "$1" | cut -d '=' -f 2-)"
fi
;;
--service) SERVICE=1 ;;
*)
if [ "$PATH_NEXT" -eq 1 ]; then
PATH_NEXT=0
cd "$1"
fi
esac
}
if [ -n "${ASF_PATH-}" ]; then
cd "$ASF_PATH"
fi
if [ -n "${ASF_ARGS-}" ]; then
for ARG in $ASF_ARGS; do
if [ -n "$ARG" ]; then
PARSE_ARG "$ARG"
fi
done
fi
for ARG in "$@"; do
if [ -n "$ARG" ]; then
PARSE_ARG "$ARG"
fi
done
BINARY_PREFIX=""
if [ -n "${ASF_USER-}" ] && [ "$(id -u)" -eq 0 ] && id -u "$ASF_USER" >/dev/null 2>&1; then
# Fix permissions first to ensure ASF has read/write access to the directory specified by --path and its own
chown -hR "${ASF_USER}:${ASF_USER}" . "$SCRIPT_DIR"
BINARY_PREFIX="su ${ASF_USER} -c"
fi
CONFIG_PATH="$(pwd)/${CONFIG_PATH}"
# Kill underlying ASF process on shell process exit
trap "trap - TERM && kill -- -$$" INT TERM
if ! command -v dotnet >/dev/null; then
echo "ERROR: dotnet CLI tools are not installed!"
exit 1
fi
dotnet --info
while :; do
if [ "$SERVICE" -eq 1 ] || ([ -f "$CONFIG_PATH" ] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"); then
# We're running ASF in headless mode so we don't need STDIN
# Start ASF in the background, trap will work properly due to non-blocking call
if [ -n "$BINARY_PREFIX" ]; then
$BINARY_PREFIX "dotnet ${DOTNET_ARGS-} $BINARY $BINARY_ARGS" &
else
dotnet ${DOTNET_ARGS-} "$BINARY" $BINARY_ARGS &
fi
# This will forward dotnet error code, set -e will abort the script if it's non-zero
wait $!
else
# We're running ASF in non-headless mode, so we need STDIN to be operative
# Start ASF in the foreground, trap won't work until process exit
if [ -n "$BINARY_PREFIX" ]; then
$BINARY_PREFIX "dotnet ${DOTNET_ARGS-} $BINARY $BINARY_ARGS"
else
dotnet ${DOTNET_ARGS-} "$BINARY" $BINARY_ARGS
fi
fi
sleep 1
done

View File

@@ -0,0 +1,9 @@
@echo off
pushd %~dp0
SETLOCAL
SET ASF_ARGS=%ASF_ARGS% %*
dotnet --info
dotnet ArchiSteamFarm.dll %ASF_ARGS%

View File

@@ -0,0 +1,108 @@
#!/usr/bin/env sh
set -eu
CONFIG_PATH="config/ASF.json"
OS_TYPE="$(uname -s)"
case "$OS_TYPE" in
"Darwin") SCRIPT_PATH="$(readlink "$0")" ;;
"FreeBSD") SCRIPT_PATH="$(readlink -f "$0")" ;;
"Linux") SCRIPT_PATH="$(readlink -f "$0")" ;;
*) echo "ERROR: Unknown OS type: ${OS_TYPE}. If you believe that our script should work on your machine, please let us know."; exit 1
esac
SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
BINARY="${SCRIPT_DIR}/ArchiSteamFarm.dll"
if [ ! -f "$BINARY" ]; then
echo "ERROR: $BINARY could not be found!"
exit 1
fi
cd "$SCRIPT_DIR"
BINARY_ARGS=""
PATH_NEXT=0
SERVICE=0
PARSE_ARG() {
BINARY_ARGS="$BINARY_ARGS $1"
case "$1" in
--path) PATH_NEXT=1 ;;
--path=*)
if [ "$PATH_NEXT" -eq 1 ]; then
PATH_NEXT=0
cd "$1"
else
cd "$(echo "$1" | cut -d '=' -f 2-)"
fi
;;
--service) SERVICE=1 ;;
*)
if [ "$PATH_NEXT" -eq 1 ]; then
PATH_NEXT=0
cd "$1"
fi
esac
}
if [ -n "${ASF_PATH-}" ]; then
cd "$ASF_PATH"
fi
if [ -n "${ASF_ARGS-}" ]; then
for ARG in $ASF_ARGS; do
if [ -n "$ARG" ]; then
PARSE_ARG "$ARG"
fi
done
fi
for ARG in "$@"; do
if [ -n "$ARG" ]; then
PARSE_ARG "$ARG"
fi
done
BINARY_PREFIX=""
if [ -n "${ASF_USER-}" ] && [ "$(id -u)" -eq 0 ] && id -u "$ASF_USER" >/dev/null 2>&1; then
# Fix permissions first to ensure ASF has read/write access to the directory specified by --path and its own
chown -hR "${ASF_USER}:${ASF_USER}" . "$SCRIPT_DIR"
BINARY_PREFIX="su ${ASF_USER} -c"
fi
CONFIG_PATH="$(pwd)/${CONFIG_PATH}"
# Kill underlying ASF process on shell process exit
trap "trap - TERM && kill -- -$$" INT TERM
if ! command -v dotnet >/dev/null; then
echo "ERROR: dotnet CLI tools are not installed!"
exit 1
fi
dotnet --info
if [ "$SERVICE" -eq 1 ] || ([ -f "$CONFIG_PATH" ] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"); then
# We're running ASF in headless mode so we don't need STDIN
# Start ASF in the background, trap will work properly due to non-blocking call
if [ -n "$BINARY_PREFIX" ]; then
$BINARY_PREFIX "dotnet ${DOTNET_ARGS-} $BINARY $BINARY_ARGS" &
else
dotnet ${DOTNET_ARGS-} "$BINARY" $BINARY_ARGS &
fi
# This will forward dotnet error code, set -e will abort the script if it's non-zero
wait $!
else
# We're running ASF in non-headless mode, so we need STDIN to be operative
# Start ASF in the foreground, trap won't work until process exit
if [ -n "$BINARY_PREFIX" ]; then
$BINARY_PREFIX "dotnet ${DOTNET_ARGS-} $BINARY $BINARY_ARGS"
else
dotnet ${DOTNET_ARGS-} "$BINARY" $BINARY_ARGS
fi
fi

View File

@@ -0,0 +1,37 @@
[Install]
WantedBy=multi-user.target
[Service]
EnvironmentFile=-/etc/asf/%i
ExecStart=dotnet /home/%i/ArchiSteamFarm/ArchiSteamFarm.dll --no-restart --process-required --service --system-required
Restart=on-success
RestartSec=1s
SyslogIdentifier=asf-%i
User=%i
# ASF security hardening, all of the below entries are optional, but their existence improves security of your system
LockPersonality=yes
PrivateDevices=yes
PrivateIPC=yes
PrivateMounts=yes
PrivateUsers=yes
ProtectClock=yes
ProtectControlGroups=yes
ProtectHome=read-only
ProtectHostname=yes
ProtectKernelLogs=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
ProtectProc=invisible
ProtectSystem=strict
ReadWritePaths=/home/%i/ArchiSteamFarm /tmp
RemoveIPC=yes
RestrictAddressFamilies=AF_INET AF_INET6
RestrictNamespaces=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
[Unit]
After=network.target
Description=ArchiSteamFarm Service (on %I)
Documentation=https://github.com/JustArchiNET/ArchiSteamFarm/wiki