Skip to content

Commit

Permalink
added immediately option for maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
simylein committed Jul 29, 2021
1 parent 98688b8 commit b007dd1
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions maintenance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ else
exit 1
fi

# parsing script arguments
ParseScriptArguments "$@"

# write date to logfile
echo "${date} executing maintenance script" >> ${screenlog}

Expand All @@ -50,16 +53,19 @@ if ! screen -list | grep -q "\.${servername}"; then
exit 1
fi

# countdown
counter="60"
while [ ${counter} -gt 0 ]; do
if [[ "${counter}" =~ ^(60|40|20|10|5|4|3|2|1)$ ]];then
echo "${blue}[Script]${nocolor} server is going into maintenance in ${counter} seconds"
screen -Rd ${servername} -X stuff "tellraw @a [\"\",{\"text\":\"[Script] \",\"color\":\"blue\"},{\"text\":\"server is going into maintenance in ${counter} seconds\"}]$(printf '\r')"
fi
counter=$((counter-1))
sleep 1s
done
# check if immediately is specified
if ! [[ ${immediately} == true ]]; then
# countdown
counter="60"
while [ ${counter} -gt 0 ]; do
if [[ "${counter}" =~ ^(60|40|20|10|5|4|3|2|1)$ ]];then
echo "${blue}[Script]${nocolor} server is going into maintenance in ${counter} seconds"
screen -Rd ${servername} -X stuff "tellraw @a [\"\",{\"text\":\"[Script] \",\"color\":\"blue\"},{\"text\":\"server is going into maintenance in ${counter} seconds\"}]$(printf '\r')"
fi
counter=$((counter-1))
sleep 1s
done
fi

# server stop
echo "stopping server..."
Expand Down

0 comments on commit b007dd1

Please sign in to comment.