Support for alloc's server fixes
This commit is contained in:
parent
fadf3c01e5
commit
d6d68b9f2d
@ -145,7 +145,6 @@ confirmation() {
|
||||
|
||||
### CONSTANTS ###
|
||||
PRIMARY_START_PORT_RANGE=50000
|
||||
TELNET_START_PORT_RANGE=60000
|
||||
BASE_DIR="${HOME}/7-Days-To-Die"
|
||||
### CONSTANTS ###
|
||||
|
||||
@ -224,11 +223,14 @@ start_server() {
|
||||
backup_configs "${server_directory}"
|
||||
|
||||
local server_port
|
||||
server_port="$((PRIMARY_START_PORT_RANGE + server_id))"
|
||||
local telnet_port
|
||||
local allocs_port
|
||||
# This multiplication gives us 5 available ports for this server, safely allows us to block off ports efficiently
|
||||
server_port="$((PRIMARY_START_PORT_RANGE + $(("${server_id}" * 5)) ))"
|
||||
server_port="${SERVER_PORT:-$server_port}"
|
||||
|
||||
local telnet_port
|
||||
telnet_port="$(( TELNET_START_PORT_RANGE + server_id ))"
|
||||
telnet_port="$(( server_port + 1 ))"
|
||||
allocs_port="$(( server_port + 2 ))"
|
||||
|
||||
telnet_port="${TELNET_PORT:-$telnet_port}"
|
||||
log "info" "Generating a few required directories in $(important "${server_directory}")"
|
||||
@ -255,6 +257,8 @@ start_server() {
|
||||
# Manage the telnet tags
|
||||
elif [[ "${REPLY}" = *"property name=\"TelnetPort\""* ]]; then
|
||||
printf "\t%s\n" "<property name=\"TelnetPort\" value=\"${telnet_port}\" />"
|
||||
elif [[ "${REPLY}" = *"property name=\"ControlPanelPort\""* ]]; then
|
||||
printf "\t%s\n" "<property name=\"ControlPanelPort\" value=\"${allocs_port}\" />"
|
||||
else
|
||||
printf "%s\n" "${REPLY}"
|
||||
fi
|
||||
@ -312,9 +316,12 @@ done" C-m
|
||||
kill_server() {
|
||||
local prefix
|
||||
local server_id
|
||||
local force
|
||||
local session
|
||||
|
||||
server_id=""
|
||||
prefix="7D2D"
|
||||
force=1
|
||||
|
||||
while :; do
|
||||
case ${1} in
|
||||
@ -322,10 +329,15 @@ kill_server() {
|
||||
printf "Usage: %s\n" \
|
||||
"kill [options]
|
||||
--server <server id: int> | -s <server id: int>
|
||||
Forcefully kills the server with the given id
|
||||
Stops the server with the given id
|
||||
|
||||
Example:
|
||||
--server 3"
|
||||
--server 3
|
||||
--force | -f
|
||||
Forces the server to close with tmux kill-session
|
||||
|
||||
Example:
|
||||
--force"
|
||||
exit
|
||||
;;
|
||||
--) # End of all options.
|
||||
@ -336,6 +348,10 @@ kill_server() {
|
||||
server_id="${1}"
|
||||
[[ -z "${server_id}" ]] && log "error" "No server id passed" && exit 1
|
||||
;;
|
||||
--force | -f)
|
||||
shift
|
||||
force=0
|
||||
;;
|
||||
-?*)
|
||||
printf 'Unknown option: %s\n' "$1" >&2
|
||||
;;
|
||||
@ -347,12 +363,26 @@ kill_server() {
|
||||
|
||||
[[ -z "${server_id}" ]] && log "error" "No server id passed" && exit 1
|
||||
|
||||
if tmux kill-session -t "${prefix}-Server-${server_id}" >/dev/null 2>&1; then
|
||||
log "info" "Stopped $(important "${prefix}-Server-${server_id}")"
|
||||
return 0
|
||||
session="${prefix}-Server-${server_id}"
|
||||
|
||||
if "${force}"; then
|
||||
|
||||
if tmux kill-session -t "${session}" >/dev/null 2>&1; then
|
||||
log "info" "Killed $(important "${prefix}-Server-${server_id}")"
|
||||
return 0
|
||||
else
|
||||
log "error" "$(important "${prefix}-Server-${server_id}") is not running"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
log "error" "$(important "${prefix}-Server-${server_id}") is not running"
|
||||
return 1
|
||||
while tmux has-session -t "${session}"; do
|
||||
log "info" "Attempting to gracefully kill $(important "${session}")"
|
||||
tmux send-keys -t "7D2D-Server-${server_id}" C-c
|
||||
log "info" "Sent Exit Request, waiting 10 seconds..."
|
||||
sleep 10
|
||||
done
|
||||
log "info" "Successfully stopped $(important "${session}")"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
@ -416,7 +446,15 @@ install() {
|
||||
sleep 5
|
||||
kill_server -s "${server_id}"
|
||||
|
||||
cp "${server_admin_xml}" "${server_directory}/"
|
||||
cp "${server_admin_xml}" "${server_directory}/Saves"
|
||||
|
||||
log "info" "Installing Allocs Server Fixes"
|
||||
local server_fixes_temp_dir
|
||||
server_fixes_temp_dir="Server-Fixes-$(date +%s)"
|
||||
wget http://illy.bz/fi/7dtd/server_fixes.tar.gz >/dev/null 2>&1
|
||||
tar xf server_fixes.tar.gz -C "${server_fixes_temp_dir}"
|
||||
cp "${server_fixes_temp_dir}/Mods/"* "${server_directory}/mods"
|
||||
rm -rf "${server_fixes_temp_dir}"
|
||||
log "info" "Successfully installed $(important "${server_name}") to $(important "${server_directory}")"
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user