Browse Source

Major Update 250814

Mumble server now uses tmux and has been updated to bring it in line
with other lgsm scripts
pull/147/head
Daniel Gibbs 11 years ago
parent
commit
6a80f7cd65
  1. 445
      Mumble/mumbleserver

445
Mumble/mumbleserver

@ -3,7 +3,7 @@
# Server Management Script # Server Management Script
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: http://danielgibbs.co.uk # Website: http://danielgibbs.co.uk
# Version: 221113 # Version: 250814
### Variables #### ### Variables ####
@ -19,57 +19,96 @@ servicename="mumble-server"
# Directorys # Directorys
rootdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" rootdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
selfname="$0" selfname="$0"
filesdir="${rootdir}/murmur" lockselfname=$(echo ".${servicename}.lock")
filesdir="${rootdir}/serverfiles"
ini="murmur.ini" ini="murmur.ini"
executable="./murmur.x86 -fg -ini ${ini}"
backupdir="backups" backupdir="backups"
# Logging # Logging
logdir="${rootdir}/log"
logfile="${logdir}/${servicename}.log"
logfiledate="${logdir}/${servicename}-$( date '+%d-%m-%Y-%H-%M-%S').log"
logdays="7" logdays="7"
logdir="${rootdir}/log"
scriptlogdir="${rootdir}/log/script"
consolelogdir="${rootdir}/log/console"
scriptlog="${scriptlogdir}/${servicename}-script.log"
consolelog="${consolelogdir}/${servicename}-console.log"
emaillog="${scriptlogdir}/${servicename}-email.log"
scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
##### Script ##### ##### Script #####
# Do not edit # Do not edit
# unless you know # unless you know
# what you are doing # what you are doing
fn_rootcheck(){ fn_scriptlog(){
if [ `whoami` = "root" ];then echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: '$1'" >> ${scriptlog}
echo -e "[\e[0;31m FAIL \e[0;39m] Script will not run as root!"
exit
fi
} }
fn_syscheck(){ # [ FAIL ]
if [ ! -e ${filesdir} ];then fn_printfail(){
echo -e "[\e[0;31m FAIL \e[0;39m] ${servicename}: cannot access ${filesdir}: No such directory" echo -en "\r\033[K[\e[0;31m FAIL \e[0;39m] $@"
}
fn_printfailnl(){
echo -e "\r\033[K[\e[0;31m FAIL \e[0;39m] $@"
}
fn_printok(){
echo -en "\r\033[K[\e[0;32m OK \e[0;39m] $@"
}
# [ OK ]
fn_printoknl(){
echo -e "\r\033[K[\e[0;32m OK \e[0;39m] $@"
}
fn_printinfo(){
echo -en "\r\033[K[\e[0;36m INFO \e[0;39m] $@"
}
fn_printinfonl(){
echo -e "\r\033[K[\e[0;36m INFO \e[0;39m] $@"
}
# [ INFO ]
fn_printokinfonl(){
echo -e "\r\033[K[\e[0;36m INFO \e[0;39m] $@"
}
fn_printwarn(){
echo -en "\r\033[K[\e[1;33m WARN \e[0;39m] $@"
}
fn_printwarnnl(){
echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@"
}
# [ .... ]
fn_printdots(){
echo -en "\r\033[K[ .... ] $@"
}
fn_rootcheck(){
if [ `whoami` = "root" ]; then
fn_printfailnl "Script will not run as root!"
exit exit
fi fi
} }
fn_runcheck(){ fn_syscheck(){
# already running check if [ ! -e "${filesdir}" ]; then
pidwc=$(screen -ls |grep -E "^${servicename}:" |awk -F . '{print $1}'|awk '{print $1}'|wc -l) fn_printfailnl "Cannot access ${systemdir}: No such directory"
if [ ${pidwc} -eq 1 ];then
echo -e "[\e[0;36m INFO \e[0;39m] ${servicename}: ${servername} is already running"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: ${servername} is already running" >> ${logfile}
exit
# multiple of same instance check
elif [ ${pidwc} -ge 2 ];then
echo -e "[\e[0;31m FAIL \e[0;39m] ${servicename}: ${servername} is running ${pidwc} times"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: ${servername} is running ${pidwc} times" >> ${logfile}
echo -e "[\e[0;32m OK \e[0;39m] ${servicename}: ${servername} stopping all ${pidwc} instances"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: ${servername} stopping all ${pidwc} instances" >> ${logfile}
fn_stopserver
exit exit
fi fi
} }
fn_inicheck(){ fn_inicheck(){
if [ ! -e ${filesdir}/${ini} ]; then if [ ! -e ${filesdir}/${ini} ]; then
echo -e "[\e[1;33m WARN \e[0;39m] ${servicename}: ${filesdir}/${ini} is missing" fn_printwarnnl "${servicename}: ${filesdir}/${ini} is missing"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: ${servername} ${filesdir}/${ini} is missing" >> ${logfile} fn_scriptlog "${servername} ${filesdir}/${ini} is missing" >> ${scriptlog}
fi fi
} }
@ -89,34 +128,33 @@ while true; do
read -p "Continue? [y/N]" yn read -p "Continue? [y/N]" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]* ) break;;
[Nn]* ) echo Exiting; return 1 ;; [Nn]* ) echo Exiting; return 1;;
* ) echo "Please answer yes or no.";; * ) echo "Please answer yes or no.";;
esac esac
done done
pidwc=$(screen -ls |grep -E "^${servicename}:" |awk -F . '{print $1}'|awk '{print $1}'|wc -l) tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l)
if [ ${pidwc} -eq 1 ];then if [ ${tmuxwc} -eq 1 ]; then
echo -e "\e[0;31mWARNING!\e[0;39m ${servicename} is currently running" echo -e "\e[0;31mWARNING!\e[0;39m ${servicename} is currently running"
while true; do while true; do
read -p "Would you like to stop ${servicename} while running the backup? [y/N]" yn read -p "Would you like to stop ${servicename} while running the backup? [y/N]" yn
case $yn in case $yn in
[Yy]* ) fn_stopserver;break;; [Yy]* ) fn_stopserver; break;;
[Nn]* ) break;; [Nn]* ) break;;
* ) echo "Please answer yes or no.";; * ) echo "Please answer yes or no.";;
esac esac
done done
fi fi
echo -en "[ .... ] Starting ${servicename}: ${servername} backup" fn_printdots "Starting backup ${servicename}: ${servername}"
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Starting ${servername} backup" >> ${scriptlog} sleep 1
sleep 0.5 fn_printok "Starting backup ${servicename}: ${servername}"
echo -en "\r[\e[0;32m OK \e[0;39m] Starting ${servicename}: ${servername} backup"
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Started ${servername} backup" >> ${scriptlog}
sleep 1 sleep 1
fn_scriptlog "Backup started"
echo -en "\n" echo -en "\n"
cd ${rootdir} cd "${rootdir}"
mkdir ${backupdir} > /dev/null 2>&1 mkdir -pv "${backupdir}" > /dev/null 2>&1
tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} * tar -cvzf "${backupdir}/${backupname}.tar.gz" --exclude "${backupdir}" *
echo -en "\r${servicename} backup complete" echo -en "\r\033[K${servicename} Backup complete"
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: backup complete" >> ${scriptlog} fn_scriptlog "Backup complete"
} }
fn_distro(){ fn_distro(){
@ -142,7 +180,7 @@ days=$(( uptime/60/60/24 ))
} }
fn_load(){ fn_load(){
load=$(uptime | awk -F 'load average' '{ print $2 }') load=$(uptime|awk -F 'load average' '{ print $2 }')
} }
fn_emailnotification(){ fn_emailnotification(){
@ -150,150 +188,275 @@ fn_distro
fn_uptime fn_uptime
fn_load fn_load
{ {
echo -e "=========================================\nServer information\n=========================================\n" echo -e "========================================\n${servicename} details\n========================================\n"
echo -e "Date: $(date)" echo -e "Service: ${servicename}"
echo -e "Distro: ${os}" echo -e "Server: ${servername}"
echo -e "Arch: ${arch}" echo -e "Failure reason: ${failurereason}"
echo -e "Kernel: ${kernel}" echo -e "Action Taken: ${actiontaken}\n"
echo -e "Hostname: $HOSTNAME" echo -e "========================================\nServer details\n========================================\n"
echo -e "Uptime: ${days}d, ${hours}h, ${minutes}m" echo -e "Date: $(date)"
echo -e "Avg Load${load}\n" echo -e "Distro: ${os}"
echo -e "=========================================\n${servicename} statistics\n=========================================\n" echo -e "Arch: ${arch}"
echo -e "Service: ${servicename}" echo -e "Kernel: ${kernel}"
echo -e "Server: ${servername}" echo -e "Hostname: $HOSTNAME"
echo -e "Failure reason: ${failurereason}" echo -e "Uptime: ${days}d, ${hours}h, ${minutes}m"
echo -e "Action Taken: ${actiontaken}\n" echo -e "Avg Load${load}\n"
echo -e "=========================================\n${servicename} log summary\n=========================================\n" echo -e "========================================\nLogs\n========================================\n"
}|tee ${logdir}/${servicename}-email.log > /dev/null 2>&1 echo -e "Script log\n===================\n"
tail -50 ${logfile} >> /${logdir}/${servicename}-email.log }|tee "${scriptlogdir}/${servicename}-email.log" > /dev/null 2>&1
mail -s "${subject}" ${email} < /${logdir}/${servicename}-email.log tail -25 "${scriptlog}" >> "${emaillog}"
echo -e "[\e[0;36m INFO \e[0;39m] Sent email notification to ${email}" if [ ! -z "${consolelog}" ]; then
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: sent email notification to ${email}" >> ${logfile} echo -e "\n\nConsole log\n====================\n" >> "${emaillog}"
tail -25 "${consolelog}" >> "${emaillog}"
fi
if [ ! -z "${gamelogdir}" ]; then
echo -e "\n\nServer log\n====================\n" >> "${emaillog}"
tail "${gamelogdir}"/*|grep -v "==>"|sed '/^$/d'|tail -25 >> "${emaillog}"
fi
mail -s "${subject}" ${email} < "${emaillog}"
fn_printinfo "Sent email notification to ${email}"
sleep 1
echo -en "\n"
fn_scriptlog "Sent email notification to ${email}"
} }
fn_emailtest(){ fn_emailtest(){
fn_rootcheck fn_rootcheck
fn_syscheck fn_syscheck
echo -e "[\e[0;32m OK \e[0;39m] Emailing test notification" fn_scriptlog "Emailing test notification"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Emailing test notification" >> ${logfile} if [ "${emailnotification}" = "on" ]; then
if [ "${emailnotification}" = "on" ];then
subject="${servicename} Email Test Notification - Testing ${servername}" subject="${servicename} Email Test Notification - Testing ${servername}"
failurereason="Testing ${servicename} email notification" failurereason="Testing ${servicename} email notification"
actiontaken="Sent test email...hello is this thing on?" actiontaken="Sent test email...hello is this thing on?"
fn_emailnotification fn_emailnotification
else else
echo -e "[\e[0;31m FAIL \e[0;39m] Email notificaion not enabled" fn_printfailnl "Email notification not enabled"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Email notificaion not enabled" >> ${logfile} fn_scriptlog "Email notification not enabled"
fi
sleep 1
echo -en "\n"
}
fn_monitorserver(){
fn_rootcheck
fn_syscheck
if [ ! -f ${lockselfname} ]; then
fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled"
sleep 1
echo -en "\n"
exit
fi
fn_printdots "Monitoring ${servicename}: ${servername}"
sleep 1
fn_scriptlog "Monitoring ${servername}"
fn_printdots "Monitoring ${servicename}: Checking session: CHECKING"
sleep 1
fn_scriptlog "Checking session: CHECKING"
tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l)
if [ ${tmuxwc} -eq 1 ]; then
fn_printok "Monitoring ${servicename}: Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
exit
else
fn_printfail "Monitoring ${servicename}: Checking session: FAIL"
fn_scriptlog "Checking session: FAIL"
sleep 1
echo -en "\n"
if [ "${emailnotification}" = "on" ]; then
subject="${servicename} Monitor - Starting ${servername}"
failurereason="${servicename} process not running"
actiontaken="${servicename} has been restarted"
fn_emailnotification
fi
fn_scriptlog "Monitor is starting ${servername}"
fn_startserver
fi fi
} }
fn_logmanager(){ fn_logmanager(){
# log manager will active if finds logs older than $logdays if [ ! -e "${consolelog}" ]; then
if [ `find ${logdir}/* -mtime +${logdays} |wc -l` -ne "0" ];then touch "${consolelog}"
echo -e "[\e[0;32m OK \e[0;39m] Starting log cleaner" fi
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Starting log cleaner" >> ${logfile} # log manager will active if finds logs older than ${logdays}
echo -e "[\e[0;36m INFO \e[0;39m] Removing logs older than ${logdays} days" if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Removing logs older than ${logdays} days" >> ${logfile} fn_printdots "Starting log cleaner"
find ${logdir}/* -mtime +${logdays} |tee >> ${logfile} sleep 1
count=$(find ${logdir}/* -mtime +${logdays}|wc -l) fn_printok "Starting log cleaner"
find ${logdir}/* -mtime +${logdays} -exec rm {} \; sleep 1
echo -e "[\e[0;36m INFO \e[0;39m] Log cleaner removed ${count} log files" fn_scriptlog "Starting log cleaner"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Log cleaner removed ${count} log files" >> ${logfile} sleep 1
echo -en "\n"
fn_printinfo "Removing logs older than ${logdays} days"
sleep 1
echo -en "\n"
fn_scriptlog "Removing logs older than ${logdays} days"
sleep 1
find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}"
find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}"
scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l)
consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l)
count=$((${scriptcount} + ${consolecount}))
find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \;
find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \;
fn_printok "Log cleaner removed ${count} log files"
sleep 1
echo -en "\n"
fn_scriptlog "Log cleaner removed ${count} log files"
fi fi
} }
fn_restartserver(){ fn_restartserver(){
echo -e "[\e[0;32m OK \e[0;39m] Restarting ${servicename}: ${servername}" fn_scriptlog "Restarting ${servername}"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Restarting ${servername}" >> ${logfile} fn_stopserver
fn_stopserver fn_startserver
sleep 1 }
fn_startserver
fn_stopserver(){
fn_rootcheck
fn_syscheck
pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l)
pidwc=$(screen -ls |grep -E "^${servicename}:" |awk -F . '{print $1}'|awk '{print $1}'|wc -l)
fn_printdots "Stopping ${servicename}: ${servername}"
sleep 1
fn_scriptlog "Stopping ${servername}"
if [ "${pid}" == "0" ]; then
fn_printfail "Stopping ${servicename}: ${servername} is already stopped"
fn_scriptlog "${servername} is already stopped"
else
#Kill murmur process that spawns separate to tmux process
for s in `tmux list-sessions -F '#{session_name}'` ; do
for pid in `tmux list-panes -s -F '#{pane_pid}' -t "$s"` ; do
kill $pid
done
tmux kill-session -t ${servicename}
fn_printok "Stopping ${servicename}: ${servername}"
fn_scriptlog "Stopped ${servername}"
done
fi
# Remove lock file
rm -f ${lockselfname}
sleep 1
echo -en "\n"
} }
fn_startserver(){ fn_startserver(){
if [ ! -d ${logdir} ];then if [ ! -d ${logdir} ];then
mkdir ${logdir} mkdir ${logdir}
mkdir ${scriptlogdir}
mkdir ${consolelogdir}
echo -e "[\e[0;36m INFO \e[0;39m] ${servicename}: ${servername} Creating log directory ${logdir}" echo -e "[\e[0;36m INFO \e[0;39m] ${servicename}: ${servername} Creating log directory ${logdir}"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: ${servername} Creating log directory ${logdir}" >> ${logfile} fn_scriptlog " Creating log directory ${logdir}" >> ${scriptlog}
fi fi
fn_rootcheck fn_rootcheck
fn_syscheck fn_syscheck
fn_runcheck
fn_inicheck
fn_logmanager fn_logmanager
cd ${filesdir} tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l)
if [ -f ${logdir} ];then if [ ${tmuxwc} -eq 0 ]; then
cp ${logfile} ${logfiledate} mv "${scriptlog}" "${scriptlogdate}"
mv "${consolelog}" "${consolelogdate}"
fi fi
echo -e "[\e[0;32m OK \e[0;39m] Starting ${servicename}: ${servername}" fn_printdots "Starting ${servicename}: ${servername}"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Starting ${servername}" >> ${logfile}
screen -d -m -S ${servicename} ./murmur.x86 -fg -ini ${ini}
sleep 1 sleep 1
pidwc=$(screen -ls |grep -E "^${servicename}:" |awk -F . '{print $1}'|awk '{print $1}'|wc -l) fn_scriptlog "Starting ${servername}"
if [ ${pidwc} -eq 0 ];then if [ ${tmuxwc} -eq 1 ]; then
echo -e "[\e[0;31m FAIL \e[0;39m] ${servicename}: ${servername} failed to start" fn_printinfo "Starting ${servicename}: ${servername} is already running"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: ${servername} failed to start" >> ${logfile} sleep 1
echo -en "\n"
fn_scriptlog "${servername} is already running"
exit
fi fi
} # Create lock file
date > ${lockselfname}
fn_stopserver(){ cd ${filesdir}
fn_rootcheck tmux new-session -d -s ${servicename} "${executable}"
fn_syscheck tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'"
pid=$(screen -ls |grep -E "^${servicename}:" |awk -F . '{print $1}'|awk '{print $1}') sleep 1
if [ -z ${pid} ];then tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l)
echo -e "[\e[0;36m INFO \e[0;39m] ${servicename}: ${servername} is already stopped" if [ ${tmuxwc} -eq 0 ]; then
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: ${servername} is already stopped" >> ${logfile} fn_printfail "Starting ${servicename}: Failed to start ${servername}"
fn_scriptlog "failed to start ${servername}"
else else
echo -e "[\e[0;32m OK \e[0;39m] Stopping ${servicename}: ${servername}" fn_printok "Starting ${servicename}: ${servername}"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Stopping ${servername}" >> ${logfile} fn_scriptlog "Started ${servername}"
pkill -P `screen -ls |grep -E "^${servicename}:" |awk -F . '{print $1}'|awk '{print $1}'`
screen -wipe > /dev/null 2>&1
fi fi
sleep 1
echo -en "\n"
} }
fn_debugserver(){ fn_debugserver(){
fn_rootcheck fn_rootcheck
fn_syscheck fn_syscheck
cd ${filesdir} echo ""
if [ -f ${logdir} ];then echo "${gamename} Debug"
cp ${logfile} ${logfiledate} echo "============================"
fi echo ""
echo -e "[\e[0;32m OK \e[0;39m] Starting ${servicename}: ${servername} Debug mode!"
sleep 0.5
echo -e "Use for identifying server issues only!" echo -e "Use for identifying server issues only!"
sleep 2 echo -e "Press CTRL+c to drop out of debug mode"
echo -e "\e[0;31mWARNING!\e[0;39m If ${servicename} is already running it will be stopped"
echo ""
echo "Start parameters:"
echo ${executable}
echo ""
while true; do while true; do
echo "If server is already running it will be stopped"
read -p "Continue? [y/N]" yn read -p "Continue? [y/N]" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]* ) break;;
[Nn]* ) echo Exiting; return 1 ;; [Nn]* ) echo Exiting; return 1;;
* ) echo "Please answer yes or no.";; * ) echo "Please answer yes or no.";;
esac esac
done done
fn_stopserver fn_stopserver
echo -e "[\e[0;36m INFO \e[0;39m] ${servicename}: Enter CTRL+C to drop out of debug mode" fn_printdots "Starting debug mode ${servicename}: ${servername}"
sleep 3 sleep 1
echo -e "[\e[0;32m OK \e[0;39m] Starting ${servicename}: ${servername}" fn_printok "Starting debug mode ${servicename}: ${servername}"
sleep 1
fn_scriptlog "Started debug mode ${servername}"
echo -en "\n"
cd ${filesdir}
./murmur.x86 -fg -ini ${ini} ./murmur.x86 -fg -ini ${ini}
} }
fn_monitorserver(){ fn_console(){
fn_rootcheck fn_rootcheck
fn_syscheck fn_syscheck
fn_logmanager echo ""
echo -e "[\e[0;32m OK \e[0;39m] Checking ${servicename}: ${servername}" echo "${gamename} Console"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Checking ${servername}" >> ${logfile} echo "============================"
fn_runcheck echo ""
echo -e "[\e[1;33m WARN \e[0;39m] ${servicename}: Monitor detected ${servername} had stopped!" echo "Press \"CTRL+b d\" to exit console"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Monitor detected ${servername} had stopped!" >> ${logfile} echo -e "\e[0;31mWARNING!\e[0;39m Do NOT press CTRL+c to exit"
if [ "${emailnotification}" = "on" ];then echo ""
subject="${servicename} Monitor - Starting ${servername}" while true; do
failurereason="${servername} had stopped" read -p "Continue? [y/N]" yn
actiontaken="restarted ${servername}" case $yn in
fn_emailnotification [Yy]* ) break;;
[Nn]* ) echo Exiting; return 1;;
* ) echo "Please answer yes or no.";;
esac
done
fn_printdots "Starting ${servicename} console"
sleep 1
tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l)
if [ ${tmuxwc} -eq 1 ]; then
fn_printoknl "Starting ${servicename} console"
sleep 1
fn_scriptlog "Console accessed"
tmux attach-session -t ${servicename}
else
fn_printfailnl "Starting ${servicename} console: ${servername} not running"
sleep 1
while true; do
read -p "Do you want to start the server? [y/N]" yn
case $yn in
[Yy]* ) fn_startserver; break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
fi fi
fn_startserver
} }
case "$1" in case "$1" in
@ -305,14 +468,16 @@ case "$1" in
fn_restartserver;; fn_restartserver;;
monitor) monitor)
fn_monitorserver;; fn_monitorserver;;
debug)
fn_debugserver;;
backup)
fn_backupserver;;
email-test) email-test)
fn_emailtest;; fn_emailtest;;
backup)
fn_backupserver;;
console)
fn_console;;
debug)
fn_debugserver;;
*) *)
echo "Usage: $0 {start|stop|restart|monitor|debug|backup|email-test}" echo "Usage: $0 {start|stop|restart|monitor|debug|backup|email-test}"
exit 1;; exit 1;;
esac esac
exit exit
Loading…
Cancel
Save