PDA

View Full Version : Start script..


NitroSniper
27-08-2002, 01:18
Hi... not sure how useful you will find this but i've re-writen the start script :) .. see below:

It has four modes start/stop/check/restart (restart does work properly yet..)

#rc.tss: Runs TeamSpeak Server #Modified NitroSniper 27/08/02
action=$1

###Edit these to suit you fancy!
HOME=/home/tss/tss2/
TSS_INI="tsserver2.ini"
TSS_LOG="tsserver2.log"
PID_FILE="tsserver2.pid"
####End of editable bit

cd $HOME
case "$action" in
'check')
#Used by crontab to check if TS is running
if test -r $PID_FILE
then
PID=`cat $PID_FILE`
if `kill -CHLD $PID >/dev/null 2>&1`
then
#TeamSpeak is hapily running now run away
exit 0
else
#TeamSpeak Server is not running! Auto-Restart
$0 start
exit 0
fi
fi
echo "TeamSpeak Server is not currently running! Start the server by typing ./tss.cmd start"
exit 0
;;
'start')
echo "NOTICE: Starting TeamSpeak Server..."
./tss -INI=$HOME/$TSS_INI -LOG=$HOME/$TSS_LOG -PID=$HOME/$PID_FILE
exit 0
;;
'stop')
if test -r $PID_FILE
then
PID=`cat $PID_FILE`
if `kill -CHLD $PID >/dev/null 2>&1`
then
kill -TERM $PID
rm $HOME/$PID_FILE
echo "NOTICE: TeamSpeak Server PID:$PID has been shutdown"
else
echo "NOTICE: TeamSpeak Server is already stopped!"
fi
else
echo "NOTICE: TeamSpeak Server is already stopped!"
fi
exit 0
;;
'restart')
if test -r $PID_FILE
then
PID=`cat $PID_FILE`
if `kill -CHLD $PID >/dev/null 2>&1`
then
$0 stop && $0 start || return=$rc_failed
else
echo "ERROR: TeamSpeak Server is not running! [PID NOT RUNNING] Try using: ./tss.cmd start"
fi
else
echo "ERROR: TeamSpeak Server is not running! [PID FILE NOT FOUND] Try using: ./tss.cmd start"
fi
exit 0
;;
*)
echo "Usage: $0 {start/stop/restart/check}"
esac
exit 0



-NitroSniper
Ps. Good job on v2.0 .. its bit buggy be we love it! :)

Rrroot
27-08-2002, 06:41
You forgot just 1 thing: there's also a server.db running :)
haven't found the official commandswitch yet, but I've narrowed it down to useing '--DB=$home/$DB_FILE'


:D

Rrroot
27-08-2002, 07:02
Patched version of Niels' script:
This runs with the log/ini/db/pid file in the old tss1 style. In /var/log/tss2/


#! /bin/bash
# Copyright (c) 2002 TeamSpeak team All rights reserved.
#
# Author: Niels Werensteijn 2002
#

case "$1" in
start)
./server_linux -INI=/var/log/tss2/server.ini -DB=/var/log/tss2/server.db -LOG=/var/log/tss2/server.log -PID=/var/log/tss2/tsserver2.pid
;;
stop)
killall -9 server_linux
;;
restart)
$0 stop && $0 start || return=$rc_failed
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0


why did I replace the "kill -TERM `cat /var/log/tss2/tsserver2.pid` ??
just because the webserver part is too easilly borked and it's, for now, the only easy way to shutdown the server.

Rrroot
27-08-2002, 07:12
forget my 2 posts for now...

the option -DB leads to a broken server.db
You won't brake the file itself, but teamspeak2 server will not be able to log in to anything anymore that way.