Network Start and Stop Scripts

Discussion in 'Systems Administration' started by xSinclare, Sep 11, 2016.

  1. Hey guys! Awhile ago I made these scripts for my server to start and stop a server. They worked pretty effectively and I decided to share them! I have a script for individual server then a script for the network right below! You can edit the messages to how ever you want and add/remove servers to your liking.

    Code (Text):
    #!/bin/sh

    java -Xms1024M -Xmx1024M -jar BungeeCord.jar
    I found a really cool
    Code (Text):
    #!/bin/sh

    java -Xmx1024M -Xms1024M -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:MaxGCPauseMillis=45 -XX:TargetSurvivorRatio=90 -XX:G1NewSizePercent=50$

    And here are my network start and stop scripts:

    Code (Text):
    #!/bin/bash
    echo -e "\e[95;1mBungee Starting\e[0m"
    sleep 5
    cd ~/bungeecord
    screen -d -m -S bungee ./start.sh
    sleep 5
    echo -e "\e[95;1mBungee Started\e[0m"
    sleep 5
    echo -e "\e[34;1mLobby Starting\e[0m"
    sleep 5
    cd ~/lobby
    screen -d -m -S lobby ./start.sh
    sleep 5
    echo -e "\e[34;1mLobby Started\e[0m"
    sleep 5
    echo -e "\e[33;1mFallback Starting\e[0m"
    sleep 5
    cd ~/Fallback
    screen -d -m -S fallback ./start.sh
    sleep 5
    echo -e "\e[33;1mFallback Started\e[0m"
    sleep 5
    echo -e "\e[32;1mCreative Starting\e[0m"
    sleep 5
    cd ~/creative
    screen -d -m -S creative ./start.sh
    sleep 5
    echo -e "\e[32;1mCreative Started\e[0m"
    sleep 5
    echo -e "\e[32;1mHCF Starting\e[0m"
    sleep 5
    cd ~/hcf
    screen -d -m -S hcf ./start.sh
    sleep 5
    echo -e "\e[32;1mHCF Started\e[0m"
    sleep 5
    echo -e "\e[31;1mBuild Server Starting\e[0m"
    sleep 5
    cd ~/buildserver
    screen -d -m -S build ./start.sh
    sleep 5
    echo -e "\e[31;1mBuild Server Started\e[0m"
    sleep 5
    echo -e "\e[30;1mDev Server Starting\e[0m"
    sleep 5
    cd ~/dev_server
    sleep 5
    screen -d -m -S dev ./start.sh
    echo -e "\e[31;1mDev Server Started\e[0m"
    sleep 5
    echo -e "\e[31;1mAll Servers Started. Task completed.\e[0m"
    sleep 4
    Code (Text):
    #!/bin/sh
    echo -e "\e[95;1mBungee Closing\e[0m"
    echo 5
    screen -p 0 -S bungee -X eval "stuff \"alert The network will be shutting down in 10 seconds!\"\015"
    echo 10
    screen -p 0 -S bungee -X eval "stuff \"end\"\015"
    echo -e "\e[95;1mBungee Closed\e[0m"
    screen -X -S bungee quit
    sleep 5
    echo -e "\e[34;1mClosing Lobby\e[0m"
    screen -p 0 -S lobby -X eval "stuff \"broadcast Server will be shutting down in 10 seconds.\"\015"
    sleep 10
    screen -p 0 -S lobby -X eval "stuff \"stop\"\015"
    echo -e "\e[34;1mLobby Closed\e[0m"
    screen -X -S lobby quit
    sleep 5
    echo -e "\e[33;1mFallback Closing\e[0m"
    screen -p 0 -S fallback -X eval "stuff \"broadcast Server will be shutting down in 10 seconds.\"\015"
    sleep 10
    screen -p 0 -S fallback -X eval "stuff \"stop\"\015"
    echo -e "\e[33;1mFallback Closed\e[0m"
    screen -X -S fallback quit
    sleep 5
    echo -e "\e[32;1mCreative Closing\e[0m"
    screen -p 0 -S creative -X eval "stuff \"broadcast Server will be shutting down in 10 seconds.\"\015"
    sleep 10
    screen -p 0 -S creative -X eval "stuff \"stop\"\015"
    echo -e "\e[32;1mCreative Closed\e[0m"
    screen -X -S creative quit
    sleep 5
    echo -e "\e[32;1mHCF Closing\e[0m"
    screen -p 0 -S hcf -X eval "stuff \"broadcast Server will be shutting down in 10 seconds.\"\015"
    sleep 10
    screen -p 0 -S hcf -X eval "stuff \"stop\"\015"
    echo -e "\e[32;1mHCF Closed\e[0m"
    screen -X -S hcf quit
    sleep 5
    echo -e "\e[31;1mBuild Server Closing\e[0m"
    screen -p 0 -S build -X eval "stuff \"broadcast Server will be shutting down in 10 seconds.\"\015"
    sleep 10
    screen -p 0 -S build -X eval "stuff \"stop\"\015"
    echo -e "\e[31;1mBuild Server Closed\e[0m"
    screen -X -S build quit
    sleep 5
    echo -e "\e[30;1mDev Server Closing\e[0m"
    screen -p 0 -S dev -X eval "stuff \"broadcast Server will be shutting down in 10 seconds.\"\015"
    sleep 10
    screen -p 0 -S dev -X eval "stuff \"stop\"\015"
    echo -e "\e[31;1mDev Server Closed\e[0m"
    screen -X -S dev quit
    sleep 5
    sleep 10
    echo -e "\e[31;1mAll Servers Closed. Task completed.\e[0m"
    echo 4

    Explanation to Spigot Scripts:
    During my time creating these scripts I came across this post and it actually helped
    with the performance of my servers. This post discusses different JVM arguments which you can include in your script. Normally most of us would use -Xmx and -Xms, but adding on different arguments and taking the time to tune your startup scripts will positively affect your server performance. Check out the post and try it out for yourself!

    I have also created screens specifically for these two so while the network is starting or stopping I can edit other stuff. If you think there is anything I can do to improve this script for my network or anyone else wanting to use this script for their network please comment below. Any and all is appreciated!
     
    #1 xSinclare, Sep 11, 2016
    Last edited: Sep 17, 2016
    • Useful Useful x 2
    • Like Like x 1
  2. jflory7

    jflory7 Retired Moderator
    Retired Benefactor

    It might be helpful as well if you explain some of the flags you're using and why in your Spigot script, so people know what you're doing there. :)
     
    • Agree Agree x 1
    • Useful Useful x 1
  3. Thank you for the feedback! I will make sure to add that in :p
     
  4. Nice scripts.
     
    • Like Like x 1
  5. Thread updated with a little explanation on a post I came across about using JVM arguments in your Spigot startup scripts! You can also view the post here.
     
  6. I wasn't having any issues. I just decided to use these flags to be more proactive for the future and making sure my servers are running in the best and most optimized state.
     

Share This Page