aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorBuildTools2020-08-24 12:50:19 +1200
committerBuildTools2020-08-24 12:50:19 +1200
commit1c121f9a3d77f24a5e5cd7bebfffca832d1a45d0 (patch)
tree5b9ea9b81683d073f3a32ea964c60d000475beab
parentf870a9273af56c104c66008d63517650c7c533c9 (diff)
downloadaur-1c121f9a3d77f24a5e5cd7bebfffca832d1a45d0.tar.gz
Added Changes from https://github.com/Misterio77/bungeecord-aur
-rw-r--r--PKGBUILD68
-rw-r--r--README.md2
-rwxr-xr-xproxy.conf35
-rw-r--r--travertine-backup@.service12
-rw-r--r--travertine.conf27
-rw-r--r--travertine.install7
-rwxr-xr-xtravertine.sh141
-rw-r--r--travertine@.service13
8 files changed, 220 insertions, 85 deletions
diff --git a/PKGBUILD b/PKGBUILD
index 33f9ebd16a7b..5a2b522530f5 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,51 +1,61 @@
# Maintainer: Johannes Joens <johannes@joens.email>
+# Contributer: Misterio <eu@misterio.me>
+# Contributer: Gordian Edenhofer <gordian.edenhofer@gmail.com>
+# Contributer: Philip Abernethy <chais.z3r0@gmail.com>
+# Contributer: sowieso <sowieso@dukun.de>
pkgname=travertine
-pkgver=156
-pkgrel=1
+pkgver=157
+pkgrel=2
pkgdesc="A fork of Waterfall to add 1.7, and other, protocol support."
arch=('any')
url="https://papermc.io/"
-license=('MIT')
+license=('custom')
depends=('java-runtime-headless>=8' 'screen' 'sudo' 'bash' 'awk' 'sed')
-optdepends=("tar: needed in order to create backups"
- "netcat: required in order to suspend an idle server")
-makedepends=('wget')
+optdepends=("tar: needed in order to create world backups"
+ "nmap-netcat: required in order to suspend an idle server")
backup=('etc/conf.d/travertine')
install="${pkgname}.install"
-source=("${pkgname}.${pkgver}.jar"::"https://papermc.io/ci/job/Travertine/lastSuccessfulBuild/artifact/Travertine-Proxy/bootstrap/target/Travertine.jar"
- "${pkgname}-backup.service"
+_subserver=proxy
+
+source=("${pkgname}.${pkgver}.jar"::"https://papermc.io/ci/job/Travertine/${pkgver}/artifact/Travertine-Proxy/bootstrap/target/Travertine.jar"
+ "${pkgname}-backup@.service"
"${pkgname}-backup.timer"
- "${pkgname}.service"
+ "${pkgname}@.service"
"${pkgname}.conf"
"${pkgname}.sh"
- "LICENSE.txt"::"https://raw.githubusercontent.com/PaperMC/Travertine/master/LICENSE.txt")
+ "${_subserver}.conf"
+ "LICENSE"::"https://raw.githubusercontent.com/PaperMC/Travertine/master/LICENSE.txt")
+
noextract=("${pkgname}.${pkgver}.jar")
-sha512sums=('SKIP'
- 'c33bfa44428b4b9dfb17abd8df613a7c9b61995417fe7cafe6444b499afe23208496f299f8df32b613520b8d886aa8da3c16824bfc7c6e2bd85def7ab12162bc'
- '8c7dd05ed781c9a5e7feb106e0e04c07bc2503d6a9fb1c9c642431d4d3cde099f3c801704a31d19512c3e89dbab57356a006c9f4284b652a7d1a6a172a3e83a2'
- '80847ed099d70d6d6c2735d2377520f9703445f4cebb38e39ffa69252da597c830448e36e13ab5b44c3b4aae9a08258db0e7ebd4f540da0b395c6c7504363fee'
- 'dbeca8fa04f7266b623491150ced524702e684d548ff121e7bdfe8035c6a0dcab23eee8baba8f3784329c0192dbdfac33f27966bb61cdea50318494d0fbcd2f9'
- 'eabfc7cd537156601ba525f79312db03a423fa6f8c8056d0148e19d56f30fe849bce685e35773b501be03196943da8e61976d35fbc7abe45e160a58aca6bc9b0'
- 'SKIP')
-_game="${pkgname}"
-_server_root="/srv/${pkgname}"
+
+_server_root="/srv/travertine"
+
package() {
- install -Dm644 ${_game}.conf "${pkgdir}/etc/conf.d/${_game}"
- install -Dm755 ${_game}.sh "${pkgdir}/usr/bin/${_game}"
- install -Dm644 ${_game}.service "${pkgdir}/usr/lib/systemd/system/${_game}.service"
- install -Dm644 ${_game}-backup.service "${pkgdir}/usr/lib/systemd/system/${_game}-backup.service"
- install -Dm644 ${_game}-backup.timer "${pkgdir}/usr/lib/systemd/system/${_game}-backup.timer"
- install -Dm644 ${_game}.${pkgver}.jar "${pkgdir}/${_server_root}/${_game}.${pkgver}.jar"
- ln -s "${_game}.${pkgver}.jar" "${pkgdir}${_server_root}/${_game}_server.jar"
+ install -Dm644 ${pkgname}.conf "${pkgdir}/etc/conf.d/${pkgname}"
+ install -Dm755 ${pkgname}.sh "${pkgdir}/usr/bin/${pkgname}"
+ install -Dm644 ${pkgname}@.service "${pkgdir}/usr/lib/systemd/system/${pkgname}@.service"
+ install -Dm644 ${pkgname}-backup@.service "${pkgdir}/usr/lib/systemd/system/${pkgname}-backup@.service"
+ install -Dm644 ${pkgname}-backup.timer "${pkgdir}/usr/lib/systemd/system/${pkgname}-backup.timer"
+ install -Dm644 ${_subserver}.conf "${pkgdir}${_server_root}/servers/${_subserver}.conf"
+ install -Dm644 ${pkgname}.${pkgver}.jar "${pkgdir}${_server_root}/servers/${_subserver}/${pkgname}.${pkgver}.jar"
+ ln -s "${pkgname}.${pkgver}.jar" "${pkgdir}${_server_root}/servers/${_subserver}/server.jar"
# Link the log files
mkdir -p "${pkgdir}/var/log/"
- install -dm2755 "${pkgdir}/${_server_root}/logs"
- ln -s "${_server_root}/logs" "${pkgdir}/var/log/${_game}"
+ install -dm2755 "${pkgdir}/${_server_root}/servers/${_subserver}/logs"
+ ln -s "${_server_root}/logs" "${pkgdir}/var/log/${pkgname}"
# Give the group write permissions and set user or group ID on execution
chmod g+ws "${pkgdir}${_server_root}"
- install -D ./LICENSE.txt "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
+ install -D ./LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
+md5sums=('38f59366695d82c7c8c1299fe3d7da5b'
+ '75c5371cd975a49f9dc615699bafaf1d'
+ '5adb94aa0f9386f4fa4864762d955df1'
+ '46dfbd02f7b07d4a07af07d94374ef3b'
+ 'f9724d01ebddfa4c1c29cf148e931eb5'
+ '692a4d273801300fec3bf1f1c11f4481'
+ 'e527a1cc406188d4d803e4f249bf7a71'
+ 'SKIP')
diff --git a/README.md b/README.md
new file mode 100644
index 000000000000..059f154a604f
--- /dev/null
+++ b/README.md
@@ -0,0 +1,2 @@
+# bungeecord-aur
+Bungeecord AUR package and management script, forked from Edenhofer. Supports multiple servers.
diff --git a/proxy.conf b/proxy.conf
new file mode 100755
index 000000000000..c6fa12f72bf1
--- /dev/null
+++ b/proxy.conf
@@ -0,0 +1,35 @@
+# Configuration file for subserver management script
+
+# Proxy subserver
+
+# Subserver parameters
+SERVER_ROOT="/srv/travertine/servers/proxy"
+BACKUP_DEST="/srv/travertine/servers/proxy/backup"
+BACKUP_PATHS="" # World paths separated by spaces relative to SERVER_ROOT
+KEEP_BACKUPS="10"
+MAIN_EXECUTABLE="server.jar"
+SESSION_NAME="travertine_proxy"
+
+# In-game commands
+# Used to broadcast messages and stop/restart the server. Defaults to "alert" and "end" on the proxy, "say" and "stop" otherwise.
+SAY_COMMAND="alert"
+STOP_COMMAND="end"
+
+# System parameters for java
+# -Xms sets the intial heap size (must be a multiple of 1024 and greater than 2MB, no spaces!)
+# -Xmx sets the maximum heap size (must be a multiple of 1024 and greater than 2MB, no spaces!)
+# -XX:ParallelGCThreads defines the number of threads the server may use
+SERVER_START_CMD="java -Xms256M -Xmx256M -XX:ParallelGCThreads=1 -jar './${MAIN_EXECUTABLE}' nogui"
+
+# System parameters for the actual game subserver
+# Describes whether a daemon process which stops the server if it is not used by a player
+# within IDLE_IF_TIME seconds should be started. The GAME_PORT is not inhereted to the server!
+
+# It's not recommended to use this on the proxy server. Try setting up all subservers (except for proxy and maybe a hub) to true for a great player experience (they can start servers from within the game, when switching servers)
+IDLE_SERVER=false # true or false
+# Ensure that if SESSION_NAME is passed through the command line and therefore set to read only by the script,
+# IDLE_SESSION_NAME gets altered according to the command line and not the configurtion file, hence invoke the variable
+IDLE_SESSION_NAME="idle_server_${SESSION_NAME}"
+GAME_PORT="25565" # used to listen for incoming connections when the server is down
+CHECK_PLAYER_TIME="30" # in seconds
+IDLE_IF_TIME="1200" # in seconds
diff --git a/travertine-backup@.service b/travertine-backup@.service
new file mode 100644
index 000000000000..2edf2f9d5f73
--- /dev/null
+++ b/travertine-backup@.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Travertine Server (%I) World Backup
+After=local-fs.target
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/travertine %I backup
+User=travertine
+Group=travertine
+
+[Install]
+WantedBy=multi-user.target
diff --git a/travertine.conf b/travertine.conf
index 6efa2ec8411e..01410d094998 100644
--- a/travertine.conf
+++ b/travertine.conf
@@ -1,28 +1,11 @@
# THIS IS THE CONFIGURATION FILE FOR THE MANAGING SCRIPT NOT FOR THE ACTUAL SERVER
# Variables are interpreted in bash. Simply using bash-syntax is sufficient.
+# Global settings
+
# General parameters
-SERVER_ROOT="/srv/travertine"
-BACKUP_DEST="/srv/travertine/backup"
-BACKUP_PATHS="world" # World paths separated by spaces relative to SERVER_ROOT
-KEEP_BACKUPS="10"
+MAIN_ROOT="/srv/travertine"
GAME_USER="travertine"
-MAIN_EXECUTABLE="travertine.jar"
-SESSION_NAME="travertine"
-
-# System parameters for java
-# -Xms sets the intial heap size (must be a multiple of 1024 and greater than 2MB, no spaces!)
-# -Xmx sets the maximum heap size (must be a multiple of 1024 and greater than 2MB, no spaces!)
-# -XX:ParallelGCThreads defines the number of threads the server may use
-SERVER_START_CMD="java -Xms512M -Xmx1024M -XX:ParallelGCThreads=1 -jar './${MAIN_EXECUTABLE}' nogui"
-# System parameters for the actual game server
-# Describes whether a daemon process which stops the server if it is not used by a player
-# within IDLE_IF_TIME seconds should be started. The GAME_PORT is not inhereted to the server!
-IDLE_SERVER=false # true or false
-# Ensure that if SESSION_NAME is passed through the command line and therefore set to read only by the script,
-# IDLE_SESSION_NAME gets altered according to the command line and not the configurtion file, hence invoke the variable
-IDLE_SESSION_NAME="idle_server_${SESSION_NAME}"
-GAME_PORT="25565" # used to listen for incoming connections when the server is down
-CHECK_PLAYER_TIME="30" # in seconds
-IDLE_IF_TIME="1200" # in seconds
+# Default subserver to manage when not specified, also used for broadcasting suspend messages
+PROXY_NAME="proxy"
diff --git a/travertine.install b/travertine.install
index 768f37733031..17805fafe3aa 100644
--- a/travertine.install
+++ b/travertine.install
@@ -18,8 +18,11 @@ post_install() {
chown -R ${_user}:${_user} "${_server_root}"
echo "The server data is stored under ${_server_root} and the server runs as ${_user} user to increase security."
- echo "Use the ${_game} script under /usr/bin/${_game} to start, stop or backup the server."
- echo "Adjust the configuration file under /etc/conf.d/${_game} to your liking."
+ echo "Use the ${_game} script under /usr/bin/${_game} to start, stop or backup each individual server, specifying its name."
+ echo "Adjust the global configuration file under /etc/conf.d/${_game} to your liking."
+ echo "You can create as many servers as you want. Just create a servername folder and servername.conf under ${_server_root}/servers for each one, tweak the configuration to your liking and put whichever server software you need (spigot, paper, etc)."
+ echo "By default, ${_game} is installed as subserver proxy, under ${_server_root}/servers/proxy"
+ echo "You can start it by using ${_game} proxy start"
}
post_upgrade() {
diff --git a/travertine.sh b/travertine.sh
index 6dda2a3105a9..44cbcf337d76 100755
--- a/travertine.sh
+++ b/travertine.sh
@@ -9,30 +9,88 @@ declare -r game="travertine"
# Avoid altering any of those later in the code since they may be readonly (IDLE_SERVER is an exception!)
# You may use this script for any game server of your choice, just alter the config file
-[[ -n "${SERVER_ROOT}" ]] && declare -r SERVER_ROOT=${SERVER_ROOT} || SERVER_ROOT="/srv/${game}"
-[[ -n "${BACKUP_DEST}" ]] && declare -r BACKUP_DEST=${BACKUP_DEST} || BACKUP_DEST="/srv/${game}/backup"
-[[ -n "${BACKUP_PATHS}" ]] && declare -r BACKUP_PATHS=${BACKUP_PATHS} || BACKUP_PATHS="world"
-[[ -n "${BACKUP_FLAGS}" ]] && declare -r BACKUP_FLAGS=${BACKUP_FLAGS} || BACKUP_FLAGS="-z"
-[[ -n "${KEEP_BACKUPS}" ]] && declare -r KEEP_BACKUPS=${KEEP_BACKUPS} || KEEP_BACKUPS="10"
-[[ -n "${GAME_USER}" ]] && declare -r GAME_USER=${GAME_USER} || GAME_USER="travertine"
-[[ -n "${MAIN_EXECUTABLE}" ]] && declare -r MAIN_EXECUTABLE=${MAIN_EXECUTABLE} || MAIN_EXECUTABLE="travertine_server.jar"
-[[ -n "${SESSION_NAME}" ]] && declare -r SESSION_NAME=${SESSION_NAME} || SESSION_NAME="${game}"
+# Server settings
+[[ -n "${MAIN_ROOT}" ]] && declare -r MAIN_ROOT=${MAIN_ROOT} || MAIN_ROOT="/srv/${game}"
+[[ -n "${GAME_USER}" ]] && declare -r GAME_USER=${GAME_USER} || GAME_USER="${game}"
+[[ -n "${PROXY_NAME}" ]] && declare -r PROXY_NAME=${PROXY_NAME} || PROXY_NAME="proxy"
+source /etc/conf.d/"${game}" 2>/dev/null || >&2 echo "Could not source /etc/conf.d/${game}"
+
+# Handling subservers
+# Check how many arguments were given
+case $# in
+ 0)
+ # If zero, use the proxy server
+ declare -r subserver="${PROXY_NAME}"
+ ;;
+ 1)
+ # If one, check wheter it's a command or a subserver
+ if [ "$1" == "start" ] ||
+ [ "$1" == "stop" ] ||
+ [ "$1" == "status" ] ||
+ [ "$1" == "restart" ] ||
+ [ "$1" == "console" ] ||
+ [ "$1" == "command" ] ||
+ [ "$1" == "backup" ] ||
+ [ "$1" == "restore" ] ||
+ [ "$1" == "-h" ] ||
+ [ "$1" == "--help" ] ||
+ [ "$1" == "idle_server_daemon" ]; then
+ # If a command, use the proxy server
+ declare -r subserver="${PROXY_NAME}"
+ else
+ # If not, use the argument as subserver
+ declare -r subserver="$1"
+ # And shift the arguments forward
+ shift
+ fi
+ ;;
+ *)
+ # If any other (two or more), we can be sure both the subserver and command were specified
+ declare -r subserver="$1"
+ shift
+ ;;
+esac
+
+echo "Using subserver: ${subserver}"
+# The full command name, including the subserver
+declare -r fullname="${myname} ${subserver}"
+
+# Default stop and say commands
+if [ ${subserver} == ${PROXY_NAME} ]; then
+ declare -r default_stop_command="end"
+ declare -r default_say_command="alert"
+else
+ declare -r default_stop_command="stop"
+ declare -r default_say_command="say"
+fi
+
+# Subserver settings
+
+[[ -n "${SERVER_ROOT}" ]] && declare -r SERVER_ROOT=${SERVER_ROOT} || SERVER_ROOT="${MAIN_ROOT}/servers/${subserver}"
+[[ -n "${BACKUP_DEST}" ]] && declare -r BACKUP_DEST=${BACKUP_DEST} || BACKUP_DEST="${MAIN_ROOT}/servers/${subserver}/backup"
+[[ -n "${BACKUP_PATHS}" ]] && declare -r BACKUP_PATHS=${BACKUP_PATHS} || BACKUP_PATHS="world"
+[[ -n "${BACKUP_FLAGS}" ]] && declare -r BACKUP_FLAGS=${BACKUP_FLAGS} || BACKUP_FLAGS="-z"
+[[ -n "${KEEP_BACKUPS}" ]] && declare -r KEEP_BACKUPS=${KEEP_BACKUPS} || KEEP_BACKUPS="10"
+[[ -n "${MAIN_EXECUTABLE}" ]] && declare -r MAIN_EXECUTABLE=${MAIN_EXECUTABLE} || MAIN_EXECUTABLE="server.jar"
+[[ -n "${SESSION_NAME}" ]] && declare -r SESSION_NAME=${SESSION_NAME} || SESSION_NAME="${game}_${subserver}"
+[[ -n "${SAY_COMMAND}" ]] && declare -r SAY_COMMAND=${SAY_COMMAND} || SAY_COMMAND="${default_say_command}"
+[[ -n "${STOP_COMMAND}" ]] && declare -r STOP_COMMAND=${STOP_COMMAND} || STOP_COMMAND="${default_stop_command}"
# Command and parameter declaration with which to start the server
[[ -n "${SERVER_START_CMD}" ]] && declare -r SERVER_START_CMD=${SERVER_START_CMD} || SERVER_START_CMD="java -Xms512M -Xmx1024M -XX:ParallelGCThreads=1 -jar './${MAIN_EXECUTABLE}' nogui"
# System parameters for the control script
-[[ -n "${IDLE_SERVER}" ]] && tmp_IDLE_SERVER=${IDLE_SERVER} || IDLE_SERVER="false"
+[[ -n "${IDLE_SERVER}" ]] && tmp_IDLE_SERVER=${IDLE_SERVER} || IDLE_SERVER="false"
[[ -n "${IDLE_SESSION_NAME}" ]] && declare -r IDLE_SESSION_NAME=${IDLE_SESSION_NAME} || IDLE_SESSION_NAME="idle_server_${SESSION_NAME}"
-[[ -n "${GAME_PORT}" ]] && declare -r GAME_PORT=${GAME_PORT} || GAME_PORT="25565"
+[[ -n "${GAME_PORT}" ]] && declare -r GAME_PORT=${GAME_PORT} || GAME_PORT="25565"
[[ -n "${CHECK_PLAYER_TIME}" ]] && declare -r CHECK_PLAYER_TIME=${CHECK_PLAYER_TIME} || CHECK_PLAYER_TIME="30"
-[[ -n "${IDLE_IF_TIME}" ]] && declare -r IDLE_IF_TIME=${IDLE_IF_TIME} || IDLE_IF_TIME="1200"
+[[ -n "${IDLE_IF_TIME}" ]] && declare -r IDLE_IF_TIME=${IDLE_IF_TIME} || IDLE_IF_TIME="1200"
# Additional configuration options which only few may need to alter
[[ -n "${GAME_COMMAND_DUMP}" ]] && declare -r GAME_COMMAND_DUMP=${GAME_COMMAND_DUMP} || GAME_COMMAND_DUMP="/tmp/${myname}_${SESSION_NAME}_command_dump.txt"
# Variables passed over the command line will always override the one from a config file
-source /etc/conf.d/"${game}" 2>/dev/null || >&2 echo "Could not source /etc/conf.d/${game}"
+source "${MAIN_ROOT}"/servers/"${subserver}".conf 2>/dev/null || >&2 echo "Could not source ${MAIN_ROOT}/servers/${subserver}.conf"
# Preserve the content of IDLE_SERVER without making it readonly
[[ -n ${tmp_IDLE_SERVER} ]] && IDLE_SERVER=${tmp_IDLE_SERVER}
@@ -51,9 +109,8 @@ else
fi
# Choose which flavor of netcat is to be used
-if command -v netcat &> /dev/null; then
- NETCAT_CMD="netcat"
-elif command -v ncat &> /dev/null; then
+# (Currently only nmap's version works)
+if command -v ncat &> /dev/null; then
NETCAT_CMD="ncat"
else
NETCAT_CMD=""
@@ -129,7 +186,7 @@ idle_server_daemon() {
no_player=$(( no_player + CHECK_PLAYER_TIME ))
# Stop the game server if no player was active for at least ${IDLE_IF_TIME}
if [[ "${no_player}" -ge "${IDLE_IF_TIME}" ]]; then
- IDLE_SERVER="false" ${myname} stop
+ IDLE_SERVER="false" ${fullname} stop
# Wait for game server to go down
for i in {1..100}; do
screen -S "${SESSION_NAME}" -Q select . > /dev/null || break
@@ -139,9 +196,16 @@ idle_server_daemon() {
# Reset timer and give the player 300 seconds to connect after pinging
no_player=$(( IDLE_IF_TIME - 300 ))
# Game server is down, listen on port ${GAME_PORT} for incoming connections
- echo -n "Netcat: "
- ${NETCAT_CMD} -v -l -p ${GAME_PORT} && echo "Netcat caught an connection. The server is coming up again..."
- IDLE_SERVER="false" ${myname} start
+ ${myname} ${PROXY_NAME} command alert "Suspending server ${subserver}"
+ player=$(${NETCAT_CMD} -i 1 -l -p ${GAME_PORT} | cut -d '' -f6 | tr -dc '[:alnum:]')
+ IDLE_SERVER="false" ${fullname} start
+ if [[ -n $player ]]; then
+ ${myname} ${PROXY_NAME} command alert "Starting server ${subserver}, as requested by $player"
+ sleep 20
+ ${myname} ${PROXY_NAME} command send $player ${subserver}
+ else
+ ${myname} ${PROXY_NAME} command alert "Starting server ${subserver}"
+ fi
fi
else
# Reset timer since there is an active player on the server
@@ -151,9 +215,16 @@ idle_server_daemon() {
# Reset timer and give the player 300 seconds to connect after pinging
no_player=$(( IDLE_IF_TIME - 300 ))
# Game server is down, listen on port ${GAME_PORT} for incoming connections
- echo -n "Netcat: "
- ${NETCAT_CMD} -v -l -p ${GAME_PORT} && echo "Netcat caught an connection. The server is coming up again..."
- IDLE_SERVER="false" ${myname} start
+ ${myname} ${PROXY_NAME} command alert "Suspending server ${subserver}"
+ player=$(${NETCAT_CMD} -i 1 -l -p ${GAME_PORT} | cut -d '' -f6 | tr -dc '[:alnum:]')
+ IDLE_SERVER="false" ${fullname} start
+ if [[ -n $player ]]; then
+ ${myname} ${PROXY_NAME} command alert "Starting server ${subserver}, as requested by $player"
+ sleep 20
+ ${myname} ${PROXY_NAME} command send $player ${subserver}
+ else
+ ${myname} ${PROXY_NAME} command alert "Starting server ${subserver}"
+ fi
fi
done
}
@@ -183,7 +254,7 @@ server_start() {
# Restart as soon as the idle_server_daemon has shut down completely
for i in {1..100}; do
if ! ${SUDO_CMD} screen -S "${IDLE_SESSION_NAME}" -Q select . > /dev/null; then
- ${SUDO_CMD} screen -dmS "${IDLE_SESSION_NAME}" /bin/bash -c "${myname} idle_server_daemon"
+ ${SUDO_CMD} screen -dmS "${IDLE_SESSION_NAME}" /bin/bash -c "${fullname} idle_server_daemon"
break
fi
[[ $i -eq 100 ]] && echo -e "An \e[39;1merror\e[0m occurred while trying to reset the idle_server!"
@@ -191,7 +262,7 @@ server_start() {
done
else
echo -en "Starting idle server daemon..."
- ${SUDO_CMD} screen -dmS "${IDLE_SESSION_NAME}" /bin/bash -c "${myname} idle_server_daemon"
+ ${SUDO_CMD} screen -dmS "${IDLE_SESSION_NAME}" /bin/bash -c "${fullname} idle_server_daemon"
echo -e "\e[39;1m done\e[0m"
fi
fi
@@ -224,19 +295,21 @@ server_stop() {
if is_player_online; then
# No player was seen on the server through list
echo -en "Server is going down..."
- game_command end
else
# Player(s) were seen on the server through list (or an error occurred)
# Warning the users through the server console
- game_command alert "Server is going down in 10 seconds! HURRY UP WITH WHATEVER YOU ARE DOING!"
- echo -en "Server is going down in..."
+ game_command ${SAY_COMMAND} "This server is going down in 10 seconds."
+ game_command save-all
+ echo -en "Server going down in..."
for i in {1..10}; do
- game_command alert "down in... $(( 10 - i ))"
- echo -n " $(( 10 - i ))"
+ if [[ $i -gt 7 ]]; then
+ game_command ${SAY_COMMAND} "$(( 11 - i ))"
+ fi
+ echo -n " $(( 11 - i ))"
sleep 1
done
- game_command end
fi
+ game_command ${STOP_COMMAND}
# Finish as soon as the server has shut down completely
for i in {1..100}; do
@@ -284,6 +357,7 @@ server_status() {
# Restart the complete server by shutting it down and starting it again
server_restart() {
+ ${myname} ${PROXY_NAME} command alert "Restarting server ${subserver}"
if ${SUDO_CMD} screen -S "${SESSION_NAME}" -Q select . > /dev/null; then
server_stop
server_start
@@ -304,8 +378,11 @@ backup_files() {
fname="$(date +%Y_%m_%d_%H.%M.%S).tar.gz"
${SUDO_CMD} mkdir -p "${BACKUP_DEST}"
if ${SUDO_CMD} screen -S "${SESSION_NAME}" -Q select . > /dev/null; then
+ game_command save-off
+ game_command save-all
sync && wait
${SUDO_CMD} tar -C "${SERVER_ROOT}" -cf "${BACKUP_DEST}/${fname}" ${BACKUP_PATHS} --totals ${BACKUP_FLAGS} 2>&1 | grep -v "tar: Removing leading "
+ game_command save-on
else
${SUDO_CMD} tar -C "${SERVER_ROOT}" -cf "${BACKUP_DEST}/${fname}" ${BACKUP_PATHS} --totals ${BACKUP_FLAGS} 2>&1 | grep -v "tar: Removing leading "
fi
@@ -342,7 +419,7 @@ backup_restore() {
echo "Please enter the corresponding number for the backup to be restored: "
i=1
for f in "${BACKUP_DEST}"/[0-9_.]*; do
- echo -e " \e[39;1m$i)\e[0m\t$f"
+ echo -e " \e[39;1m$i)\e[0m\t$f"
i=$(( i + 1 ))
done
echo -en "Restore backup number: "
@@ -422,7 +499,7 @@ help() {
This script was design to easily control any ${game} server. Quite every parameter for a given
${game} server derivative can be altered by editing the variables in the configuration file.
- Usage: ${myname} {start|stop|status|backup|restore|command <command>|console}
+ Usage: ${fullname} {start|stop|status|backup|restore|command <command>|console}
start Start the ${game} server
stop Stop the ${game} server
restart Restart the ${game} server
diff --git a/travertine@.service b/travertine@.service
new file mode 100644
index 000000000000..80cf6757bdee
--- /dev/null
+++ b/travertine@.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Travertine Server (%I)
+After=local-fs.target network.target multi-user.target
+
+[Service]
+Type=forking
+ExecStart=/usr/bin/travertine %I start
+ExecStop=/usr/bin/travertine %I stop
+User=travertine
+Group=travertine
+
+[Install]
+WantedBy=multi-user.target