Trying to run a bash script for starting up a Minecraft server in AMP

  • 62 Views
  • Last Post 21 March 2020
Claw256 posted this 21 March 2020

Hi,

I have a minecraft server folder, and it comes with a server startup script called startserver.sh, I want to run this script to startup the server, as it has a feature that will create a small ramdisk for the world folder, and I want to use this feature.

I do not see any option in AMP that will let me run a script to launch the minecraft server.

My VPS that I use for my AMP installation runs Ubuntu 18.04.

Here is the full startup script for the minecraft server that I want to run:

#!/usr/bin/env bash
DO_RAMDISK=0
if [[ $(cat server-setup-config.yaml | grep 'ramDisk:' | awk 'BEGIN {FS=":"}{print $2}') =~ "yes" ]]; then
    SAVE_DIR=$(cat server.properties | grep 'level-name' | awk 'BEGIN {FS="="}{print $2}')
    mv $SAVE_DIR "${SAVE_DIR}_backup"
    mkdir $SAVE_DIR
    sudo mount -t tmpfs -o size=2G tmpfs $SAVE_DIR
    DO_RAMDISK=1
fi
    if [ -f serverstarter-2.0.0.jar ]; then
            echo "Skipping download. Using existing serverstarter-2.0.0.jar"
         java -d64 -jar serverstarter-2.0.0.jar
               if [[ $DO_RAMDISK -eq 1 ]]; then
               sudo umount $SAVE_DIR
               rm -rf $SAVE_DIR
               mv "${SAVE_DIR}_backup" $SAVE_DIR
               fi
               exit 0
    else
            export URL="https://yoosk.pl/serverstarter-2.0.0.jar"
    fi
        echo $URL
        which wget >> /dev/null
        if [ $? -eq 0 ]; then
            echo "DEBUG: (wget) Downloading ${URL}"
            wget -O serverstarter-2.0.0.jar "${URL}"
   else
            which curl >> /dev/null
            if [ $? -eq 0 ]; then
                echo "DEBUG: (curl) Downloading ${URL}"
                curl -o serverstarter-2.0.0.jar "${URL}"
            else
                echo "Neither wget or curl were found on your system. Please install one and try again"
         fi
      fi
java -d64 -jar serverstarter-2.0.0.jar
if [[ $DO_RAMDISK -eq 1 ]]; then
    sudo umount $SAVE_DIR
    rm -rf $SAVE_DIR
    mv "${SAVE_DIR}_backup" $SAVE_DIR
fi

If someone could help me out with this that would be great.


Thanks,

-Claw

Mike posted this 21 March 2020

You don't need the bash script. You just tell AMP to start your jar file directly. Using a RAMDisk with AMP is not supported at this time.

Close