• Be part of the TeaParty!
    Click here for more information

TeaSpeak Autostart-Script

cuginosimo

New member
I was inspired by this guide and I tested it on AWS EC2 and it works!

(SOURCE: https://www.howtoforge.com/tutorial/how-to-install-and-use-Tea*Speak-server-on-centos-7/#configuring-systemd-service)



TeaSpeak server can be easily managed using the commands above, it is recommended to setup a systemd service unit so that you can start and manage the server using the service. This will also ensure that the service is automatically started at boot time.

Create a new systemd service file by running the following command.

nano /lib/systemd/system/teaspeak.service

Populate the file with the following content.

Code:
[Unit]
Description=TeaSpeak Server Service
After=network.target

[Service]
Type=forking
WorkingDirectory=/home/teaspeak/
ExecStart=/home/teaspeak/teastart.sh start
ExecStop=/home/teaspeak/teastart.sh stop
User=teaspeak
Group=teaspeak
PIDFile=/home/teaspeak/tpid.pid
Restart=always
RestartSec=9
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=teaspeak

[Install]
WantedBy=multi-user.target


Save the file and exit from the editor. Now you can start Tea*Speak using:

systemctl start teaspeak

To configure Tea*Speak to automatically start at boot time, use.

systemctl enable teaspeak

To check if Tea*Speak service is started correctly, you can run the following command to check the status of the Tea*Speak service.

systemctl status teaspeak
 

Sparky

Active member
it's good but by that why we miss the "live logs" wich can some times help us (I mean this part ./teastart_autorestart.sh attach)
but otherwith great job :D
 

BIOS

Well-known member
Code:
vi /etc/init.d/teaspeak
insert

Code:
#!/bin/sh
### BEGIN INIT INFO
# Provides:         teaspeak
# Required-Start:     $local_fs $network
# Required-Stop:    $local_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:     0 1 6
# Description:         Teaspeak Server
### END INIT INFO


# INIT Script by BIOS
######################################
# Customize values for your needs: "User"; "DIR"

USER="yourusername"
DIR="pfadtoteaspeakdir"

###### Teaspeak server start/stop script ######

case "$1" in
start)
su $USER -c "${DIR}/teastart_minimal.sh start"
;;
stop)
su $USER -c "${DIR}/teastart_minimal.sh stop"
;;
restart)
su $USER -c "${DIR}/teastart_minimal.sh restart"
;;
status)
su $USER -c "${DIR}/teastart_minimal.sh status"
;;
*)
echo "Usage: {start|stop|restart|status}" >&2
exit 1
;;
esac
exit 0
Make script executable:

Code:
chmod 755 /etc/init.d/teaspeak
The script is ready and needs to be defined as an autostart:

Code:
update-rc.d teaspeak defaults
The next reboot will start the Teaspeak server automatically.

Options of the script start / stop / restart / status:

Teaspeak Server start:

Code:
/etc/init.d/teaspeak start
Teaspeak Server stop:

Code:
/etc/init.d/teaspeak  stop
Teaspeak Server restart:

Code:
/etc/init.d/teaspeak  restart
Teaspeak Server status:

Code:
/etc/init.d/teaspeak  status