View previous topic :: View next topic |
Author |
Message |
RayVad n00b
Joined: 10 Nov 2005 Posts: 67 Location: Netherlands
|
Posted: Mon May 01, 2006 11:19 pm Post subject: teamspeak server start/stop script |
|
|
I'm still wondering how i have to configure the start/stop script under Gentoo.
Everytime the server is rebooting the pid file is still there and not been removed, so i need to remove it and restart is manualy.
Does anyone have a running good running teamspeak start/stop script there in the init.d directory?
My script:
#! /bin/bash
# Copyright (c) 2004 TeamSpeak team All rights reserved.
#
# Author: pwk.linuxfan 2004
# Modified by Derek "Cybernaut" Jackson - www.DigitalNines.com
#
# chkconfig: 345 85 15
# description: Runs and kills TeamSpeak Voice server at boot time and shutdown.
# Source function library.
#. /etc/rc.d/init.d/functions
# START OF CONFIG SECTION
# WARNING ! For security reasons we advise: DO NOT RUN THE SERVER AS ROOT
USER=tss
DIR=/data/tss2_rc2
# END OF CONFIG SECTION
# See how we were called.
case "$1" in
start)
if [ -e $DIR/tsserver2.pid ]; then
echo "tsserver2.pid already exists...server already started ?";
echo "If you are sure the server is not running, delete tsserver2.pid"
exit 1
else
if [ "$UID" = "0" ]; then
for c in $(seq 1 10); do
echo -n "!"
sleep 1
done
echo !
fi
echo "Starting the TeamSpeak Voice server..."
if [ -e $DIR/server_linux ]; then
if [ ! -x $DIR/server_linux ]; then
echo "server_linux is not executable; trying to set it."
chmod u+x $DIR/server_linux
fi
if [ -x $DIR/server_linux ]; then
WD=`pwd`
cd $DIR
su $USER -c "$DIR/server_linux -PID=tsserver2.pid" &
cd $WD
else
echo "server_linux is not executable; fix this."
exit 4
fi
else
echo "Couldnt find server_linux."
exit 5
fi
fi
;;
stop)
if [ -e $DIR/tsserver2.pid ]; then
echo -n "Stopping the TeamSpeak Voice server..."
if ( kill -TERM `cat $DIR/tsserver2.pid` ); then
for c in $(seq 1 300); do
if [ -e $DIR/tsserver2.pid ]; then
echo -n "."
sleep 1
fi
done
fi
if [ -e $DIR/tsserver2.pid ]; then
echo "server does not shutdown cleanly - killing"
kill -KILL `cat $DIR/tsserver2.pid`
rm $DIR/tsserver2.pid
sleep 5
else
echo "done"
fi
else
echo "tsserver2.pid is missing; is the server stopped already?"
#exit 7 - Should not be here as doesn't allow restart if server is already stopped.
fi
;;
restart)
$0 stop && $0 start || exit 1
;;
status)
if [ -e $DIR/tsserver2.pid ]; then
echo "The TeamSpeak Voice server is running."
exit 0
else
echo "The TeamSpeak Voice server is stopped."
exit 3
fi
;;
passwords)
if [ -e $DIR/server.log ]; then
date=$(cat $DIR/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 $DIR/server.log | grep "superadmin account info: username: superadmin" | tail -n 1 | sed "s/^.*username: superadmin password: \([a-z0-9]\+\).*$/\1/")
pass=$(cat $DIR/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
;;
*)
echo "Usage: $0 {start|stop|restart|status|passwords}"
exit 2
esac
exit 0
Thanks in advance,
Ray |
|
Back to top |
|
|
Zepp Veteran
Joined: 15 Mar 2004 Posts: 1246 Location: Ontario, Canada
|
Posted: Tue May 02, 2006 6:04 am Post subject: |
|
|
Doesn't teamspeak have a proper init script to start and stop the service? (would of swore it did ) |
|
Back to top |
|
|
vert Apprentice
Joined: 07 May 2002 Posts: 214 Location: Delft, The Netherlands
|
Posted: Tue May 02, 2006 11:15 am Post subject: |
|
|
I put this in my user crontab:
Code: |
@reboot /opt/homebrew/tss2_rc2/restart_script
|
and the restart script is:
Code: |
cd /opt/homebrew/tss2_rc2/
./teamspeak2-server_startscript stop
./teamspeak2-server_startscript start
|
This is under Fedora (VPS I'm running) with a standard install, but I don't see why it shouldn't work for Gentoo.
Hmm, just emerged it, seems Gentoo is sticking the start/stop script in init.d (where it belongs). So I imagine you can just do
Code: |
rc-update add teamspeak2-server default
|
that should take care of for each reboot. If you have problems with a stale pid file, just do a "/etc/init.d/teamspeak2-server zap" to clear it. Then you can do "/etc/init.d/teamspeak2-server start" to start it again.
Update: Ok, only just read your post (shouldn't hit the reply button that quickly). Anyway, init script seems to be working for me. _________________ Myth on Gentoo |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|