Helpful scripts

Discussion in 'Server & Community Management' started by RiotShielder, Jun 15, 2013.

  1. I doubt many of you advanced owners out there will need these, but it might help someone out there.

    These are just some scripts made to update spigot/bungee cord, as well as start multiple servers in screen instances, along with the ability to restart the server automagically when it shuts down or crashes. (Please note that these are all tested on Ubuntu server 12.04)

    Update script

    This will download the latest versions of BungeeCord and Spigot, then move them to the folder you specify, and then remove the downloaded .jars. Be sure not to execute the script while your servers are running
    Code (Text):
    cp spigot.jar /path/to/your/spigot.jar
    cp BungeeCord.jar /path/to/your/BungeeCord.jar
    rm -rf spigot.jar
    rm -rf BungeeCord.jar
    Startup script (You need the script below for this to work)

    This will startup multiple servers (Or just 1, depending on how many you want) in screen sessions. you will be able to reconnect to the server with screen -r <easytoremembername>
    Code (Text):
    cd /path/to/your/server/folder
    screen -S <easytoremembername> -d -m /path/to/your/server/
    cd /path/to/your/bungee/folder
    screen -S bungeerestart -d -m /path/to/your/bungee/folder/
    Startup script (For individual servers) (Script above recommended in combination with this if you have 2+ servers)

    This will startup another screen session, in which the server will actually be ran in. If the
    server were to crash or shutdown it'll restart automatically, to stop a server you will need to first login via ssh, connect to the console, shutdown the server, then when it says "Its off...sleeping for 5" you will press CTRL-Z
    Code (Text):
    # /bin/sh
    while true
    screen -S <servername> java -Xms512M -Xmx2G -jar spigot.jar nogui
    echo Its off..sleeping for 5
    sleep 5
    Not sure if this was 100% clear, I made it for my server so they won't work without a little configuration on your end
    #1 RiotShielder, Jun 15, 2013
    Last edited: Mar 21, 2014
    • Useful Useful x 3
  2. I can't get this to work, when it gets to the screen part, it says screen is terminating, im on centos tho,.
  3. All of these scripts are made for Ubuntu, and I haven't used CentOS in ages, I can't really help you here.
    • Creative Creative x 1
  4. bash is bash... Same on Ub and CentOS.
    • Agree Agree x 1
  5. jtaylor69

    jtaylor69 Retired Moderator

    To get around the updating while server is running; you could place the newly downloaded updates into an /update folder and then in the server start up scripts, move from the update folder to the main server directories.
    • Agree Agree x 1
  6. I actually have more recent scripts that I have been meaning to add which will backup, auto restart, etc, etc, with a crontab and scripts.
    • Like Like x 1
  7. jtaylor69

    jtaylor69 Retired Moderator

    Possibilities are endless! :)
    • Agree Agree x 1
  8. For some reason, the scripts using screen don't work, it always says screen is terminating :p
  9. Has anyone found a fix? The restart scripts always seem to completely terminate the screen session.
  10. I've fixed it, I'll post it tomorrow.
  11. tmux
  12. Oh, I think I remember what the problem was. Install dos2unix, then use dos2unix /path/to/
    I believe the problem was the file was encoded wrong, that should fix it.
  13. To install dos2unix do we type:
    Code (Text):
    yum install dos2unix
    And after that, what do we do? I'm a bit confused, could you be a bit more specific?
  14. Not trying to hijack your thread but is there a need for other scripts?
  15. Use this command on the script
    Code (Text):
    dos2unix /path/to/
  16. What exactly do you mean
  17. Just to make sure, I add that to the script? Does it matter which line?
  18. No simply run that command on the console onto the script
  19. Sorry for being such a hassle. So assuming my server is offline, I would type that into console which will start up the server? And when the server stops, it won't terminate the screen and it'll successfully restart the server?
  20. No, you only need to use that command on the script once, then you start it up using the script provided