ServerPackCreator-Help Help

Fun Stuff

Fun Stuff

Self-extracting, self-contained script

It's possible to store the contents of your server pack in side a bash script which upon execution, will extract itself, and therefor the contents of the server pack, to a sub-directory in your users home-directory and then immediately start the server.

So instead of shipping/sending a ZIP-file to CurseForge, Modrinth, your friends, you can send them a script and tell them to simply run it.

build-script

#!/bin/bash cd $1 tar cf ../$1.tar ./* cd .. if [ -e "$1.tar" ]; then gzip $1.tar if [ -e "$1.tar.gz" ]; then cat decompress $1.tar.gz > $1.bsx else echo "$1.tar.gz does not exist" exit 1 fi else echo "$1.tar does not exist" exit 1 fi echo "$1.bsx created" exit 0

decompress-script

#!/bin/bash echo "" echo "Self Extracting Installer" echo "" export TMPDIR=`mktemp -d /tmp/selfextract.XXXXXX` script=$(basename "$0") me=${HOME}/mc-servers/$(echo $script | sed 's/.bsx//g') mkdir -p $me ARCHIVE=`awk '/^__ARCHIVE_BELOW__/ {print NR + 1; exit 0; }' $0` tail -n+$ARCHIVE $0 | tar xzv -C $TMPDIR echo "Copying server pack to $me" cp -r $TMPDIR/* $me rm -rf $TMPDIR cd $me ./start.sh exit 0 __ARCHIVE_BELOW__

How To

Create both the build and the decompress scripts inside the server-packs directory of ServerPackCreator.

Run the build-script with the server pack you want to create a self-extracting script of like so: ./build <ServerPackFolder>, where <ServerPackFolder> is to be replaced with the name of the server pack folder, for example All_the_Mods_9_-_ATM9, so the call becomes ./build All_the_Mods_9_-_ATM9.

Depending on the size of your server pack, this may take a while.

When the script finishes you should see All_the_Mods_9_-_ATM9.bsx created in your console and a file called All_the_Mods_9_-_ATM9.bsx in your server-packs folder. The script file should be roughly the same size as the folder of your server pack.

Copy the script to some other directory and run it: ./All_the_Mods_9_-_ATM9.bsx

It will extract the contents to /tmp/selfextract.XXXXXX first, then create a new folder inside your users home-directory and copy the files there, so you then have /home/<YOUR_USER>/mc-servers/All_the_Mods_9_-_ATM9.

When all files have been copied, the extract-script switches to the aforementioned directory and runs the start.sh-script, immediately starting the server.

Done!

Nice, quick and easy server pack provision.

Last modified: 22 September 2024