Teamspeak start stop script
After my server was restarted twice by my hosting center I decided to make sure Teamspeak would start automatically. I read a few posts on how other people did it but in the end I decided that I created my own minimal script.
My two goals with this init script was:
- Run the Teamspeak server as an unprivileged user.
- Make sure the Teamspeak server starts up after reboot even though it wasn’t shut down properly
- A little bonus was that it reuses much of the init script that is bundled with the installation
Init script (/etc/init.d/teamspeak):
#!/bin/sh
TEAMSPEAK_DIR=/usr/local/teamspeak
TEAMSPEAK_USER=teamspeak
# Make sure that Teamspeak starts even though it wasn't closed nicely last time (ie. by a power cut)
if [ $(su - $TEAMSPEAK_USER -c "ps ux" |grep tsserver2.pid|grep -v grep|wc -l) -eq 0 ] && [ -f ${TEAMSPEAK_DIR}/tsserver2.pid ]
then
rm ${TEAMSPEAK_DIR}/tsserver2.pid
fi
cd ${TEAMSPEAK_DIR}
su - $TEAMSPEAK_USER -c "./teamspeak2-server_startscript $1"
cd -
Teamspeak start stop script
© 2008 by Jacob Emcken is licensed under CC BY-SA 4.0