Forum

Results 1 to 8 of 8
  1. #1
    Join Date
    June 2011
    Location
    Russian Federation
    Posts
    204

    Restart script (when server crashed)

    guys, I'm sorry if the topic has already been raised to me, I just need a clear and distinct answer. The additions are many scripts that prevent auto-crash the server. I personally need the simple, high-quality, reliable, and of course hard-working. Just a lot of them do not know what to choose.

    On the advice of a good script auto-crash server some sort
    Sincerely, Arthur

  2. #2
    Join Date
    March 2010
    Location
    Germany
    Posts
    114
    Hey,
    I have running a script like this one:
    https://gist.github.com/2667773

  3. #3
    Join Date
    June 2011
    Location
    Russian Federation
    Posts
    204
    Thank you for having responded to me.
    At a very simple form that pleases, I would like to clarify, I'm changing it up just the way my server and score it in the crontab
    Do I understand you?

    example:

    Code:
    #!/bin/sh
    # Automatically restarts a TeamSpeak3 Server once it has crashed.
    # Required init.d integration of the Server
    
    # Author   : Maximilian Narr
    # Homepage : devmx.de
    # eMail    : [email protected]
    
    # Adapt it to your path where the TS3 Server is located.
    cd /home/tsserver/server
    
    if [ -e ts3server.pid ]
    then
            if ( !(kill -0 $(cat ts3server.pid) 2> /dev/null) )
            then
                    # Start command
                    sh /home/tsserver/ts3server_startscript.sh restart
            fi
    else
                    # Start command
                    sh /home/tsserver/ts3server_startscript.sh restart
    fi
    crontab

    Code:
    */1 * * * * cd /scripts/crash.sh
    
    or
    
    */1 * * * * cd ~/scripts && sh crash.sh
    And here's another question, whether the server is run teamspeak automatically after you reboot the server machine? or the script is only responsible for auto-crash server?

  4. #4
    Join Date
    March 2010
    Location
    Germany
    Posts
    114
    Thank you for having responded to me.
    At a very simple form that pleases, I would like to clarify, I'm changing it up just the way my server and score it in the crontab
    Do I understand you?
    Yep, you simply have to adapt the paths to the directory where your server is located.

    In the crontab

    Code:
    */1 * * * * sh /path/to/your/file/crash.sh
    should be enough.

    The script is ONLY for autorestarting the server, it does not automatically start it on boot. Therefore you have make an init.d integration and link it then to rc2.d resp. rc0.d.

    This is my script for that: https://gist.github.com/2686934

    1. Create the file teamspeak in /etc/init.d:
    Code:
    nano /etc/init.d/teamspeak
    Copy the code from the above link and edit it that it fits with your configuration

    2. Now you can control the TeamSpeak3 Server like that:
    Code:
    # Start the server
    /etc/init.d/teamspeak start
    
    # Stop the server
    /etc/init.d/teamspeak stop
    
    # Restart the server
    /etc/init.d/teamspeak restart
    
    # Get status of the server
    /etc/init.d/teamspeak status
    3. Link the file to rc0.d directory to automatically stop the server on shutdown and to rc2.d directory to start the server automatically on startup. Also you might add it to rc6.d to start the server on reboot.

    Code:
    cd /etc/rc0.d
    
    # Adapt the number to a lower value for higher priority
    sudo ln -s /etc/init.d/teamspeak K50teamspeak
    Code:
    cd /etc/rc2.d
    
    # Adapt the number to a lower value for higher priority
    sudo ln -s /etc/init.d/teamspeak S50teamspeak
    Code:
    cd /etc/rc6.d
    
    # Adapt the number to a lower value for higher priority
    sudo ln -s /etc/init.d/teamspeak S50teamspeak
    4. Now you got it, and the server should automatically restart on startup. In the first script you can now also use it this way:

    Code:
    #!/bin/sh
    # Automatically restarts a TeamSpeak3 Server once it has crashed.
    # Required init.d integration of the Server
    
    
    # Author   : Maximilian Narr
    # Homepage : devmx.de
    # eMail    : [email protected]
    
    
    # Adapt it to your path where the TS3 Server is located.
    cd /home/tsserver/server
    
    
    if [ -e ts3server.pid ]
    then
            if ( !(kill -0 $(cat ts3server.pid) 2> /dev/null) )
            then
                    # Start command
                    /etc/init.d/teamspeak restart
            fi
    else
                    # Start command
                    /etc/init.d/teamspeak restart
    fi
    I hope this helps
    Last edited by Maxe___; July 6th, 2012 at 09:30 PM.

  5. #5
    Join Date
    June 2011
    Location
    Russian Federation
    Posts
    204
    Thank you very much. everything works well!!

  6. #6
    Join Date
    March 2010
    Location
    Germany
    Posts
    114
    Quote Originally Posted by Ar2rJke View Post
    Thank you very much. everything works well!!
    You're welcome

  7. #7
    Join Date
    June 2011
    Location
    Russian Federation
    Posts
    204
    Topic can be closed. Oche useful for those who are not identified with the choice of a script.

  8. #8
    Join Date
    July 2007
    Location
    Germany
    Posts
    14
    teamspeak file
    PHP Code:
    #!/bin/bash
    ### BEGIN INIT INFO
    # Provides: teamspeak
    # Required-Start: $remote_fs $syslog
    # Required-Stop: $remote_fs $syslog
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Start TeamSpeak3 Server
    # Description: Start the TeamSpeak3 Server
    ### END INIT INFO

    ### Start adaptable information ###

    # User which will run the Teamspeak-Server
    USER=ts3

    # The installation directory of the Teamspeak-Server
    DIR=/home/ts3/

    ### End adaptable information ###

    if [ $== "start" ]; then
            
    # Be sure to specify additional starting parameters here
            
    su -"cd $DIR && $DIR/ts3server_startscript.sh start" $USER
    elif 
    [ $== "restart" ]; then
            su 
    -"cd $DIR && $DIR/ts3server_startscript.sh stop" $USER

            
    # Be sure to specify additional starting parameters here
            
    su -"cd $DIR && $DIR/ts3server_startscript.sh start" $USER
    else
            
    su -"cd $DIR && $DIR/ts3server_startscript.sh $1" $USER
    fi 

    I did all like from Step 1 to 3. The Commands like
    PHP Code:
    /etc/init.d/teamspeak start 
    works fine, but when i restart the Server, Teamspeak is not restarting...

    Can someone help me?

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Server crashed, now I can't restart Teamspeak3
    By ggalloway in forum Linux / FreeBSD
    Replies: 3
    Last Post: February 4th, 2012, 11:49 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
  •