I have done few month ago a Linux script that announce on my server a reboot message with a timer. Since I have done some changes on my Linux, I have this error (launchSave.sh) Syntax error: "(" unexpected
for this line TIMER=("30" "20" "5" "2" "1" "1" "1")
The two modifications I have done on my Linux is using dash rather than bash (I changed it back to try) and using kexec for warm reboots (with this tutorial : https://wiki.debian.org/BootProcessSpeedup#Using_readahead_to_load_files_from_disk). I don't know if it's the reason but I suspect it. Like you can see I'm not an expert of Linux and script.
I have test declare -a TIMER=
and TIMER("30" "20" "5" "2" "1" "1" "1")
but always a "(" or ")" syntax
error.
EDIT
#! /bin/bash
TIMER=("30" "20" "5" "2" "1" "1" "1") ## Time between each annoucer
TOTAL_TIME="60" ## Total time variable of the timer to be subtracted
BUNGEECORD="bungeecord"
TODAY=`date +"%d%b%Y"`
mkdir /save/logs/${TODAY}
exec > /save/logs/${TODAY}/stop-log.txt ## Log file
screen -x ${BUNGEECORD} -X stuff 'maintenance\n' ## Starting maintenance mode
screen -x ${BUNGEECORD} -X stuff 'alert &cVous pourrez vous reconnecter dans 5 minutes environ !\n'
## Loop to advert player from restarting
for time in ${TIMER[@]}
do
screen -x ${BUNGEECORD} -X stuff 'alert &cRedémarrage automatique journalier dans &4'$TOTAL_TIME' &csecondes.\n'
TOTAL_TIME=$(($TOTAL_TIME-$time))
sleep $time
done
cd /home || exit
## Loop to stop every single server of the list above
for server in *
do
## Disociate BungeeCord to other server.
if [ ! $server = ${BUNGEECORD} ]; then
echo "Shutting down : $server"
screen -x $server -X stuff "stop\n" ## run stop command in server screen
if [ $? -eq 0 ]; then
echo "$server successfully shutting down"
else
echo "Error found during shutting down : $server"
fi
else
echo "Shutting down : ${BUNGEECORD}"
screen -x ${BUNGEECORD} -X stuff "end\n" ## run stop command in server screen
if [ $? -eq 0 ]; then
echo "${BUNGEECORD} successfully shutting down"
else
echo "Error found during shutting down : ${BUNGEECORD}"
fi
fi
done
sh sauvegarde.sh ## Launch save script
exit
B.