dedicated linux script

    Joined
    Apr 11, 2015
    Messages
    5
    Reaction score
    0
    Hello,

    I would like to write a linux script which runs update before starting the server in a loop.
    Idea is that server crash/restart would automatically run update.

    The problem is that the "StarMade-Starter.jar" never returns. Is there an option to force it to do only update and exit afterwards?

    Here is the script:


    #!/bin/bash
    while true
    do
    java -jar ./StarMade-Starter.jar -nogui -force -nobackup
    ./StarMade-dedicated-server-linux.sh
    sleep 100
    done
     
    Joined
    Jun 27, 2013
    Messages
    896
    Reaction score
    166
    Hello,

    I would like to write a linux script which runs update before starting the server in a loop.
    Idea is that server crash/restart would automatically run update.

    The problem is that the "StarMade-Starter.jar" never returns. Is there an option to force it to do only update and exit afterwards?

    Here is the script:

    Bash:
    #!/bin/bash
    while true
    do
      java -jar ./StarMade-Starter.jar -nogui -force -nobackup
      ./StarMade-dedicated-server-linux.sh
      sleep 100
    done
    I suppose you have to get a bit more crafty than just calling the starter that is primarily intended to launch an interactive client session.
    Instead, you'd retrieve the latest available remote version number, compare it to your local version, and if they don't match, download and unpack the latest build.

    I'd probably do it by manually downloading the archive and putting it in a designated directory from where the script would unpack it. The reasoning behind that is sometimes a brand new patch may not work as intended, and you might want to have a human confirm it is stable enough, instead of a robot screwing up your world database... of course it could be fully automated if you want to live rough and dangerous ;)

    Bash:
    PROG_DIR=/path/to/your/starmade
    REMOTE=$(wget -q -O- https://registry.star-made.org/api/v1/current_version | awk 'BEGIN {FS="\""} {print $8}')
    LOCAL=$(awk 'BEGIN {FS="#"} {print $1}'  "${PROG_DIR}/version.txt")
    echo "Starmade version: local <${LOCAL}> remote <${REMOTE}>"
    There is also https://files.star-made.org/releasebuildindex.json that you can parse to get even more detailed version info, and could use that to just download those files that have changed (which is basically what StarMade-Starter.jar is doing).

    I seem to remember seeing some updater shell or maybe Python script thing on github, but I can't recall the author's name nor that of the script.
     
    Joined
    Apr 11, 2015
    Messages
    5
    Reaction score
    0
    Thanks for the tip. I wish there would be server side flag which checks version every hour/day and updates itself.

    In addition, i would like to see daily auto shutdown possibility.

    I host this server and many times for days i cannot check on its state, and several times it has been just stuck.
     
    Joined
    Jan 5, 2016
    Messages
    27
    Reaction score
    5
    I used a Script I found:
    Server Management Script
    This could be what youre looking for. The rest is simple cron.
    Note, you might have to edit the
    cd StarMade/
    part in every section (start, stop etc) to the absolute path in order for it to work with cron.