motorhead102482
April 7th, 2022, 01:32 AM
I'm using Ubuntu 20.04.4 LTS. I'm having issues running a Valheim plus server as a service with systemd and systemctl. I can get the service to run and I can load the game in, but for some reason it doesn't seem to pull save files from the right place. I have a .service file setup to open a .sh file which has the file save location in the correct directory location. If I stop the service and straight run the .sh file it works like it should. If I run it as a service it acts like it can't see that information. The other thing is if I play the game as a service it remembers what I was doing in the game when it was running as a service. If I run it directly from the script, it remembers where I was in the game in that instance (two different points). To me it seems like it's saving the game in a different place when ran as a service, but I can't figure out why or where. The save files I expect it to use don't seem to be getting file updates when I look at the last save date/time on them if I run the game as a service. I'm at a loss. Thanks for any help in advance.
Here's the file path for the .service file:
/lib/systemd/system/BushwookiePVP.service
Here's the contents of the file:
[Unit]
Description=Valheim service
Wants=network.target
After=network-online.target
[Service]
Environment=SteamAppID=892970
Environment=LD_LIBRARY_PATH=/home/russ/Steam/ValheimPVP:$LD_LIBRARY_PATH
Type=simple
Restart=on-failure
RestartSec=10
KillSignal=SIGINT
Group=russ
WorkingDirectory=/home/russ/Steam/ValheimPVP
ExecStart=/home/russ/Steam/ValheimPVP/start_BushwookiePVP_bepinex.sh
[Install]
WantedBy=multi-user.target
Here are the contents of the .sh file above, but as I mentioned previously, it works fine if I just run it from CLI:
#!/bin/sh
# BepInEx running script
#
# This script is used to run a Unity game with BepInEx enabled.
#
# Usage: Configure the script below and simply run this script when you want to run your game modded.
# -------- SETTINGS --------
# ---- EDIT AS NEEDED ------
# EDIT THIS: The name of the executable to run
# LINUX: This is the name of the Unity game executable [preconfigured]
# MACOS: This is the name of the game app folder, including the .app suffix [must provide if needed]
executable_name="valheim_server.x86_64"
# EDIT THIS: Valheim server parameters
# Can be overriden by script parameters named exactly like the ones for the Valheim executable
# (e.g. ./start_server_bepinex.sh -name "MyValheimPlusServer" -password "somethingsafe" -port 2456 -world "myworld" -public 1)
server_name="Bushwookie PVP (V+ Mod)"
server_password=
server_port=2459
server_world="PVP Bushwookie"
server_public=1
server_savedir="$HOME/.config/unity3d/IronGate/Valheim"
# The rest is automatically handled by BepInEx for Valheim+
# Set base path of start_server_bepinex.sh location
export VALHEIM_PLUS_SCRIPT="$(readlink -f "$0")"
export VALHEIM_PLUS_PATH="$(dirname "$VALHEIM_PLUS_SCRIPT")"
# Whether or not to enable Doorstop. Valid values: TRUE or FALSE
export DOORSTOP_ENABLE=TRUE
# What .NET assembly to execute. Valid value is a path to a .NET DLL that mono can execute.
export DOORSTOP_INVOKE_DLL_PATH="${VALHEIM_PLUS_PATH}/BepInEx/core/BepInEx.Preloader.dll"
# Which folder should be put in front of the Unity dll loading path
export DOORSTOP_CORLIB_OVERRIDE_PATH="${VALHEIM_PLUS_PATH}/unstripped_corlib"
# ----- DO NOT EDIT FROM THIS LINE FORWARD ------
# ----- (unless you know what you're doing) ------
if [ ! -x "$1" -a ! -x "${VALHEIM_PLUS_PATH}/$executable_name" ]; then
echo "Please open start_server_bepinex.sh in a text editor and provide the correct executable."
exit 1
fi
doorstop_libs="${VALHEIM_PLUS_PATH}/doorstop_libs"
arch=""
executable_path=""
lib_postfix=""
os_type=$(uname -s)
case $os_type in
Linux*)
executable_path="${VALHEIM_PLUS_PATH}/${executable_name}"
lib_postfix="so"
;;
Darwin*)
executable_name="$(basename "${executable_name}" .app)"
real_executable_name="$(defaults read "${VALHEIM_PLUS_PATH}/${executable_name}.app/Contents/Info" CFBundleExecutable)"
executable_path="${VALHEIM_PLUS_PATH}/${executable_name}.app/Contents/MacOS/${real_executable_name}"
lib_postfix="dylib"
;;
*)
echo "Cannot identify OS (got $(uname -s))!"
echo "Please create an issue at https://github.com/BepInEx/BepInEx/issues.
exit 1
;;
esac
executable_type=$(LD_PRELOAD="" file -b "${executable_path}");
case $executable_type in
*64-bit*)
arch="x64"
;;
*32-bit*|*i386*)
arch="x86"
;;
*)
echo "Cannot identify executable type (got ${executable_type})!"
echo "Please create an issue at https://github.com/BepInEx/BepInEx/issues."
exit 1
;;
esac
doorstop_libname=libdoorstop_${arch}.${lib_postfix }
export LD_LIBRARY_PATH="${doorstop_libs}":"${LD_LIBRARY_PATH}"
export LD_PRELOAD="$doorstop_libname":"${LD_PRELOAD}"
export DYLD_LIBRARY_PATH="${doorstop_libs}"
export DYLD_INSERT_LIBRARIES="${doorstop_libs}/$doorstop_libname"
export templdpath="$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="${VALHEIM_PLUS_PATH}/linux64":"${LD_LIBRARY_PATH}"
export SteamAppId=892970
for arg in "$@"
do
case $arg in
-name)
server_name=$2
shift 2
;;
-password)
server_password=$2
shift 2
;;
-port)
server_port=$2
shift 2
;;
-world)
server_world=$2
shift 2
;;
-public)
server_public=$2
shift 2
;;
-savedir)
server_savedir=$2
shift 2
;;
esac
done
"${VALHEIM_PLUS_PATH}/${executable_name}" -name "${server_name}" -password "${server_password}" -port "${server_port}" -world "${server_world}" -public "${server_public}" -savedir "${server_savedir}"
export LD_LIBRARY_PATH=$templdpath
Here's the file path for the .service file:
/lib/systemd/system/BushwookiePVP.service
Here's the contents of the file:
[Unit]
Description=Valheim service
Wants=network.target
After=network-online.target
[Service]
Environment=SteamAppID=892970
Environment=LD_LIBRARY_PATH=/home/russ/Steam/ValheimPVP:$LD_LIBRARY_PATH
Type=simple
Restart=on-failure
RestartSec=10
KillSignal=SIGINT
Group=russ
WorkingDirectory=/home/russ/Steam/ValheimPVP
ExecStart=/home/russ/Steam/ValheimPVP/start_BushwookiePVP_bepinex.sh
[Install]
WantedBy=multi-user.target
Here are the contents of the .sh file above, but as I mentioned previously, it works fine if I just run it from CLI:
#!/bin/sh
# BepInEx running script
#
# This script is used to run a Unity game with BepInEx enabled.
#
# Usage: Configure the script below and simply run this script when you want to run your game modded.
# -------- SETTINGS --------
# ---- EDIT AS NEEDED ------
# EDIT THIS: The name of the executable to run
# LINUX: This is the name of the Unity game executable [preconfigured]
# MACOS: This is the name of the game app folder, including the .app suffix [must provide if needed]
executable_name="valheim_server.x86_64"
# EDIT THIS: Valheim server parameters
# Can be overriden by script parameters named exactly like the ones for the Valheim executable
# (e.g. ./start_server_bepinex.sh -name "MyValheimPlusServer" -password "somethingsafe" -port 2456 -world "myworld" -public 1)
server_name="Bushwookie PVP (V+ Mod)"
server_password=
server_port=2459
server_world="PVP Bushwookie"
server_public=1
server_savedir="$HOME/.config/unity3d/IronGate/Valheim"
# The rest is automatically handled by BepInEx for Valheim+
# Set base path of start_server_bepinex.sh location
export VALHEIM_PLUS_SCRIPT="$(readlink -f "$0")"
export VALHEIM_PLUS_PATH="$(dirname "$VALHEIM_PLUS_SCRIPT")"
# Whether or not to enable Doorstop. Valid values: TRUE or FALSE
export DOORSTOP_ENABLE=TRUE
# What .NET assembly to execute. Valid value is a path to a .NET DLL that mono can execute.
export DOORSTOP_INVOKE_DLL_PATH="${VALHEIM_PLUS_PATH}/BepInEx/core/BepInEx.Preloader.dll"
# Which folder should be put in front of the Unity dll loading path
export DOORSTOP_CORLIB_OVERRIDE_PATH="${VALHEIM_PLUS_PATH}/unstripped_corlib"
# ----- DO NOT EDIT FROM THIS LINE FORWARD ------
# ----- (unless you know what you're doing) ------
if [ ! -x "$1" -a ! -x "${VALHEIM_PLUS_PATH}/$executable_name" ]; then
echo "Please open start_server_bepinex.sh in a text editor and provide the correct executable."
exit 1
fi
doorstop_libs="${VALHEIM_PLUS_PATH}/doorstop_libs"
arch=""
executable_path=""
lib_postfix=""
os_type=$(uname -s)
case $os_type in
Linux*)
executable_path="${VALHEIM_PLUS_PATH}/${executable_name}"
lib_postfix="so"
;;
Darwin*)
executable_name="$(basename "${executable_name}" .app)"
real_executable_name="$(defaults read "${VALHEIM_PLUS_PATH}/${executable_name}.app/Contents/Info" CFBundleExecutable)"
executable_path="${VALHEIM_PLUS_PATH}/${executable_name}.app/Contents/MacOS/${real_executable_name}"
lib_postfix="dylib"
;;
*)
echo "Cannot identify OS (got $(uname -s))!"
echo "Please create an issue at https://github.com/BepInEx/BepInEx/issues.
exit 1
;;
esac
executable_type=$(LD_PRELOAD="" file -b "${executable_path}");
case $executable_type in
*64-bit*)
arch="x64"
;;
*32-bit*|*i386*)
arch="x86"
;;
*)
echo "Cannot identify executable type (got ${executable_type})!"
echo "Please create an issue at https://github.com/BepInEx/BepInEx/issues."
exit 1
;;
esac
doorstop_libname=libdoorstop_${arch}.${lib_postfix }
export LD_LIBRARY_PATH="${doorstop_libs}":"${LD_LIBRARY_PATH}"
export LD_PRELOAD="$doorstop_libname":"${LD_PRELOAD}"
export DYLD_LIBRARY_PATH="${doorstop_libs}"
export DYLD_INSERT_LIBRARIES="${doorstop_libs}/$doorstop_libname"
export templdpath="$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="${VALHEIM_PLUS_PATH}/linux64":"${LD_LIBRARY_PATH}"
export SteamAppId=892970
for arg in "$@"
do
case $arg in
-name)
server_name=$2
shift 2
;;
-password)
server_password=$2
shift 2
;;
-port)
server_port=$2
shift 2
;;
-world)
server_world=$2
shift 2
;;
-public)
server_public=$2
shift 2
;;
-savedir)
server_savedir=$2
shift 2
;;
esac
done
"${VALHEIM_PLUS_PATH}/${executable_name}" -name "${server_name}" -password "${server_password}" -port "${server_port}" -world "${server_world}" -public "${server_public}" -savedir "${server_savedir}"
export LD_LIBRARY_PATH=$templdpath