Valheim BepINex
gamesA brutal exploration and survival game for 1-10 players, set in a procedurally-generated purgatory inspired by viking culture incl the Plugin Framework BepInEx
README
Valheim BepInEx
Author & Contributers
| Name | Github Profile | Buy me a Coffee |
|---|---|---|
| gOOvER | https://github.com/gOOvER |
Valheim
A brutal exploration and survival game for 1-10 players, set in a procedurally-generated purgatory inspired by viking culture. Battle, build, and conquer your way to a saga worthy of Odin’s patronage! https://store.steampowered.com/app/892970/Valheim/
BepInEx
BepInEx is a general purpose framework for Unity modding. BepInEx includes tools and libraries to
- load custom code (hereafter plugins) into the game on launch;
- patch in-game methods, classes and even entire assemblies without touching original game files;
- configure plugins and log game to desired outputs like console or file;
- manage plugin dependencies.
BepInEx is currently one of the most popular modding tools for Unity on GitHub.
This pack is preconfigured and usable for Valheim modding. In particular, the changes from base BepInEx releases are:
- Added preconfigured BepInEx.cfg with console enabled.
- Added unstripped Unity + Mono BCL DLLs for current versions of the game. See this issue comment for more info.
- Updated Doorstop configuration and BepInEx to allow to load unstripped DLLs without having to overwrite game DLLs.
- Added scripts necessary to run both game and dedicated server on Linux machines
Automatic Mod Downloading
Mods can be downloaded from modpacks automatically by entering the "dependency string" for the modpack from https://valheim.thunderstore.io/
Server Ports
| Port | default |
|---|---|
| Game | 2456 |
| Query | 2457 |
Updating
Because the DOORSTOP_CORLIB_OVERRIDE_PATH=./unstripped_corlib; has been removed from the startup with the latest update of this egg. If your server is already running, update the startup manually.
Docker Images (1)
| Name | Image |
|---|---|
ghcr.io/ptero-eggs/games:valheim | ghcr.io/ptero-eggs/games:valheim |
Startup Command
export DOORSTOP_ENABLED=1; export DOORSTOP_TARGET_ASSEMBLY=./BepInEx/core/BepInEx.Preloader.dll; export LD_LIBRARY_PATH="./doorstop_libs:$LD_LIBRARY_PATH"; export LD_PRELOAD="libdoorstop_x64.so:$LD_PRELOAD"; export LD_LIBRARY_PATH="./linux64:$LD_LIBRARY_PATH"; export SteamAppId=892970; ./valheim_server.x86_64 -nographics -batchmode -name "{{SERVER_NAME}}" -port {{SERVER_PORT}} -world "{{WORLD}}" -password "{{PASSWORD}}" -public {{PUBLIC_SERVER}} -saveinterval {{BACKUP_INTERVAL}} -backups {{BACKUP_COUNT}} -backupshort {{BACKUP_SHORTTIME}} -backuplong {{BACKUP_LONGTIME}} $( [[ {{ENABLE_CROSSPLAY}} -eq 1 ]] && echo " -crossplay ") > >(sed -uE "{{CONSOLE_FILTER}}") & trap "{{STOP}}" 15; wait $! Variables (17)
Server Name
Name that appears in server browser.
- Environment:
SERVER_NAME- Default:
My Server- User Viewable:
- ❌
- User Editable:
- ❌
- Rules:
required|string|max:60
Server Password
Server password.
- Environment:
PASSWORD- Default:
secret- User Viewable:
- ❌
- User Editable:
- ❌
- Rules:
required|string|min:5|max:20
World Name
Name to load if switching between multiple saved worlds.
- Environment:
WORLD- Default:
Dedicated- User Viewable:
- ❌
- User Editable:
- ❌
- Rules:
required|string|max:20
Public Server
- Environment:
PUBLIC_SERVER- Default:
1- User Viewable:
- ❌
- User Editable:
- ❌
- Rules:
required|boolean
Auto Update
- Environment:
AUTO_UPDATE- Default:
1- User Viewable:
- ❌
- User Editable:
- ❌
- Rules:
required|boolean
Enable Crossplay
Enable crossplay support
- Environment:
ENABLE_CROSSPLAY- Default:
0- User Viewable:
- ❌
- User Editable:
- ❌
- Rules:
required|boolean
Beta Branch
- Environment:
SRCDS_BETAID- Default:
None- User Viewable:
- ❌
- User Editable:
- ❌
- Rules:
max:30
Beta Password
- Environment:
SRCDS_BETAPASS- Default:
None- User Viewable:
- ❌
- User Editable:
- ❌
- Rules:
max:30
Backup Interval
Change how often the world will save in seconds. Default: 1800 (30 minutes).
- Environment:
BACKUP_INTERVAL- Default:
1800- User Viewable:
- ❌
- User Editable:
- ❌
- Rules:
required|numeric|min:0
Backup Count
Sets how many automatic backups will be kept. The first is the 'short' backup length, and the rest are the 'long' backup length. When default values are used means one backup that is 2 hours old, and 3 backups that are 12 hours apart. Default: 4.
- Environment:
BACKUP_COUNT- Default:
4- User Viewable:
- ❌
- User Editable:
- ❌
- Rules:
required|numeric|min:0
Backup Shorttime
Sets the interval between the first automatic backups in seconds. Default: 7200 (2 hours).
- Environment:
BACKUP_SHORTTIME- Default:
7200- User Viewable:
- ❌
- User Editable:
- ❌
- Rules:
required|numeric|min:0
Backup Longtime
Sets the interval between the subsequent automatic backups in seconds. Default: 43200 (12 hours).
- Environment:
BACKUP_LONGTIME- Default:
43200- User Viewable:
- ❌
- User Editable:
- ❌
- Rules:
required|numeric|min:0
[System] Console Filter
Remove unwanted outputs from the console.
- Environment:
CONSOLE_FILTER- Default:
/^\(Filename:.*Line:[[:space:]]+[[:digit:]]+\)$/d; /^([[:space:]]+)?$/d- User Viewable:
- ❌
- User Editable:
- ❌
- Rules:
string
[System] App ID
Valheim steam app id for auto updates.
- Environment:
SRCDS_APPID- Default:
896660- User Viewable:
- ❌
- User Editable:
- ❌
- Rules:
nullable|numeric
[System] LD Library Path
Required to load server libraries.
- Environment:
LD_LIBRARY_PATH- Default:
./linux64- User Viewable:
- ❌
- User Editable:
- ❌
- Rules:
required|string
[System] Shutdown Command
- Environment:
STOP- Default:
kill -2 $!; wait;- User Viewable:
- ❌
- User Editable:
- ❌
- Rules:
required|string|max:20
ModPack
Enter the Dependency String name for a ModPack to automatically be installed NOTE: If the modpack Updates, you will need to update this variable with the new Dependency String. This is done to allow Old Versions to be used. CHANGING THIS REQUIRES A SERVER REINSTALL
- Environment:
V_MODPACK- Default:
None- User Viewable:
- ❌
- User Editable:
- ❌
- Rules:
string|nullable
Installation Script
ghcr.io/ptero-eggs/installers:debianbash#!/bin/bash
# Valheim Installation Script
#
# Server Files: /mnt/server
# Image to install with is 'debian:buster-slim'
apt -y update
apt -y --no-install-recommends --no-install-suggests install wget
## just in case someone removed the defaults.
if [ "${STEAM_USER}" == "" ]; then
echo -e "steam user is not set.\n"
echo -e "Using anonymous user.\n"
STEAM_USER=anonymous
STEAM_PASS=""
STEAM_AUTH=""
else
echo -e "user set to ${STEAM_USER}"
fi
## download and install steamcmd
cd /tmp
mkdir -p /mnt/server/steamcmd
curl -sSL -o steamcmd.tar.gz https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
tar -xzvf steamcmd.tar.gz -C /mnt/server/steamcmd
cd /mnt/server/steamcmd
# SteamCMD fails otherwise for some reason, even running as root.
# This is changed at the end of the install process anyways.
chown -R root:root /mnt
export HOME=/mnt/server
## install game using steamcmd
./steamcmd.sh +force_install_dir /mnt/server +login ${STEAM_USER} ${STEAM_PASS} ${STEAM_AUTH} +app_update ${SRCDS_APPID} ${EXTRA_FLAGS} +quit
## set up 32 bit libraries
mkdir -p /mnt/server/.steam/sdk32
cp -v linux32/steamclient.so ../.steam/sdk32/steamclient.so
## set up 64 bit libraries
mkdir -p /mnt/server/.steam/sdk64
cp -v linux64/steamclient.so ../.steam/sdk64/steamclient.so
echo "-------------------------------------------------------"
echo "installing BepInEx and Selected ModPacks..."
echo "-------------------------------------------------------"
if ! api_response=$(curl -sfSL -H "accept: application/json" "https://thunderstore.io/api/experimental/package/denikson/BepInExPack_Valheim/"); then
fatal "Error: could not retrieve BepInEx release info from Thunderstore.io API"
fi
download_url=$(jq -r ".latest.download_url" <<< "$api_response" )
version_number=$(jq -r ".latest.version_number" <<< "$api_response" )
if [ ! -z "$V_MODPACK" ]
then
#Modpack Name dashes to slashes for URL
V_MODPACK=$(echo "$V_MODPACK" | sed 's/-/\//g')
#Extract dependencies from ModPack JSON data
V_MODPACK_DEPENDENCIES=$(curl -sfSL -H "accept: application/json" "https://thunderstore.io/api/experimental/package/${V_MODPACK}" | jq -r '.dependencies[]')
fi
cd /mnt/server
#echo $download_url
wget --content-disposition $download_url
unzip -o denikson-BepInExPack_Valheim-${version_number}.zip
cp -r /mnt/server/BepInExPack_Valheim/* /mnt/server
if [ ! -z "$V_MODPACK" ]
then
#Delete Old Mods
rm -rf /mnt/server/BepInEx/plugins/*
#Download and extract the modpack dlls files
for V_MODPACK_DEPENDENCY in $V_MODPACK_DEPENDENCIES; do
#ignore bepinex
if [[ "$V_MODPACK_DEPENDENCY" == *"denikson-BepInExPack_Valheim"* ]]; then
continue # Skip this dependency
fi
#replace dashes with slashes for url
V_MODPACK_DEPENDENCY_WITH_SLASH=$(echo "$V_MODPACK_DEPENDENCY" | sed 's/-/\//g')
#download dependencies
wget -O "$V_MODPACK_DEPENDENCY.zip" "https://thunderstore.io/package/download/$V_MODPACK_DEPENDENCY_WITH_SLASH"
#Set the destination directory and ensure it exists
destination_directory="/mnt/server/BepInEx/plugins"
if [ ! -d "$destination_directory" ]; then
mkdir -p "$destination_directory"
fi
#Extract DLL files from the ZIP and delete the zip file
unzip -j "$V_MODPACK_DEPENDENCY.zip" "*.dll" -d "$destination_directory"
#Cleanup
rm $V_MODPACK_DEPENDENCY.zip
done
fi
##cleanup
echo "-------------------------------------------------------"
echo "cleanup files..."
echo "-------------------------------------------------------"
rm -fR BepInExPack_Valheim
rm -fR icon.png
rm -fR denikson-BepInExPack_Valheim-*
rm -fR manifest.json
rm -fR README.m
#rm -fR start_*
echo "-------------------------------------------------------"
echo "Installation completed"
echo "-------------------------------------------------------"