Teamspeak 2 and Teamspeak 3 on ClearOS
Install TeamSpeak 2 on ClearOS Box. With will provide Log Support, and integrated Webgui interface so you can see if it is running.
With TeamSpeak 3 beta released the installation will be the similar with the exception to setting up the server and clients.
Please see this video for TeamSpeak 3 Installation
http://www.youtube.com/watch?v=j8SgpKjK__Q
TeamSpeak 3 also has limitation as Ventrilo does. TeamSpeak 3 is now required licenses files in order to run the server.
This How-To will only be for TeamSpeak 2, but installation should be very similar if you have TeamSpeak 3.
I have also included a TeamSpeak 3 startup script at the bottom. - This has not been tested.
Install Program Tools
SSH logon
You can pickup WinSCP here; http://winscp.net/eng/index.php
Putty here; http://www.chiark.greenend.org.uk/~sgtatham/putty/ This all could be done via Putty too if you want.
Get the latest version of Team Speak 2 Download here http://www.teamspeak.com/?page=downloads&archive=1
Get the latest version of Team Speak 3 Download here http://www.teamspeak.com/?page=downloads
Install Team Speak 2
Create a new user within the Webgui
User: ts2 Name: Team Speak Last Name: Server
Everything else is up to you, but don’t give it access to anything
Logon to you ClearOS box via SSH
Go: /home/ts2
Copy the ts2_server_rc2_VERSION.tar.bz22 file into this directory
Command chown ts2:allusers ts2_server_rc2_VERSION.tar.bz2
Type: tar -xzf ts2_server_rc2_VERSION.tar.bz2
You can delete the zip file if you like
Type: chown -R ts2:allusers /home/ts2/tss2_rc2 Type: chmod -R 0755 /home/ts2/tss2_rc2 Type: mv server_linux server
TeamSpeak has a great web interface that you can create and setup your TeamSpeak server. you can usually find it here.
TeamSpeak also has a website to check to see if all ports are working etc.
Modifying your Script File
Next will be to create script file so you can load the service from CLI or later in the webgui.
You need to run the service in order for it to create some files, including the .log file.
Copy the text below into a script file
Location of the file
/etc/rc.d/init.d/
Name the script file
ts2
Enter the following information into the script file.
#!/bin/bash # # Team Speak This shell script takes care of starting and stopping # the Team Speak Subsystem (ts). # # chkconfig: - 90 10 # description: Team Speak Server. # processname: server # config: /do_not_remove/server.ini # pidfile: /do_not_remove/server.pid # Source function library. . /etc/rc.d/init.d/functions # CONFIG prog="Team Speak 2" vent_path=/home/ts2/tss2_rc2 # <---- Replace with the path to your /tss_rc2 directory vent_user=ts2 # <---- Replace with sudo user vent_bin=$vent_path/ vent_server=server vent_log=$vent_path/server.log vent_pid=$vent_path/server.pid # Startup Team Speak 2 servers. start(){ sudo -u $vent_user $vent_path/$vent_server ret=0 if [ $ret -eq 0 ]; then STARTTIMEOUT=30 while [ $STARTTIMEOUT -gt 0 ]; do RESPONSE=`ls -al server.pid 2>&1` && break echo "$RESPONSE" | grep -q "root" && break break sleep 1 let STARTTIMEOUT=${STARTTIMEOUT}-1 done if [ $STARTTIMEOUT -eq 0 ]; then echo "Timeout error occurred trying to start $prog Daemon." action $"Starting $prog: " /bin/false else action $"Starting $prog: " /bin/true fi else action $"Starting $prog: " /bin/false fi return $ret } stop(){ VENTPID=`cat "$vent_pid" 2>/dev/null ` if [ -n "$VENTPID" ]; then /bin/kill "$VENTPID" >/dev/null 2>&1 ret=$? if [ $ret -eq 0 ]; then STOPTIMEOUT=60 while [ $STOPTIMEOUT -gt 0 ]; do /bin/kill -0 "$VENTPID" >/dev/null 2>&1 || break sleep 1 let STOPTIMEOUT=${STOPTIMEOUT}-1 done if [ $STOPTIMEOUT -eq 0 ]; then echo "Timeout error occurred trying to stop $prog Daemon." ret=1 action $"Stopping $prog: " /bin/false else action $"Stopping $prog: " /bin/true fi else action $"Stopping $prog: " /bin/false fi else ret=1 action $"Stopping $prog: " /bin/false fi return $ret } restart(){ stop start } password(){ if [ -e $vent_path/server.log ]; then date=$(cat $vent_path/server.log | grep "admin account info: username:admin" | tail -n 1 | sed "s/^\([0-9]\+-[0-9]\+-[0-9]\+ [0-9]\+:[0-9]\+:[0-9]\+\).*$/\1/") spass=$(cat $vent_path/server.log | grep "superadmin account info: username: superadmin" | tail -n 1 | sed "s/^.*username: superadmin password: \([a-z0-9]\+\).*$/\1/") pass=$(cat $vent_path/server.log | grep "admin account info: username: admin" | tail -n 1 | sed "s/^.*username: admin password: \([a-z0-9]\+\).*$/\1/") echo "Following passwords were generated on $date" echo "superadmin = \"$spass\"" echo "admin = \"$pass\"" else echo "server.log not found; maybe the server has not been started yet?" exit 1 fi } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status vent ;; restart) restart ;; password) password ;; *) echo $"Usage: $0 {start|stop|status|restart|password}" exit 1 esac
Copy the same text above into a file and put it under
Type: chkconfig --add ts2 Type: chkconfig --levels 345 ts2 on && chkconfig --list ts2
Now you can start your server
Type: service ts2 start
ignore it, because the file is not there, as you just created it. Then you should see the system come back as “OK” in green.
service ts2 restart service ts2 stop
chmod -xw /etc/rc.d/init.d/ts2
Almost Done
Next we need to create a link file under the /var/log so we can view it via the webgui.
Type: mkdir /var/log/ts2 Type: cd /home/ts2//tss2_rc2/ Type: cp server.log /var/log/ts2/server.log Type: rm server.log then Y Type: chown -R ts2:allusers /var/log/ts2/server.log Type: ln -s /var/log/ts2/tss2_rc2/server.log server.log
Now restart the webconfig service
Type: service webconfig restart
Now you should be able to access your log menu and see
ts2/server.log
Next we'll want to add the necessary changes to the webgui in order to see the server as a service.
You need to locate the following file.
/var/webconfig/api/daemon.inc.php
And insert this line.
"ts2" => array("httpd", "server", "no", "Team Speak 2 Server", "no", null),
Restart the webconfig
Type: service webconfig restart
You should be all done!!!
#Teamspeak 3 screen startup script v0.93 #Written by mancert ############################################################################## ############# # Remember to start the teamspeak server manually the first time so you get the # server admin password and the server admin token. # If you want to use mysql database, remember to create a ts3db_mysql.ini file # in the folder ts3 in installed in. And make sure ts3server.ini is set right. # Changelog @ http://forum.teamspeak.com/showthread.php?t=46989 # # The test start option will check if you are missing anything before you start the script # ########################################################################################### ############################ OPTIONS ###################################################### TITLE='Teamspeak 3 Server' # Name for the server NAME='ts3' # Name for screen session DAEMON='ts3server_linux_x86' # Server binary, here the 32bit TS3='/home/ts3/ts3' # Path to ts3 binary USER='ts3' # User running server USERG='users' # Usergroup of user OPT='$opt' #inifile=server.inifile LOGFILE='/var/log/ts3.log' # Logfile location and file ############################ END OPTIONS ################################################## ########################### NO NEED TO EDIT UNDER HERE #################################### precheck () { # Checking for screen if methode 1 is chosen. if [ ! -x /usr/bin/screen ]; then echo "" echo "You do not have Screen installed. Please install it and try again." echo "$(date +"%b %a %d %H:%M:%S"): You do not have Screen installed." >> $LOGFILE echo "" exit 1 fi # Checking for sudo if [ ! -x /usr/bin/sudo ]; then echo "" echo "You do not have Sudo installed. Please install it and try again." echo "$(date +"%b %a %d %H:%M:%S"): You do not have Sudo installed." >> $LOGFILE echo "" exit 1 fi # Checking for awk if [ ! -x /usr/bin/awk ]; then echo "" echo "You do not have Awk installed. Please install it and try again." echo "$(date +"%b %a %d %H:%M:%S"): You do not have awk installed." >> $LOGFILE echo "" exit 1 fi # Checking for ts3 binary if [ ! -x $TS3/\$DAEMON ]; then echo "Can't find $TS3$DAEMON" echo "Is the configs done right? Is $TITLE installed?" echo "$(date +"%b %a %d %H:%M:%S"): Can't find $TS3/$DAEMON" >> $LOGFILE exit 1 fi echo echo "All seems fine, try $0 start" echo } #Screen command INTERFACE="/usr/bin/screen -A -m -d -S $NAME" service_start() { TEST=$(ps ax | grep SCREEN | grep $NAME | grep $DAEMON | wc -l) # Server not running and no pid-file found if [ "$TEST" = "0" ] && [ ! -f $TS3/$NAME-screen.pid ]; then echo echo "Starting $TITLE" echo "$(date +"%b %a %d %H:%M:%S"): Starting $TITLE" >> $LOGFILE cd $TS3 LIBPATH=$(pwd) su $USER -c "export LD_LIBRARY_PATH=$LIBPATH:$LD_LIBRARY_PATH ; $INTERFACE $TS3/$DAEMON $OPT" >> $LOGFILE sleep 1 sudo -u $USER ps -ef | grep -v grep | grep SCREEN | grep $NAME | awk '{print $2}' > $TS3/$NAME-screen.pid chown $USER:$USERG $TS3/$NAME-screen.pid echo "$TITLE screen process ID written to $TS3/$NAME-screen.pid" echo "$TITLE started." echo "$(date +"%b %a %d %H:%M:%S"): $TITLE started" >> $LOGFILE echo exit 1 fi # Server not running and a pid-file is found if [ "$TEST" = "0" ] && [ -f $TS3/$NAME-screen.pid ]; then echo echo "Server not running but pid-file present" echo "Removing pid-file" echo "$(date +"%b %a %d %H:%M:%S"): Server not running but pid-file present" >> $LOGFILE echo "$(date +"%b %a %d %H:%M:%S"): Removing pid-file" >> $LOGFILE rm $TS3/$NAME-screen.pid echo "Old pid file removed" echo "$(date +"%b %a %d %H:%M:%S"): Old pid file removed" >> $LOGFILE echo echo "Starting $TITLE" echo "$(date +"%b %a %d %H:%M:%S"): Starting $TITLE" >> $LOGFILE cd $TS3 LIBPATH=$(pwd) su $USER -c "export LD_LIBRARY_PATH=$LIBPATH:$LD_LIBRARY_PATH ; $INTERFACE $TS3/$DAEMON $OPT" >> $LOGFILE sleep 1 sudo -u $USER ps -ef | grep -v grep | grep SCREEN | grep $NAME | awk '{print $2}' > $TS3/$NAME-screen.pid chown $USER:$USERG $TS3/$NAME-screen.pid echo "$TITLE screen process ID written to $TS3/$NAME-screen.pid" echo "$TITLE started." echo "$(date +"%b %a %d %H:%M:%S"): $TITLE started" >> $LOGFILE echo fi # Server running and no pid file-found, creates a new one! if [ "$TEST" = "1" ] && [ ! -f $TS3/$NAME-screen.pid ]; then echo echo "Server is running but no pid file. Creating a new pid file!!" echo "$(date +"%b %a %d %H:%M:%S"): Server is running but no pid file. Creating a new pid file!!" >> $LOGFILE sudo -u $USER ps -ef | grep -v grep | grep SCREEN | grep $NAME | awk '{print $2'} > $TS3/$NAME-screen.pid chown $USER:$USERG $TS3/$NAME-screen.pid echo echo "$TITLE is running and new pid-file created" echo "$(date +"%b %a %d %H:%M:%S"): $TITLE is running and new pid-file created" >> $LOGFILE echo fi # Server running and pid-file found if [ "$TEST" = "1" ] && [ -f $TS3/$NAME-screen.pid ]; then echo echo "$TITLE is running!!" echo "$(date +"%b %a %d %H:%M:%S"): $TITLE is running!!" >> $LOGFILE echo fi } service_stop() { TEST1=$(ps ax | grep SCREEN | grep $NAME | grep $DAEMON | wc -l) # Server is not running and no pid-file found if [ "$TEST1" = "0" ] && [ ! -f $TS3/$NAME-screen.pid ]; then echo echo "$TITLE is not running!!" echo "$(date +"%b %a %d %H:%M:%S"): $TITLE is not running!!" >> $LOGFILE echo fi # Server is not running and pid-file found if [ "$TEST1" = "0" ] && [ -f $TS3/$NAME-screen.pid ]; then echo echo "Server is not running but pid-file is present" echo "Removing pid-file" echo "$(date +"%b %a %d %H:%M:%S"): Server is not running but pid-file is present" >> $LOGFILE echo "$(date +"%b %a %d %H:%M:%S"): Removing pid-file" >> $LOGFILE rm $TS3/$NAME-screen.pid echo echo "Pid file removed" echo "$(date +"%b %a %d %H:%M:%S"): Pid file removed" >> $LOGFILE echo fi # Server is running but no pid-file found if [ "$TEST1" = "1" ] && [ ! -f $TS3/$NAME-screen.pid ]; then echo echo "$TITLE is running but no pid file found." echo "Stopping $TITLE" echo "$(date +"%b %a %d %H:%M:%S"): $TITLE is running but no pid file found." >> $LOGFILE echo "$(date +"%b %a %d %H:%M:%S"): Stopping $TITLE" >> $LOGFILE sudo -u $USER ps -ef | grep -v grep | grep SCREEN | grep $NAME | awk '{print $2'} > $TS3/$NAME-screen.pid chown $USER:$USERG $TS3/$NAME-screen.pid for id in $(cat $TS3/$NAME-screen.pid) do kill -9 $id echo "Killing process ID $id" echo "Removing $TITLE screen pid file" rm -rf $TS3/$NAME-screen.pid break done # Wipe all old screen sessions su $USER -c "screen -wipe 1> /dev/null 2> /dev/null" echo "$TITLE stopped" echo "$(date +"%b %a %d %H:%M:%S"): $TITLE stopped" >> $LOGFILE echo fi # Server running and pid-file found if [ "$TEST1" = "1" ] && [ -f $TS3/$NAME-screen.pid ]; then echo echo "Stopping $TITLE" echo "$(date +"%b %a %d %H:%M:%S"): Stopping $TITLE" >> $LOGFILE for id in $(cat $TS3/$NAME-screen.pid) do kill -9 $id echo "Killing process ID $id" echo "Removing $TITLE screen pid file" rm -rf $TS3/$NAME-screen.pid break done # Wipe all old screen sessions su $USER -c "screen -wipe 1> /dev/null 2> /dev/null" echo "$TITLE stopped" echo "$(date +"%b %a %d %H:%M:%S"): $TITLE stopped" >> $LOGFILE echo fi } case "$1" in 'start') service_start ;; 'stop') service_stop ;; 'restart') service_stop sleep 1 service_start ;; 'test') precheck ;; *) echo "Usage $0 start|stop|restart|test"