| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- #!/bin/bash
- # LGSM fn_start function
- # Author: Daniel Gibbs
- # Website: http://danielgibbs.co.uk
- # Version: 080214
- # Description: Starts the server.
- local modulename="Starting"
- fn_start_teamspeak3(){
- # Create any missing log dirs
- if [ ! -d ${scriptlogdir} ];then
- mkdir ${rootdir}/log
- mkdir ${scriptlogdir}
- fn_printinfo "Creating log directorys ${scriptlogdir}"
- fn_scriptlog "Creating log directorys ${scriptlogdir}"
- fi
- if [ ! -h ${rootdir}/log/server ]; then
- ln -sv ${gamelogdir} ${rootdir}/log/server
- fi
- fn_check_root
- fn_check_systemdir
- fn_check_ts3status
- if [ "${ts3status}" = "Server is running" ]; then
- fn_printinfo "${servername} is already running"
- fn_scriptlog "${servername} is already running"
- sleep 1
- echo -en "\n"
- exit
- fi
- if [ ! -e ${servercfgfullpath} ]; then
- fn_printwarn "${servercfgfullpath} is missing"
- fn_scriptlog "${servercfgfullpath} is missing"
- sleep 1
- fn_printinfo "Creating blank ${servercfgfullpath}"
- fn_scriptlog "Creating blank ${servercfgfullpath}"
- sleep 1
- fn_printinfo "${servercfgfullpath} can remain blank by default."
- fn_scriptlog "${servercfgfullpath} can remain blank by default."
- sleep 1
- touch "${servercfgfullpath}"
- fi
- fn_logs
- fn_printdots "${servername}"
- fn_scriptlog "${servername}"
- sleep 1
- mv "${scriptlog}" "${scriptlogdate}"
- # Create lock file
- date > "${rootdir}/${lockselfname}"
- cd "${executabledir}"
- ./ts3server_startscript.sh start inifile=${servercfgfullpath} > /dev/null 2>&1
- sleep 1
- fn_check_ts3status
- #
- if [ "${ts3status}" = "Server seems to have died" ] || [ "${ts3status}" = "No server running (ts3server.pid is missing)" ];then
- fn_printfailnl "Unable to start ${servername}"
- fn_scriptlog "Unable to start ${servername}"
- echo -en " Check log files: ${rootdir}/log"
- else
- fn_printok "${servername}"
- fn_scriptlog "Started ${servername}"
- fi
- sleep 0.5
- echo -en "\n"
- }
- fn_start_tmux(){
- fn_check_root
- fn_check_systemdir
- fn_check_ip
- if [ "${gamename}" == "Counter Strike: Global Offensive" ]; then
- startfix=1
- fn_csgofix
- fi
- fn_details_config
- fn_parms
- fn_logs
- fn_printdots "${servername}"
- fn_scriptlog "${servername}"
- sleep 1
- fn_check_tmux
- fn_check_steamcmd
- tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -Ec "^${servicename}:")
- if [ "${tmuxwc}" -eq 0 ]; then
- fn_scriptlog "Rotating log files"
- if [ "${engine}" == "unreal2" ]; then
- mv "${gamelog}" "${gamelogdate}"
- fi
- mv "${scriptlog}" "${scriptlogdate}"
- mv "${consolelog}" "${consolelogdate}"
- fi
- if [ "${tmuxwc}" -eq 1 ]; then
- fn_printinfo "${servername} is already running"
- fn_scriptlog "${servername} is already running"
- sleep 1
- echo -en "\n"
- exit
- fi
- # Create lock file
- date > "${rootdir}/${lockselfname}"
- cd "${executabledir}"
- tmux new-session -d -s ${servicename} "${executable} ${parms}" 2> "${scriptlogdir}/.${servicename}-tmux-error.tmp"
- # tmux pipe-pane not supported in tmux versions < 1.6
- if [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd [:digit:]|tail -c 3)" -lt "16" ]; then
- echo "Console logging disabled: Tmux => 1.6 required" >> "${consolelog}"
- echo "Currently installed: $(tmux -V)" >> "${consolelog}"
- else
- tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'"
- fi
- sleep 1
- tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:")
- if [ "${tmuxwc}" -eq 0 ]; then
- fn_printfailnl "Unable to start ${servername}"
- fn_scriptlog "Unable to start ${servername}"
- echo -en " Check log files: ${rootdir}/log"
- if [ -s "${scriptlogdir}/.${servicename}-tmux-error.tmp" ]; then
- fn_scriptlog "tmux returned the following error"
- cat "${scriptlogdir}/.${servicename}-tmux-error.tmp" >> "${scriptlog}"
- fi
- else
- fn_printok "${servername}"
- fn_scriptlog "Started ${servername}"
- fi
- rm "${scriptlogdir}/.${servicename}-tmux-error.tmp"
- sleep 1
- echo -en "\n"
- }
- if [ "${gamename}" == "Teamspeak 3" ]; then
- fn_start_teamspeak3
- else
- fn_start_tmux
- fi
|