4 changed files with 56 additions and 253 deletions
@ -0,0 +1,55 @@ |
|||
A Saga of how a Viking <strike>wrote</strike> *bash*ed some <strike>scripts</strike> runes together that led him on a journey to the tenth (or so) missing realm of Valheim! |
|||
|
|||
... *pausing for effect* ... |
|||
|
|||
Upon the whims of Odin, I was chosen to undergo the trial of Valheim, where, by chance, I met my liege, Sir Gloor, an outstanding burly Viking Warrior and Shaman (long beard, pointy hat), who had long discovered the secrets of Valheim, due to his divine connections. Blah blah blah ...etc. etc. etc., (skip the prologue)....booorrrriiinnngggg. Anyways, in order to be able to set out on adventures on dedicated servers, I'll point out some viking-ways to get you set up. First, you'll need 5 wood and 2 stones... |
|||
|
|||
I won't go into to much detail, as lot of the knowledge to run on a server is similar to other server in Linuxgsm. So I will point to links to their site as I go along. You can either copy the whole repository, or just wget <path_to_Linuxgsm.sh>. |
|||
First the game has it's own parameters for starting that should be set. Like other games managed with Linuxgsm, these can be found in the corresponding game folder, in Valheim's case: lgsm/config-default/config-lgsm/vhserver/_default.cfg. You shouldn't edit this file, as a copy will be made elsewhere upon installing the server, at lgsm/conifg-lgsm/vhserver/_default.cfg. Note: this file is always checked by the code if it has been changed, and will always be reset to match the version of github. |
|||
|
|||
I will suggest setting the following in the common.cfg, which will apply to all game instances created: |
|||
`- steamuser=` |
|||
|
|||
(In the _default.cfg, I mention at the steam section, that you should login prior to install, as the default is to log on anonymously, which is, at the time of this writting, not allowed, as the server requires username and password. You should only need to set your username within the configuration file (common.cfg or '*instance*.cfg), and after logging on manually into steamcmd and entering your password once, it should remember the server as trustworthy. You may need to enter it manually again later, depending, otherwise you can add steampass="" in the file as well. It's just a matter of security, depending if you are willing to risk your steam account, should the server be compromised.) |
|||
|
|||
And then for specific game instances (i.e. vhserver, vhserver-2, etc.), you should |
|||
- `name` (server name as it appears in steam server list) |
|||
- `world` (the save name of the game world found under .config/unity3d/IronGate/Valheim/worlds/ ) |
|||
- `password` |
|||
- `public` (if you wish to change the default value: public) |
|||
|
|||
Technically, you can choose which settings are global for all servers (common.cfg) or localised for just a specific instance (*instance*.cfg). It is up to you to sharpen your axe and make the best choice for your situation. For example, I've chosen to make notification "global", turning them on in the common.cfg, so all games will be reported. |
|||
|
|||
Depending if you have a beta branch: |
|||
- `branch` |
|||
- `branchpassword` (this is presently lacking in the parent branch of Linuxgsm, but works for Valheim! Viking Power!) |
|||
|
|||
There are suggestions and steps to backing up the the entire server setup of Linuxgsm: https://docs.linuxgsm.com/commands/backup |
|||
I have done that, but I have also included, similarly, the automating backups of the actual world file (.config/unity3d/IronGate/Valheim/worlds/). Here is an example: |
|||
```bash |
|||
#!/bin/bash |
|||
cd /home/<user>/.config/unity3d/IronGate/Valheim/worlds/ |
|||
|
|||
files=`ls ./*.fwl` |
|||
for i in $files |
|||
do |
|||
file=`basename -s .fwl $i` |
|||
tar -czf "$1_$file.tar.gz" $file.fwl $file.db |
|||
done; |
|||
``` |
|||
This script combines to the files need for the world into one tar file, and does so for every unique world file. It takes a name as a parameter and places it in front of the world's name. So I have a monthly back up called Monthly_<world_name>.tar.gz, that automatically overwrites itself every month. And similarly, the daily backup overwrites itself everyday. You can customize it as needed. This is an excerpt from cronjob: |
|||
``` |
|||
#Valheim World Backups |
|||
0 0 * * * /home/<user>/<script_name>.sh Daily >/dev/null 2>&1 |
|||
0 1 1 * * /home/<user>/<script_name>.sh Monthly >/dev/null 2>&1 |
|||
``` |
|||
#$@&%*! *swearing after smashing a finger with the hammer while chiseling the words out* |
|||
|
|||
Presently, gamedig does not support Valheim, so I've set the default to check the session value, which is adequet. |
|||
|
|||
At this time in writing, I've added alert notification for rocketchat, which on the main repository is presently lacking. |
|||
|
|||
|
|||
All is as Odin wishes, |
|||
|
|||
A Saga, by the IT Viking |
@ -1 +0,0 @@ |
|||
A Saga of how a Viking <strike>wrote</strike> bashed some <strike>scripts</strike> runes together that led him on a journey to the missing tenth (or so) missing realm of Valheim! |
@ -1,252 +0,0 @@ |
|||
#!/bin/bash |
|||
# LinuxGSM update_steamcmd.sh function |
|||
# Author: Daniel Gibbs |
|||
# Website: https://linuxgsm.com |
|||
# Description: Handles updating using SteamCMD. |
|||
|
|||
functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" |
|||
|
|||
fn_update_steamcmd_dl(){ |
|||
info_config.sh |
|||
# Detects if unbuffer command is available for 32 bit distributions only. |
|||
info_distro.sh |
|||
if [ "$(command -v stdbuf)" ]&&[ "${arch}" != "x86_64" ]; then |
|||
unbuffer="stdbuf -i0 -o0 -e0" |
|||
fi |
|||
if [ -d "${steamcmddir}" ]; then |
|||
cd "${steamcmddir}" || exit |
|||
fi |
|||
|
|||
# If GoldSrc (appid 90) servers. GoldSrc (appid 90) require extra commands. |
|||
if [ "${appid}" == "90" ]; then |
|||
# If using a specific branch. |
|||
if [ -n "${branch}" ]; then |
|||
${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" -beta "${branch}" +quit | tee -a "${lgsmlog}" |
|||
else |
|||
${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" +quit | tee -a "${lgsmlog}" |
|||
fi |
|||
elif [ "${shortname}" == "ac" ]; then |
|||
${unbuffer} ${steamcmdcommand} +@sSteamCmdForcePlatformType windows +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" +quit |
|||
# All other servers. |
|||
else |
|||
if [ -n "${branch}" ]; then |
|||
if [ -n "${branchpassword}" ]; then |
|||
${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" -beta "${branch}" -betapassword "${branchpassword}" +quit | tee -a "${lgsmlog}" |
|||
else |
|||
${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" -beta "${branch}" +quit | tee -a "${lgsmlog}" |
|||
fi |
|||
else |
|||
${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" +quit | tee -a "${lgsmlog}" |
|||
fi |
|||
fi |
|||
fix.sh |
|||
} |
|||
|
|||
fn_update_steamcmd_localbuild(){ |
|||
# Gets local build info. |
|||
fn_print_dots "Checking local build: ${remotelocation}" |
|||
fn_appmanifest_check |
|||
# Uses appmanifest to find local build. |
|||
localbuild=$(grep buildid "${appmanifestfile}" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3) |
|||
|
|||
# Set branch for updateinfo. |
|||
IFS=' ' read -ra branchsplits <<< "${branch}" |
|||
if [ "${#branchsplits[@]}" -gt 1 ]; then |
|||
branchname="${branchsplits[1]}" |
|||
else |
|||
branchname="public" |
|||
fi |
|||
|
|||
# Checks if localbuild variable has been set. |
|||
if [ -z "${localbuild}" ]||[ "${localbuild}" == "null" ]; then |
|||
fn_print_fail "Checking local build: ${remotelocation}" |
|||
fn_script_log_fatal "Checking local build" |
|||
core_exit.sh |
|||
else |
|||
fn_print_ok "Checking local build: ${remotelocation}" |
|||
fn_script_log_pass "Checking local build" |
|||
fi |
|||
} |
|||
|
|||
fn_update_steamcmd_remotebuild(){ |
|||
# Gets remote build info. |
|||
if [ -d "${steamcmddir}" ]; then |
|||
cd "${steamcmddir}" || exit |
|||
fi |
|||
|
|||
# Removes appinfo.vdf as a fix for not always getting up to date version info from SteamCMD. |
|||
if [ "$(find "${HOME}" -type f -name "appinfo.vdf" | wc -l)" -ne "0" ]; then |
|||
find "${HOME}" -type f -name "appinfo.vdf" -exec rm -f {} \; |
|||
fi |
|||
|
|||
remotebuild=$(${steamcmdcommand} +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +quit | sed '1,/branches/d' | sed "1,/${branchname}/d" | grep -m 1 buildid | tr -cd '[:digit:]') |
|||
if [ "${installer}" != "1" ]; then |
|||
fn_print_dots "Checking remote build: ${remotelocation}" |
|||
# Checks if remotebuild variable has been set. |
|||
if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then |
|||
fn_print_fail "Checking remote build: ${remotelocation}" |
|||
fn_script_log_fatal "Checking remote build" |
|||
core_exit.sh |
|||
else |
|||
fn_print_ok "Checking remote build: ${remotelocation}" |
|||
fn_script_log_pass "Checking remote build" |
|||
fi |
|||
else |
|||
# Checks if remotebuild variable has been set. |
|||
if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then |
|||
fn_print_failure "Unable to get remote build" |
|||
fn_script_log_fatal "Unable to get remote build" |
|||
core_exit.sh |
|||
fi |
|||
fi |
|||
} |
|||
|
|||
fn_update_steamcmd_compare(){ |
|||
fn_print_dots "Checking for update: ${remotelocation}" |
|||
if [ "${localbuild}" != "${remotebuild}" ]; then |
|||
fn_print_ok_nl "Checking for update: ${remotelocation}" |
|||
echo -en "\n" |
|||
echo -e "Update available" |
|||
echo -e "* Local build: ${red}${localbuild}${default}" |
|||
echo -e "* Remote build: ${green}${remotebuild}${default}" |
|||
if [ -v "${branch}" ]; then |
|||
echo -e "* Branch: ${branch}" |
|||
fi |
|||
echo -e "https://steamdb.info/app/${appid}/" |
|||
echo -en "\n" |
|||
fn_script_log_info "Update available" |
|||
fn_script_log_info "Local build: ${localbuild}" |
|||
fn_script_log_info "Remote build: ${remotebuild}" |
|||
if [ -v "${branch}" ]; then |
|||
fn_script_log_info "Branch: ${branch}" |
|||
fi |
|||
fn_script_log_info "${localbuild} > ${remotebuild}" |
|||
|
|||
unset updateonstart |
|||
check_status.sh |
|||
# If server stopped. |
|||
if [ "${status}" == "0" ]; then |
|||
fn_update_steamcmd_dl |
|||
# If server started. |
|||
else |
|||
fn_stop_warning |
|||
exitbypass=1 |
|||
command_stop.sh |
|||
exitbypass=1 |
|||
fn_update_steamcmd_dl |
|||
exitbypass=1 |
|||
command_start.sh |
|||
fi |
|||
date +%s > "${lockdir}/lastupdate.lock" |
|||
alert="update" |
|||
alert.sh |
|||
else |
|||
fn_print_ok_nl "Checking for update: ${remotelocation}" |
|||
echo -en "\n" |
|||
echo -e "No update available" |
|||
echo -e "* Local build: ${green}${localbuild}${default}" |
|||
echo -e "* Remote build: ${green}${remotebuild}${default}" |
|||
if [ -v "${branch}" ]; then |
|||
echo -e "* Branch: ${branch}" |
|||
fi |
|||
echo -e "https://steamdb.info/app/${appid}/" |
|||
echo -en "\n" |
|||
fn_script_log_info "No update available" |
|||
fn_script_log_info "Local build: ${localbuild}" |
|||
fn_script_log_info "Remote build: ${remotebuild}" |
|||
if [ -v "${branch}" ]; then |
|||
fn_script_log_info "Branch: ${branch}" |
|||
fi |
|||
fi |
|||
} |
|||
|
|||
fn_appmanifest_info(){ |
|||
appmanifestfile=$(find "${serverfiles}" -type f -name "appmanifest_${appid}.acf") |
|||
appmanifestfilewc=$(find "${serverfiles}" -type f -name "appmanifest_${appid}.acf" | wc -l) |
|||
} |
|||
|
|||
fn_appmanifest_check(){ |
|||
fn_appmanifest_info |
|||
# Multiple or no matching appmanifest files may sometimes be present. |
|||
# This error is corrected if required. |
|||
if [ "${appmanifestfilewc}" -ge "2" ]; then |
|||
fn_print_error "Multiple appmanifest_${appid}.acf files found" |
|||
fn_script_log_error "Multiple appmanifest_${appid}.acf files found" |
|||
fn_print_dots "Removing x${appmanifestfilewc} appmanifest_${appid}.acf files" |
|||
for appfile in ${appmanifestfile}; do |
|||
rm -f "${appfile:?}" |
|||
done |
|||
appmanifestfilewc1="${appmanifestfilewc}" |
|||
fn_appmanifest_info |
|||
# if error can not be resolved. |
|||
if [ "${appmanifestfilewc}" -ge "2" ]; then |
|||
fn_print_fail "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files" |
|||
fn_script_log_fatal "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files" |
|||
echo -e "* Check user permissions" |
|||
for appfile in ${appmanifestfile}; do |
|||
echo -e " ${appfile}" |
|||
done |
|||
core_exit.sh |
|||
else |
|||
fn_print_ok "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" |
|||
fn_script_log_pass "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" |
|||
fn_print_info_nl "Forcing update to correct issue" |
|||
fn_script_log_info "Forcing update to correct issue" |
|||
fn_update_steamcmd_dl |
|||
fi |
|||
elif [ "${appmanifestfilewc}" -eq "0" ]; then |
|||
fn_print_error_nl "No appmanifest_${appid}.acf found" |
|||
fn_script_log_error "No appmanifest_${appid}.acf found" |
|||
fn_print_info_nl "Forcing update to correct issue" |
|||
fn_script_log_info "Forcing update to correct issue" |
|||
fn_update_steamcmd_dl |
|||
fn_appmanifest_info |
|||
if [ "${appmanifestfilewc}" -eq "0" ]; then |
|||
fn_print_fail_nl "Still no appmanifest_${appid}.acf found" |
|||
fn_script_log_fatal "Still no appmanifest_${appid}.acf found" |
|||
core_exit.sh |
|||
fi |
|||
fi |
|||
} |
|||
|
|||
fn_stop_warning(){ |
|||
fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" |
|||
fn_script_log_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" |
|||
totalseconds=3 |
|||
for seconds in {3..1}; do |
|||
fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update: ${totalseconds}" |
|||
totalseconds=$((totalseconds - 1)) |
|||
sleep 1 |
|||
if [ "${seconds}" == "0" ]; then |
|||
break |
|||
fi |
|||
done |
|||
fn_print_warn_nl "Updating server: SteamCMD: ${selfname} will be stopped during update" |
|||
} |
|||
|
|||
# The location where the builds are checked and downloaded. |
|||
remotelocation="SteamCMD" |
|||
check_steamcmd.sh |
|||
|
|||
if [ "${forceupdate}" == "1" ]; then |
|||
# forceupdate bypasses update checks. |
|||
check_status.sh |
|||
if [ "${status}" != "0" ]; then |
|||
fn_stop_warning |
|||
exitbypass=1 |
|||
command_stop.sh |
|||
fn_update_steamcmd_dl |
|||
date +%s > "${lockdir}/lastupdate.lock" |
|||
exitbypass=1 |
|||
command_start.sh |
|||
else |
|||
fn_update_steamcmd_dl |
|||
date +%s > "${lockdir}/lastupdate.lock" |
|||
fi |
|||
else |
|||
fn_print_dots "Checking for update" |
|||
fn_print_dots "Checking for update: ${remotelocation}" |
|||
fn_update_steamcmd_localbuild |
|||
fn_update_steamcmd_remotebuild |
|||
fn_update_steamcmd_compare |
|||
fi |
Loading…
Reference in new issue