Forum


Notice to all users

We are migrating towards a new forum system located at community.teamspeak.com, as such this forum will become read-only on January 29, 2020

Results 1 to 9 of 9
  1. #1
    Join Date
    December 2013
    Location
    Germany
    Posts
    13

    Message Program for Teamspeakserver

    Good Morning,

    I search a program for my Teamspeakserver that he send Textmessages automaticly on 5 minutes, 10 minutes, ... or induvidual.
    I used my servers on Linux, Debian.
    Thanks for help

    King Regrads,

    Pierre

  2. #2
    Join Date
    June 2011
    Location
    Germany
    Posts
    4,368
    This should be possible via some bash scripts and putty, but why would one want to do that? I would be really annoyed if I got chat messages all the time.

  3. #3
    Join Date
    December 2013
    Location
    Germany
    Posts
    13
    Because I host much Server for month or for 24 hours. And I want this for the 24 hour Server.
    Every hour the message come: "Your Server is shutting down in 23 Hours" and for this I need a bash script.
    Can you make a bash script for this ?
    Thanks for four reply.

  4. #4
    Join Date
    June 2011
    Location
    Germany
    Posts
    4,368
    Obviously, you have a system that shuts down servers after 24h, why doesn't that one do it? On the other hand, ever server displays its uptime and everyone who paid attention to Math in the first grade is easily able to find out the remaining time.

  5. #5
    Join Date
    February 2012
    Location
    Nuremberg, Bavaria
    Posts
    258
    Hello,
    Quote Originally Posted by ShadowFM View Post
    Every hour the message come: "Your Server is shutting down in 23 Hours" and for this I need a bash script.
    Therefore you have to re-calculate the uptime of the server into minutes/hours...

    The uptime of the virtual server is given in seconds:
    serverinfo
    [ ... ] virtualserver_uptime=851651 [ ... ]

  6. #6
    Join Date
    June 2011
    Location
    Germany
    Posts
    4,368
    If you click on the server in the TS client (which is what I was talking about), the uptime is given in days, hours, minutes and seconds.

  7. #7
    Join Date
    February 2012
    Location
    Nuremberg, Bavaria
    Posts
    258
    Quote Originally Posted by ShadowFM View Post
    Every hour the message come: "Your Server is shutting down in 23 Hours" and for this I need a bash script.
    Can you make a bash script for this ?
    I made a short script therefore (copy and paste the code in a new file called *.sh - e.g. "rest_time.sh"):
    Code:
    #!/bin/bash
    set -e
    #
    # About: Informs online clients about rest server uptime, until the server will be deleted or shut down.
    # Author: Sebastian Kraetzig <[email protected]>
    #
    # License: GNU GPLv3
    #
    # Other projects:
    # - TS3 WebApp http://addons.teamspeak.com/directory/tools/mobile-apps/Fast-TeamSpeak-3-WebApp-by-Sebi94.html
    # - TS3 UpdateScript http://addons.teamspeak.com/directory/tools/miscellaneous/Script-Automated-TeamSpeak-3-update-with-version-checker.html
    #
    # Forum: http://ts3webapp-forum.kraetzig.org/forum/
    #
    
    echo -e "\nAbout: Informs online clients about rest server uptime, until the server will be deleted or shut down.";
    echo -e "Author: Sebastian Kraetzig <[email protected]>";
    echo -e "License: GNU GPLv3\n";
    echo -e "Version: 1.0 (2013-12-02)\n";
    echo -e "---------------------------------\n";
    
    
    
    #################################
    #       S E T T I N G S         #
    #################################
    
    # Address of TeamSpeak 3 server
    # Example: INSTANCE_SERVER_ADDRESS="my.teamspeak.name"
    # Example: INSTANCE_SERVER_ADDRESS="127.0.0.1"
    INSTANCE_SERVER_ADDRESS=""
    
    # SID (Server ID) of virtual TeamSpeak 3 server
    # Example: VIRTUAL_SERVER_ID="1"
    VIRTUAL_SERVER_ID=""
    
    # Set ServerQuery port
    # Default '10011'
    # Example: SERVER_QUERY_PORT="10011"
    SERVER_QUERY_PORT="10011"
    
    # Set ServerQurry login name
    # Default (full permissions) 'serveradmin'
    # Example: SERVER_QUERY_ADMIN="serveradmin"
    SERVER_QUERY_ADMIN="serveradmin"
    
    # Set ServerQuery login password
    # Example: SERVER_QUERY_PASSWORD="verySecretRandom2013Password"
    SERVER_QUERY_PASSWORD=""
    
    # Set ServerQuery nickname, which will be displayed for messages
    # Example: SERVER_QUERY_NICKNAME="Admin"
    SERVER_QUERY_NICKNAME=""
    
    # After which time should the server shut down/deleted? (Time in seconds)
    # Example (24 hour): MAX_UPTIME_UNTIL_DELETE="86400"
    MAX_UPTIME_UNTIL_DELETE_SHUTDOWN=""
    
    # Delete or just shut down the server?
    # Possible values: shutdown, delete
    # Example: DELETE_OR_SHUTDOWN_SERVER="shutdown"
    DELETE_OR_SHUTDOWN_SERVER=""
    
    
    
    #########################################
    #       M A I N   P R O G R A M         #
    #########################################
    
    if [[ "$INSTANCE_SERVER_ADDRESS" == "" ]] || [[ "$SERVER_QUERY_PORT" == "" ]] || [[ "$SERVER_QUERY_ADMIN" == "" ]] || [[ "$SERVER_QUERY_PASSWORD" == "" ]] || [[ "$MAX_UPTIME_UNTIL_DELETE_SHUTDOWN" == "" ]] || [[ "$DELETE_OR_SHUTDOWN_SERVER" == "" ]] || [[ "$VIRTUAL_SERVER_ID" == "" ]]; then
            echo -e "\nYou have to set your settings first! One or more are empty. Please open this file and fill out the variables.\n";
            exit 1;
    fi
    
    (
            echo "open $INSTANCE_SERVER_ADDRESS $SERVER_QUERY_PORT"
            sleep 2s
            echo "login $SERVER_QUERY_ADMIN $SERVER_QUERY_PASSWORD"
            sleep 2s
            echo "use sid=$VIRTUAL_SERVER_ID"
            sleep 1s
            echo "serverinfo"
            sleep 2s
            echo "logout"
            echo "quit"
    ) | telnet > SERVER_INFO.tmp || true > /dev/null
    
    VIRTUAL_SERVER_UPTIME_IN_SECONDS=$(grep -Eo "virtualserver_uptime=([0-9]+)" SERVER_INFO.tmp | grep -Eo "[0-9]+")
    
    REST_UPTIME_IN_SECONDS=`expr $MAX_UPTIME_UNTIL_DELETE_SHUTDOWN - $VIRTUAL_SERVER_UPTIME_IN_SECONDS`
    
    # Calculate rest uptime for days, hours and minutes
    DAYS=""
    HOURS=""
    MINUTES=""
    
    (
            echo "open $INSTANCE_SERVER_ADDRESS $SERVER_QUERY_PORT"
            sleep 2s
            echo "login $SERVER_QUERY_ADMIN $SERVER_QUERY_PASSWORD"
            sleep 2s
            echo "use sid=$VIRTUAL_SERVER_ID"
            sleep 1s
            echo "clientupdate client_nickname=$SERVER_QUERY_NICKNAME"
            # Edit the the message you want to send - make sure, that whitespaces " " are written as "\s"
            echo "sendtextmessage targetmode=3 target=1 msg=Your\sServer\sis\sshutting\sdown\sin\s$DAYS\sdays,\s$HOURS\shours\sand\s$MINUTES\sminutes."
            sleep 2s
            echo "logout"
            echo "quit"
    ) | telnet > /dev/null 2> /dev/null || true
    
    if [[ "$REST_UPTIME_IN_SECONDS" -le "0" ]]; then
            if [[ "$DELETE_OR_SHUTDOWN_SERVER" == "shutdown" ]]; then
                    echo -e "Server will be shutdown right now...\n"
            elif [[ "$DELETE_OR_SHUTDOWN_SERVER" == "delete" ]]; then
                    echo -e "Server will be deleted right now...\n"
            fi
    
            (
                    echo "open $INSTANCE_SERVER_ADDRESS $SERVER_QUERY_PORT"
                    sleep 2s
                    echo "login $SERVER_QUERY_ADMIN $SERVER_QUERY_PASSWORD"
                    sleep 2s
                    if [[ "$DELETE_OR_SHUTDOWN_SERVER" == "shutdown" ]]; then
                            echo "serverstop sid=$VIRTUAL_SERVER_ID";
                    elif [[ "$DELETE_OR_SHUTDOWN_SERVER" == "delete" ]]; then
                            echo "serverdelete sid=$VIRTUAL_SERVER_ID";
                    fi
                    sleep 1s
                    echo "logout"
                    echo "quit"
            ) | telnet > /dev/null 2> /dev/null || true
    fi
    
    # Delete temporary file with uptime information
    rm SERVER_INFO.tmp
    
    exit 0;
    You have to fill out the "settings" variables between "SETTINGS" and "MAIN PROGRAM". It's static, well you have to set the virtual server id to identify the server. If you want to check more servers, you can save the script more times under different names. To automate the messaging, you can use your cronjobs:

    Code:
    $ cronjob -e
    0 * * * * /bin/bash /path/to/script.sh
    The script is currently not working correct, because my brain is sleeping at the moment.

    You have to find a solution, how you can get the rest of days, hours and minutes from the rest time of seconds. The script sends currently the message "Your Server is shutting down in $DAYS days, $HOURS hours and $MINUTES minutes.".

    The three time variables are empty that's the reason, why you will see the following message: "Your Server is shutting down in days, hours and minutes."

    PS: It's a very easy script, which I have developed in quarter of an hour. If you or somebody has some freetime left, you can make it more powerful and better.
    Last edited by Sebi94; December 2nd, 2013 at 09:16 PM. Reason: EDIT: removed "gm" and added "sendtextmessage" as well as nickname

  8. #8
    Join Date
    December 2013
    Location
    Germany
    Posts
    13
    Thanks Sebi94 for your help

  9. #9
    Join Date
    February 2012
    Location
    Nuremberg, Bavaria
    Posts
    258
    No problem. If you have the solution for the three empty variables, let me/us know it.

    Thanks in advance!

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: April 11th, 2010, 02:06 PM

Tags for this Thread

Posting Permissions

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