Server scripts

    Joined
    Jun 25, 2013
    Messages
    16
    Reaction score
    0
    • Legacy Citizen 2
    • Legacy Citizen
    I'm sharing all scripts that I have written for my StarMade server, with launch commands and other goodies. There are four scripts. Let me tell you what they are for and how to use them.



    Main features

    • Automatic server restarting
    • Handling of some server lockdowns
    • Logging of server state and player count



    Alternatives

    When I was creating this thread I could not find any server scripts. Now there are some scripts around and I'd like to give them some advertising space here. My script is probably not what you are looking for if you need a finished user frindly server script.

    StarMade control panel - Loads of useful tools with nice interface

    StarMade Server Script for Ubuntu - Minecraft style server script ported for StarMade



    Scripts

    start.sh starts the server process and restarts it if the process goes down. It also keeps a log about its own actions.

    run echoes the command that starts the server process so the start script can run it. Start command is stored to a separate script so you don't need to kill the start script if you want to try a different command to launch the server.

    update.sh updates the server.

    probe.sh monitors and logs the server state. It also kills the server process (so the start script can start the server again) if the the server reports its status offline. Server state and player amount resolution methods are similar to those that starmade-servers.com uses. Probe reads a 'status' file written by update and start scripts for better server state resolution.

    Probe should be always tested after server update as it may easily get broken. You will need to modify the probe if your server supports over 255 players.



    Setup

    Untar: tar -zxvf starmadeServerScripts.tar.gz

    Copy starmadeServerScripts/* to your server directory where the StarMade and StarMade-Starter.jar are located. Change directory to your server directory.

    Make a softlink to the StarMade directory: ln -s StarMade server



    Requirements

    Linux with bash and other typical stuff.

    rlwrap: Defined in the run script for better server console. You can as well delete rlwrap from the run command.

    nice and ionice: Defined in the run script for server performance. You can as well delete these from the run command.

    netcat, tail and awk: Required for probe functionality.

    wget: Required to use the update script.



    Usage

    Run the server by launching start.sh in screen. The start script runs the server in forground and the probe in background. You can comment the probe out to not run in or to run it separately. You can monitor the scripts from log files created in the server log directory.

    You may want to keep the probe on even when you shut down the server script. You can comment the probe script off from the start script and just launch it in a separate screen/process.

    Important

    Probe can kill the server process. Use start and update scripts so the killing functionality works as intended. Probe can kill any Java process originating from the server directory or below.



    Downloads

    http://mikuz.org/random/starmade/starmadeServerScripts_v1.0.tar.gz

    http://mikuz.org/random/starmade/starmadeServerScripts_v1.1.tar.gz

    These scripts are released in spirit of sharing rather than as software distribution. I do not take responsibility for any damage they may cause.



    Changelog

    v1.1 - 20.10.2013

    • Fix probe serverAlive bug which affected some netcat versions
     
    Joined
    Aug 3, 2013
    Messages
    7
    Reaction score
    0
    You should just make a startup script similar to MineCraft. This system is really buggy. Tried everything and it\'ll never start. has syntax errors to begin with.

    \'System Link is present named \"server\" in scripts folder that poitns to /home/starmade/server/StarMade/ Netcat and all that installed.




    root@debian:/home/starmade/server/StarMade/starmadeServerScripts# sh start.sh
    start.sh: 9: function: not found
    1375640743
    start.sh: 12: Syntax error: \"}\" unexpected
    root@debian:/home/starmade/server/StarMade/starmadeServerScripts#
    Initiating probe..
    cat: /home/starmade/server/StarMade/starmadeServerScripts/state: No such file or directory
    /home/starmade/server/StarMade/starmadeServerScripts/probe.sh: line 55: [: 13756 40743: unary operator expected
    Down for 0 minutes
    cat: /home/starmade/server/StarMade/starmadeServerScripts/state: No such file or directory
    /home/starmade/server/StarMade/starmadeServerScripts/probe.sh: line 41: let: tDi ff=1375640743-: syntax error: operand expected (error token is \"-\")
    /home/starmade/server/StarMade/starmadeServerScripts/probe.sh: line 42: let: hDi ff=/60: syntax error: operand expected (error token is \"/60\")
    cat: /home/starmade/server/StarMade/starmadeServerScripts/state: No such file or directory
    /home/starmade/server/StarMade/starmadeServerScripts/probe.sh: line 75: [: : int eger expression expected
    Need 4 minutes down for probe to issue a shutdown. Looks like the server is on l ockdown.
    root@debian:/home/starmade/server/StarMade/starmadeServerScripts#
     
    Joined
    Jun 25, 2013
    Messages
    16
    Reaction score
    0
    • Legacy Citizen 2
    • Legacy Citizen
    \"function: not found\" - that sounds like you are not using bash or a similar rich shell. I\'m afraid this script is made for bash. See http://stackoverflow.com/questions/12468889/bash-script-error-function-not-found-why-would-this-appear.

    Also it looks like you did not copy the scripts to you server directory. This step is instructed in the Setup section.
     
    Joined
    Jun 23, 2013
    Messages
    15
    Reaction score
    0
    I have a dedicated server running Ubuntu 12.

    Installed StarMade server, rlwrap, nice and ionice, netcat, and wget (came with the OS).

    Followed all the directions.

    The script WILL start the server up just fine, and restart it fine, as well.

    But, it seems like the probe fails to see if the server is acctually running or not.

    So, it starts the server, and never gets a ping saying the server is up.

    So, it constantly restarts the server every 10 mins, because the probe script thinks the server is down, when it\'s acctually up.

    The only thing I didn\'t do was, run the probe script is a separate screen. I have only tried to run the start.sh script, which also launches the probe.sh script in the background.

    See attached link, for screenshot of the error:

    http://i.imgur.com/ysAqtLf.jpg

    Thank you for any, and all help!

    - warezit
     
    Joined
    Jun 25, 2013
    Messages
    16
    Reaction score
    0
    • Legacy Citizen 2
    • Legacy Citizen
    You probably do not have \"awk\" and/or \"tail\" installed. I will add these to requirements.

    Sorry for the long response time. There was an option to subscribe to a thread but I can\'t find it anymore.

    Let\'s proceed to a more fine-grained explanation. This is what I\'m getting:


    connection made. starting new processor 51169, /127.0.0.1; local: 4242, /127.0.0.1, keepalive false
    [SERVER] connection registered
    [SERVER][PROCESSOR] client setup completed. listening for input
    Client null and not first try
    Client null and not first try
    [SERVER] client has not send any login information: 2000 / 10000
    java.io.EOFException
    at java.io.DataInputStream.readInt(DataInputStream.java:392)
    at org.schema.schine.network.server.ServerProcessor.run(SourceFile:800)
    at java.lang.Thread.run(Thread.java:724)
    [SERVER] Client \'null\' HAS BEEN DISCONNECTED . PROBE: false
    [SERVER] COULD NOT UNREGISTER CLIENT null
    [SERVER] COULD NOT UNREGISTER CLIENT null
    [SERVER] SERVER PROCESSOR STOPPED FOR null
    connection made. starting new processor 51170, /127.0.0.1; local: 4242, /127.0.0.1, keepalive false
    [SERVER] connection registered
    Client null and not first try
    [SERVER][PROCESSOR] client setup completed. listening for input
    [SERVER] This client is an info ping (server-lists): /127.0.0.1
    [SERVER] Executing scheduled disconnect!
    [SERVER] Client \'Info-Pinger (server-lists)\' HAS BEEN DISCONNECTED . PROBE: true
    [SERVER] PROBE SUCCESSFULLY EXECUTED. STOPPING PROCESSOR. (Ping of a Starter to start server)
    Up for 156 minutes, 1 players


    In your case the probe stops at \"[SERVER] SERVER PROCESSOR STOPPED FOR null\" because command \"echo \"\" | netcat -v -w 1 localhost 4242 2>&1|tail -1|awk \'{print $5}\'\" does not print \"true\".

    If you need to debug more you can run the server request command in steps. Try:

    1. echo \"\" | netcat -v -w 1 localhost 4242
    2. echo \"\" | netcat -v -w 1 localhost 4242 2>&1|tail -1
    3. echo \"\" | netcat -v -w 1 localhost 4242 2>&1|tail -1|awk \'{print $5}\'

    The steps should respectfully produce following results:

    1. localhost [127.0.0.1] 4242 (?) open
    2. localhost [127.0.0.1] 4242 (?) open
    3. open
     
    Joined
    Jun 20, 2012
    Messages
    230
    Reaction score
    6
    ionice: ioprio_set failed: Operation not permitted

    i get this when trying to start it watch dog log says

    05.09.13 20:38:05 Running command: \'ionice -c2 -n0 nice -n -10 rlwrap java -Xms128m -Xmx2g -XX:ParallelGCThreads=4 -XX:MaxPermSize=256m -d64 -server -jar StarMade.jar -server\'
    05.09.13 20:38:05 Server \'StarMade\' crashed with exit code 0. Restarting...



    over and over and over
     
    Joined
    Aug 3, 2013
    Messages
    12
    Reaction score
    0
    • Legacy Citizen 2
    • Legacy Citizen
    I have converted the MinecraftWiki.net script:

    https://github.com/phrasz/StarMadeScript
     
    Joined
    Jun 25, 2013
    Messages
    16
    Reaction score
    0
    • Legacy Citizen 2
    • Legacy Citizen
    Well you can remove \"ionice -c2 -n0 \" from the first line or the \"run\" file to fix the problem.

    You could also try different parameters, like: \"ionice -c1 \" or \"ionice -n0 \".

    Maybe you could check \"/etc/security/limits.conf\" file if it mentions anything about ionice. I can\'t help you any further as I can\'t reproduce your problem.

    ionice is there to help StarMade to utilize your hard drive. StarMade\'s way to keep its database is purely evil and ionice might help (also it might hurt).
     
    Joined
    Jun 20, 2013
    Messages
    18
    Reaction score
    3
    • Legacy Citizen 2
    • Legacy Citizen
    Hey there, my issue is, ive got everything working appart from the probing, ive got Gawk and netcat, and so it seems i have tail also , i could verify this from using yum, appart from tail, but if i type info tail i get up information about it. The issue im getting however is basically the same as Warezit where it cant seem to probe the server, i also did the 3 tests:

    If you need to debug more you can run the server request command in steps. Try:

    1. echo \"\" | netcat -v -w 1 localhost 4242
    2. echo \"\" | netcat -v -w 1 localhost 4242 2>&1|tail -1
    3. echo \"\" | netcat -v -w 1 localhost 4242 2>&1|tail -1|awk \'{print $5}\'

    which came out as this

    1. localhost [127.0.0.1] 4242 open
    2. localhost [127.0.0.1] 4242 open
    3. get nothing coming up



    also another quick note, on my Node i also run other servers so i was wondering another way to kill the process instead of killing all java instances.
     
    Joined
    Jun 25, 2013
    Messages
    16
    Reaction score
    0
    • Legacy Citizen 2
    • Legacy Citizen
    The third step basically tries to take output of the second step and print the fifth \'word\'. Since you only have 4 \'words\' it doesn\'t work. Using following prints the \"open\" word in your netcat output which it is supposed to find:


    echo \"\" | netcat -v -w 1 localhost 4242 2>&1|tail -1|awk \'{print $4}\'

    Apparently netcat outputs aren\'t as standard as I thought. The script should try to find the \"open\" word instead of expecting it to be the fifth word.

    EDIT: This bug is fixed in v1.1



    It does check that the java instance is under the current directory of the script:


    if [[ \"$processDir\" == $BASEDIR/* ]]; then

    You can also specify the location of the Java instance you want to kill more accurately by editing that line. Of course it would also be quite valid to write PID of the process to a file and kill that PID. I find my approach less error prone though.
     
    Joined
    Jul 9, 2013
    Messages
    14
    Reaction score
    2
    • Purchased!
    Ahh, I see.

    That isn\'t really a bug. But that netcat is not uniform. That is a bug...

    @alicheek, what kind of operating system do you use?

    Cheers :3

    - Zodiak
     
    Joined
    Jun 20, 2013
    Messages
    18
    Reaction score
    3
    • Legacy Citizen 2
    • Legacy Citizen
    Ah thanks for that Mikuz.

    My only issue seems to be the probe now when i tested: echo \"\" | netcat -v -w 1 localhost 4242 2>&1|tail -1

    I get : [127.0.0.1] 4242: Connection refused


    Not too sure why.
     
    Joined
    Jun 20, 2013
    Messages
    18
    Reaction score
    3
    • Legacy Citizen 2
    • Legacy Citizen
    sorry ignore me :P seems i must of messed it up in the server config !
     
    Joined
    Jun 25, 2013
    Messages
    16
    Reaction score
    0
    • Legacy Citizen 2
    • Legacy Citizen
    Hope the way the script kills the server doesn\'t cause problems for you.
     
    Joined
    Jun 25, 2013
    Messages
    16
    Reaction score
    0
    • Legacy Citizen 2
    • Legacy Citizen
    I see it as a bug if it causes undocumented/unintended behaviour, whether or not it\'s caused by a bug in another software. I don\'t think netcat documents consistent status output as a feature so it isn\'t really a netcat bug.