Advertisement
Guest User

Untitled

a guest
Jun 21st, 2016
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 75.24 KB | None | 0 0
  1. #!/bin/bash
  2. #shopt -s extglob
  3. #/etc/init.d/mcservers
  4.  
  5. ### BEGIN INIT INFO
  6. # Provides: mcservers
  7. # Required-Start: $local_fs $remote_fs $mysqld $mysql $mongo
  8. # Required-Stop: $local_fs $remote_fs $mysqld $mysql $mongo
  9. # Should-Start: $network
  10. # Should-Stop: $network
  11. # Default-Start: 4 5 6
  12. # Default-Stop: 0 1 6
  13. # Short-Description: mcservers Service Script
  14. # Description: Runs multiple Minecraft screen process as a service
  15. # this service will safely start, stop, restart, update, and edit each server.
  16. # This script will allow you to update and run various tasks.
  17. ### END INIT INFO
  18. #
  19. #
  20. # Script Configuration Setting
  21. User=root
  22. USER_DIRECTORY="/home/minecraft"
  23. MINECRAFT_DIRECTORY="MCServers"
  24. #Screen color output. Change the color codes to your choices.
  25. #References https://wiki.archlinux.org/index.php/Color_Bash_Prompt#List_of_colors_for_prompt_and_Bash
  26. #Just change what appears between the ' and '.
  27. #Do NOT change the name before the =, it's used as references in the script.
  28. #If you wish to have no color, replace the codes for colors with the code for NOCOLOR: \033[0m
  29. RED='\e[0;31m' # Red
  30. GREEN='\e[0;32m' # Green
  31. LIGHTGREEN='\e[0;92m' # Light Green
  32. YELLOW='\e[0;33m' # Yellow
  33. ###DO NOT CHANGE BELOW!
  34. NOCOLOR='\033[0m' # Reset
  35. exist="false"
  36. ###
  37. #
  38. # Load Settings
  39. SERVER_SETTINGS="$USER_DIRECTORY/$MINECRAFT_DIRECTORY"
  40. if [ -f "$SERVER_SETTINGS/servers.cfg" ] ; then
  41. . "$SERVER_SETTINGS/servers.cfg"
  42. else {
  43. # create_serverscfg
  44. echo -e "\n${RED}ERROR! ${GREEN}${SERVER_SETTINGS}/servers.cfg ${RED}Not Found!${NOCOLOR}"
  45. echo -e "${YELLOW}Creating Default Template...${NOCOLOR}"
  46. cd "$SERVER_SETTINGS" || { echo -e -n "${RED}ERROR! Cannot Change Directories to ${SERVER_SETTINGS} from " pwd "!${NOCOLOR}\n" && exit; }
  47. {
  48. echo '# Server Settings servers.cfg'
  49. echo ' '
  50. echo 'BUNGEECORD_URL="http://ci.md-5.net/job/BungeeCord/lastBuild/artifact/bootstrap/target/BungeeCord.jar" #Newest Builds of Bungeecord.jar. Type "none" if you do not wish to download this.'
  51. echo 'BUNGEECORD="BungeeCord.jar" #Choice name of saved and displayed .jar'
  52. echo 'BUILDTOOLS_URL="https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar" #Newest Builds of Buildtools. Type "none" if you do not wish to download this.'
  53. echo 'BUILDTOOLS_BUILD_VERSION="--rev latest" #Leave blank for current release version of MC. If specific build wanted, add: --rev 1.8, --rev 1.8.8, --rev latest.'
  54. echo 'BUILDTOOLS_SPIGOT="spigot-1.9.2.jar" #Make sure this is the exact name of the spigot file output from BuildTools.jar.'
  55. echo 'BUILDTOOLS_OUTPUT="Spigot-1.9.2.jar" #Choice name of buildtools.jar output to be renamed to when copied out of buildtools.'
  56. echo 'SPIGOT_LATEST="Spigot192.jar" #Choice name of saved and displayed .jar'
  57. echo 'MINECRAFT_SERVER_URL="https://s3.amazonaws.com/Minecraft.Download/versions/1.9/minecraft_server.1.9.jar" #Choice version of minecraft_server.jar. Update URL when Mojang releases newer versions. Type "none" if you do not wish to download this.'
  58. echo 'MINECRAFT_SERVER="Minecraft_Server.jar" #Choice name of saved and displayed .jar'
  59. echo 'MINECRAFT_SNAPSHOT_URL="none" #Choice version of minecraft__snapshot_server.jar. Update URL to your choice. Can be used for custom versions of MC/Forge/Sponge/etc. Type "none" if you do not wish to download this.'
  60. echo 'MINECRAFT_SNAPSHOT="Minecraft_Snapshot_Server.jar" #Choice name of saved and displayed .jar'
  61. echo 'MANUAL_BACKUPS_LOCATION="none" #Choice of where backups are saved. Default: none = Disables Backup until directory is set.'
  62. echo ' '
  63. echo 'SHOW_SCREENS="True" #Do you want to show the screen listings after server Start, Stop, and Restarts?'
  64. echo ' '
  65. echo '# Survival Server Settings'
  66. echo 'SURVIVAL=0 #Server Group Unique Name. Must be different than other server groups. Increment the ID# for each additional server listing. Best if you keep these in order.'
  67. echo 'SERVER_ENABLED[$SURVIVAL]="true" #Is this server allowed to start? If Yes, "true", otherwise "false."'
  68. echo 'SERVER_NAME[$SURVIVAL]="Survival" #Server Group Display/Screen Name. Can be anything.'
  69. echo 'SERVER_PATH[$SURVIVAL]="Survival" #Server root directory where the server_core.jar will be saved and executed? Directory must be in same location as this config.'
  70. echo 'SERVER_CORE[$SURVIVAL]="Spigot-1.9.2.jar" #Server Core .jar name to run off of. Good use if using custom .jar files separate from last Buildtools run.'
  71. echo 'SERVER_EXTRAS[$SURVIVAL]="none" #If none to place, place: "none". Ex: "rm /plugins/plugin/data.txt && command two;"'
  72. echo 'START_ARGS[$SURVIVAL]="java -server -Xmx1024M -XX:+UseConcMarkSweepGC -jar" #Server starting arguments. Best only to change the -Xmx for memory use and server.jar at the end.' #Removed max perm size, no longer needed since MC 1.8
  73. echo 'SHUTDOWN_CMD[$SURVIVAL]="stop" #Command used to tell the server, nicely, to shut down via screen/console.'
  74. echo 'MSG_CMD[$SURVIVAL]="say" #Command used to announce the SHUTDOWN_MSG1 and 2 prior to shutdown. Used for announced countdown.'
  75. echo 'SHUTDOWN_MAX_WAIT[$SURVIVAL]=30 #How long to wait until server is shut down completely, before continueing on with the script. If server is down before the set number, the script exits.'
  76. echo 'SHUTDOWN_SECONDS[$SURVIVAL]=20 #Number of seconds until MSG_CMD is used to shut down. Each second repeates the shutdown_msgs as the countdown decreases.'
  77. echo 'SHUTDOWN_MSG1[$SURVIVAL]="&KD&rShutting down in " #First half of the shutdown message, followed by the number of seconds remaining.'
  78. echo 'SHUTDOWN_MSG2[$SURVIVAL]=" Seconds&KD&r." #Second half of the shutdown message, after the number of seconds remaining.'
  79. echo ' '
  80. echo '# BungeeCord Server Settings'
  81. echo 'BUNGEE=1'
  82. echo 'SERVER_ENABLED[$BUNGEE]=true'
  83. echo 'SERVER_NAME[$BUNGEE]="BungeeCord"'
  84. echo 'SERVER_PATH[$BUNGEE]="BungeeCord"'
  85. echo 'SERVER_CORE[$BUNGEE]="BungeeCord.jar"'
  86. echo 'SERVER_EXTRAS[$BUNGEE]="none"'
  87. echo 'START_ARGS[$BUNGEE]="java -server -Xmx200M -XX:+UseConcMarkSweepGC -jar -DIReallyKnowWhatIaAmDoingISwear"'
  88. echo 'SHUTDOWN_CMD[$BUNGEE]="end"'
  89. echo 'MSG_CMD[$BUNGEE]="alert"'
  90. echo 'SHUTDOWN_MAX_WAIT[$BUNGEE]=30'
  91. echo 'SHUTDOWN_SECONDS[$BUNGEE]=5'
  92. echo 'SHUTDOWN_MSG1[$BUNGEE]="Shutting down in "'
  93. echo 'SHUTDOWN_MSG2[$BUNGEE]=" Seconds."'
  94. } >> servers.cfg
  95.  
  96. sleep 1
  97. echo -e "${LIGHTGREEN}Config ${GREEN}servers.cfg${LIGHTGREEN} created in ${GREEN}$SERVFER_SETTIGNS${LIGHTGREEN}.${NOCOLOR}"
  98. }
  99. fi
  100. #
  101. #
  102. # Run commands as the user supplied in $USER
  103. command() {
  104. ME=$(whoami)
  105. if [ "$ME" == $User ] ; then
  106. bash -c "$1"
  107. else
  108. su $User -c "$1"
  109. fi
  110. }
  111. # Check if the screen is running.
  112. is_running() {
  113. if ps ax | grep java | grep "${SERVER_NAME[$1]}" > /dev/null ; then
  114. return 0 #If the screen does NOT exist, returns false, or nothing.
  115. else
  116. return 1 #If the screen does exist, return true.
  117. fi
  118. }
  119. # Checks if the server is running then send a message. # Bug Found, needs fixed. If status checking a server ID higher than current listed servers, shows ID (NoName) Active, even though it doesn't exist.
  120. get_running() {
  121. if is_running "$1" ; then
  122. echo -e "${LIGHTGREEN}Server ID:${GREEN}$1 ${SERVER_NAME[$1]}${LIGHTGREEN}: Active.${NOCOLOR}"
  123. else
  124. if [ "${SERVER_ENABLED[$1]}" = true ] ; then
  125. echo -e "${LIGHTGREEN}Server ID:${GREEN}$1 ${SERVER_NAME[$1]}${LIGHTGREEN}: ${RED}Offline.${NOCOLOR}"
  126. else
  127. echo -e "${LIGHTGREEN}Server ID:${GREEN}$1 ${SERVER_NAME[$1]}${LIGHTGREEN}: ${YELLOW}Disabled.${NOCOLOR}"
  128. fi
  129. fi
  130. }
  131. start_servers() {
  132. if server_exist "$1" ; then
  133. exist="false"
  134. echo -e "${LIGHTGREEN}Server ID:${GREEN}$1 ${SERVER_NAME[$1]}${LIGHTGREEN}...${NOCOLOR} "
  135. if is_running "$1" ; then
  136. echo -e " ${GREEN}Running!${NOCOLOR}"
  137. else
  138. if [ "${SERVER_ENABLED[$1]}" == true ] ; then
  139. while [ "$exist" == "false" ]; do
  140. if [ -d "$SERVER_SETTINGS/${SERVER_PATH}" ] ; then
  141. if [ "${SERVER_EXTRAS[$1]}" != none ] ; then
  142. #Run specific commands based on each server listed of the servers.cfg
  143. echo -e "${LIGHTGREEN}Running Extra_Commands For ${GREEN}${SERVER_NAME[$1]}${LIGHTGREEN}.${NOCOLOR}"
  144. command "cd $SERVER_SETTINGS/${SERVER_PATH[$1]} && ${SERVER_EXTRAS[$1]}"
  145. fi
  146. #Either this is the Spigot.jar or Bungeecord as listed in the servers.cfg
  147. if [ -f "$SERVER_SETTINGS/${SERVER_CORE[$1]}" ] ; then
  148. { cp "$SERVER_SETTINGS/${SERVER_CORE[$1]}" "${SERVER_SETTINGS}/${SERVER_PATH[$1]}/${SERVER_CORE[$1]}"
  149. echo -e " ${LIGHTGREEN}Copied ${GREEN}${SERVER_CORE[$1]}${LIGHTGREEN} from ${GREEN}${SERVER_SETTINGS}${LIGHTGREEN}!${NOCOLOR}"
  150. }
  151. else {
  152. echo -e "\n${RED}ERROR! ${LIGHTGREEN}${SERVER_CORE[$1]} ${RED}Not Found!${NOCOLOR}"
  153. echo -e "${LIGHTGREEN} Has ${YELLOW}service mcservers update spigot/minecraft/snapshot/bungee/all${LIGHTGREEN} been ran?${NOCOLOR}"
  154. echo -e "${LIGHTGREEN} If you have recently ran ${YELLOW}update${LIGHTGREEN}, did output a different ${GREEN}filename/version${LIGHTGREEN} or ${GREEN} failed?${NOCOLOR}"
  155. echo -e "${LIGHTGREEN} Update your ${GREEN}servers.cfg${LIGHTGREEN} in ${GREEN}${SERVER_SETTINGS}${NOCOLOR}"
  156. }
  157. fi
  158. exist="true"
  159. else
  160. {
  161. if [ "$2" != "skip" ] ; then
  162. echo -e "\n${RED}ERROR! ${YELLOW}${SERVER_PATH[$1]}${LIGHTGREEN} in ${YELLOW}${SERVER_SETTINGS}${LIGHTGREEN} Doesn't Exist!${NOCOLOR}"
  163. echo -e "${LIGHTGREEN}Should ${GREEN}${SERVER_PATH[$1]}${LIGHTGREEN} be created and started?${NOCOLOR}"
  164. yes_or_no yn
  165. case "$yn" in
  166. Y) {
  167. echo -e "\n${LIGHTGREEN}Creating ${GREEN}${SERVER_PATH[$1]} ${LIGHTGREEN}in ${GREEN}${SERVER_SETTINGS}${LIGHTGREEN}...${NOCOLOR}"
  168. cd "${SERVER_SETTINGS}" || { echo -e -n "${RED}ERROR! Cannot Change Directories to ${SERVER_SETTINGS} from " pwd "!${NOCOLOR}\n" && exit; }
  169. mkdir "${SERVER_PATH[$1]}"
  170. echo -e "${LIGHTGREEN}Created.${NOCOLOR}"
  171. };;
  172. N) {
  173. echo -e "${GREEN}$SERVER_PATH[$1]${LIGHTGREEN} Not Created. ${GREEN}${SERVER_NAME[$1]}${LIGHTGREEN} cannot start without it."
  174. };;
  175. esac
  176. fi
  177. }
  178. fi
  179. done
  180. cd "$SERVER_SETTINGS/${SERVER_PATH[$1]}" || { echo -e -n "${RED}ERROR! Cannot Change Directories to ${SERVER_SETTINGS}/${SERVER_PATH[$1]} from " pwd "!${NOCOLOR}\n" && exit; }
  181. command "screen -dmS ${SERVER_NAME[$1]} ${START_ARGS[$1]} -Dserver=${SERVER_NAME[$1]} ${SERVER_CORE[$1]}"
  182. echo -e " ${GREEN}Starting!${NOCOLOR}"
  183. else
  184. echo -e " ${YELLOW}DISABLED!${NOCOLOR}"
  185. fi
  186. fi
  187. exist="false"
  188. fi
  189. }
  190. stop_servers() {
  191. if server_exist "$1" ; then
  192. echo -e -n "\n${LIGHTGREEN}To stop countdown/script entirely: ${YELLOW}CTRL${LIGHTGREEN}+${YELLOW}C${LIGHTGREEN}.${NOCOLOR}"
  193. i="3"
  194. while [ "$i" -gt 0 ]; do
  195. echo -e -n "${LIGHTGREEN} .${NOCOLOR}"
  196. sleep 1
  197. : $((i--))
  198. done
  199. echo " "
  200. if is_running "$1" ; then
  201. echo ""
  202. echo -e -n "${RED}Stopping Server ${LIGHTGREEN}ID:${GREEN}$1 ${SERVER_NAME[$1]}${RED}...${NOCOLOR}"
  203. else
  204. echo -e "${LIGHTGREEN}Server ID:${GREEN}$1 ${SERVER_NAME[$1]}${LIGHTGREEN}: ${YELLOW}Already Offline?${NOCOLOR}"
  205. fi
  206. if is_running "$1" ; then
  207. i="${SHUTDOWN_SECONDS[$1]}"
  208. while [ "$i" -gt 0 ]; do
  209. command "screen -rx ${SERVER_NAME[$1]} -X eval 'stuff \"${MSG_CMD[$1]} ${SHUTDOWN_MSG1[$1]}$i${SHUTDOWN_MSG2[$1]}\"\015'"
  210. echo -e -n "${LIGHTGREEN} ${i}s...${NOCOLOR}"
  211. sleep 1
  212. : $((i--))
  213. done
  214. echo -e "\n${LIGHTGREEN} Executing ${SHUTDOWN_CMD[$1]}."
  215. command "screen -rx ${SERVER_NAME[$1]} -X eval 'stuff \"${SHUTDOWN_CMD[$1]}\"\015'"
  216. sleep 3
  217. echo -e -n "${LIGHTGREEN} Waiting until server is offline.${NOCOLOR}"
  218. i="${SHUTDOWN_MAX_WAIT[$1]}"
  219. while [ "$i" -gt 0 ]; do
  220. if is_running "$1" ; then
  221. echo -e -n "${LIGHTGREEN} .${NOCOLOR}"
  222. sleep 1
  223. : $((i--))
  224. else
  225. i="0"
  226. fi
  227. done
  228. echo -e " "
  229. if is_running "$1" ; then
  230. echo -e "${GREEN}${SERVER_NAME} ${LIGHTGREEN}has not finished shutting down after 10 seconds.${NOCOLOR}"
  231. echo -e "${LIGHTGREEN}Please ${YELLOW}Wait${LIGHTGREEN} or ${YELLOW}Check${LIGHTGREEN} it's screen."
  232. echo -e "${LIGHTGREEN} Use: ${YELLOW}service mcservers screen $1${NOCOLOR}"
  233. fi
  234. fi
  235. fi
  236. }
  237. restart_servers() {
  238. if server_exist "$1" ; then
  239. echo -e -n "${YELLOW}Restarting ${LIGHTGREEN}Server ID:${GREEN}$1 ${SERVER_NAME[$1]}... ${NOCOLOR}"
  240. if is_running "$1" ; then
  241. stop_servers "$1"
  242. sleep 2
  243. start_servers "$1"
  244. else
  245. start_servers "$1"
  246. fi
  247. fi
  248. }
  249. update_spigot(){
  250. if [ "${BUILDTOOLS_URL}" == "none" ] ; then
  251. echo -e "\n${YELLOW}Skipping... BUILDTOOLS_URL=\"none\"\n${NOCOLOR}"
  252. else
  253. cd "$SERVER_SETTINGS/buildtools" || { echo -e -n "${RED}ERROR! Cannot Change Directories to ${SERVER_SETTINGS}/buildtools from " pwd "!${NOCOLOR}\n" && exit; }
  254. if [ "$1" == "clean" ] ; then
  255. echo " "
  256. echo -e -n "${LIGHTGREEN}Cleaning Up in: ${NOCOLOR}"
  257. pwd;
  258. command "find . | grep -v 'buildtools.sh' | xargs rm -rf"
  259. fi
  260. if [ -f "BuildTools.jar?" ] ; then
  261. command "rm BuildTools.jar?"
  262. echo " "
  263. fi
  264. if [ -f "BuildTools.jar" ] ; then
  265. command "rm BuildTools.jar"
  266. fi
  267. echo -e -n "\n${LIGHTGREEN}Downloading Latest ${GREEN}BuildTools.jar ${LIGHTGREEN}for${GREEN} ${BUILDTOOLS_SPIGOT} ${LIGHTGREEN}Please Wait.${NOCOLOR}"
  268. i="3"
  269. while [ "$i" -gt 0 ]; do
  270. echo -e -n "${LIGHTGREEN} .${NOCOLOR}"
  271. sleep 1
  272. : $((i--))
  273. done
  274. echo -e "\n${LIGHTGREEN}Downloading ${GREEN}BuildTools.jar${LIGHTGREEN}...${NOCOLOR}"
  275. curl "${BUILDTOOLS_URL}" -o "BuildTools.jar"
  276. echo -e "\n${LIGHTGREEN}Running ${GREEN}Buildtools.jar${NOCOLOR}\n"
  277. HOME=$USER_DIRECTORY java -jar "BuildTools.jar" ${BUILDTOOLS_BUILD_VERSION}
  278. #${BUILDTOOL_BUILD_VERSION}
  279. echo -e "\n${LIGHTGREEN}Copying${GREEN} ${BUILDTOOLS_SPIGOT} ${LIGHTGREEN}to${GREEN} $SERVER_SETTINGS ${LIGHTGREEN}as${GREEN} ${BUILDTOOLS_OUTPUT}${LIGHTGREEN}.${NOCOLOR}"
  280. if [ -f "${BUILDTOOLS_SPIGOT}" ] ; then
  281. { command "cp $SERVER_SETTINGS/buildtools/${BUILDTOOLS_SPIGOT} ../${BUILDTOOLS_OUTPUT}"
  282. echo -e "${GREEN}Spigot ${LIGHTGREEN}Servers will be updated upon next ${YELLOW}Start${LIGHTGREEN}/${YELLOW}Restart${LIGHTGREEN}.${NOCOLOR}"
  283. }
  284. else {
  285. echo -e "\n${RED}ERROR! ${GREEN}${BUILDTOOLS_SPIGOT} ${RED}Not Found!${NOCOLOR}"
  286. echo -e "${LIGHTGREEN} Did ${GREEN}BuildTools.jar${LIGHTGREEN} output a different ${GREEN}filename/version${LIGHTGREEN}?${NOCOLOR}"
  287. echo -e "${LIGHTGREEN} If so, update your ${GREEN}servers.cfg${LIGHTGREEN} in ${GREEN}${SERVER_SETTINGS}${NOCOLOR}"
  288. echo -e "${LIGHTGREEN} with ${GREEN}BUILDTOOLS_SPIGOT=\"CoreFileName.jar\" ${LIGHTGREEN}from ${GREEN}${SERVER_SETTINGS}/buildtools${LIGHTGREEN}.${NOCOLOR}"
  289. }
  290. fi
  291. fi
  292. }
  293. update_minecraft(){
  294. if [ "${MINECECRAFT_SERVER_URL}" == "none" ] ; then
  295. echo -e "\n${YELLOW}Skipping... MINECECRAFT_SERVER_URL=\"none\"\n${NOCOLOR}"
  296. exit
  297. else
  298. echo -e -n "${LIGHTGREEN}Deleting Old ${GREEN}${MINECRAFT_SERVER}${LIGHTGREEN}...${NOCOLOR}"
  299. cd "$SERVER_SETTINGS" || { echo -e -n "${RED}ERROR! Cannot Change Directories to ${SERVER_SETTINGS} from " pwd "!${NOCOLOR}\n" && exit; }
  300. pwd;
  301. if [ -f "${MINECRAFT_SERVER}" ] ; then
  302. { rm "${MINECRAFT_SERVER}"
  303. echo -e "${LIGHTGREEN} Deleted!${NOCOLOR}"
  304. }
  305. else { echo -e "${LIGHTGREEN} None Detected.${NOCOLOR}"
  306. }
  307. fi
  308. if [ -f "${MINECRAFT_SERVER}?" ] ; then
  309. command "rm ${MINECRAFT_SERVER}?"
  310. echo " "
  311. fi
  312. echo -e -n "\n${LIGHTGREEN}Downloading Latest ${GREEN}${MINECRAFT_SERVER} ${LIGHTGREEN}From Minecraft.net. Please Wait.${NOCOLOR}"
  313. i="3"
  314. while [ "$i" -gt 0 ]; do
  315. echo -e -n "${LIGHTGREEN} .${NOCOLOR}"
  316. sleep 1
  317. : $((i--))
  318. done
  319. echo -e "\n"
  320. curl "${MINECRAFT_SERVER_URL}" -o "${MINECRAFT_SERVER}"
  321. if [ -f "${MINECRAFT_SERVER}" ] ; then
  322. { echo -e "\n${GREEN}Vanilla Minecraft ${LIGHTGREEN}Servers will be updated upon next ${YELLOW}Start${LIGHTGREEN}/${YELLOW}Restart${LIGHTGREEN}.${NOCOLOR}"
  323. }
  324. else {
  325. echo -e "\n${RED}ERROR! ${GREEN}${MINECRAFT_SERVER} ${RED}Not Found!${NOCOLOR}"
  326. echo -e "${LIGHTGREEN} Did the download of the ${GREEN}${MINECRAFT_SERVER_URL}${RED} Fail?${NOCOLOR}"
  327. echo -e "${LIGHTGREEN} If so, update your ${GREEN}servers.cfg${LIGHTGREEN} in ${GREEN}${SERVER_SETTINGS}${NOCOLOR}"
  328. echo -e "${LIGHTGREEN} with ${GREEN}MINECRAFT_SERVER_URL=\"URL-To-CoreFileName.jar\" ${LIGHTGREEN}from ${GREEN}Minecraft.net/download${LIGHTGREEN}.${NOCOLOR}"
  329. }
  330. fi
  331. fi
  332. }
  333. update_snapshot(){
  334. if [ "${MINECRAFT_SNAPSHOT_URL}" == "none" ] ; then
  335. echo -e "\n${YELLOW}Skipping... MINECECRAFT_SNAPSHOT_URL=\"none\"\n${NOCOLOR}"
  336. else
  337. echo -e -n "${LIGHTGREEN}Deleting Old ${GREEN}${MINECRAFT_SNAPSHOT}${LIGHTGREEN}... ${NOCOLOR}"
  338. cd "$SERVER_SETTINGS" || { echo -e -n "${RED}ERROR! Cannot Change Directories to ${SERVER_SETTINGS} from " pwd "!${NOCOLOR}\n" && exit; }
  339. pwd;
  340. if [ -f "${MINECRAFT_SNAPSHOT}" ] ; then
  341. { rm "${MINECRAFT_SNAPSHOT}"
  342. echo -e "${LIGHTGREEN} Deleted."
  343. }
  344. else { echo -e "${LIGHTGREEN} None Detected."
  345. }
  346. fi
  347. if [ -f "${MINECRAFT_SNAPSHOT}?" ] ; then
  348. command "rm ${MINECRAFT_SNAPSHOT}?"
  349. echo " "
  350. fi
  351. echo -e -n "\n${LIGHTGREEN}Downloading Latest ${GREEN}${MINECRAFT_SNAPSHOT} ${LIGHTGREEN}From Minecraft.net. Please Wait.${NOCOLOR}"
  352. i="3"
  353. while [ "$i" -gt 0 ]; do
  354. echo -e -n "${LIGHTGREEN} .${NOCOLOR}"
  355. sleep 1
  356. : $((i--))
  357. done
  358. echo -e "\n"
  359. curl "${MINECRAFT_SNAPSHOT_URL}" -o "${MINECRAFT_SNAPSHOT}"
  360. if [ -f "${MINECRAFT_SNAPSHOT}" ] ; then
  361. { echo -e "\n${GREEN}Minecraft Snapshot ${LIGHTGREEN}Servers will be updated upon next ${YELLOW}Start${LIGHTGREEN}/${YELLOW}Restart${LIGHTGREEN}.${NOCOLOR}"
  362. }
  363. else {
  364. echo -e "\n${RED}ERROR! ${GREEN}${MINECRAFT_SNAPSHOT} ${RED}Not Found!${NOCOLOR}"
  365. echo -e "${LIGHTGREEN} Did the download of the ${GREEN}${MINECRAFT_SNAPSHOT_URL}${RED} Fail?${NOCOLOR}"
  366. echo -e "${LIGHTGREEN} If so, update your ${GREEN}servers.cfg${LIGHTGREEN} in ${GREEN}${SERVER_SETTINGS}${NOCOLOR}"
  367. echo -e "${LIGHTGREEN} with ${GREEN}MINECRAFT_SNAPSHOT_URL=\"URL-To-CoreFileName.jar\"${LIGHTGREEN}.${NOCOLOR}"
  368. }
  369. fi
  370. fi
  371. }
  372. update_bungee(){
  373. if [ "${BUNGEECORD_URL}" == "none" ] ; then
  374. echo -e "\n${YELLOW}Skipping... BUNGEECORD_URL=\"none\"\n${NOCOLOR}"
  375. else
  376. echo -e -n "${LIGHTGREEN}Deleting Old ${GREEN}${BUNGEECORD}... ${NOCOLOR}"
  377. cd "$SERVER_SETTINGS" || { echo -e -n "${RED}ERROR! Cannot Change Directories to ${SERVER_SETTINGS} from " pwd "!${NOCOLOR}\n" && exit; }
  378. pwd;
  379. if [ -f "${BUNGEECORD}" ] ; then
  380. { rm "${BUNGEECORD}"
  381. echo -e "${LIGHTGREEN} Deleted."
  382. }
  383. else { echo -e "${LIGHTGREEN}None Detected."
  384. }
  385. fi
  386. if [ -f "${BUNGEECORD}?" ] ; then
  387. command "rm ${BUNGEECORD}?"
  388. echo " "
  389. fi
  390. echo -e -n "\n${LIGHTGREEN}Downloading Latest ${GREEN}${BUNGEECORD}${LIGHTGREEN} Please Wait.${NOCOLOR}"
  391. i="3"
  392. while [ "$i" -gt 0 ]; do
  393. echo -e -n "${LIGHTGREEN} .${NOCOLOR}"
  394. sleep 1
  395. : $((i--))
  396. done
  397. echo -e "\n"
  398. curl "${BUNGEECORD_URL}" -o "${BUNGEECORD}"
  399. if [ -f "${BUNGEECORD}" ] ; then
  400. { echo -e "\n${GREEN}${BUNGEECORD}${LIGHTGREEN} Servers will be updated upon next ${YELLOW}Start${LIGHTGREEN}/${YELLOW}Restart${LIGHTGREEN}.${NOCOLOR}"
  401. }
  402. else {
  403. echo -e "\n${RED}ERROR! ${GREEN}${BUNGEECORD} ${RED}Not Found!${NOCOLOR}"
  404. echo -e "${LIGHTGREEN} Did the download of the ${GREEN}${BUNGEECORD_URL}${RED} Fail?${NOCOLOR}"
  405. echo -e "${LIGHTGREEN} If so, update your ${GREEN}servers.cfg${LIGHTGREEN} in ${GREEN}${SERVER_SETTINGS}${NOCOLOR}"
  406. echo -e "${LIGHTGREEN} with ${GREEN}BUNGEECORD_URL=\"URL-To-FileName.jar\"${LIGHTGREEN}.${NOCOLOR}"
  407. }
  408. fi
  409. fi
  410. }
  411. show_screens(){
  412. if [ "${SHOW_SCREENS}" == "True" ] || [ "${SHOW_SCREENS}" == "true" ] || [ "${SHOW_SCREENS}" == "TRUE" ]; then {
  413. command "screen -ls"
  414. echo -e "\n ${LIGHTGREEN}Access Screen: ${YELLOW}service mcservers screen ID#${LIGHTGREEN}.${NOCOLOR}"
  415. echo -e " ${LIGHTGREEN}If a \"${YELLOW}Starting!${LIGHTGREEN}\" server isn't listed, it's offline."
  416. echo -e " ${LIGHTGREEN}If meant to be online, check the server log:${NOCOLOR}"
  417. echo -e " ${YELLOW}service mcservers log ID#${LIGHTGREEN}.${NOCOLOR}"
  418. }
  419. fi
  420. }
  421. yes_or_no(){
  422. while [[ "$exist" != [yYnN] ]]
  423. do
  424. echo -e -n "${LIGHTGREEN}(${YELLOW}Y${LIGHTGREEN})es or (${YELLOW}N${LIGHTGREEN})o: ${NOCOLOR}"
  425. read -r -s -n1 exist
  426. case "$exist" in
  427. "y"|"Y") { eval "$1"="Y"
  428. };;
  429. "n"|"N") { eval "$1"="N"
  430. };;
  431. *){
  432. echo -e "\n\n${LIGHTGREEN}Please input (${YELLOW}Y${LIGHTGREEN})es or (${YELLOW}N${LIGHTGREEN})o only.${NOCOLOR}"
  433. };;
  434. esac
  435. done
  436. echo -e "\n"
  437. }
  438. server_exist(){
  439. if [ "$SERVER_NAME[$1]" = "" ] ; then
  440. echo -e "\n${LIGHTGREEN}$1${YELLOW} Does Not Exist!"
  441. return 1
  442. else
  443. return 0
  444. fi
  445. }
  446. not_a_number(){
  447. echo -e "\n${LIGHTGREEN}Server ID ${RED}Must Be A Number!${NOCOLOR}"
  448. }
  449.  
  450. commandsyml_template(){
  451. echo -e "\n${YELLOW}Creating commands.yml Template in ${SERVER_SETTINGS}/commandsTEMPLATE.yml${NOCOLOR}"
  452. if [ -f "$SERVER_SETTINGS/commandsTEMPLATE.yml" ] ; then
  453. echo -e "${YELLOW}CAUTION!${GREEN} commandsTEMPLATE.yml${LIGHTGREEN} Already Exists!${NOCOLOR}"
  454. echo -e "${LIGHTGREEN}Do you wish to overwrite it?"
  455. rm "${SERVER_SETTINGS}/commandsTEMPLATE.yml"
  456. yes_or_no yn
  457. else
  458. yn="Y"
  459. fi
  460. case "$yn" in
  461. Y) { cd "$SERVER_SETTINGS" || { echo -e -n "${RED}ERROR! Cannot Change Directories to ${SERVER_SETTINGS} from " pwd "!${NOCOLOR}\n" && exit; }
  462. {
  463. echo '# This is the commands configuration file for Bukkit.'
  464. echo '# For documentation on how to make use of this file, check out the Bukkit Wiki at'
  465. echo '# http://wiki.bukkit.org/Commands.yml'
  466. echo '# '
  467. echo '# If you need help on this file, feel free to join us on irc or leave a message'
  468. echo '# on the forums asking for advice.'
  469. echo '# '
  470. echo '# IRC: #spigot @ irc.spi.gt'
  471. echo '# (If this means nothing to you, just go to http://www.spigotmc.org/pages/irc/ )'
  472. echo '# Forums: http://www.spigotmc.org/'
  473. echo '# Bug tracker: http://www.spigotmc.org/go/bugs'
  474. echo ' '
  475. echo 'command-block-overrides: {} # Remove the {} if enabling/adding anything in the listing below it.'
  476. echo '#- summon'
  477. echo '#- tellraw'
  478. echo '#- setblock'
  479. echo '#- tp'
  480. echo '#- give'
  481. echo '#- clear'
  482. echo '#- scoreboard'
  483. echo '#- clone'
  484. echo '#- execute'
  485. echo '#- fill'
  486. echo '#- kill'
  487. echo '#- particle'
  488. echo '#- replaceitem'
  489. echo '#- setblock'
  490. echo '#- spawnpoint'
  491. echo '#- spreadplayers'
  492. echo '#- stats'
  493. echo '#- summon'
  494. echo '#- testfor'
  495. echo '#- testforblock'
  496. echo '#- testforblocks'
  497. echo '#- time'
  498. echo '#- trigger'
  499. echo '#- weather'
  500. echo '#- xp'
  501. echo '#- blockdata'
  502. echo '#- effect'
  503. echo '#- enchant'
  504. echo '#- entitydata'
  505. echo '#- gamerule'
  506. echo '#- particle'
  507. echo '#- playsound'
  508. echo 'aliases: {} # Remove the {} if enabling/adding anything in the listing below it.'
  509. echo '# w:'
  510. echo '# - mywarp $1-'
  511. echo '# warp:'
  512. echo '# - mywarp $1-'
  513. echo '# warps:'
  514. echo '# - mywarp list $1-'
  515. echo '# setwarp:'
  516. echo '# - mywarp create $1-'
  517. echo '# delwarp:'
  518. echo '# - mywarp delete $1-'
  519. } >> commandsTEMPLATE.yml
  520. echo -e "\n${LIGHTGREEN}Done!"
  521. };;
  522. N) {
  523. echo -e "\n${GREEN}commandsTEMPLATE.tml ${LIGHTGREEN}has not be altered.${NOCOLOR}"
  524. };;
  525. esac
  526. }
  527. spigotyml_template(){
  528. echo -e "\n${YELLOW}Creating spigot.yml Template in ${SERVER_SETTINGS}/spigotTEMPLATE.yml${NOCOLOR}"
  529. if [ -f "$SERVER_SETTINGS/spigotTEMPLATE.yml" ] ; then
  530. echo -e "${YELLOW}CAUTION!${GREEN} spigotTEMPLATE.yml${LIGHTGREEN} Already Exists!${NOCOLOR}"
  531. echo -e "${LIGHTGREEN}Do you wish to overwrite it?"
  532. rm "${SERVER_SETTINGS}/spigotTEMPLATE.yml"
  533. yes_or_no yn
  534. else
  535. yn="Y"
  536. fi
  537. case "$yn" in
  538. Y) { cd "$SERVER_SETTINGS" || { echo -e -n "${RED}ERROR! Cannot Change Directories to ${SERVER_SETTINGS} from " pwd "!${NOCOLOR}\n" && exit; }
  539. {
  540. echo '# This is the main configuration file for Spigot.'
  541. echo '# As you can see, theres tons to configure. Some options may impact gameplay, so use'
  542. echo '# with caution, and make sure you know what each option does before configuring.'
  543. echo '# For a reference for any variable inside this file, check out the Spigot wiki at'
  544. echo '# http://www.spigotmc.org/wiki/spigot-configuration/'
  545. echo '# '
  546. echo '# If you need help with the configuration or have any questions related to Spigot,'
  547. echo '# join us at the IRC or drop by our forums and leave a post.'
  548. echo '# '
  549. echo '# IRC: #spigot @ irc.spi.gt ( http://www.spigotmc.org/pages/irc/ )'
  550. echo '# Forums: http://www.spigotmc.org/'
  551. echo ' '
  552. echo 'config-version: 8'
  553. echo 'settings:'
  554. echo ' save-user-cache-on-stop-only: false'
  555. echo ' bungeecord: false #Enable this if using BungeeCord'
  556. echo ' late-bind: true'
  557. echo ' sample-count: 12'
  558. echo ' player-shuffle: 1000'
  559. echo ' filter-creative-items: true'
  560. echo ' user-cache-size: 1000'
  561. echo ' int-cache-limit: 1024'
  562. echo ' moved-wrongly-threshold: 0.07'
  563. echo ' moved-too-quickly-threshold: 100.0'
  564. echo ' timeout-time: 60'
  565. echo ' restart-on-crash: true'
  566. echo ' restart-script: ./startserver.sh'
  567. echo ' netty-threads: 4'
  568. echo ' attribute:'
  569. echo ' maxHealth:'
  570. echo ' max: 2048.0'
  571. echo ' movementSpeed:'
  572. echo ' max: 2048.0'
  573. echo ' attackDamage:'
  574. echo ' max: 2048.0'
  575. echo ' debug: false'
  576. echo 'commands:'
  577. echo ' tab-complete: 2'
  578. echo ' log: true'
  579. echo ' spam-exclusions:'
  580. echo ' - /skill'
  581. echo ' silent-commandblock-console: true'
  582. echo ' replace-commands:'
  583. echo ' - setblock'
  584. echo ' - summon'
  585. echo ' - testforblock'
  586. echo ' - tellraw'
  587. echo ' #- give'
  588. echo ' #- clear'
  589. echo 'messages:'
  590. echo ' whitelist: [Bouncer]: We are sorry, but you are not...\n on THE list...'
  591. echo ' unknown-command: I am sorry, but I did not understand...'
  592. echo ' server-full: We cannot fit another warm body here...'
  593. echo ' outdated-client: Please update your client to {0}'
  594. echo ' outdated-server: You young wipper snappers and your upgrading...\n You are on {0}, we are not quite there yet!'
  595. echo ' restart: Please return in a moment.\nRebooting conciousness...'
  596. echo 'stats:'
  597. echo ' disable-saving: false'
  598. echo ' forced-stats:'
  599. echo ' achievement.openInventory: 1'
  600. echo 'global-api-cache: false'
  601. echo 'world-settings:'
  602. echo ' default:'
  603. echo ' verbose: false'
  604. echo ' growth:'
  605. echo ' cactus-modifier: 100'
  606. echo ' cane-modifier: 100'
  607. echo ' melon-modifier: 100'
  608. echo ' mushroom-modifier: 100'
  609. echo ' pumpkin-modifier: 100'
  610. echo ' sapling-modifier: 100'
  611. echo ' wheat-modifier: 100'
  612. echo ' netherwart-modifier: 100'
  613. echo ' entity-activation-range:'
  614. echo ' animals: 32'
  615. echo ' monsters: 32'
  616. echo ' misc: 16'
  617. echo ' entity-tracking-range:'
  618. echo ' players: 128'
  619. echo ' animals: 48'
  620. echo ' monsters: 48'
  621. echo ' misc: 32'
  622. echo ' other: 128'
  623. echo ' ticks-per:'
  624. echo ' hopper-transfer: 10'
  625. echo ' hopper-amount: 1'
  626. echo ' mob-spawn-range: 4'
  627. echo ' anti-xray: #anti-xray customized to not only hide ores, but detur world-download clients. Replaces all hidden blocks with random tnt and redstoneblocks. Big Boom!'
  628. echo ' enabled: true'
  629. echo ' engine-mode: 2'
  630. echo ' hide-blocks:'
  631. echo ' - 1'
  632. echo ' - 3'
  633. echo ' - 14'
  634. echo ' - 15'
  635. echo ' - 16'
  636. echo ' - 21'
  637. echo ' - 48'
  638. echo ' - 49'
  639. echo ' - 54'
  640. echo ' - 56'
  641. echo ' - 73'
  642. echo ' - 74'
  643. echo ' - 82'
  644. echo ' - 129'
  645. echo ' - 130'
  646. echo ' replace-blocks:'
  647. echo ' - 46'
  648. echo ' - 152'
  649. echo ' nerf-spawner-mobs: false'
  650. echo ' random-light-updates: true'
  651. echo ' save-structure-info: true'
  652. echo ' max-bulk-chunks: 12'
  653. echo ' max-entity-collisions: 6'
  654. echo ' dragon-death-sound-radius: 1000'
  655. echo ' hunger:'
  656. echo ' walk-exhaustion: 0.2'
  657. echo ' sprint-exhaustion: 0.8'
  658. echo ' combat-exhaustion: 0.3'
  659. echo ' regen-exhaustion: 3.0'
  660. echo ' max-tnt-per-tick: 4'
  661. echo ' max-tick-time:'
  662. echo ' tile: 20'
  663. echo ' entity: 25'
  664. echo ' item-despawn-rate: 18000'
  665. echo ' merge-radius:'
  666. echo ' item: 4.0'
  667. echo ' exp: 4.0'
  668. echo ' arrow-despawn-rate: 1800'
  669. echo ' enable-zombie-pigmen-portal-spawns: true'
  670. echo ' wither-spawn-sound-radius: 512'
  671. echo ' view-distance: 10'
  672. echo ' hanging-tick-frequency: 100'
  673. echo ' zombie-aggressive-towards-villager: true'
  674. echo ' chunks-per-tick: 100'
  675. echo ' clear-tick-list: true'
  676. echo ' hopper-alt-ticking: true'
  677. } >> spigotTEMPLATE.yml
  678. echo -e "\n${LIGHTGREEN}Done!"
  679. };;
  680. N) {
  681. echo -e "\n${GREEN}spigotTEMPLATE.tml ${LIGHTGREEN}has not be altered.${NOCOLOR}"
  682. };;
  683. esac
  684. }
  685.  
  686. #helpyml_template(){ #At this time, I have no information to go off of for a decent help setup. Leaving off script until then.
  687. # echo -e "\n${YELLOW}Creating help.yml Template in ${SERVER_SETTINGS}/helpTEMPLATE.yml${NOCOLOR}"
  688. # if [ -f $SERVER_SETTINGS/"helpTEMPLATE.yml" ] ; then
  689. # echo -e "${YELLOW}CAUTION!${GREEN} helpTEMPLATE.yml${LIGHTGREEN} Already Exists!${NOCOLOR}"
  690. # echo -e "${LIGHTGREEN}Do you wish to overwrite it?"
  691. # rm "${SERVER_SETTINGS}/helpTEMPLATE.yml"
  692. # yes_or_no yn
  693. # else
  694. # yn="Y"
  695. # fi
  696. # case "$yn" in
  697. # Y) { cd $SERVER_SETTINGS || { echo -e -n "${RED}ERROR! Cannot Change Directories to ${SERVER_SETTINGS} from " pwd "!${NOCOLOR}\n" && exit; }
  698. # {
  699. # echo ''
  700. # } >> helpTEMPLATE.yml
  701. # echo -e "\n${LIGHTGREEN}Done!"
  702. # };;
  703. # N) {
  704. # echo -e "\n${GREEN}helpTEMPLATE.tml ${LIGHTGREEN}has not be altered.${NOCOLOR}"
  705. # };;
  706. # esac
  707. #}
  708. bukkityml_template(){
  709. echo -e "\n${YELLOW}Creating bukkit.yml Template in ${SERVER_SETTINGS}/bukkitTEMPLATE.yml${NOCOLOR}"
  710. if [ -f "$SERVER_SETTINGS/bukkitTEMPLATE.yml" ] ; then
  711. echo -e "${YELLOW}CAUTION!${GREEN} bukkitTEMPLATE.yml${LIGHTGREEN} Already Exists!${NOCOLOR}"
  712. echo -e "${LIGHTGREEN}Do you wish to overwrite it?"
  713. rm "${SERVER_SETTINGS}/bukkitTEMPLATE.yml"
  714. yes_or_no yn
  715. else
  716. yn="Y"
  717. fi
  718. case "$yn" in
  719. Y) { cd "$SERVER_SETTINGS" || { echo -e -n "${RED}ERROR! Cannot Change Directories to ${SERVER_SETTINGS} from " pwd "!${NOCOLOR}\n" && exit; }
  720. {
  721. echo '# This is the main configuration file for Bukkit.'
  722. echo '# As you can see, theres actually not that much to configure without any plugins.'
  723. echo '# For a reference for any variable inside this file, check out the Bukkit Wiki at'
  724. echo '# http://wiki.bukkit.org/Bukkit.yml'
  725. echo '# '
  726. echo '# If you need help on this file, feel free to join us on irc or leave a message'
  727. echo '# on the forums asking for advice.'
  728. echo '# '
  729. echo '# IRC: #spigot @ irc.spi.gt'
  730. echo '# (If this means nothing to you, just go to http://www.spigotmc.org/pages/irc/ )'
  731. echo '# Forums: http://www.spigotmc.org/'
  732. echo '# Bug tracker: http://www.spigotmc.org/go/bugs'
  733. echo ' '
  734. echo ' '
  735. echo 'settings:'
  736. echo ' allow-end: true'
  737. echo ' warn-on-overload: true'
  738. echo ' permissions-file: permissions.yml'
  739. echo ' update-folder: UpdatePluginsOnNextServerStart'
  740. echo ' use-exact-login-location: true'
  741. echo ' world-container:'
  742. echo ' plugin-profiling: false'
  743. echo ' connection-throttle: 5000'
  744. echo ' query-plugins: true'
  745. echo ' deprecated-verbose: default'
  746. echo ' shutdown-message: Server going down for a bit. Please visit Site for information.'
  747. echo 'spawn-limits:'
  748. echo ' monsters: 75'
  749. echo ' animals: 45'
  750. echo ' water-animals: 25'
  751. echo ' ambient: 45'
  752. echo 'chunk-gc:'
  753. echo ' period-in-ticks: 600'
  754. echo ' load-threshold: 100'
  755. echo 'ticks-per:'
  756. echo ' animal-spawns: 400'
  757. echo ' monster-spawns: 10'
  758. echo ' autosave: 6000'
  759. echo 'database:'
  760. echo ' username: spigotserver314'
  761. echo ' isolation: SERIALIZABLE'
  762. echo ' driver: org.sqlite.JDBC'
  763. echo ' password: cookoo4tootwo'
  764. echo ' url: jdbc:sqlite:{DIR}{NAME}.db'
  765. echo '#worlds:'
  766. echo '# world1:'
  767. echo '# generator: CleanroomGenerator:10,stone,20,dirt,1,grass'
  768. } >> bukkitTEMPLATE.yml
  769. echo -e "\n${LIGHTGREEN}Done!"
  770. };;
  771. N) {
  772. echo -e "\n${GREEN}bukkitTEMPLATE.tml ${LIGHTGREEN}has not be altered.${NOCOLOR}"
  773. };;
  774. esac
  775. }
  776. serverproperties_template(){
  777. echo -e "\n${YELLOW}Creating server.properties Template in ${SERVER_SETTINGS}/serverTEMPLATE.properties${NOCOLOR}"
  778. if [ -f "$SERVER_SETTINGS/serverTEMPLATE.properties" ] ; then
  779. echo -e "${YELLOW}CAUTION!${GREEN} serverTEMPLATE.properties${LIGHTGREEN} Already Exists!${NOCOLOR}"
  780. echo -e "${LIGHTGREEN}Do you wish to overwrite it?"
  781. rm "${SERVER_SETTINGS}/serverTEMPLATE.properties"
  782. yes_or_no yn
  783. else
  784. yn="Y"
  785. fi
  786. case "$yn" in
  787. Y) { cd "$SERVER_SETTINGS" || { echo -e -n "${RED}ERROR! Cannot Change Directories to ${SERVER_SETTINGS} from " pwd "!${NOCOLOR}\n" && exit; }
  788. {
  789. echo '#All variables listed are explained at: http://minecraft.gamepedia.com/Server.properties'
  790. echo '#Minecraft server properties'
  791. echo ' '
  792. echo 'generator-settings='
  793. echo 'op-permission-level=1 #Setting to 1 for new server owners protection'
  794. echo 'allow-nether=true'
  795. echo 'resource-pack-hash='
  796. echo 'level-name=helloworld'
  797. echo 'enable-query=false'
  798. echo 'allow-flight=false'
  799. echo 'announce-player-achievements=false #I personally find this annoying on servers. Default is true.'
  800. echo 'server-port=25565 #Set this to a port other than 25565 is running BungeeCord!'
  801. echo 'max-world-size=29999984'
  802. echo 'level-type=DEFAULT'
  803. echo 'enable-rcon=false #For the love of god, keep this false!'
  804. echo 'rcon.password=asdf1238asd168 #If rcon is enabled, CHANGE THIS to something UNIQUE, and HARD to GUESS!'
  805. echo 'rcon.port=25575 #If rcon is enabled, CHANGE THIS to something UNIQUE, Unused, and HARD to GUESS!'
  806. echo 'level-seed='
  807. echo 'force-gamemode=true'
  808. echo 'server-ip='
  809. echo 'network-compression-threshold=256'
  810. echo 'max-build-height=256 #Did you know there is no max limit for this setting? Just dont kill your server!'
  811. echo 'spawn-npcs=true'
  812. echo 'white-list=false'
  813. echo 'spawn-animals=true'
  814. echo 'snooper-enabled=true #Leave this to true if youd like to help Mojang improve. Send anonomous details of server stats to Mojang.'
  815. echo 'online-mode=true #Set this to false if running through BungeeCord!'
  816. echo 'resource-pack='
  817. echo 'pvp=true'
  818. echo 'difficulty=1'
  819. echo 'enable-command-block=true'
  820. echo 'gamemode=0'
  821. echo 'player-idle-timeout=30 #30 minutes of inactivity will kick player.'
  822. echo 'max-players=10'
  823. echo 'max-tick-time=60000'
  824. echo 'spawn-monsters=true'
  825. echo 'spawn-animals=true'
  826. echo 'generate-structures=true'
  827. echo 'view-distance=7'
  828. echo 'motd=A Brand New Minecraft Server!'
  829. echo 'use-native-transport=true'
  830. echo 'spawn-protection=16 #0 disables spawn protection, 1 protects a 3x3 area. Imagine the size of the default 16! No max size. Only OPs can edit in this protection. If no OPs in the OPs listing, this option is disabled.'
  831. echo 'hardcore=false'
  832. } >> serverTEMPLATE.properties
  833. echo -e "\n${LIGHTGREEN}Done!"
  834. };;
  835. N) {
  836. echo -e "\n${GREEN}serverTEMPLATE.properties ${LIGHTGREEN}has not be altered.${NOCOLOR}"
  837. };;
  838. esac
  839. }
  840.  
  841. # Service Start Arguments
  842. SERVERS=${#SERVER_NAME[@]}
  843. case "$1" in
  844. start){ #Until I find a better way to have start/stop the server upon system start/stop, going to the basics.
  845. for (( i = 0; i < $SERVERS; i++ )) ; do
  846. start_servers $i skip
  847. sleep 2
  848. done
  849. };;
  850. stop){ #Until I find a better way to have start/stop the server upon system start/stop, going to the basics.
  851. for (( i = 0; i < $SERVERS; i++ )) ; do
  852. stop_servers $i
  853. sleep 5
  854. done
  855. };;
  856. screen){
  857. if [[ "$2" =~ ^[0-9]+$ ]] ; then
  858. if server_exist "$2" ; then
  859. if is_running "$2" ; then
  860. case "$3" in
  861. kill|Kill) {
  862. if [ "$4" != "Y" ] && [ "$4" != "y" ] ; then
  863. echo -e "\n${RED}Are you sure you want to kill &{YELLOW}${SERVER_NAME[$2]}${RED}?${NOCOLOR}"
  864. yes_or_no yn
  865. echo " "
  866. else
  867. yn=Y
  868. fi
  869. yes_or_no yn
  870. case "$yn" in
  871. Y) {
  872. command "screen -XS ${SERVER_NAME[$2]} kill"
  873. echo -e "${GREEN}${SERVER_NAME[$2]} ${LIGHTGREEN}Has Been ${YELLOW}Killed${NOCOLOR}"
  874. };;
  875. N) { echo -e "\n${GREEN}${SERVER_NAME[$2]} ${LIGHTGREEN} Will live another millisecond.${NOCOLOR}" #I really need to find something else to say here...
  876. };;
  877. esac
  878. };;
  879. send|Send) {
  880. if [ "$4" != "" ] ; then
  881. {
  882. command "screen -rx ${SERVER_NAME[$2]} -X eval 'stuff \"${*:4}\"\015'"
  883. echo -e "${LIGHTGREEN} Command Sent to server.${NOCOLOR}"
  884. }
  885. else
  886. {
  887. echo -e "\n${LIGHTGREEN}Input any command and text after ${YELLOW}SEND${LIGHTGREEN} to send a command to select server screen.${NOCOLOR}"
  888. echo -e "${LIGHTGREEN} Example: ${YELLOW}mcservers screen 1 send say Hello World!${NOCOLOR}"
  889. echo -e "\n${LIGHTGREEN}Tip: Wanting to send a message to all servers, such as ${YELLOW}Say ${LIGHTGREEN}or${YELLOW} Broadcast${LIGHTGREEN},${NOCOLOR}"
  890. echo -e "${LIGHTGREEN}AND you are using Bungee, may I suggest sending an ${YELLOW}Alert${LIGHTGREEN} message to that server?${NOCOLOR}"
  891. }
  892. fi
  893. };;
  894. "") { #if nothing after ServerID#, will open it's screen. Otherwise the above or below cases are ran.
  895. echo -e "\n${YELLOW}CAUTION! ${LIGHTGREEN}To Exit Screen: Hold ${YELLOW}CTRL${LIGHTGREEN}+${YELLOW}A${LIGHTGREEN}, let go and hit ${YELLOW}D${LIGHTGREEN}.${NOCOLOR}"
  896. read -s -n1 exist
  897. command "screen -x ${SERVER_NAME[$2]}"
  898. echo " "
  899. };;
  900. *|help){
  901. echo -e "${LIGHTGREEN} | ${YELLOW} Kill${LIGHTGREEN} | ${YELLOW} Send${LIGHTGREEN} | ${YELLOW} (Or Nothing)${LIGHTGREEN} |${NOCOLOR}"
  902. };;
  903. esac
  904. else
  905. echo -e "\n${LIGHTGREEN}Server ${GREEN}$2 ${SERVER_NAME[$2]}${LIGHTGREEN}: ${RED}Offline.${NOCOLOR}"
  906. fi
  907. else
  908. echo -e "\n${YELLOW}Server Choice Does Not Exit In servers.cfg!"
  909. fi
  910. else
  911. not_a_number
  912. fi
  913. };;
  914. backup){
  915. if [ ${MANUAL_BACKUPS_LOCATION} == "none" ] ; then
  916. {
  917. echo -e "${LIGHTGREEN}Backup Function Disabled Until MANUAL_BACKUPS_LOCATION is set with a directory.${NOCOLOR}"
  918. }
  919. else
  920. {
  921. case "$2" in
  922. Clean|clean) {
  923. if [[ "$3" =~ ^[0-9]+$ ]] ; then
  924. echo -e "\n${LIGHTGREEN}Checking directory size of ${SERVER_NAME[$2]}... ${YELLOW}CTRL${LIGHTGREEN}+${YELLOW}C ${LIGHTGREEN}To Cancel.${NOCOLOR}"
  925. command "du -hs ${MANUAL_BACKUPS_LOCATION}/${SERVER_PATH[$2]}"
  926. if [ "$3" != "Y" ] && [ "$3" != "y" ] ; then
  927. echo -e "\n${LIGHTGREEN}Clean out backups older than $3 days?${NOCOLOR}"
  928. yes_or_no yn
  929. echo " "
  930. else
  931. yn=Y
  932. fi
  933. yes_or_no yn
  934. case "$yn" in
  935. Y) { find "${MANUAL_BACKUPS_LOCATION}"* -mtime +"$3" -exec rm {} \;
  936. };;
  937. N) { echo -e "\n${LIGHTGREEN}Backup Cleaning Discontinued.${NOCOLOR}"
  938. };;
  939. esac
  940. else
  941. echo -e "\n${LIGHTGREEN}Backup Clean setup will clean out backups older than User Choice days.${NOCOLOR}"
  942. fi
  943. };;
  944. List|list) {
  945. echo -e "\n${LIGHTGREEN}Listing Backups in ${GREEN}${MANUAL_BACKUPS_LOCATION}${LIGHTGREEN}...${NOCOLOR}"
  946. command "ls -lh -F ${MANUAL_BACKUPS_LOCATION}"
  947. };;
  948. *|help) {
  949. {
  950. if [[ "$2" =~ ^[0-9]+$ ]] ; then
  951. if server_exist "$2" ; then
  952. if is_running "$2" ; then
  953. echo -e "\n${YELLOW}CAUTION! ${LIGHTGREEN}Not Advised to manually backup a server while it's running!${NOCOLOR}"
  954. else
  955. echo -e "\n${LIGHTGREEN}Server ${GREEN}$2 ${SERVER_NAME[$2]}${LIGHTGREEN}: ${RED}Offline.${NOCOLOR}"
  956. fi
  957. echo -e "\n${LIGHTGREEN}Checking directory size of ${SERVER_NAME[$2]}... ${YELLOW}CTRL${LIGHTGREEN}+${YELLOW}C ${LIGHTGREEN}To Cancel.${NOCOLOR}"
  958. command "du -hs ${MANUAL_BACKUPS_LOCATION}/${SERVER_PATH[$2]}"
  959. echo -e "\n${LIGHTGREEN}The size of ${GREEN}${MANUAL_BACKUPS_LOCATION}${LIGHTGREEN} is...${NOCOLOR}"
  960. command "du -hs ${MANUAL_BACKUPS_LOCATION}"
  961. if [ "$3" != "Y" ] && [ "$3" != "y" ] ; then
  962. echo -e -n "\n${LIGHTGREEN}Do you wish to backup the WHOLE directory/server?${NOCOLOR} "
  963. yes_or_no yn
  964. echo " "
  965. else
  966. yn=Y
  967. fi
  968. case "$yn" in
  969. Y){
  970. echo -e "${LIGHTGREEN}Backing up ${GREEN}${SERVER_NAME[$2]}${LIGHTGREEN}. . .${NOCOLOR}"
  971. if is_running "$2" ; then
  972. command "screen -rx ${SERVER_NAME[$2]} -X eval 'stuff \"${MSG_CMD[$1]} Saving Disabled. Backing Up!\"\015'"
  973. command "screen -rx ${SERVER_NAME[$2]} -X eval 'stuff \"save-all\"\015'"
  974. command "screen -rx ${SERVER_NAME[$2]} -X eval 'stuff \"save-off\"\015'"
  975. fi
  976. env GZIP=-9 tar czf "${MANUAL_BACKUPS_LOCATION}/${SERVER_PATH[$2]}-$(date +%d-%m-%Y--%H-%M).tar.gz" "${SERVER_SETTINGS}/${SERVER_PATH[$2]}"
  977. if is_running "$2" ; then
  978. command "screen -rx ${SERVER_NAME[$2]} -X eval 'stuff \"${MSG_CMD[$1]} Server Saving Enabled. Backing Complete!\"\015'"
  979. command "screen -rx ${SERVER_NAME[$2]} -X eval 'stuff \"save-on\"\015'"
  980. fi
  981. echo -e "${LIGHTGREEN}DONE!${NOCOLOR}"
  982. echo -e "\n${LIGHTGREEN}The size of ${MANUAL_BACKUPS_LOCATION}${LIGHTGREEN} is...${NOCOLOR}"
  983. command "du -hs ${MANUAL_BACKUPS_LOCATION}"
  984. };;
  985. N){
  986. echo -e "${LIGHTGREEN}Backup Cancelled for ${GREEN}${SERVER_NAME[$2]}${LIGHTGREEN}.${NOCOLOR}"
  987. };;
  988. esac
  989. else
  990. exit
  991. fi
  992. else
  993. #not_a_number
  994. echo -e "\n${LIGHTGREEN}Choices:${NOCOLOR}"
  995. echo -e "${LIGHTGREEN} | ${YELLOW} ID#${LIGHTGREEN} | ${YELLOW} Clean${LIGHTGREEN} | ${YELLOW} List${LIGHTGREEN} |${NOCOLOR}"
  996. fi
  997. }
  998. };;
  999. esac
  1000. }
  1001. fi
  1002. };;
  1003. create){
  1004. case "$2" in
  1005. server.properties){
  1006. serverproperties_template
  1007. };;
  1008. bukkit.yml){
  1009. bukkityml_template
  1010. };;
  1011. spigot.yml){
  1012. spigotyml_template
  1013. };;
  1014. #help.yml){ #Leaving off until a good help.yml setup comes around. I have it disabled on my servers. Suggestions?
  1015. # helpyml_template
  1016. #};;
  1017. commands.yml){
  1018. commandsyml_template
  1019. };;
  1020. help|*){
  1021. echo -e "\n${LIGHTGREEN}Choices (Case SeNsItIvE!):${NOCOLOR}"
  1022. echo -e " ${YELLOW} server.properties${LIGHTGREEN} | ${YELLOW} bukkit.yml${LIGHTGREEN} | ${YELLOW} commands.yml${LIGHTGREEN} | ${YELLOW} spigot.yml${NOCOLOR}\n"
  1023. };;
  1024. esac
  1025. echo -e "${LIGHTGREEN}To modify the default templates, ${YELLOW}service mcservers edit nameTEMPLATE.yml${NOCOLOR}\n"
  1026. sleep 2
  1027. };;
  1028. edit|view){
  1029. echo -e "\n${YELLOW}CAUTION! ${LIGHTGREEN}Never Use TAB while editing. Use Spaces!${NOCOLOR}"
  1030. echo -e " ${LIGHTGREEN}If the editor shows blank, the Server ID does not contain that file.${NOCOLOR}"
  1031. echo -e "${LIGHTGREEN}To Exit View/Edit: Hold ${YELLOW}CTRL${LIGHTGREEN}+${YELLOW}X${LIGHTGREEN}, let go and hit ${YELLOW}Y${LIGHTGREEN}/${YELLOW}N${LIGHTGREEN} To Save Changes or Not.${NOCOLOR}"
  1032. read -s -n1 exist
  1033. case "$2" in
  1034. mcservers) {
  1035. if [ -f /etc/init.d/mcservers ] ; then #Hey, I know this is stupid, but for reduntcy and possibility of the script running elsewhere, I'm placing a file check here.
  1036. command "nano /etc/init.d/mcservers"
  1037. else
  1038. echo -e "${GREEN}/etc/init.d/mcservers ${YELLOW}Doen't Exist...?!${NOCOLOR}"
  1039. echo -e " ${LIGHTGREEN}How are you running this!? Please edit this script to match it's location.${NOCOLOR}"
  1040. fi
  1041. };;
  1042. servers.cfg){
  1043. if [ -f "$SERVER_SETTINGS/servers.cfg" ] ; then
  1044. command "nano ${SERVER_SETTINGS}/servers.cfg"
  1045. else
  1046. echo -e "${GREEN}${SERVER_SETTINGS}/servers.cfg ${YELLOW}Doen't Exist...?!${NOCOLOR}"
  1047. echo -e " ${LIGHTGREEN}How are you running this!? Please edit this script to match it's location!${NOCOLOR}"
  1048. fi
  1049. };;
  1050. server.properties|bukkit.yml|spigot.yml|config.yml|eula.txt|help.yml|commands.yml){
  1051. if [[ "$3" =~ ^[0-9]+$ ]] ; then
  1052. if server_exist "$3" ; then
  1053. if [ -f "$SERVER_SETTINGS/${SERVER_PATH[$3]}/$2" ] ; then
  1054. command "nano $SERVER_SETTINGS/${SERVER_PATH[$3]}/$2"
  1055. else
  1056. echo -e "${LIGHTGREEN}$SERVER_SETTINGS/${SERVER_PATH[$3]}/$2 ${YELLOW}Doen't Exist!${NOCOLOR}"
  1057. fi
  1058. else
  1059. exit
  1060. fi
  1061. else
  1062. not_a_number
  1063. fi
  1064. };;
  1065. log){
  1066. if [[ "$3" =~ ^[0-9]+$ ]] ; then
  1067. if server_exist "$3" ; then
  1068. echo -e " \n${LIGHTGREEN}This Only Shows The LATEST.log file.${NOCOLOR}"
  1069. echo -e " ${LIGHTGREEN}Previous logs need to be extracted from their respective archives.${NOCOLOR}"
  1070. echo -e -n " ${LIGHTGREEN}Press any key to continue...${NOCOLOR}"
  1071. read -s -n1 exist
  1072. command "nano $SERVER_SETTINGS/${SERVER_PATH[$3]}/logs/latest.log"
  1073. else
  1074. exit
  1075. fi
  1076. else
  1077. not_a_number
  1078. fi
  1079. };;
  1080. serverTEMPLATE.properties|bukkitTEMPLATE.yml|spigotTEMPLATE.yml|commandsTEMPLATE.yml){
  1081. if [ -f "$SERVER_SETTINGS/$2" ] ; then
  1082. command "nano $SERVER_SETTINGS/$2"
  1083. else
  1084. echo -e "${LIGHTGREEN}$SERVER_SETTINGS/$2 ${YELLOW}Doen't Exist!${NOCOLOR}"
  1085. fi
  1086. };;
  1087. *|help){
  1088. echo -e "\n${LIGHTGREEN}Choices (Case SeNsItIvE!):${NOCOLOR}"
  1089. echo -e " ${YELLOW} servers.cfg${LIGHTGREEN} | ${YELLOW} server.properties ID#${LIGHTGREEN} | ${YELLOW} bukkit.yml ID#${LIGHTGREEN} | ${YELLOW} commands.yml ID#${LIGHTGREEN} | ${YELLOW} help.yml ID#${LIGHTGREEN} | ${YELLOW} spigot.yml ID#${LIGHTGREEN} | ${YELLOW} eula.txt ID#${LIGHTGREEN} | ${YELLOW} log ID#${NOCOLOR}"
  1090. echo -e " ${LIGHTGREEN}Example: ${YELLOW}service mcservers edit log 1${NOCOLOR}"
  1091. echo -e "${LIGHTGREEN}A standard server file doesn't exist? Notify the author, or edit the script.${NOCOLOR}"
  1092. echo -e "${LIGHTGREEN} Otherwise, ${YELLOW}nano ${LIGHTGREEN}or ${YELLOW}vim $SERVER_SETTINGS/file/location/filename.cfg${NOCOLOR}"
  1093. };;
  1094. esac
  1095. };;
  1096. overwrite|import){
  1097. case "$2" in
  1098. server.properties|bukkit.yml|spigot.yml|commands.yml){
  1099. templatefile="nofile.xyz"
  1100. case "$2" in
  1101. server.properties){ templatefile="serverTEMPLATE.properties"
  1102. };;
  1103. bukkit.yml){ templatefile="bukkitTEMPLATE.yml"
  1104. };;
  1105. #help.yml){ templatefile="helpTEMPLATE.yml"
  1106. #};;
  1107. spigot.yml){ templatefile="spigotTEMPLATE.yml"
  1108. };;
  1109. commands.yml){ templatefile="commandsTEMPLATE.yml"
  1110. };;
  1111. esac
  1112. if [ -f "$SERVER_SETTINGS/${templatefile}" ] ; then
  1113. if [[ "$3" =~ ^[0-9]+$ ]] ; then
  1114. if server_exist "$3" ; then
  1115. if [ -d "$SERVER_SETTINGS/${SERVER_PATH[$3]}" ] ; then
  1116. echo -e "\n${LIGHTGREEN}Are you sure you want to copy $2\'s template to ${SERVER_PATH[$3]}?${NOCOLOR}"
  1117. yes_or_no yn
  1118. case "$yn" in
  1119. Y){
  1120. cd "${SERVER_SETTINGS}" || { echo -e -n "${RED}ERROR! Cannot Change Directories to ${SERVER_SETTINGS} from " pwd "!${NOCOLOR}\n" && exit; }
  1121. cp "${templatefile}" "${SERVER_PATH[$3]}/$2"
  1122. echo -e "\n${LIGHTGREEN}$2${LIGHTGREEN} in ${GREEN}${SERVER_PATH[$3]}${LIGHTGREEN} has been overwritten by ${GREEN}${templatefile}${LIGHTGREEN}.${NOCOLOR}"
  1123. };;
  1124. N){
  1125. echo -e "\n${GREEN}$2${LIGHTGREEN} in ${GREEN}${SERVER_PATH[$3]}${LIGHTGREEN} has not been overwritten.${NOCOLOR}"
  1126. };;
  1127. esac
  1128. else
  1129. echo -e "\n${GREEN}$SERVER_SETTINGS/${SERVER_PATH[$3]} ${YELLOW}Doen't Exist!${NOCOLOR}"
  1130. echo -e "${LIGHTGREEN}Please start/create ${GREEN}${SERVER_NAME[$3]} ${LIGHTGREEN}first.${NOCOLOR}"
  1131. fi
  1132. else
  1133. echo -e "\n${YELLOW}Server Choice Does Not Exit In servers.cfg!"
  1134. fi
  1135. else
  1136. not_a_number
  1137. fi
  1138. else
  1139. echo -e "\n${LIGHTGREEN}$SERVER_SETTINGS/$2 ${YELLOW}Doen't Exist!${NOCOLOR}"
  1140. echo -e "${LIGHTGREEN}Create the template with: ${YELLOW}service mcservers create $2${NOCOLOR}"
  1141. fi
  1142. };;
  1143. help|*){
  1144. echo -e "\n${LIGHTGREEN}Choices (Case SeNsItIvE!):${NOCOLOR}"
  1145. echo -e "${LIGHTGREEN} | ${YELLOW} server.properties ID#${LIGHTGREEN} | ${YELLOW} bukkit.yml$ ID#${LIGHTGREEN} |${NOCOLOR}"
  1146. echo -e "${LIGHTGREEN} | ${YELLOW} commands.yml ID# ${LIGHTGREEN} | ${YELLOW} spigot.yml ID#${LIGHTGREEN} |${NOCOLOR}"
  1147. };;
  1148. esac
  1149. echo -e "\n${LIGHTGREEN}To modify the files in the servers or templates, ${YELLOW}service mcservers edit${NOCOLOR}"
  1150. sleep 2
  1151. };;
  1152. server|servers){
  1153. case "$2" in
  1154. "start"){
  1155. echo " "
  1156. if [ "$3" == "all" ] ; then
  1157. { for (( i = 0; i < $SERVERS; i++ )) ; do
  1158. start_servers $i "$4"
  1159. sleep 2
  1160. done
  1161. echo " "
  1162. show_screens
  1163. }
  1164. else {
  1165. if [[ "$3" =~ ^[0-9]+$ ]] ; then
  1166. start_servers "$3"
  1167. echo " "
  1168. show_screens
  1169. else
  1170. not_a_number
  1171. fi
  1172. }
  1173. fi
  1174. };;
  1175. "stop"){
  1176. echo " "
  1177. if [ "$3" == "all" ] ; then
  1178. for (( i = 0; i < $SERVERS; i++ )) ; do
  1179. stop_servers $i
  1180. sleep 5
  1181. done
  1182. echo " "
  1183. show_screens
  1184. else {
  1185. if [[ "$3" =~ ^[0-9]+$ ]] ; then
  1186. stop_servers "$3"
  1187. echo " "
  1188. show_screens
  1189. else
  1190. not_a_number
  1191. fi
  1192. }
  1193. fi
  1194. };;
  1195. restart){
  1196. echo " "
  1197. if [ "$3" == "all" ] ; then
  1198. for (( i = 0; i < $SERVERS; i++ )) ; do
  1199. restart_servers $i "$4"
  1200. sleep 5
  1201. done
  1202. echo " "
  1203. show_screens
  1204. else {
  1205. if [[ "$3" =~ ^[0-9]+$ ]] ; then
  1206. restart_servers "$3"
  1207. echo " "
  1208. show_screens
  1209. else
  1210. not_a_number
  1211. fi
  1212. }
  1213. fi
  1214. };;
  1215. status){
  1216. echo " "
  1217. if [[ "$3" =~ ^[0-9]+$ ]] ; then
  1218. if [ "$3" ] ; then {
  1219. get_running "$3"
  1220. echo " "
  1221. show_screens
  1222. }
  1223. else
  1224. not_a_number
  1225. fi
  1226. else {
  1227. for (( i = 0; i < $SERVERS; i++ )) ; do
  1228. get_running $i
  1229. sleep 1
  1230. done
  1231. echo " "
  1232. show_screens
  1233. }
  1234. fi
  1235. };;
  1236. *){ echo -e "\n${LIGHTGREEN}Choices: "
  1237. echo -e "${LIGHTGREEN} | ${YELLOW}Start${LIGHTGREEN} | ${YELLOW}Stop${LIGHTGREEN} |${NOCOLOR}"
  1238. echo -e "${LIGHTGREEN} | ${YELLOW}Restart${LIGHTGREEN} | ${YELLOW}Status${LIGHTGREEN} |${NOCOLOR}"
  1239. echo -e " ${LIGHTGREEN}Followed by Server ${YELLOW}ID# ${LIGHTGREEN}.${NOCOLOR}"
  1240. echo -e "${LIGHTGREEN}Example: ${YELLOW}service mcservers server start 1 ${LIGHTGREEN}(or replace ${YELLOW}1 ${LIGHTGREEN}with ${YELLOW}All${LIGHTGREEN}.)${NOCOLOR}"
  1241. echo -e "${LIGHTGREEN}IDs in: ${YELLOW}service mcservers server status${NOCOLOR}"
  1242. }
  1243. esac
  1244. };;
  1245. update){
  1246. case "$2" in
  1247. spigot) {
  1248. echo -e "\n${LIGHTGREEN}Do you want to update your server ${GREEN}${BUILDTOOLS_SPIGOT}${LIGHTGREEN} file?${NOCOLOR}"
  1249. yes_or_no yn
  1250. echo " "
  1251. case "$yn" in
  1252. Y){
  1253. if [ "$3" == "clean" ] ; then
  1254. update_spigot "clean"
  1255. else
  1256. update_spigot "noclean"
  1257. fi
  1258. };;
  1259. N){ echo -e "${GREEN}${BUILDTOOLS_SPIGOT} ${LIGHTGREEN}Unchanged.${NOCOLOR}"
  1260. echo " "
  1261. };;
  1262. esac
  1263. };;
  1264. minecraft|vanilla) {
  1265. echo -e "\n${LIGHTGREEN}Do you want to update your server ${GREEN}${MINECRAFT_SERVER}${LIGHTGREEN} file?${NOCOLOR}"
  1266. yes_or_no yn
  1267. echo " "
  1268. case "$yn" in
  1269. Y){
  1270. update_minecraft
  1271. };;
  1272. N){ echo -e "${GREEN}${MINECRAFT_SERVER} ${LIGHTGREEN}Unchanged.${NOCOLOR}"
  1273. };;
  1274. esac
  1275. };;
  1276. snapshot) {
  1277. echo -e "\n${LIGHTGREEN}Do you want to update your server ${GREEN}${MINECRAFT_SNAPSHOT}${LIGHTGREEN} file?${NOCOLOR}"
  1278. yes_or_no yn
  1279. echo " "
  1280. case "$yn" in
  1281. Y){
  1282. update_snapshot
  1283. };;
  1284. N){ echo -e "${GREEN}${MINECRAFT_SNAPSHOT} ${LIGHTGREEN}Unchanged.${NOCOLOR}"
  1285. };;
  1286. esac
  1287. };;
  1288. bungee|bungeecord) {
  1289. echo -e "\n${LIGHTGREEN}Do you want to update your ${GREEN}${BUNGEECORD} ${LIGHTGREEN}file?${NOCOLOR}"
  1290. yes_or_no yn
  1291. echo " "
  1292. case "$yn" in
  1293. Y) { echo -e "${LIGHTGREEN}Updating to latest ${GREEN}${BUNGEECORD} ${LIGHTGREEN}Build...${NOCOLOR}"
  1294. update_bungee
  1295. };;
  1296. N){ echo -e "${GREEN}${BUNGEECORD} ${LIGHTGREEN}Unchanged.${NOCOLOR}"
  1297. };;
  1298. esac
  1299. };;
  1300. all) {
  1301. echo -e "\n${LIGHTGREEN}Do you want to update ${YELLOW}ALL ${LIGHTGREEN}files?${NOCOLOR}"
  1302. echo -e " ${RED}All URLs Should Be Updated in $SERVER_SETTINGS/servers.cfg${NOCOLOR}\n"
  1303. yes_or_no yn
  1304. case "$yn" in
  1305. Y) { echo -e "${LIGHTGREEN}Updating All Files to latest Builds...${NOCOLOR}"
  1306. if [ "$3" == "clean" ] ; then
  1307. update_spigot "clean"
  1308. else
  1309. update_spigot "noclean"
  1310. fi
  1311. update_minecraft
  1312. update_snapshot
  1313. update_bungee
  1314. };;
  1315. N){ echo -e "${LIGHTGREEN}No Files Unchanged.${NOCOLOR}"
  1316. };;
  1317. esac
  1318. };;
  1319. *){ echo -e "\n${LIGHTGREEN}Choices: "
  1320. echo -e "${LIGHTGREEN} | ${YELLOW}Spigot${LIGHTGREEN} | ${YELLOW}Minecraft${LIGHTGREEN} |${NOCOLOR}"
  1321. echo -e "${LIGHTGREEN} | ${YELLOW}Snapshot${LIGHTGREEN} | ${YELLOW}Bungeecord${LIGHTGREEN} | ${YELLOW}All${NOCOLOR}"
  1322. echo -e "${LIGHTGREEN}Example: ${YELLOW}service mcservers update minecraft${NOCOLOR}"
  1323. echo -e " ${LIGHTGREEN}Results in updating/downloading the minecraft core server file.${NOCOLOR}"
  1324. echo -e "${LIGHTGREEN}+${YELLOW}Clean${LIGHTGREEN} after ${YELLOW}Spigot${LIGHTGREEN} or ${YELLOW}All${LIGHTGREEN} will wipe BuildTools directory before udpating.${NOCOLOR}"
  1325. echo -e "${LIGHTGREEN}Example: ${YELLOW}service mcservers update spigot clean${NOCOLOR}"
  1326. };;
  1327. esac
  1328. };;
  1329. help|*) {
  1330. echo -e "\n${LIGHTGREEN}Below Effect All Servers Listed In ${GREEN}$SERVER_SETTINGS/servers.cfg${LIGHTGREEN}.${NOCOLOR}"
  1331. echo -e "\n${LIGHTGREEN} Server +"
  1332. echo -e " ${LIGHTGREEN} Status (ID#)${NOCOLOR} - ${LIGHTGREEN}Status and ID# of all servers.${NOCOLOR}"
  1333. echo -e " ${LIGHTGREEN} Start ID#/All${NOCOLOR} - ${LIGHTGREEN}Start select server.${NOCOLOR}" #Hidden note: If mcservers server start all skip, script will skip the user answer to create missing server_path directories that are missing.
  1334. echo -e " ${LIGHTGREEN} Stop ID#/All${NOCOLOR} - ${LIGHTGREEN}Stop select server.${NOCOLOR}"
  1335. echo -e " ${LIGHTGREEN} Restart ID#/All${NOCOLOR} - ${LIGHTGREEN}Restart select server.${NOCOLOR}" #Hidden note: If mcservers server start all skip, script will skip the user answer to create missing server_path directories that are missing.
  1336. echo -e "\n${LIGHTGREEN} Update +${NOCOLOR} - ${LIGHTGREEN}Update to latest releases.${NOCOLOR}"
  1337. echo -e " ${LIGHTGREEN} Spigot${NOCOLOR} - ${LIGHTGREEN}Update Spigot.jar to Latest Build.${NOCOLOR}"
  1338. echo -e " ${LIGHTGREEN} Minecraft${NOCOLOR} - ${LIGHTGREEN}Download Minecraft_Server.jar.${NOCOLOR}"
  1339. echo -e " ${LIGHTGREEN} Snapshot${NOCOLOR} - ${LIGHTGREEN}Download Snapshot.jar.${NOCOLOR}"
  1340. echo -e " ${LIGHTGREEN} Bungeecord${NOCOLOR} - ${LIGHTGREEN}Download latest Bungeecord.jar.${NOCOLOR}"
  1341. echo -e " ${LIGHTGREEN} All${NOCOLOR} - ${LIGHTGREEN}Update all of the above.${NOCOLOR}"
  1342. echo -e "\n${LIGHTGREEN} Screen ID#+${NOCOLOR}"
  1343. echo -e " ${LIGHTGREEN} (NOTHING)${NOCOLOR} - ${LIGHTGREEN}View screen of Server ID.${NOCOLOR}"
  1344. echo -e " ${LIGHTGREEN} Kill${NOCOLOR} - ${LIGHTGREEN}Kill Server Of Choice. CAUTION!${NOCOLOR}"
  1345. echo -e " ${LIGHTGREEN} Send${NOCOLOR} - ${LIGHTGREEN}Sends following text to server screen.${NOCOLOR}"
  1346. echo -e "\n${LIGHTGREEN} Configuration Management${NOCOLOR}"
  1347. echo -e " ${LIGHTGREEN} Create${NOCOLOR} - ${LIGHTGREEN}Create Template Files for MC Servers.${NOCOLOR}"
  1348. echo -e " ${LIGHTGREEN} Edit${NOCOLOR} - ${LIGHTGREEN}View/Edit Template or Server ID files.${NOCOLOR}"
  1349. echo -e " ${LIGHTGREEN} Overwrite${NOCOLOR} - ${LIGHTGREEN}Overwrite Server's file with Template file.${NOCOLOR}"
  1350. echo -e " \n${LIGHTGREEN} Backup +${NOCOLOR}"
  1351. echo -e " ${LIGHTGREEN} ID#${NOCOLOR} - ${LIGHTGREEN}Backup WHOLE Server ID. Add Y skips question.${NOCOLOR}"
  1352. echo -e " ${LIGHTGREEN} Clean Days#${NOCOLOR} - ${LIGHTGREEN}Clean out backups older than #Days. Add Y skips question.${NOCOLOR}"
  1353. echo -e " ${LIGHTGREEN} List${NOCOLOR} - ${LIGHTGREEN}Lists all backups residing in backup directory${NOCOLOR}"
  1354. echo -e "\n${LIGHTGREEN} Help${NOCOLOR} - ${LIGHTGREEN}What you see before you now...${NOCOLOR}"
  1355. echo -e "\n${LIGHTGREEN}Use of these commands are as follows:${YELLOW} service mcservers server status 1${NOCOLOR}"
  1356. };;
  1357. esac
  1358. echo -e "${NOCOLOR}" #Cut back on last blank lines and color bleeds before user input after script finishes.
  1359. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement