forked from landsverk/minecraft-serverscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
minecraft
executable file
·101 lines (88 loc) · 3.65 KB
/
minecraft
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash
# /etc/init.d/minecraft
### BEGIN INIT INFO
# Provides: minecraft
# Required-Start: $local_fs $remote_fs mysql
# Required-Stop: $local_fs $remote_fs mysql
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Minecraft server
# Description: Invocates the minecraft server maintainance script
### END INIT INFO
# ================================= Copyright =================================
# Version 1.20 (2012-08-22), Copyright (C) 2011-2012
# Author: M3tal_Warrior (http://www.minecraftwiki.net/wiki/User:M3tal_Warrior)
# This script is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or any later
# version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
# As this is only a script, theres no copy of the GNU General Public License
# distributed along with this script.
# See <http://www.gnu.org/licenses/> for the licence text.
# ================================= Settings ==================================
# Here you can change almost everything for the script to fill your needs.
# For information on the possible settings view the commented script at
# http://www.minecraftwiki.net/wiki/M3tal_Warrior_Server_Startup_Script
# General settings
MAINTAIN_SCRIPT_PATH='/root/server/minecraft'
MAINTAIN_SCRIPT_NAME='server_control'
USERNAME='root'
SERVERTYPE='Vanilla'
SERVICE='minecraft_server.jar'
SERVERPATH='/root/server/minecraft/'
BACKUPPATH='/root/server/minecraft/backups'
# Advanced settings
CPU_COUNT=2
MIN_SERVER_RAM='820M'
MAX_SERVER_RAM='1224M'
JVM_OPTIONS='nogui'
USE_RAMFS='no'
USE_RAMDIR='minecraft'
# Expert settings
UPDATEBUKKIT="http://dl.bukkit.org/latest-rb/craftbukkit.jar"
UPDATEVANILLA="https://s3.amazonaws.com/MinecraftDownload/launcher/minecraft_server.jar"
INVOCATION="java -Xmx$MAX_SERVER_RAM -Xms$MIN_SERVER_RAM -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalPacing -XX:ParallelGCThreads=$CPU_COUNT -XX:+AggressiveOpts -jar $SERVICE $JVM_OPTIONS"
# ============================= Script invocation =============================
# Since there was trouble with the user setting (being overridden by startup
# and such) and I splitted the script in an init script and a maintainance
# script. The latter is thus always invocated with the right user environment
# and can be located anywhere in the system (preferrably in the users home
# directory)
# ----------------------------- Download selection ----------------------------
# Selects the download location depending on what server you like to use.
case "$SERVERTYPE" in
Vanilla)
UPDATEURL="$UPDATEVANILLA"
;;
Bukkit)
UPDATEURL="$UPDATEBUKKIT"
;;
*)
echo "No valid server type has been provided - Exiting..."
exit 1
;;
esac
# ------------------------------ Variable export ------------------------------
# Don't change anything in here! It exports the relevant settings for the
# maintainance script to use them (by inheriting / making them envvars).
export SERVERTYPE
export SERVICE
export USE_RAMFS
export USE_RAMDIR
export SERVERPATH
export BACKUPPATH
export INVOCATION
export UPDATEURL
# -------------------------------- Invocation ---------------------------------
if [ `whoami` = "$USERNAME" ] ; then
bash -c "$MAINTAIN_SCRIPT_PATH/$MAINTAIN_SCRIPT_NAME $*"
else
su $USERNAME -c "$MAINTAIN_SCRIPT_PATH/$MAINTAIN_SCRIPT_NAME $*"
fi
exit 0