brianmiller / phvalheim-server

PhValheim backend server
GNU General Public License v2.0
26 stars 5 forks source link

Encountered some issues with importWorld.sh #47

Open Garethp opened 7 months ago

Garethp commented 7 months ago

I encountered some errors in importWorld.sh which I managed to fix with some minor tweaking, so I thought I'd create an issue for them and look at contributing those fixes.

  1. I got a syntax error for if [ $worldName == "" ]; then which I managed to fix by changing it to if [[ $worldName == "" ]]; then
  2. If your import doesn't have .config/unity3d/IronGate/Valheim/prefs, then the script fails to insert a record into the DB for that world because $worldCreation is empty. This I solved with
if [ -z "$worldCreation" ]; then
    worldCreation=$(date +'%F %T')
fi

Additionally, I had to add an extra option to check for worlds in another location in the import_wip folder because I was importing from an export I did on a dedicated game server, not from my local computer. It'd be nice to have a --world option to point directly to the file you want to import. I first tried

if [ -d "import_wip/worlds" ]; then
        worldDir="import_wip/worlds"
fi

Which is where my .db and .fwl files were location however the script failed to cp from there, even though the location was correct. Instead, I had to change it to an absolute path, and it copied correctly:

        worldDir="/opt/stateless/games/valheim/scripts/import_wip/worlds"

It might be worth adding the current working directory here and here to make them absolute paths as well.

Also, even if it's not ready yet it would still be good to have some mention of this import script in the README, since there doesn't appear to be any other method for importing worlds

brianmiller commented 5 months ago

Nice additions... yes,.. it's a quick script to selfishly help me.

Maybe it's time to add a real import function...