5 changed files with 146 additions and 12 deletions
@ -1,2 +1,113 @@ |
|||
#!/bin/bash |
|||
steamcmd +login anonymous +force_install_dir /home/vhadmin/ +app_update 896660 validate +exit |
|||
|
|||
# Check if server is active |
|||
status=$(systemctl show valheim -p ActiveState --value) |
|||
# shutdown server if it is active |
|||
if [[ $status == active ]]; then |
|||
echo "Server is active: executing shutdown..." |
|||
systemctl stop valheim |
|||
sleep 1 |
|||
fi |
|||
|
|||
# Install Valheim |
|||
installdir="/home/vhadmin" |
|||
steamcmd +login anonymous +force_install_dir "$installdir" +app_update 896660 validate +exit |
|||
|
|||
# Install Mods |
|||
modsite="https://valheim.thunderstore.io" |
|||
moddir="$installdir/BepInEx/plugins" |
|||
|
|||
rm_ife() { |
|||
if [[ -e "$1" ]]; then |
|||
rm -r "$1" |
|||
fi |
|||
} |
|||
|
|||
get_modver() { |
|||
mod="$1" |
|||
modauthor=$(echo "$mod" | cut -d '-' -f 1) |
|||
modname=$(echo "$mod" | cut -d '-' -f 2) |
|||
modpath="$modauthor/$modname" |
|||
|
|||
web_version=$(wget -qO - "$modsite/package/$modpath/" | grep -oP "/package/download/$modpath/\K([\d.]+)" | head -1) |
|||
loc_version=$(grep -osP '"version_number": "\K([\d.]+)' "$moddir/$mod/manifest.json") |
|||
|
|||
if [[ $web_version != $loc_version ]]; then |
|||
echo $web_version |
|||
fi |
|||
} |
|||
|
|||
dl_mod() { |
|||
modauthor=$(echo "$1" | cut -d '-' -f 1) |
|||
modname=$(echo "$1" | cut -d '-' -f 2) |
|||
modpath="$modauthor/$modname" |
|||
|
|||
wget -qO "$mod.zip" "$modsite/package/download/$modpath/$2" |
|||
} |
|||
|
|||
tmpdir=$(mktemp -d) |
|||
cd "$tmpdir" |
|||
|
|||
# Install BepinEx |
|||
mod='denikson-BepInExPack_Valheim' |
|||
modver=$(get_modver "$mod") |
|||
if [[ -n $modver ]]; then |
|||
echo "Installing mod: $mod" |
|||
dl_mod "$mod" "$modver" |
|||
unzip -q "$mod.zip" |
|||
mkdir "BepInExPack_Valheim/BepInEx/plugins/$mod" |
|||
mv BepInExPack_Valheim/BepInEx/plugins/*.dll "BepInExPack_Valheim/BepInEx/plugins/$mod/" |
|||
mv manifest.json README.md "BepInExPack_Valheim/BepInEx/plugins/$mod/" |
|||
rm -r BepInExPack_Valheim/BepInEx/config |
|||
ln -s /vol/data/config/BepInEx BepInExPack_Valheim/BepInEx/config |
|||
mv BepInExPack_Valheim/* "$installdir/" |
|||
rm -r * |
|||
else |
|||
echo "Mod already latest: $mod" |
|||
fi |
|||
|
|||
# Install Additional Mods |
|||
if [[ -e /vol/data/config/server ]]; then |
|||
. /vol/data/config/server |
|||
else |
|||
vh_mods=() |
|||
fi |
|||
|
|||
for mod in "${vh_mods[@]}"; do |
|||
modver=$(get_modver "$mod") |
|||
if [[ -n $modver ]]; then |
|||
echo "Installing mod: $mod" |
|||
dl_mod "$mod" "$modver" |
|||
unzip -q "$mod.zip" |
|||
# annoyingly, mod zips don't all have the same structure |
|||
# find all .dll files, and put them in the plugin dir |
|||
mkdir -p "$moddir/$mod/" |
|||
for dll in $(find -name '*.dll'); do |
|||
mv "$dll" "$moddir/$mod/" |
|||
done |
|||
mv manifest.json README.md "$moddir/$mod/" |
|||
rm -r * |
|||
else |
|||
echo "Mod already latest: $mod" |
|||
fi |
|||
done |
|||
|
|||
vh_mods+=('denikson-BepInExPack_Valheim') |
|||
cd "$moddir" |
|||
|
|||
for mod in *; do |
|||
if $(echo "${vh_mods[@]}" | grep -qv "\b$mod\b"); then |
|||
echo "Removing mod: $mod" |
|||
rm -r "$mod" |
|||
fi |
|||
done |
|||
|
|||
# Clean Up |
|||
rm -r "$tmpdir" |
|||
chown -R vhadmin:vhadmin $installdir |
|||
# start server back up if it was active |
|||
if [[ $status == active ]]; then |
|||
echo "Server was active: starting server again..." |
|||
systemctl start valheim |
|||
sleep 5 |
|||
fi |
|||
|
@ -1,15 +1,24 @@ |
|||
#!/bin/bash |
|||
export templdpath=$LD_LIBRARY_PATH |
|||
export LD_LIBRARY_PATH=./linux64:$LD_LIBRARY_PATH |
|||
|
|||
# BepInEx-specific settings |
|||
# NOTE: Do not edit unless you know what you are doing! |
|||
#### |
|||
export DOORSTOP_ENABLE=TRUE |
|||
export DOORSTOP_INVOKE_DLL_PATH=./BepInEx/core/BepInEx.Preloader.dll |
|||
export DOORSTOP_CORLIB_OVERRIDE_PATH=./unstripped_corlib |
|||
|
|||
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 |
|||
|
|||
echo "Starting server" |
|||
echo "Starting server..." |
|||
|
|||
# Load Config |
|||
. /vol/data/config/server |
|||
|
|||
# NOTE: Minimum password length is 5 characters & Password cant be in the server name. |
|||
# NOTE: You need to make sure the ports 2456-2458 is being forwarded to your server through your local router & firewall. |
|||
./valheim_server.x86_64 -name "${vh_name:?}" -port 2456 -world "${vh_world:?}" -password "${vh_pass:?}" -public ${vh_public:?} |
|||
|
|||
export LD_LIBRARY_PATH=$templdpath |
|||
exec ./valheim_server.x86_64 -name "${vh_name:?}" -port "${vh_port:?}" -world "${vh_world:?}" -password "${vh_pass:?}" -public "${vh_public:?}" |
|||
|
@ -0,0 +1,11 @@ |
|||
[Unit] |
|||
After=network-online.target local-fs.target |
|||
Before=valheim.service |
|||
Description=Valheim install/update service |
|||
|
|||
[Service] |
|||
ExecStart=/usr/local/bin/vh-install |
|||
Type=oneshot |
|||
|
|||
[Install] |
|||
WantedBy=multi-user.target |
Loading…
Reference in new issue