Skip to content

Instantly share code, notes, and snippets.

@jairovsky
Created June 2, 2024 23:51
Show Gist options
  • Save jairovsky/c7c749b50b47e4d894acb655d8727de5 to your computer and use it in GitHub Desktop.
Save jairovsky/c7c749b50b47e4d894acb655d8727de5 to your computer and use it in GitHub Desktop.
Valheim server unit file for SystemD (with mods/BepInEx)
#!/bin/sh
/home/USER/bin/steam/steamcmd.sh +@sSteamCmdForcePlatformType linux +force_install_dir $(realpath .) +login anonymous +app_update 896660 -beta none validate +quit
# Download SteamCMD and unzip it somewhere
# Create the folder /home/USER/Downloads/valheim and put this script inside
# give exec permissions: chmod +x ./install_or_update.sh
# then execute it: ./install_or_update.sh
# You can re-execute this script from time to time to update the server. A good idea is to run it whenever there's an update to the actual game on Steam.
[Unit]
Description=Valheim Dedicated Server
Wants=network-online.target
After=network.target network-online.target
# recommended usage:
# You don't need to (and shouldn't) run it as root.
# Put this file inside $HOME/.config/systemd/user
# Then manage it like this:
# systemctl --user daemon-reload (every time you modify this file)
# systemctl --user [start/stop] valheim
# systemctl --user enable valheim (if you want the server to run automatically on system startup)
# journalctl -xf -u valheim --user (check the latest server logs to analyze problems)
#
# -name is the server name as it appears in the game server list
# -world is the database file name that's stored in $HOME/.config/unity3d/IronGate/Valheim/worlds_local
# -public 1 uses Playfab to make your server reachable across the internet. It is a good option if you have issues opening ports on your router.
#
# If you don't want mods, remove the Environment=LD_PRELOAD line
# BepInEx doesn't come bundled with the server, you need to download separately and put the BepInEx folder and libdoorstop.so in their appropriate paths
[Service]
WorkingDirectory=/home/USER/Downloads/valheim
Environment=LD_LIBRARY_PATH=./linux64
Environment=LD_PRELOAD=./linux64/libdoorstop.so
Environment=DOORSTOP_TARGET_ASSEMBLY=./BepInEx/core/BepInEx.Preloader.dll
Environment=DOORSTOP_ENABLED=1
Environment=SteamAppId=892970
ExecStart=/home/USER/Downloads/valheim/valheim_server.x86_64 -name "MyServerName" -port "2456" -nographics -batchmode -world "MyWorld" -password "myP@ssw0rd" -public 1 -crossplay -modifier raids muchless -modifier deathpenalty veryeasy
[Install]
WantedBy=default.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment