muldereric
10-01-2004, 16:01
I translated the debian script I found in the German section (http://www.teamspeak.org/forums/showthread.php?s=&threadid=5912&highlight=debain)n so it would be easier for you guys to read. But I have some troubles, because the script isn't working correctly.
If do everything that is explained in the header, everything works fine and the server starts while booting.
But when I log in and type "rctss stop", the server stops (as expected). But when I try to run it again, the server starts twice!!!
When I try to kill it after it started twice, the script tells me there is currently no server running!
Could somebody help me fixing the bugs???
Here it is:
#! /bin/sh
#
# Shellscript, starts a TeamSpeakServer under a different user than root
#
#
# FearFactor (f@fearfactor.de)
# DE -> EN Translation by The Specialist (muldereric********.com)
# ============================================
#
# Requirements:
#
# - An installed version of TeamSpeak Server
# - The user under which the server is running, must exist and
# have full access to the directory of the TS-server
# (view current Status with "ls -l")
# If you don't have full access, read the manpage for 'chown'
#
# Example: "chown user:group /path/to/server"
# Read/Write/Execute rights can be changed using 'chmod'
# Example: "chmod 770 /path/to/server"
# - Those were the variables that needed to be changed
#
# To start the script while booting, place it as 'rctss' in the
# directory /etc/init.d and change the read/write rights
# Example "chmod 755 rctss"
# With this rights it is possible to run the server under any user # you wish to run it from.
# To start start the server without typing the full path to the # binary, make a hard link to /usr/bin.
#
# Example "ln path-to-script /usr/bin"
# Example "ln /etc/init.d/rctss /usr/bin"
#
# To be able to start the TS-server while entering a certain # runlevel, another symbolic link must be made.
# (To see which runlevel is the standard runlevel, # check /etc/inittab)
#
# Example Debian "ln -s /etc/init.d/rctss /etc/rc2.d/S99tss"
# Example SuSE "ln -s /etc/init.d/rctss /etc/rc.d/rc2.d/S99tss"
#
#
# To start/stop the server manually, type:
# "rctss start"
# "rctss stop"
#
# "rctss status" shows all running TSS-Processes and
# administrator passwords!!! (read from server.log)
# < !!! PLEASE MODIFY THESE VARIABLES !!! >
#
# User to run the the server as
DAEMON_USER="tss"
# Description, Path & Executable from the server
DESC="TeamSpeakServer"
DIR=/home/tss/tss2_rc2
BIN=server_linux
#
# </ !!! PLEASE MODIFY THESE VARIABLES !!! >
NAME="tss"
DAEMON=$DIR/$BIN
PATH=$DIR:/bin:/usr/bin:/sbin:/usr/sbin
PARAMS="-pid=$DIR/$NAME.pid -db=$DIR/server.dbs -ini=$DIR/server.ini -log=$DIR/server.log -httpdocs=$DIR/httpdocs"
# If the server is not found within the given directory,
# then, of course, nothing happens!
test -x $DAEMON || echo TSS-Daemon not found in $DIR
test -x $DAEMON || echo ===> Check the variables DIR and BIN!
test -x $DAEMON || exit 0
case "$1" in
start)
echo "Starting $DESC"
cd $DIR
# starts the server under the name of the given user
ps -lC $BIN | grep -e $BIN > /dev/null && echo "===> $DESC Server is ready to start!"
ps -lC $BIN | grep -e $BIN > /dev/null || su $DAEMON_USER -c "$DAEMON $PARAMS > /dev/null"
sleep 3
;;
stop)
echo "Stopping $DESC"
test -f $DIR/$NAME.pid && kill -TERM `cat $DIR/$NAME.pid`
test -f $DIR/$NAME.pid || echo "===> $DESC is currently not running!"
sleep 2
;;
restart)
$0 stop
sleep 4
$0 start
;;
status)
echo "Running processes from $DESC:"
ps -lC $BIN | grep -e $BIN || echo "===> $DESC is currently not running!"
echo
echo "ADMIN Password (Source: server.log):"
echo --
cat $DIR/server.log|grep -e "admin account"|tr " " "\n"|grep -A 3 -e "username:"
echo --
echo
;;
*)
echo "Parameter: $0 {start|stop|status|restart}"
exit 1
;;
esac
If do everything that is explained in the header, everything works fine and the server starts while booting.
But when I log in and type "rctss stop", the server stops (as expected). But when I try to run it again, the server starts twice!!!
When I try to kill it after it started twice, the script tells me there is currently no server running!
Could somebody help me fixing the bugs???
Here it is:
#! /bin/sh
#
# Shellscript, starts a TeamSpeakServer under a different user than root
#
#
# FearFactor (f@fearfactor.de)
# DE -> EN Translation by The Specialist (muldereric********.com)
# ============================================
#
# Requirements:
#
# - An installed version of TeamSpeak Server
# - The user under which the server is running, must exist and
# have full access to the directory of the TS-server
# (view current Status with "ls -l")
# If you don't have full access, read the manpage for 'chown'
#
# Example: "chown user:group /path/to/server"
# Read/Write/Execute rights can be changed using 'chmod'
# Example: "chmod 770 /path/to/server"
# - Those were the variables that needed to be changed
#
# To start the script while booting, place it as 'rctss' in the
# directory /etc/init.d and change the read/write rights
# Example "chmod 755 rctss"
# With this rights it is possible to run the server under any user # you wish to run it from.
# To start start the server without typing the full path to the # binary, make a hard link to /usr/bin.
#
# Example "ln path-to-script /usr/bin"
# Example "ln /etc/init.d/rctss /usr/bin"
#
# To be able to start the TS-server while entering a certain # runlevel, another symbolic link must be made.
# (To see which runlevel is the standard runlevel, # check /etc/inittab)
#
# Example Debian "ln -s /etc/init.d/rctss /etc/rc2.d/S99tss"
# Example SuSE "ln -s /etc/init.d/rctss /etc/rc.d/rc2.d/S99tss"
#
#
# To start/stop the server manually, type:
# "rctss start"
# "rctss stop"
#
# "rctss status" shows all running TSS-Processes and
# administrator passwords!!! (read from server.log)
# < !!! PLEASE MODIFY THESE VARIABLES !!! >
#
# User to run the the server as
DAEMON_USER="tss"
# Description, Path & Executable from the server
DESC="TeamSpeakServer"
DIR=/home/tss/tss2_rc2
BIN=server_linux
#
# </ !!! PLEASE MODIFY THESE VARIABLES !!! >
NAME="tss"
DAEMON=$DIR/$BIN
PATH=$DIR:/bin:/usr/bin:/sbin:/usr/sbin
PARAMS="-pid=$DIR/$NAME.pid -db=$DIR/server.dbs -ini=$DIR/server.ini -log=$DIR/server.log -httpdocs=$DIR/httpdocs"
# If the server is not found within the given directory,
# then, of course, nothing happens!
test -x $DAEMON || echo TSS-Daemon not found in $DIR
test -x $DAEMON || echo ===> Check the variables DIR and BIN!
test -x $DAEMON || exit 0
case "$1" in
start)
echo "Starting $DESC"
cd $DIR
# starts the server under the name of the given user
ps -lC $BIN | grep -e $BIN > /dev/null && echo "===> $DESC Server is ready to start!"
ps -lC $BIN | grep -e $BIN > /dev/null || su $DAEMON_USER -c "$DAEMON $PARAMS > /dev/null"
sleep 3
;;
stop)
echo "Stopping $DESC"
test -f $DIR/$NAME.pid && kill -TERM `cat $DIR/$NAME.pid`
test -f $DIR/$NAME.pid || echo "===> $DESC is currently not running!"
sleep 2
;;
restart)
$0 stop
sleep 4
$0 start
;;
status)
echo "Running processes from $DESC:"
ps -lC $BIN | grep -e $BIN || echo "===> $DESC is currently not running!"
echo
echo "ADMIN Password (Source: server.log):"
echo --
cat $DIR/server.log|grep -e "admin account"|tr " " "\n"|grep -A 3 -e "username:"
echo --
echo
;;
*)
echo "Parameter: $0 {start|stop|status|restart}"
exit 1
;;
esac