Egg Repository

Pterodactyl Community Egg Repository

Valheim BepINex

A brutal exploration and survival game for 1-10 players, set in a procedurally-generated purgatory inspired by viking culture incl the Plugin Framework BepInEx

Read Me

Valheim BepInEx

Author & Contributers

Name Github Profile Buy me a Coffee
gOOvER https://github.com/gOOvER ko-fi

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.

Yolks
NameTag
ghcr.io/ptero-eggs/games:valheimghcr.io/ptero-eggs/games:valheim
Variables
NameDescriptionEnvironment VariableDefault ValueUser ViewableUser Editable
Server NameName that appears in server browser.SERVER_NAMEMy ServerYesYes
Server PasswordServer password.PASSWORDsecretYesYes
World NameName to load if switching between multiple saved worlds.WORLDDedicatedYesYes
Public ServerPUBLIC_SERVER1YesYes
Auto UpdateAUTO_UPDATE1YesYes
Enable CrossplayEnable crossplay supportENABLE_CROSSPLAY0YesYes
Beta BranchSRCDS_BETAIDYesYes
Beta PasswordSRCDS_BETAPASSYesYes
Backup IntervalChange how often the world will save in seconds. Default: 1800 (30 minutes).BACKUP_INTERVAL1800YesYes
Backup CountSets 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.BACKUP_COUNT4YesYes
Backup ShorttimeSets the interval between the first automatic backups in seconds. Default: 7200 (2 hours).BACKUP_SHORTTIME7200YesYes
Backup LongtimeSets the interval between the subsequent automatic backups in seconds. Default: 43200 (12 hours).BACKUP_LONGTIME43200YesYes
[System] Console FilterRemove unwanted outputs from the console.CONSOLE_FILTER/^\(Filename:.*Line:[[:space:]]+[[:digit:]]+\)$/d; /^([[:space:]]+)?$/dNoNo
[System] App IDValheim steam app id for auto updates.SRCDS_APPID896660YesNo
[System] LD Library PathRequired to load server libraries.LD_LIBRARY_PATH./linux64NoNo
[System] Shutdown CommandSTOPkill -2 $!; wait;NoNo
ModPackEnter 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 REINSTALLV_MODPACKYesYes
Install Script
#!/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 "-------------------------------------------------------"