1. When making a thread, please tag your thread accordingly using the menu to the left of the textfield where you name your thread where applicable. Server Advertisements and Mod Releases should be contained to their respective subforums.

Server Help How to change the universe directory?

Discussion in 'Multiplayer' started by Zigadenus, Aug 29, 2016.

  1. Zigadenus

    Zigadenus Scruffy Nerf-Herder

    Greetings,
    I am new to this forum. I am using the GOG version of Starbound on Linux (Kubuntu 14.04).

    How can I change the server's universe directory? When I start the server, it loads the same universe files the single player game is using. Is there any way to seperate 1P and MP universes besides using another installation directory or user account for the server? I didn't find any such starbound_server.config option or command line option on the web.

    Thanks for any advice
    Zigadenus
     
  2. Ledhead

    Ledhead Phantasmal Quasar

    I presume you already run the starbound_dedicated.exe instead of simply joining game via IP using SP to host.
    Win32 or Win64 folder depending on which ever server executable you use. You will find a file called sbinit.config which contains -
    Code:
    {
      "assetDirectories" : [
        "..\\assets\\",
        "..\\mods\\"
      ],
    
      "storageDirectory" : "..\\storage\\",
    
      "defaultConfiguration" : {
        "gameServerBind" : "*",
        "queryServerBind" : "*",
        "rconServerBind" : "*"
      }
    }
    you are going to want to edit line 7, and change "..\\storage\\", too another directory maybe something like "..\\storagemulti\\" this will change the location where universes and player files are stored in and it will now be seperate from SP however you will need to make a backup of the original file before hand and change files each time you want to run a seperate universe, you may also need to copy your player files into the new folder.

    Alternatively you can just swap universe folders in the storage folder whenever you want to try a new universe

    To be honest, it is much much less mucking around too duplicate the game elsewhere for hosting servers and using one of the many methods available to link workshop content into the mods dir.
     
  3. Zigadenus

    Zigadenus Scruffy Nerf-Herder

    Thanks, I will test that. On Linux, sbinit.config is in the folder game/linux and the server executable is named starbound_server. (Mentioned for other Linux users.)
    I just want to permanently separate my SP universe from the server universe, preferably within one Starbound installation. If the storageDirectory entry in the sbinit.config is doing that, it's exactly what I'm looking for. I will post my results after testing, thanks again.
     
  4. Ledhead

    Ledhead Phantasmal Quasar

    It will work :) just make sure you rename the old one to something else such as sbinit.config.old or and swap between them for SP or MP.
     
  5. Zigadenus

    Zigadenus Scruffy Nerf-Herder

    Ah, I overlooked that in your previous post. :oops: Unfortunately it's not exactly what I'm looking for. I don't want to switch the config file every time I start the server or client, though I could make a script doing that. I'm looking for a way to permanently tell the server to use another universe directory than the client without workarounds like two installations or config swapping. If SB really has no "normal" way to change only the server universe directory, I may make a feature request in the suggestions forum.

    That said, your tip solves my problem for now. :party: I will have time to test it at the weekend. Stay tuned.
     
  6. Ledhead

    Ledhead Phantasmal Quasar

    Well you could use symbolic links and remove the storage folder from the base game completely and then you could use two shortcuts one for sp one for mp.
     
  7. Zigadenus

    Zigadenus Scruffy Nerf-Herder

    Could you please elaborate on that? Client and server would still use the same storage whether "real" or linked, no?

    I'm off to work now. :)
     
  8. Ledhead

    Ledhead Phantasmal Quasar

    Sure, first some info on mklink.
    Symbolic link is a process which is able to trick the system into thinking a directory exists where the link is placed but in actual fact the folder or file could exist on a remote network drive or an entire different drive.

    I use this trick too link workshop mods to the mods dir of a server, the game doesn't read the pak file thinking its in the workshop sub folder it loads it as if I placed the pak file into the mods folder :) what this means for you is -

    You could create a new folder on your storage drive somewhere and call it "Starbound universes" then move the storage folder from the Starbounds dir into this new folder, rename it 'single-player' them duplicate it and call it 'multiplayer' now clear the universe files from the multiplayer folder.
    Now this part is the tricky bit, you would now create two symbolic links one for the SP and one for the MP name they will appear like a windows shortcut and 0kb file size. Name them both "storage" now you have completely separated the universes from the game folder you just place which ever link you want at the time into the Starbound dir and it should in theory trick the game into thinking the folder storage is actually in the games dir but really it's a completely different name and located somewhere else.

    You could use this trick along with a windows script or shortcut to switch the links out when you launch said Starbound.exe so you would have two Starbound shortcuts one will link too the mp and one the sp then just launch which one you want at the time.

    You could do the opposite of this since a symbolic link is 0kb in size as you are not actually moving or making any copies of the file so you loose no storage as a result. This means you could instead create a new Starbound folder somewhere in your system and symbolic link every folder and file in the original Starbound game directory except for the storage folder ;) I think you can see what twill happen here.

    The new Starbound will behave exactly like the original as if you copied it all except with a file size of 0kb the only extra space would be the new storage folder.

    Keep in mind doing it this way will allow Starbound to update via steam as normal since we are not making a new Starbound copy we are linking the original meaning any mods or edits, updates to your Starbound via steam will take effect immediately on your linked copy ;) very useful and saves HDD space aswell as time re copying when things update.


    Skim this http://www.makeuseof.com/tag/what-is-a-symbolic-link-what-are-its-uses-makeuseof-explains/ you will soon understand this hidden feature of Windows and Linux and my rumblings will make a lot more sense as for how it works.

    Alternatively if you didn't want to just copy the Starbound game to due hassles of getting workshop mods to load on your new copy this symbolic link method will work that and cost you no storage space. I have a tool on here called (Starbound Workshop Easy Linker) posted it today in the modding section which does the task for you!

    You can use this to link your current workshop and Starbound mods and the best part is you can copy the shortcuts created in your mods dir right into your copied Starbound install :) as the link will work from absolutely any location on your system.

    I hope this helps, I can explain better when I'm at my workspace or add me on steam you can find my steam url in my profile and I can send you example images or if you really want to know now you can google or look on my steam profile for my Starbound workshop linking guide which has images and has a tool to make the links yourself easily.
     
    Last edited: Sep 2, 2016
  9. Zigadenus

    Zigadenus Scruffy Nerf-Herder

    Thanks for the very comprehensive description and your kind offer to send me examples. Although I still don't use Windows and have the GOG version of Starbound ;) (see above) I'm familiar with all three kinds of Windows' links. Linux only has two kind of links, symbolic and hardlinks. Only the former can link directories, they are comparable to Windows' shortcuts – not its symbolic links. This can lead to misunderstandings between Windows and Linux users, thence this short clarification. Linux' hardlinks can only link files, they're just additional directory entries pointing to the same data on the drive.

    So this is indeed another functioning workaround. I don't like Linux' symlinks because they're just shortcuts = files themselves, not part of the file system itself, and thus not completely transparent to both system and programs. But I could easily recreate the whole Starbound installation directory as hard linked files in real directories so they don't use any additional hard drive space (apart from some bytes for the directory entries). This is done via this command:

    Code:
    cp -al source dest
    It recreates the whole "source" tree (option -a) in "dest" but doesn't copy (cp) but hard link (option -l) the files.

    After that, I would empty the storage directory of the linked version so that the server creates a new universe there. Then I can start the client or server with the universe of my choosing by starting them from the respective directory. Again, thanks for pointing me towards this alternative.



    While I'm devising solutions for any Linux users, :geek: here's a simple way to change the storage directory in the sbinit.config itself by using the program "sed" which is pre-installed on most Linux systems. It changes a text file directly.
    Code:
    sed -i s/storage/storage.multi/g sbinit.config
    would change "storage" to "storage.multi" and
    Code:
    sed -i s/storage.multi/storage/g sbinit.config
    would change it back to "storage".

    Time's up again, more next time. Thanks for the stimulating exchange!
     
  10. Ledhead

    Ledhead Phantasmal Quasar

    Ooo nice seems Unix systems have some good and bad points vs windows to clarify I didn't know if you had any understanding of deeper system options so I wrote it expecting zero understanding :) glad to help either way. Certainly would be easier if chuckle just implemented multiple universes but I can see why they didn't go this route.
     
  11. Zigadenus

    Zigadenus Scruffy Nerf-Herder

    I have to correct myself here after doing some reading. POSIX/Linux symlinks are nowadays stored in the inodes of the file system, except "if the target path exceeds the available inode space" (Wikipedia). Also described in the linked article are the differences of NTFS symlinks to POSIX symlinks. In case someone wants to educate him/herself in this matter. :geek:

    I also found a big flaw in my hard link solution: Since the files are hard linked in a new real directory tree, any new files created after that in the original folders are not automatically created/linked to the second one. One would have to run the cp command after every use of Starbound and any of its updates to hard link any new files. Again, this could be put in a script to be executed after Starbound stops, but its not the simple solution I am looking for.

    So I'm back to "only" the two options of either switching multiple copies of sbinit.config or modifying it with the sed command. In terms of the KISS principle, the latter should be simpler because it doesn't need multiple sbinits. I think I'll go with that.

    I will setup the server either today or tomorrow.

    A fact many Windows and Linux users tend to forget regularly. Every operating system is just a tool to achieve goals that differ from case to case, and should only be rated for it's ability to reach those goals. Sometimes one is better in this regard, sometimes both are even, and sometimes just different.

    That said, Windows is a special case because most people don't know any other systems and thus don't have any comparison, thinking the way Windows does things is "the way things are done", period. Even you missed my initial statement and automatically assumed I had Windows. ;)

    Absolutely understandable. I didn't found comprehensive information about this problem on the net, let alone solutions, so if this thread helps others with this on Windows and Linux, all the better. :)

    Indeed it would. But I don't see any understandable reason not to simply implement multiply storage paths in the config, apart from the overwhelming number of features competing for the attention of the developers. Do you have other reasons in mind I may be missing?
     
  12. Ledhead

    Ledhead Phantasmal Quasar

    I will be sure to look those up, actually I responded with windows and skimmed the OP but mainly responded the way I did because I figured anyone who needed help trying to use two universe folders would probably be OS N00B as you stated that was reasonable assumption and thus didn't think they would be using linux.

    Second reasoning behind it is well, hardly any gamers use Linux.. This also another great assumption backed up by low OS adaption rate and gamer attitude in general, along with pre-defined knowladge that Linux based systems have less compatible experiences with games. I have been saying this for years but if Linux had wide support or suddenly ran windows games native like windows does gamers would switch to unix for gaming because of less overheads.


    About "left with two methods"
    I don't quite think so, what do you need to have update other than your player files from the main SB dir? everything asset wise is stored in a .pak if you can link recursively to maintain the dir structure on the dest end should still be a valid idea.
     
  13. Zigadenus

    Zigadenus Scruffy Nerf-Herder

    Soo, my first test succeeded after finding and fixing another little but important error.

    My previous sed commands would change all occurrences of "storage" into "storage.multi", breaking the line "storageDirectory" : "../storage/" by changing it into "storage.multiDirectory" : "../storage.multi/". The correct sed commands must be
    Code:
    sed -i s#/storage/#/storage.multi/#g sbinit.config
    and
    Code:
    sed -i s#/storage.multi/#/storage/#g sbinit.config
    These look for "/storage/" instead of "storage", so storageDirectory is left alone. I spare you the syntax details of sed here.

    So this is the complete sed-based solution:

    The Linux version of Starbound already has two scripts for starting the client or server respectively. Like the binaries, they are located in the folder game/linux. We can simply insert the sed commands into them.
    • In the script run-client.sh insert sed -i s#/storage.multi/#/storage/#g sbinit.config right after the line
      cd "`dirname \"$0\"`"
    • In the script run-server.sh insert sed -i s#/storage/#/storage.multi/#g sbinit.config right after the line cd "`dirname \"$0\"`"
    • In the folder game create an empty folder named storage.multi
    The next time you start a server, it uses the storage.multi folder for universe and player files. At its first run, it also creates a new starbound_server.config with default values there.

    You can then start the client that will use the old storage folder, select your single player character, and log into the server. You will start on your single player ship in transit to your new start world in the new server universe. All your possessions on in your inventory and on your ship will be where you left them. Starbound will save your location in both universes separately, so you will find yourself at the same spot you left in either the single player universe or the server universe.

    I don't know how often Starbound creates new files outside of the storage directory, if any. If it does not or seldom, this is indeed not a big problem. The updates I mentioned were updates to the game itself. But they are rare an thus not a big problem if one runs the cp command right after them. But you still have to remember that.

    So you're right that my hard link solution could still be valid, but it also still is way more complicated than the config method.
     
  14. Ledhead

    Ledhead Phantasmal Quasar

    Interesting, I wish windows had scripts for the game launcher , that seems like a hell better method aswell. You got me here Linux is more flexible (no surprise). Personally trying to use a multi-verse is harder than it had to be (shrug)
     
  15. Zigadenus

    Zigadenus Scruffy Nerf-Herder

    The start scripts don't do any magic, though. They just set the working directory to their own location, then they run the game. The server script also opens a Terminal window to run the server in, checks when the server stops, then closes the Terminal Window. That's all the scripts do, but it is nonetheless convenient to have them for easy tinkering.

    You could make your own scripts for Starbound, maybe using Windows' Power Shell (I only know of its existence but never used it myself).
    I guess so, but I don't know enough about Windows to say for sure. Linux' flexibility on the file level may come from its UNIX heritage and from being one of the server OS'. One definite advantage in my experience is that it has pre-installed many useful tools like sed you would first have to find and download for Windows. Thousands of other programs can be installed in an instant with the package managing system most Linux distributions use, it's a kind of "App Store" for the system and all applications which Linux has for nearly twenty years.
    Yeah, even our best scientists didn't crack this nut yet. :mwahaha: Seriously, this whole thread wouldn't be necessary if SB had an server universe path option. But you have to work with what you got. (shrug)

    This afternoon, I will test my server with a friend.
     
  16. Ledhead

    Ledhead Phantasmal Quasar

    My God, I don't believe it haha. I frigging forgot to mention that I swear I saw a separate configuration file for the dedicated server which had a storage line in it... I must have because the server has variables for wiping the universe dir and player dir to make sure players are forced to create a new character for joining the server.


    I am familiar with unix package distribution it's far superior to Windows along with the kernel update procedure. Windows has only just with windows 10 moved too an update system to update the OS version over the net. But it's still worse than Ubuntu which is what I like best. Only reason I use Windows is due to wide adoption and program support.
     
  17. Zigadenus

    Zigadenus Scruffy Nerf-Herder

    *loading shotgun* You don't say … :cautious: Do you remember its location and name?

    I also wondered about those variables, especially the universe wiping, since it can't mean either a) that the player's local universe would be deleted, or b) that the server's universe would be deleted every time a (new) player logs in. So what do those variables do exactly?
    So, this time *I* stumbled into the noob trap. But it led me to look up since when Linux had package managers, which I didn't know before, so …
     
  18. Ledhead

    Ledhead Phantasmal Quasar

    Well don't load the gun too fast haha because I'm not 100 percent certain. However these are the parameters of the configuration
    http://starbound.gamepedia.com/Starbound.config

    Location: Storage
    Name: Starbound_Server.config

    (yes I know the url is for Starbound.config however they are identical mostly)
     
    Last edited: Sep 4, 2016
  19. Zigadenus

    Zigadenus Scruffy Nerf-Herder

    I looked up this list before opening this thread, there is no storage line in it. Besides, it would be a little odd if the server had to look at a config file in the storage directory for the location of the actual storage directory to use. That's why the sbinit.config is not in storage but in Win32/Win64/linux.
     
  20. Zigadenus

    Zigadenus Scruffy Nerf-Herder

    Report from our first game: All worked perfectly. The client and server ran smoothly for two players on my Athlon II X-3 435 2.9 GHz with 8 GB RAM without any noticable lag. The MP universe is separated from my SP universe as planned. Thanks for the help, working out a solution with you was much more fun than doing it alone. :)
     
    Ledhead likes this.

Share This Page