Forum

Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18
  1. #16
    Join Date
    October 2011
    Posts
    4

    TeamSpeak 3 Linux service install

    I felt like sharing my work.

    This script I used on CentOS 5.6 it should work on ubuntu, you might have to edit the service script it creates due to how ubuntu and CentOS differ in creating blank lines. (sudo vi /etc/init.d/teamspeak3)

    What this script does:
    Creates the system user "_ts3srvr".
    Creates system user folder ( i.e. /home/_ts3srvr ).
    wget's teamspeak3-server_linux-amd64-3.0.0.tar.gz (need to confirm server version, i.e. 3.0.0. also the variable 'Filelocation' needs to be set).
    - or you can let wget get an error but you need to put teamspeak3-server_linux-amd64-3.0.0.tar.gz in the folder "/home/_ts3srvr/".
    creates the service script to start teamspeak 3 at startup.
    - if the service script exist then it assumes your updating TeamSpeak and stops the service.
    Makes the script executable.
    Adds the new service script to startup.
    - it should work on CentOS or ubuntu.
    Adds the ports that TeamSpeak uses.
    Allows teamspeak to run as a daemon.
    Extracts teamspeak3-server_linux-amd64-3.0.0.tar.gz to /home/_ts3srvr/ (/home/_ts3srvr/teamspeak3-server_linux-amd64).
    Ensures the user "_ts3srvr" is owner of the folder /home/_ts3srvr/ and everything in it.
    Finally starts the new TeamSpeak3 service.

    Code:
    #!/bin/sh
    ts3serveruser=_ts3srvr
    useradd -m -r -s /bin/sh $ts3serveruser
    myOSlc=$(uname -s | tr '[A-Z]' '[a-z]')
    if [ "$(uname -m)" = 'x86_64' ]; then
    myArch='amd64'
    else
    myArch=$(uname -m)
    fi
    Filelocation='http or ftp path for TS3ServerFile.tar.gz'
    TS3InstallPath=/home/$ts3serveruser
    TS3ServerVersionMajor='3.0.0'
    TS3ServerFldr='teamspeak3-server_'"$myOSlc"'-'"$myArch"
    TS3ServerFile="$TS3ServerFldr"'-'"$TS3ServerVersionMajor"'.tar.gz'
    wget -O$TS3InstallPath/$TS3ServerFile "$Filelocation"/"$TS3ServerFile"
    if test ! -e "$TS3InstallPath/$TS3ServerFile"; then echo 'File not found: '"$TS3InstallPath/$TS3ServerFile"; exit 1; fi
    if test ! -x /etc/init.d/teamspeak3; then
    echo '#!/bin/sh' > /etc/init.d/teamspeak3;\
    echo '### BEGIN INIT INFO' >>/etc/init.d/teamspeak3;\
    echo '# Provides:          teamspeak3' >>/etc/init.d/teamspeak3;\
    echo '# Required-Start:    $local_fs $network' >>/etc/init.d/teamspeak3;\
    echo '# Required-Stop:     $local_fs $network' >>/etc/init.d/teamspeak3;\
    echo '# Should-Start:      mysql' >>/etc/init.d/teamspeak3;\
    echo '# Should-Stop:       mysql' >>/etc/init.d/teamspeak3;\
    echo '# Default-Start:     3 5' >>/etc/init.d/teamspeak3;\
    echo '# Default-Stop:      0 1 6' >>/etc/init.d/teamspeak3;\
    echo '# Short-Description: TeamSpeak3 Server Daemon' >>/etc/init.d/teamspeak3;\
    echo '# Description:       Starts/Stops/Restarts the TeamSpeak Server Daemon' >>/etc/init.d/teamspeak3;\
    echo '### END INIT INFO' >>/etc/init.d/teamspeak3;\
    echo '' >>/etc/init.d/teamspeak3;\
    echo 'set -e' >>/etc/init.d/teamspeak3;\
    echo '' >>/etc/init.d/teamspeak3;\
    echo 'PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin' >>/etc/init.d/teamspeak3;\
    echo 'DESC="TeamSpeak3 Server" >>/etc/init.d/teamspeak3;\
    echo 'NAME=teamspeak3' >>/etc/init.d/teamspeak3;\
    echo 'USER='"$ts3serveruser" >>/etc/init.d/teamspeak3;\
    echo 'DIR='"$TS3InstallPath/$TS3ServerFldr" >>/etc/init.d/teamspeak3;\
    echo 'DAEMON=$DIR/ts3server_startscript.sh' >>/etc/init.d/teamspeak3;\
    echo '#PIDFILE=/var/run/$NAME.pid' >>/etc/init.d/teamspeak3;\
    echo 'SCRIPTNAME=/etc/init.d/$NAME' >>/etc/init.d/teamspeak3;\
    echo '' >>/etc/init.d/teamspeak3;\
    echo '# Gracefully exit if the package has been removed.' >>/etc/init.d/teamspeak3;\
    echo 'test -x $DAEMON || exit 0' >>/etc/init.d/teamspeak3;\
    echo '' >>/etc/init.d/teamspeak3;\
    echo 'cd $DIR' >>/etc/init.d/teamspeak3;\
    echo 'sudo -u $USER ./ts3server_startscript.sh $1 $2' >>/etc/init.d/teamspeak3;\
    echo '' >>/etc/init.d/teamspeak3;\
    echo 'exit 0' >>/etc/init.d/teamspeak3;
    chmod 755 /etc/init.d/teamspeak3; sudo chown root:root /etc/init.d/teamspeak3;
    if sudo test -x /usr/sbin/update-rc.d; then
    sudo update-rc.d teamspeak3 defaults
    fi
    if sudo test -x /sbin/chkconfig; then
    sudo chkconfig --add teamspeak3;sudo chkconfig teamspeak3 on
    fi
    sudo iptables -I INPUT -p tcp --dport 10011 -j ACCEPT
    sudo iptables -I INPUT -p tcp --dport 30033 -j ACCEPT
    sudo iptables -I INPUT -p udp --dport 9989 -j ACCEPT
    sudo service iptables save
    echo 'Defaults!'"$TS3InstallPath/$TS3ServerFldr"'/ts3server_startscript.sh   !requiretty' >> /etc/sudoers
    visudo -c
    else
    sudo service teamspeak3 stop	
    fi
    cd $TS3InstallPath
    tar xzf $TS3ServerFile
    chown -R $ts3serveruser:$ts3serveruser $TS3InstallPath
    sudo service teamspeak3 start $1
    exit 0
    The "superadmin" password should display on screen along with a token. It should only display the one time so take notes!

  2. #17
    Join Date
    October 2011
    Posts
    1

    Tryed your script.

    I tryed your script , but it seem i cant connect to the server ?

    Ubuntu 10.04.1 LTS

    Welcome to Ubuntu!
    * Documentation: https://help.ubuntu.com/
    Last login: Mon Oct 3 21:55:24 2011 from 87.59.41.2
    [email protected]:~# #!/bin/sh
    [email protected]:~# ts3serveruser=_ts3srvr
    [email protected]:~# useradd -m -r -s /bin/sh $ts3serveruser
    [email protected]:~# #!/bin/sh
    [email protected]:~# ts3serveruser=_ts3srvr
    [email protected]:~# useradd -m -r -s /bin/sh $ts3serveruser
    myOSlc=$(uname -s | tr '[A-Z]' '[a-z]')
    useradd: user '_ts3srvr' already exists
    [email protected]:~# myOSlc=$(uname -s | tr '[A-Z]' '[a-z]')
    [email protected]:~# if [ "$(uname -m)" = 'x86_64' ]; then
    > myArch='amd64'
    > else
    > myArch=$(uname -m)
    > fi
    [email protected]:~# Filelocation='http or ftp path for TS3ServerFile.tar.gz'
    [email protected]:~# TS3InstallPath=/home/$ts3serveruser
    [email protected]:~# TS3ServerVersionMajor='3.0.0'
    [email protected]:~# TS3ServerFldr='teamspeak3-server_'"$myOSlc"'-'"$myArch"
    [email protected]:~# TS3ServerFile="$TS3ServerFldr"'-'"$TS3ServerVersionMajor"'.tar.g z'
    [email protected]:~# wget -O$TS3InstallPath/$TS3ServerFile "$Filelocation"/"$TS3Serve rFile"
    --2011-10-03 23:31:19-- http://http%20or%20ftp%20path%20for%20ts3serverfile.tar .gz/teamspeak3-server_linux-amd64-3.0.0.tar.gz
    Resolving http or ftp path for ts3serverfile.tar.gz... if test ! -e "$TS3Install Path/$TS3ServerFile"; then echo 'File not found: '"$TS3InstallPath/$TS3ServerFil e"; exit 1; fi
    if test ! -x /etc/init.d/teamspeak3; then
    echo '#!/bin/sh' > /etc/init.d/teamspeak3;\
    echo '### BEGIN INIT INFO' >>/etc/init.d/teamspeak3;\
    echo '# Provides: teamspeak3' >>/etc/init.d/teamspeak3;\
    echo '# Required-Start: $local_fs $network' >>/etc/init.d/teamspeak3;\
    echo '# Required-Stop: $local_fs $network' >>/etc/init.d/teamspeak3;\
    echo '# Should-Start: mysql' >>/etc/init.d/teamspeak3;\
    echo '# Should-Stop: mysql' >>/etc/init.d/teamspeak3;\
    echo '# Default-Start: 3 5' >>/etc/init.d/teamspeak3;\
    echo '# Default-Stop: 0 1 6' >>/etc/init.d/teamspeak3;\
    echo '# Short-Description: TeamSpeak3 Server Daemon' >>/etc/init.d/teamspeak3;\
    echo '# Description: Starts/Stops/Restarts the TeamSpeak Server Daemon' >> /etc/init.d/teamspeak3;\
    echo '### END INIT INFO' >>/etc/init.d/teamspeak3;\
    echo '' >>/etc/init.d/teamspeak3;\
    echo 'set -e' >>/etc/init.d/teamspeak3;\
    echo '' >>/etc/init.d/teamspeak3;\
    echo 'PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin' >>/etc/ init.d/teamspeak3;\
    echo 'DESC="TeamSpeak3 Server" >>/etc/init.d/teamspeak3;\
    echo 'NAME=teamspeak3' >>/etc/init.d/teamspeak3;\
    echo 'USER='"$ts3serveruser" >>/etc/init.d/teamspeak3;\
    echo 'DIR='"$TS3InstallPath/$TS3ServerFldr" >>/etc/init.d/teamspeak3;\
    echo 'DAEMON=$DIR/ts3server_startscript.sh' >>/etc/init.d/teamspeak3;\
    echo '#PIDFILE=/var/run/$NAME.pid' >>/etc/init.d/teamspeak3;\
    echo 'SCRIPTNAME=/etc/init.d/$NAME' >>/etc/init.d/teamspeak3;\
    echo '' >>/etc/init.d/teamspeak3;\
    echo '# Gracefully exit if the package has been removed.' >>/etc/init.d/teamspea k3;\
    echo 'test -x $DAEMON || exit 0' >>/etc/init.d/teamspeak3;\
    echo '' >>/etc/init.d/teamspeak3;\
    echo 'cd $DIR' >>/etc/init.d/teamspeak3;\
    echo 'sudo -u $USER ./ts3server_startscript.sh $1 $2' >>/etc/init.d/teamspeak3;\
    echo '' >>/etc/init.d/teamspeak3;\
    echo 'exit 0' >>/etc/init.d/teamspeak3;
    chmod 755 /etc/init.d/teamspeak3; sudo chown root:root /etc/init.d/teamspeak3;
    failed: Name or service not known.
    wget: unable to resolve host address `http or ftp path for ts3serverfile.tar.gz'
    [email protected]:~# if test ! -e "$TS3InstallPath/$TS3ServerFile"; then echo 'File n ot found: '"$TS3InstallPath/$TS3ServerFile"; exit 1; fi
    [email protected]:~# if test ! -x /etc/init.d/teamspeak3; then
    > echo '#!/bin/sh' > /etc/init.d/teamspeak3;\
    > echo '### BEGIN INIT INFO' >>/etc/init.d/teamspeak3;\
    > echo '# Provides: teamspeak3' >>/etc/init.d/teamspeak3;\
    > echo '# Required-Start: $local_fs $network' >>/etc/init.d/teamspeak3;\
    > echo '# Required-Stop: $local_fs $network' >>/etc/init.d/teamspeak3;\
    > echo '# Should-Start: mysql' >>/etc/init.d/teamspeak3;\
    > echo '# Should-Stop: mysql' >>/etc/init.d/teamspeak3;\
    > echo '# Default-Start: 3 5' >>/etc/init.d/teamspeak3;\
    > echo '# Default-Stop: 0 1 6' >>/etc/init.d/teamspeak3;\
    > echo '# Short-Description: TeamSpeak3 Server Daemon' >>/etc/init.d/teamspeak3; \
    > echo '# Description: Starts/Stops/Restarts the TeamSpeak Server Daemon' >>/etc/init.d/teamspeak3;\
    > echo '### END INIT INFO' >>/etc/init.d/teamspeak3;\
    > echo '' >>/etc/init.d/teamspeak3;\
    > echo 'set -e' >>/etc/init.d/teamspeak3;\
    > echo '' >>/etc/init.d/teamspeak3;\
    > echo 'PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin' >>/et c/init.d/teamspeak3;\
    > echo 'DESC="TeamSpeak3 Server" >>/etc/init.d/teamspeak3;\
    > echo 'NAME=teamspeak3' >>/etc/init.d/teamspeak3;\
    > echo 'USER='"$ts3serveruser" >>/etc/init.d/teamspeak3;\
    > echo 'DIR='"$TS3InstallPath/$TS3ServerFldr" >>/etc/init.d/teamspeak3;\
    > echo 'DAEMON=$DIR/ts3server_startscript.sh' >>/etc/init.d/teamspeak3;\
    > echo '#PIDFILE=/var/run/$NAME.pid' >>/etc/init.d/teamspeak3;\
    > echo 'SCRIPTNAME=/etc/init.d/$NAME' >>/etc/init.d/teamspeak3;\
    > echo '' >>/etc/init.d/teamspeak3;\
    > echo '# Gracefully exit if the package has been removed.' >>/etc/init.d/teamsp eak3;\
    > echo 'test -x $DAEMON || exit 0' >>/etc/init.d/teamspeak3;\
    > echo '' >>/etc/init.d/teamspeak3;\
    > echo 'cd $DIR' >>/etc/init.d/teamspeak3;\
    > echo 'sudo -u $USER ./ts3server_startscript.sh $1 $2' >>/etc/init.d/teamspeak3 ;\
    > echo '' >>/etc/init.d/teamspeak3;\
    > echo 'exit 0' >>/etc/init.d/teamspeak3;
    > chmod 755 /etc/init.d/teamspeak3; sudo chown root:root /etc/init.d/teamspeak3;
    > if sudo test -x /usr/sbin/update-rc.d; then
    > sudo update-rc.d teamspeak3 defaults
    > fi
    > if sudo test -x /sbin/chkconfig; then
    > sudo chkconfig --add teamspeak3;sudo chkconfig teamspeak3 on
    > fi
    > sudo iptables -I INPUT -p tcp --dport 10011 -j ACCEPT
    > sudo iptables -I INPUT -p tcp --dport 30033 -j ACCEPT
    > sudo iptables -I INPUT -p udp --dport 9989 -j ACCEPT
    > sudo service iptables save
    > echo 'Defaults!'"$TS3InstallPath/$TS3ServerFldr"'/ts3server_startscript.sh ! requiretty' >> /etc/sudoers
    > visudo -c
    > else
    > sudo service teamspeak3 stop
    > fi
    > cd $TS3InstallPath
    > tar xzf $TS3ServerFile
    > chown -R $ts3serveruser:$ts3serveruser $TS3InstallPath
    > sudo service teamspeak3 start $1
    > exit 0
    > ls
    > ^C
    Next step ? iam kinda lost here..

  3. #18
    Join Date
    October 2011
    Posts
    4

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Linux autostart script
    By Ar2rJke in forum Linux / FreeBSD
    Replies: 1
    Last Post: October 12th, 2011, 11:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •