Jump to content

iLLNESS

Members
  • Posts

    4
  • Joined

Posts posted by iLLNESS

  1. UPDATE 2: I'm an idiot. I had the script in the library folder and not the base game folder. Works now :)

     

    Are hooks still working?

     

    I have tried a few examples in this thread, and resorted to the example from the wiki.

     

    Inside /usr/local/lib/7dtd/hooks/playerConnect after chmod +x:

    #!/bin/bash
    . /usr/local/lib/7dtd/common.sh
    
    telnetCommand $1 "sayplayer $4 \"Hello $3.\""
    

     

    It does not do anything on player connect. Running the script manually results in:

    failed to load external entity "/home/sdtd/instances/sayplayer/config.xml"
    failed to load external entity "/home/sdtd/instances/sayplayer/config.xml"
    failed to load external entity "/home/sdtd/instances/sayplayer/config.xml"
    Telnet not enabled.
    

     

    Telnet is enabled in the instance configuration, but is passworded.

     

    UPDATE: seems as though the hook is not pulling the instance name like it should. telnetCommand $1 just sets the instance name as the first word in the " ". I assume this should not be the case?

  2. Ok, here is a shutdown script which I tested on Ubuntu Server 14.04 LTS but should work for most other flavors of Linux since it uses Bash.

     

    EDIT: Yes, the same thing can be done with just a few lines of code but I like to standardize my scripts and make them re-usable as well as make it where as little needs to be changed in the script as practical.

     

    Create a file such as 7dtd-shutdown.sh and set permissions on it:

    mkdir -p /var/scripts
    touch /var/scripts/7dtd-shutdown.sh
    chown root:root /var/scripts/7dtd-shutdown.sh
    chmod 755 /var/scripts/7dtd-shutdown.sh
    

     

    Add the following text to the script:

    #!/bin/bash
    #############################################
    ## Name          : 7dtd-shutdown.sh
    ## Version       : 1.0
    ## Date          : 2016-01-18
    ## Author        : LHammonds
    ## Purpose       : Warn players and shutdown game.
    ## Compatibility : Verified on Ubuntu Server 14.04 LTS
    ## Requirements  : Must be run as root.
    ## Parameters    : #1 = 7dtd server instance name (required)
    ## Run Frequency : Can run as often as needed.
    ## Exit Codes    : None
    ################ CHANGE LOG #################
    ## DATE       WHO WHAT WAS CHANGED
    ## ---------- --- ----------------------------
    ## 2016-01-18 LTH Created script.
    #############################################
    
    ## Import standard variables and functions. ##
    . /usr/local/lib/7dtd/common.sh
    
    LogFile="/var/log/7dtd-shutdown.log"
    
    ## Requirement Check: Script must run as root user.
    if [ "$(id -u)" != "0" ]; then
     ## FATAL ERROR DETECTED: Document problem and terminate script.
     echo -e "\nERROR: Root user required to run this script.\n"
     echo -e "Type 'sudo su' to temporarily become root user.\n"
     exit
    fi
    
    ## Check parameter.
    if [ "${1}" == "" ]; then
     echo -e "[ERROR] Missing required parameter. Enter the server instance."
     echo -e "Syntax: ${ScriptName} [serverInstance]"
     echo -e "Example 1: ${ScriptName} alpha13"
     echo -e "Example 2: ${ScriptName} hamcraft"
     echo -e "Here is a list of valid instances:"
     7dtd.sh instances list
     exit 1
    else
     InstanceName="${1}"
    fi
    
    telnetCommand ${InstanceName} "say \"Server shutdown in 1 minute\""
    sleep 30
    telnetCommand ${InstanceName} "say \"Server shutdown in 30 seconds\""
    sleep 20
    telnetCommand ${InstanceName} "say \"Server shutdown in 10 seconds\""
    sleep 7
    telnetCommand ${InstanceName} "say \"Server shutdown in 3 seconds\""
    sleep 1
    telnetCommand ${InstanceName} "say \"Server shutdown in 2 seconds\""
    sleep 1
    telnetCommand ${InstanceName} "say \"Server shutdown in 1 second\""
    sleep 1
    telnetCommand ${InstanceName} "say \"Be right back!\""
    sleep 1
    telnetCommand ${InstanceName} "shutdown"
    echo "`date +%Y-%m-%d_%H:%M:%S` - [iNFO] Shutting down ${InstanceName} instance." | tee -a ${LogFile}
    
    

     

    You can then schedule it in the root account (accessible by doing "sudo su" from your admin account) and then type "crontab -e"

     

    Example crontab schedule:

    ########################################
    # Name: Crontab Schedule for root user
    # Author: LHammonds
    ############# Update Log ###############
    # 2016-01-18 - LTH - Created schedule
    ########################################
    SHELL=/bin/sh
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    
    # Crontab SYNTAX:
    # minute(0-59) hour(0-23) day-of-month(1-31) month(1-12) day-of-week(0-6) command-to-execute
    #
    # Adjust the time clock
    #
    0 1-23 * * * /usr/sbin/ntpdate ntp.ubuntu.com > /dev/null 2>&1
    #
    # Shutdown 7dtd instances for daily reboot:
    #
    0 3 * * * /var/scripts/7dtd-shutdown.sh HamCraft > /dev/null 2>&1
    0 3 * * * /var/scripts/7dtd-shutdown.sh WalkingDead > /dev/null 2>&1
    0 3 * * * /var/scripts/7dtd-shutdown.sh Vanilla > /dev/null 2>&1
    2 3 * * * /var/scripts/reboot.sh
    

     

    Summary of what it is doing:

     

    The schedule is configured to run the script 3 times simultaneously at 3:00am to shutdown 3 instances of servers called "HamCraft", "WalkingDead" and "Vanilla"

     

    The shutdown of the 7dtd instances should take just a little over 1 minute so a server-wide reboot script is scheduled to go off at 3:02am

     

    While connected to one of the servers during this period, players will get a notice that the server will be shutdown in 1 minute. Then get another notice 30 seconds later, etc. and eventually get disconnected automatically when the instance is shutdown.

     

    LHammonds

     

    Nice! Just what I'm looking for.

     

    is your reboot script for the computer? or is it to fire up your instances?

  3. Alloc, Great work man I'm really loving the scripts after a week or so of use. It's made running a server very streamlined!

     

    I had checked around for a way to auto reboot the server and most implementations are windows based client programs.

     

    I notice there is a ticket you previously created for this kind of feature https://7dtd.illy.bz/ticket/15

     

    I was wondering if this is still being planned on implementation? Ideally it would be nice if it:

    - Run script at specified time/interval (interval could be bash)

    - Check if users online

    - If users online, say countdown to server restart while monitoring if users connected.

     

    - If no users online or prior to that final time there are no users, initiate restart.

  4. Hey there! First time posting!

     

    Got a server setup on ubuntu and the server fixes/improvements, everything seems to be running fine except for the logs under the webserver. No log shows up when I click on it, and it continues to throw errors until I go back to the map.

     

    2016-01-01T19:30:13 22933.850 ERR Error in ApiHandler.HandleRequest(): Handler getlog threw an exception:
    2016-01-01T19:30:13 22933.850 EXC index and count exceed length of list
    ArgumentException: index and count exceed length of list
     at System.Collections.Generic.List`1[AllocsFixes.NetConnections.Servers.Web.LogBuffer+LogEntry].CheckRange (Int32 idx, Int32 count) [0x00000] in <filename unknown>:0
     at System.Collections.Generic.List`1[AllocsFixes.NetConnections.Servers.Web.LogBuffer+LogEntry].GetRange (Int32 index, Int32 count) [0x00000] in <filename unknown>:0
     at AllocsFixes.NetConnections.Servers.Web.LogBuffer.GetRange (System.Int32& _start, Int32 _count, System.Int32& _end) [0x00000] in <filename unknown>:0
     at AllocsFixes.NetConnections.Servers.Web.API.GetLog.HandleRequest (System.Net.HttpListenerRequest req, System.Net.HttpListenerResponse resp, AllocsFixes.NetConnections.S$
     at AllocsFixes.NetConnections.Servers.Web.Handlers.ApiHandler.HandleRequest (System.Net.HttpListenerRequest req, System.Net.HttpListenerResponse resp, AllocsFixes.NetConn$
    UnityEngine.Debug:Internal_LogException(Exception, Object)
    UnityEngine.Debug:LogException(Exception)
    Logger:masterLogException(Exception)
    Logger:Exception(Exception)
    Log:Exception(Exception)
    AllocsFixes.NetConnections.Servers.Web.Handlers.ApiHandler:HandleRequest(HttpListenerRequest, HttpListenerResponse, WebConnection, Int32)
    AllocsFixes.NetConnections.Servers.Web.Web:HandleRequest(IAsyncResult)
    System.Net.ListenerAsyncResult:InvokeCallback(Object)
    
    (Filename:  Line: -1)
    

     

    I've tried reinstalling the mods and checking file permissions for the output log but I don't see any obvious signs.

     

    What could be causing this issue?

×
×
  • Create New...