mirror of
https://github.com/msmhq/msm.git
synced 2024-08-30 18:12:35 +00:00
Implemented server restart.
Also added output for the server_worlds_to_ram function to match server_worlds_to_disk in output.
This commit is contained in:
parent
7a272e8026
commit
b307be0488
43
msm
43
msm
@ -238,6 +238,7 @@ server_ensure_links() {
|
||||
server_worlds_to_ram() {
|
||||
# Only proceed if there is a ramdisk path set in config
|
||||
if $RAMDISK_STORAGE_PATH; then
|
||||
echo -n "Synchronising flagged worlds on disk to RAM... "
|
||||
local i=${server_world_offset[$1]}
|
||||
local max=$(( $i + ${server_num_worlds[$1]} ))
|
||||
|
||||
@ -249,6 +250,7 @@ server_worlds_to_ram() {
|
||||
|
||||
i=$(( $i + 1 ))
|
||||
done
|
||||
echo "Done."
|
||||
fi
|
||||
}
|
||||
|
||||
@ -256,7 +258,7 @@ server_worlds_to_ram() {
|
||||
# $1: The ID of the server
|
||||
server_worlds_to_disk() {
|
||||
if $RAMDISK_STORAGE_PATH; then
|
||||
echo -n "Synchronising worlds to disk... "
|
||||
echo -n "Synchronising worlds in RAM to disk... "
|
||||
local i=${server_world_offset[$1]}
|
||||
local max=$(( $i + ${server_num_worlds[$1]} ))
|
||||
|
||||
@ -623,7 +625,7 @@ server_rename() {
|
||||
}
|
||||
|
||||
# Starts a single server
|
||||
# $1: The ID of the server to start
|
||||
# $1: The ID of the server
|
||||
server_start() {
|
||||
if server_is_running $1; then
|
||||
echo "Server \"${server_name[$1]}\" is already running!"
|
||||
@ -659,7 +661,7 @@ server_save_all() {
|
||||
}
|
||||
|
||||
# Stops a single server
|
||||
# $1: The ID of the server to stop
|
||||
# $1: The ID of the server
|
||||
server_stop() {
|
||||
if server_is_running $1; then
|
||||
server_save_all $1
|
||||
@ -671,11 +673,25 @@ server_stop() {
|
||||
server_wait_for_stop $1
|
||||
|
||||
echo "Done."
|
||||
|
||||
# Synchronise all worlds in RAM to disk
|
||||
server_worlds_to_disk $1
|
||||
else
|
||||
echo "Server \"${server_name[$1]}\" was not running."
|
||||
fi
|
||||
}
|
||||
|
||||
# Restarts a single server
|
||||
# $1: The ID of the server
|
||||
server_restart() {
|
||||
# Restarts the server if it is already running
|
||||
if server_is_running $1; then
|
||||
server_stop $1
|
||||
fi
|
||||
|
||||
server_start $1
|
||||
}
|
||||
|
||||
|
||||
### Main Functions
|
||||
|
||||
@ -1022,7 +1038,6 @@ main() {
|
||||
if server_is_running $id; then
|
||||
if [[ $3 != "now" ]]; then
|
||||
server_eval $id "say ${server_stop_message[$id]}"
|
||||
|
||||
echo "Issued the warning \"${server_stop_message[$id]}\" to players."
|
||||
|
||||
echo -n "Shutting down... "
|
||||
@ -1040,12 +1055,30 @@ main() {
|
||||
fi
|
||||
|
||||
server_stop $id
|
||||
server_worlds_to_disk $id
|
||||
else
|
||||
echo "Server \"${server_name[$id]}\" was not running."
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
if server_is_running $id && [[ $3 != "now" ]]; then
|
||||
server_eval $id "say ${server_restart_message[$id]}"
|
||||
echo "Issued the warning \"${server_restart_message[$id]}\" to players."
|
||||
|
||||
echo -n "Restarting... "
|
||||
|
||||
for ((i=${server_restart_delay[$id]}; i>0; i--)); do
|
||||
tput sc # Save cursor position
|
||||
echo -n "in $i seconds."
|
||||
sleep 1
|
||||
|
||||
tput rc # Restore cursor to position of last `sc'
|
||||
tput el # Clear to end of line
|
||||
done
|
||||
|
||||
echo -e "Now."
|
||||
fi
|
||||
|
||||
server_restart $id
|
||||
;;
|
||||
worlds)
|
||||
;;
|
||||
|
Loading…
Reference in New Issue
Block a user