City of Arabel
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Running Arabel Locally with WSL

    Scheduled Pinned Locked Moved Server Management
    1 Posts 1 Posters 80 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DoctorDethD
      DoctorDeth
      last edited by DoctorDeth

      This document has been verified!

      The end result of this guide is to have a fully functional version of Arbel running on your local PC. This requires a minimum of Windows 10 to function. This guide is probably also not for the faint of heart. There are some very technical things that need to happen for all this to work. If you're tech-savvy, give it a go and maybe we can refine the instructions to be clearer and script-y over time.

      Install Windows Linux Subsystem

      Enable/install WLS on Windows: https://learn.microsoft.com/en-us/windows/wsl/install

      Choose Ubuntu as the Linux distribution. You will probably want to do a wsl --list --online and choose Ubuntu-24.04 (the latest at the time of writing).

      Use a simple username and password when prompted (like your name and blahblah).

      Once installed, run it from the start menu.

      It is also highly recommended to install Windows Terminal from here: https://github.com/microsoft/terminal/releases

      Convert PuTTY SSH Key

      You probably already have an SSH key to get to the server. The WSL system is separate from your Windows system and requires different keys. However, you can use the key you already have and convert it to an OpenSSH key and use the same key/passphrase from WSL. Doing this seems like a lot of trouble, but it will save you a lot of time and headache if you can automatically copy down the same binaries (both for NWN and NWNX) to run locally rather than building NWNX yourself.

      Open PuttyGen and load your current private key. From the "Conversions" menu, select "Export OpenSSH Key" and save the key to c:\temp (create the directory if necessary) as just id_rsa.

      Copy the text in the first box in PuTTYGen "Public key for pasting...". Create a new text file in c:\temp called id_rsa.pub (lower case file name). Paste the contents. Verify that it's all one long line. Save and exit.

      In the "Ubuntu" window, copy/paste the following (paste these lines one at a time if you run in to problems - some things like creating directories will fail the second time you execute them but that's fine):

      mkdir ~/.ssh
      cp /mnt/c/temp/id_rsa ~/.ssh
      cp /mnt/c/temp/id_rsa.pub ~/.ssh
      echo -e "Host arabel\n    Hostname www.cityofarabel.com\n    User arabel\n" > ~/.ssh/config
      chmod 700 ~/.ssh
      chmod 600 ~/.ssh/id_rsa ~/.ssh/config
      chmod 644 ~/.ssh/id_rsa.pub
      

      Install the Database

      Arabel relies on a database to store persistent settings for all sorts of things. You will need to run this database locally and copy the contents of the existing database from the server. Luckily, that only requires a few commands.

      Important: Type sudo date and type your password you used when creating the Ubuntu subsystem. This is to prime the sudo command with your password. If you don't, sudo will eat the following line as the password (i.e. bad).

      Copy-paste the following:

      sudo apt update
      sudo apt -y upgrade
      sudo apt -y install postgresql postgresql-client dos2unix
      sudo service postgresql start
      sudo -u postgres createuser -d -s $USER
      sudo -u postgres psql -c "alter user $USER with password 'AraDbPass';"
      createdb $USER
      WIN_USER=$(powershell.exe '$env:UserName' | dos2unix)
      

      Run this next command by itself. It will probably ask you if you want to confirm the connection. Say "Yes"

      scp -p arabel:/home/arabel/db/db_dump.gz .
      

      Finally, import the database.

      gzip -dc db_dump.gz | psql -d $USER
      

      Change the Postgres user password. For ease of use, use the same password you created when setting up WSL.

      sudo passwd postgres
      

      Process check

      Copy-paste the following:

      cd $HOME
      ssh arabel hostname
      

      This will ask for your PuTTY passphrase. If this does not return "www.cityofarabel.com" or returns an error - do not proceed!! Check your SSH setup.

      Copy Server Files

      Note: this only needs to be done once. After everything is setup, there's another command (below) that can refresh all the local files to keep them in sync with the server.

      Copy/Paste the following:

      cd $HOME
      rsync -aLzv arabel:/home/arabel/server .
      rsync -aLzv arabel:/home/arabel/nwnx .
      cd $HOME/server/bin/linux-x86
      ./nwserver-linux
      

      Windows Defender might throw a warning. Click "Allow Access". Type "quit" in the Ubuntu window.

      Running nwserver will create the Neverwinter Nights folder under $HOME/.local/share/Neverwinter Nights. Dealing with spaces in filenames is a pain, however. This will be rectified in the steps below.

      Use Existing Hak Files

      So as not to duplicate many GB of hak files, we can use the ones already on your system. From the Ubuntu window, find the directory your files are located. Depending on your setup, this could be many possible places. By default, though (from the WSL point of view) it will be in

      /mnt/c/users/$WIN_USER/Documents/Neverwinter\ Nights/hak
      

      or maybe

      /mnt/c/users/$WIN_USER/OneDrive/Documents/Neverwinter\ Nights/hak
      

      or maybe somewhere different. In a Windows File Explorer, find your "NWN.ini" file in your Neverwinter folder. There are "Alias" entries that show where your HAK and TLK directories are. Typically they will be C:\users\something\blah\blah. To convert this path to a WSL path C: becomes /mnt/c, then swap all the backslashes to slashes and prefix any space with a backslash.

      For example,

      C:\users\CrazyUser\Some Funky Path\Neverwinter Nights\hak
      

      becomes

      /mnt/c/users/CrazyUser/Some\ Funky\ Path/Neverwinter\ Nights
      

      Case matters!!

      Ultimately, if your Neverwinter Nights is in a non-default location (not C:\users\%USERPROFILE%\Documents\Neverwinter Nights), you will have to adjust the commands below here.

      In the Ubuntu window, you should be able to do a ls /mnt/c/watever where the path is what you figured out from above for your haks and see a full listing of all your hak files. If not, try to figure out what's wrong with your path. Once the ls is working, you can proceed.

      Create a link because dealing with spaces is a pain:

      cd $HOME
      ln -s .local/share/Neverwinter\ Nights nwn
      

      Create the links for hak, modules, and tlk. Note the quotes around the path because of the spaces on the Windows NWN dir, or escape the space with a backslash.

      We are also linking the modules directory here, so if you edit the module in the Windows Toolset, running the server here will run the modified module.

      cd $HOME/nwn
      rmdir hak
      ln -s "/mnt/c/users/$WIN_USER/Documents/Neverwinter Nights/hak" hak
      rmdir tlk
      ln -s "/mnt/c/users/$WIN_USER/Documents/Neverwinter Nights/tlk" tlk
      rmdir modules
      ln -s "/mnt/c/users/$WIN_USER/Documents/Neverwinter Nights/modules" modules
      

      As a test:

      ls $HOME/nwn/hak
      

      If that command doesn't show you a list of hak files, something is wrong with your links.

      Starting The Server

      Copy the start script

      cd $HOME
      scp -p arabel:/home/arabel/wsl/local_server.sh .
      chmod +x local_server.sh
      

      First, run it in refresh mode so everything is up to date. Note that running "refresh module" will overwrite your local Arabel.mod, so only run this when you want to pull the new module from the server. This will overwrite Arabel.mod in your Windows Neverwinter Nights\modules directory!!!

      Also, the first time you refresh haks from the server, it's likely to download everything because of the time stamp differences on the files. This wouldn't happen again unless you manually download something with FileZilla and that would get updated with the correct timestamp next time.

      ./local_server.sh refresh server
      
      # Commented out, but if you want, un-comment this and run to fetch the latest module to your local machine.
      # ./local_server.sh refresh module
      

      Run the server. By default, this will load Arabel.mod.

      cd $HOME
      ./local_server.sh
      

      Hopefully, it starts.

      Keeping Up To Date

      Note that for HAKs, TLK files, and the Arabel.mod file, there's only one copy of this on your computer and it is located in your Windows Documents\Neverwinter Nights folder (or sub-folder). If you have locally changed files and run these commands, they WILL overwrite your local files with the version from the server.

      Refreshing the module.

      If you run ./local_server.sh refresh module this will copy the latest module from the server to your Windows machine (equivalent to running `getarabel.bat')

      ./local_server.sh refresh module
      

      Refresh Other Stuff

      To refresh other things (not as common) you can run

      ./local_server.sh refresh server
      

      This will refresh HAK and TLK files, as well as the main server files (nwserver) and NWNX binaries.

      CAUTION / NOTE / WARNING / BENEFIT / COOL-FEATURE!!

      Running ./local_server.sh refresh server will update the HAK and TLK files under your Windows directory.

      This will only download changed files. The initial HAK download might download a file or two if there are timestamp differences between your system and the server. This should not occur on subsequent downloads.

      You could use the "refresh server" option in lieu of downloading HAK files manually. It will always figure out which ones need updating automatically. Obviously, don't run this if you're editing HAK files locally and haven't uploaded them to the server yet.

      In theory, practice and theory are the same. In practice, however, they are not.

      1 Reply Last reply Reply Quote
      • folkloreF folklore moved this topic from Team Lead Forums on
      • 1 / 1
      • First post
        Last post