#!/usr/bin/env bash
|
|
#
|
|
# Einfaches Start/Stopp/Restart Script
|
|
# (C) 2021 by bithost GbR
|
|
#
|
|
### START CONFIG ###
|
|
INSTANCE_NAME='DemoProject'
|
|
START_CMD='/home/demo/runscript.sh'
|
|
### END CONFIG - DO NOT EDIT BELOW THIS MESSAGE!!! ###
|
|
|
|
PS3='Was möchtest du machen? '
|
|
options=("Server starten" "Server stoppen" "Server neustarten" "Abbruch")
|
|
select opt in "${options[@]}"
|
|
do
|
|
case $opt in
|
|
"Server starten")
|
|
echo "Server wird gestartet..."
|
|
tmux new-session -d -s $INSTANCE_NAME $START_CMD
|
|
break
|
|
;;
|
|
"Server stoppen")
|
|
echo "Server wird gestoppt"
|
|
tmux send-keys -t $INSTANCE_NAME.0 'quit' ENTER
|
|
break
|
|
;;
|
|
"Server neustarten")
|
|
echo "Server wird neugestartet"
|
|
tmux send-keys -t $INSTANCE_NAME.0 say' Automatischer Neustart in 180 Sekunden!' ENTER
|
|
sleep 120
|
|
tmux send-keys -t $INSTANCE_NAME.0 say' Automatischer Neustart in 60 Sekunden!' ENTER
|
|
sleep 40
|
|
tmux send-keys -t $INSTANCE_NAME.0 say' Automatischer Neustart in 30 Sekunden!' ENTER
|
|
sleep 20
|
|
|
|
COUNT=10
|
|
while [ $COUNT -gt 0 ]; do
|
|
tmux send-keys -t $INSTANCE_NAME.0 say' Automatischer Neustart in ' $COUNT ' Sekunden!' ENTER
|
|
let COUNT=COUNT-1
|
|
sleep 1
|
|
done
|
|
|
|
tmux send-keys -t $INSTANCE_NAME.0 'quit' ENTER
|
|
|
|
tmux new-session -d -s $INSTANCE_NAME $START_CMD
|
|
break
|
|
;;
|
|
"Abbruch")
|
|
break
|
|
;;
|
|
*) echo "Unbekannte Eingabe: $REPLY";;
|
|
esac
|
|
done
|