Auto-syncing Wurm map dump to web server

In my downtime I help host KangaWU, an Australia-based Wurm Unlimited server. One of the things we needed was auto-generated map dumps syncing to our web server to allow frequent updates of the online map. Looking at the options available, I decided on using rsync in a cron job, with public/private key pairs for authentication.

The first roadblock was that since cron runs a limited environment, it doesn’t have access to any passphrase entered into ssh-agent. Using keychain installed in user-space works so that the passphrase can be entered in a terminal session and still be accessible to cron jobs. So:

  • Since keychain isn’t in a CentOS 7 package, downloaded the tarball and extracted to $HOME/util/keychain-2.8.2
  • Created a refresh-keychain script to start keychain if it hasn’t already been started:
  • Made sure the above script was in PATH and executed in .bashrc
  • Executed it for the first time, to enter the passphrase

This does mean that on server restart the passphrase needs to be entered, hence adding it to .bashrc so that when that happens you get asked. Now that’s done, I thought I’d add a .ssh config file to make sure that I don’t need to specify an identity file each time I connect:

  • Create a new file $HOME/.ssh/config, with the following:
  • Verify that it works, with ssh yourwebhost.com

Write up a short script to rsync the files. Note the trailing / at the end of the source, which indicates that the contents of that directory are to be copied to the destination directory, rather than creating the source directory within the destination:

Now, a script for cron to call:

Add a cron entry to run the script at 4:30am each day and we’re done:

While at some point a live map would be ideal, this does the job for now, with maps being at most 24hrs out of date.

This entry was posted in Software. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *