aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorBuildTools2020-08-24 10:35:47 +1200
committerBuildTools2020-08-24 10:35:47 +1200
commit6bb675f92e2cea6f0751c5552ef079ce62e742d2 (patch)
tree23bf0c0b1669b070de07afab542d86c90b4a5a4a
parent985b59bbb0d1ae3f144911959f2a25ebaa9fca60 (diff)
downloadaur-6bb675f92e2cea6f0751c5552ef079ce62e742d2.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--waterfall-backup@.service12
-rw-r--r--waterfall.conf27
-rw-r--r--waterfall.install7
-rwxr-xr-xwaterfall.sh141
-rw-r--r--waterfall@.service13
8 files changed, 220 insertions, 85 deletions
diff --git a/PKGBUILD b/PKGBUILD
index de3c37a213b3..3b46f25f157e 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=waterfall
-pkgver=369
-pkgrel=1
+pkgver=370
+pkgrel=2
pkgdesc="A fork of BungeeCord to improve performance and stability."
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/waterfall')
install="${pkgname}.install"
-source=("${pkgname}.${pkgver}.jar"::"https://papermc.io/ci/job/Waterfall/lastSuccessfulBuild/artifact/Waterfall-Proxy/bootstrap/target/Waterfall.jar"
- "${pkgname}-backup.service"
+_subserver=proxy
+
+source=("${pkgname}.${pkgver}.jar"::"https://papermc.io/ci/job/Waterfall/${pkgver}/artifact/Waterfall-Proxy/bootstrap/target/Waterfall.jar"
+ "${pkgname}-backup@.service"
"${pkgname}-backup.timer"
- "${pkgname}.service"
+ "${pkgname}@.service"
"${pkgname}.conf"
"${pkgname}.sh"
- "LICENSE.txt"::"https://raw.githubusercontent.com/PaperMC/Waterfall/master/LICENSE.txt")
+ "${_subserver}.conf"
+ "LICENSE"::"https://raw.githubusercontent.com/PaperMC/Waterfall/master/LICENSE.txt")
+
noextract=("${pkgname}.${pkgver}.jar")
-sha512sums=('SKIP'
- 'ea7d97c4193efca14a286fd72dbf44c0b20ec94be40c5da646c141f7cd30d1e67c07349f2d1edc5e08489b0aecec4d940ea8fbca6da03ebd1f04802a67262f63'
- '2e21b6e5c9bc4ca4ea7cedd79811afcb4a9b0dc0f51a92fa2bc4dcf33f0f7ef88a165e3621cb4752877c69758bba651016761c69e53f9be93ce7c3c2a372c1a4'
- '6a65fd2d0e18000b79adfa3ad640b0c2f1329f2210cbd922f22d2bb957ca8b336e76707c12f859c9fab7d9eca65bf6833756d22da0f92603c54fab5f9ca1dbf2'
- '80ed2d6a8fb3f3995e37a17619403697e21dd99d21839e8b807b289113f9fe44e815ebe004f41c371a71182fb0800c09a381a6be0cac53ca3907799b10717244'
- 'e55d174655d82eb45b0f9afb3276db7db5feb5b964265a36853f24e6da37d57e8702276e357e1d75234477422a25ac89103d6ac87c11a7e50142e50c6249d1c8'
- 'SKIP')
-_game="${pkgname}"
-_server_root="/srv/${pkgname}"
+
+_server_root="/srv/waterfall"
+
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=('9fb8c15d63a878ec9f11c8cbc6b69bac'
+ '4c718e2d8aab760d4e2c2d66d262485e'
+ 'e43edd4fa467326c2fd7606fb336350c'
+ 'd2b077821aa4bb08236a2ff110dd5d6a'
+ 'eead14ee047e6635005177e59d132a43'
+ 'aeba0d41f95979d34a3c33107d50e54a'
+ '7e394351b749f9e7bbd8ea60f4768c1b'
+ '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..3753740fc21e
--- /dev/null
+++ b/proxy.conf
@@ -0,0 +1,35 @@
+# Configuration file for subserver management script
+
+# Proxy subserver
+
+# Subserver parameters
+SERVER_ROOT="/srv/waterfall/servers/proxy"
+BACKUP_DEST="/srv/waterfall/servers/proxy/backup"
+BACKUP_PATHS="" # World paths separated by spaces relative to SERVER_ROOT
+KEEP_BACKUPS="10"
+MAIN_EXECUTABLE="server.jar"
+SESSION_NAME="waterfall_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/waterfall-backup@.service b/waterfall-backup@.service
new file mode 100644
index 000000000000..0582dc8dd6d2
--- /dev/null
+++ b/waterfall-backup@.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Waterfall Server (%I) World Backup
+After=local-fs.target
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/waterfall %I backup
+User=waterfall
+Group=waterfall
+
+[Install]
+WantedBy=multi-user.target
diff --git a/waterfall.conf b/waterfall.conf
index 0f436720fe4d..af73e846634c 100644
--- a/waterfall.conf
+++ b/waterfall.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/waterfall"
-BACKUP_DEST="/srv/waterfall/backup"
-BACKUP_PATHS="world" # World paths separated by spaces relative to SERVER_ROOT
-KEEP_BACKUPS="10"
+MAIN_ROOT="/srv/waterfall"
GAME_USER="waterfall"
-MAIN_EXECUTABLE="waterfall.jar"
-SESSION_NAME="waterfall"
-
-# 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/waterfall.install b/waterfall.install
index e0180a5faa8e..86c94ee67c2b 100644
--- a/waterfall.install
+++ b/waterfall.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/waterfall.sh b/waterfall.sh
index 02be61d2bdeb..8519017f45c5 100755
--- a/waterfall.sh
+++ b/waterfall.sh
@@ -9,30 +9,88 @@ declare -r game="waterfall"
# 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="waterfall"
-[[ -n "${MAIN_EXECUTABLE}" ]] && declare -r MAIN_EXECUTABLE=${MAIN_EXECUTABLE} || MAIN_EXECUTABLE="waterfall_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/waterfall@.service b/waterfall@.service
new file mode 100644
index 000000000000..8915224ac1f2
--- /dev/null
+++ b/waterfall@.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Waterfall Server (%I)
+After=local-fs.target network.target multi-user.target
+
+[Service]
+Type=forking
+ExecStart=/usr/bin/waterfall %I start
+ExecStop=/usr/bin/waterfall %I stop
+User=waterfall
+Group=waterfall
+
+[Install]
+WantedBy=multi-user.target