Forum

Results 1 to 1 of 1
  1. #1
    Join Date
    December 2009
    Location
    Germany
    Posts
    1

    [Outdated] Start/stop TS3 Server in Debian Linux start-stop-daemon (not screen)

    Edit by mod
    Please don't use this outdated script anymore! The script got an overhaul long time ago.
    Please use the minimal or startscript instead


    Hi,

    I didn't like to start the TS3 Server by running screen, so I took the TS2 startup script and modified it to TS3. I'm posting my setup here with the hope to help some people.

    I installed the files, which are in the distribution package, to /usr/local/lib/teamspeak3, that are:

    Code:
    doc/*
    serverquerydocs/*
    sql/*
    CHANGELOG
    LICENSE
    libts3db_mysql.so
    libts3db_sqlite3.so
    ts3server_linux_x86
    Note: The doc/*, serverquerydocs/*, CHANGELOG and LICENSE could be in documentation directory, but it's not important.

    Next I created the file /etc/default/teamspeak3:
    Code:
    #whether to start teamspeak 3 server on startup
    ENABLED=1
    
    # the configuration file (inifile)
    CONF=/etc/teamspeak3/ts3server.ini
    
    # data directory
    # make sure to have a symbolic link to /usr/local/lib/teamspeak3/libts3db_<engine>.so in the data directory
    # this directory is, where the ts3server.sqlitedb goes, when using sqlite engine, also the files/ directory
    DATADIR=/DATA/teamspeak3
    Note: create a link to the engine object file in the data directory. In my example it would be:
    Code:
    cd /DATA/teamspeak3
    ln -s /usr/local/lib/teamspeak3/libts3db_sqlite3.so
    Next is /etc/teamspeak3/ts3server.ini:
    Code:
    machine_id=
    default_voice_port=9987
    voice_ip=0.0.0.0
    licensepath=
    filetransfer_port=30033
    filetransfer_ip=0.0.0.0
    query_port=10011
    query_ip=0.0.0.0
    dbplugin=ts3db_sqlite3
    dbpluginparameter=
    dbsqlpath=/usr/local/lib/teamspeak3/sql/
    dbsqlcreatepath=create_sqlite/
    logpath=/var/log/teamspeak3
    logquerycommands=0
    Notes:
    - Don't forget to create /var/log/teamspeak3 (or whatever you use).
    - I have no license (yet), so I couldn't test it. But the change should be minimal.

    Now the most important: /etc/init.d/teamspeak3
    Code:
    #!/bin/sh
    ### BEGIN INIT INFO
    # Provides:          teamspeak3
    # Required-Start:    $local_fs $network
    # Required-Stop:     $local_fs $network
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: TeamSpeak 3 Server
    # Description:       VoIP chat
    ### END INIT INFO
    
    PATH=/usr/sbin:/usr/bin:/sbin:/bin
    DESC="Teamspeak 3 Server (VoIP chat)"
    NAME=teamspeak3
    DAEMON=/usr/local/lib/teamspeak3/ts3server_linux_x86
    PIDFILE=/var/run/$NAME.pid
    SCRIPTNAME=/etc/init.d/$NAME
    
    # Read configuration variable file if it is present
    [ -r /etc/default/$NAME ] && . /etc/default/$NAME
    
    DAEMON_ARGS="inifile=$CONF"
    
    # Exit if the package is not installed
    [ -x "$DAEMON" ] || exit 0
    
    # Exit if not ENABLE=1
    [ $ENABLED -eq 1 ] || exit 0
    
    # Load the VERBOSE setting and other rcS variables
    [ -f /etc/default/rcS ] && . /etc/default/rcS
    
    # Define LSB log_* functions.
    # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
    . /lib/lsb/init-functions
    
    # Function that starts the daemon/service
    do_start()
    {
            # Return
            #   0 if daemon has been started
            #   1 if daemon was already running
            #   2 if daemon could not be started
    
            start-stop-daemon --start \
                              --quiet \
                              --pidfile $PIDFILE \
                              --chdir $DATADIR \
                              --background --make-pidfile \
                              --exec $DAEMON \
                              --test -- \
                              $DAEMON_ARGS >/dev/null 2>&1 \
                    || return 1
    
            start-stop-daemon --start \
                              --quiet \
                              --pidfile $PIDFILE \
                              --chdir $DATADIR \
                              --background --make-pidfile \
                              --exec $DAEMON -- \
                              $DAEMON_ARGS >/dev/null 2>&1 \
                    || return 2
    }
    
    # Function that stops the daemon/service
    do_stop()
    {
            # Return
            #   0 if daemon has been stopped
            #   1 if daemon was already stopped
            #   2 if daemon could not be stopped
            #   other if a failure occurred
    
            start-stop-daemon --stop \
                              --quiet \
                              --retry=TERM/30/KILL/5 \
                              --pidfile $PIDFILE
    
            RETVAL=$?
            # Delete pidfile when exit.
            rm -f $PIDFILE
            return "$RETVAL"
    }
    
    case "$1" in
      start)
            [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
            do_start
            case "$?" in
                    0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                    2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
            esac
            ;;
      stop)
            [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
            do_stop
            case "$?" in
                    0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                    2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
            esac
            ;;
      status)
            [ -e $PIDFILE ] && echo "$NAME seems to be running with pid: `cat $PIDFILE`." \
                            || echo "$NAME is not running."
            ;;
      restart|force-reload)
            log_daemon_msg "Restarting $DESC" "$NAME"
            do_stop
            case "$?" in
              0|1)
                    do_start
                    case "$?" in
                            0) log_end_msg 0 ;;
                            1) log_end_msg 1 ;; # Old process is still running
                            *) log_end_msg 1 ;; # Failed to start
                    esac
                    ;;
              *)
                    # Failed to stop
                    log_end_msg 1
                    ;;
            esac
            ;;
      *)
            echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
            exit 3
            ;;
    esac
    Note: I have to run the server as root, because otherwise the "instance check error" appears.

    WARNING: If you start the TS3 Server for the first time, you should NOT use the /etc/init.d/teamspeak3 script, because then you will never see the admin's serverquery account password!

    Test your setup by manually running /etc/init.d/teamspeak3 start|stop|restart. If everything worked fine, you can use "update-rc.d teamspeak3 defaults" (or something like that) to create the startup and kill links in /etc/rc*.d/ (or do it manually).

    nix
    Last edited by florian_fr40; November 9th, 2011 at 04:45 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: November 25th, 2013, 06:27 PM
  2. [DEBIAN] Trying to start teamspeak3 server with screen
    By Ghostaunt in forum Linux / FreeBSD
    Replies: 22
    Last Post: November 10th, 2013, 12:55 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
  •