Page 51 of 71 FirstFirst ... 41495051525361 ... LastLast
Results 751 to 765 of 1065

Thread: Native Linux server (with management scripts)

  1. #751
    Refugee
    Join Date
    Jul 2015
    Posts
    12
    Rep Power
    0
    LHammonds Not sure if it will work, but try double quoting the message.


    Code:
    "say \"Hello, World!\""
    Last edited by mudfly; 01-15-2016 at 03:48 AM. Reason: code quotes

  2. #752
    Fun Pimps Staff Alloc's Avatar
    Join Date
    Oct 2013
    Location
    Germany - Darmstadt
    Posts
    3,126
    Rep Power
    1
    Yeah, sorry, forgot to update those
    Double quoting as mudfly showed is right. Quoting the command with single quotes as LHammonds did should work too but AFAIR shell variables don't get expanded in those (might be wrong on this one though ).

  3. #753
    Hunter LHammonds's Avatar
    Join Date
    Sep 2014
    Location
    Behind you!
    Posts
    138
    Rep Power
    0
    When I around to configuring my server for automated messages via crontab, I'll post what I have done here so others can see (as well as my own forums). I plan to make a how-to article some day on how to setup a 7dtd server and Alloc is integral to that process. Again, can't thank you enough for what you've done.

  4. #754
    Hunter LHammonds's Avatar
    Join Date
    Sep 2014
    Location
    Behind you!
    Posts
    138
    Rep Power
    0

    Lightbulb

    Ok, here is a shutdown script which I tested on Ubuntu Server 14.04 and 16.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 sdtd-shutdown.sh and set permissions on it:
    Code:
    mkdir -p /var/scripts/prod
    touch /var/scripts/prod/sdtd-shutdown.sh
    chown root:root /var/scripts/prod/sdtd-shutdown.sh
    chmod 755 /var/scripts/prod/sdtd-shutdown.sh
    Add the following text to the script:
    Code:
    #!/bin/bash
    #############################################
    ## Name          : sdtd-shutdown.sh
    ## Version       : 1.0
    ## Date          : 2016-01-18
    ## Author        : LHammonds
    ## Purpose       : Warn players and shutdown game.
    ## Compatibility : Verified on Ubuntu Server 14.04 thru 16.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/sdtd-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:
    Code:
    ########################################
    # 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
    #
    # 7dtd: Shutdown 7dtd instances for daily reboot:
    #
    0 3 * * * /var/scripts/prod/sdtd-shutdown.sh HamCraft > /dev/null 2>&1
    0 3 * * * /var/scripts/prod/sdtd-shutdown.sh WalkingDead > /dev/null 2>&1
    0 3 * * * /var/scripts/prod/sdtd-shutdown.sh Vanilla > /dev/null 2>&1
    2 3 * * * /var/scripts/prod/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
    Last edited by LHammonds; 05-09-2017 at 01:46 PM.

  5. #755
    Refugee
    Join Date
    Jul 2015
    Posts
    12
    Rep Power
    0
    Alloc,

    I have this crazy idea to try to get 7 days to die linux dedicated server running in docker, I am not sure how much code will have to be written from scratch, or if I will leverage some of your source code to achieve this. I am just starting to explore this idea. I am curious what license you distribute your code under. I checked the repositories you are hosting in Trac and I do not see any license or copyright information. The source I write will be distributed on github, with the docker image hosted at dockerhub.com and released under a permissive license such as MIT, BSD, or Apache. Since I don't have permission to license your work, if I were to use any of it, I am just asking for clarification.

    I am also open to the idea of collaborating on this with you, if this is something you may be interested in.

  6. #756
    Refugee
    Join Date
    Jan 2016
    Posts
    4
    Rep Power
    0
    Quote Originally Posted by LHammonds View Post
    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:
    Code:
    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:
    Code:
    #!/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:
    Code:
    ########################################
    # 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?

  7. #757
    Hunter LHammonds's Avatar
    Join Date
    Sep 2014
    Location
    Behind you!
    Posts
    138
    Rep Power
    0
    Quote Originally Posted by iLLNESS View Post
    Nice! Just what I'm looking for.

    is your reboot script for the computer? or is it to fire up your instances?
    This particular script just handles shutting down the 7dtd instances that are running.

    If you look at the example crontab schedule, you can see the 7dtd-shutdown script is being called 3 times which is shutting down 3 instances that are running. Once the instances are down, you call a server reboot script like the crontab shows (reboot.sh).

    If you only maintain a single instance, you could incorporate the server reboot into the 7dtd-shutdown script. Once you know the instance is down, simply reboot the server at the end of the script.

    There's a bunch of ways you can handle it. My script was focusing primarily on the shutdown of the 7dtd instance only.

    If you want more information on the setup of Ubuntu Server or automation scripts, you can find what I have done on my forum.

    LHammonds

  8. #758
    Fun Pimps Staff Alloc's Avatar
    Join Date
    Oct 2013
    Location
    Germany - Darmstadt
    Posts
    3,126
    Rep Power
    1
    Quote Originally Posted by LHammonds View Post
    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.
    ...
    LHammonds
    Nice job
    Thanks for sharing, I'm quite sure a lot of people will find this post helpful.



    Quote Originally Posted by mudfly View Post
    I have this crazy idea to try to get 7 days to die linux dedicated server running in docker, I am not sure how much code will have to be written from scratch, or if I will leverage some of your source code to achieve this. I am just starting to explore this idea. I am curious what license you distribute your code under. I checked the repositories you are hosting in Trac and I do not see any license or copyright information. The source I write will be distributed on github, with the docker image hosted at dockerhub.com and released under a permissive license such as MIT, BSD, or Apache. Since I don't have permission to license your work, if I were to use any of it, I am just asking for clarification.

    I am also open to the idea of collaborating on this with you, if this is something you may be interested in.
    Code reuse: No idea, never worked with Docker so far so I don't know how much will be applicable there.

    Regarding the license: I haven't set any as I never know what I should choose Feel free to use anything of what I wrote however you want, it's meant to be there for others to enhance it if they want. If you have any explicit suggestion on what license I should put on the stuff (so there's no worries about it not stating any license) feel free to PM me.


    Regards,
    Chris

  9. #759
    Refugee
    Join Date
    Jul 2015
    Posts
    12
    Rep Power
    0
    Alloc,

    That is pretty awesome of you to share your code, deciding on a license is hard. The main reason I would feel better with you applying a license, or even just author information is to give you credit for your work.

    Based on your attitude I picked a license for you! Of course it is meant to be tounge-in-cheek, but perhaps maybe it is appropriate

    http://www.wtfpl.net/

    I am still learning docker, and getting something like 7dtd running inside docker is going to be a big challenge. I will keep you posted on my progress.

    Cheers!
    Mudfly

  10. #760
    Survivor
    Join Date
    May 2014
    Location
    Atlanta, GA - USA
    Posts
    77
    Rep Power
    0
    Are other Linux dedicated servers still having issues with RAM usage? The Linux server is way improved compared to the initial release of A13, but the 32-bit version still attempts to over-allocate RAM beyond its 4GB limit. When the over-allocation happens the server crashes of course.

    I have worked around this to an extent with a script that monitors the "virtmem" process variable. When the server virtmem exceeds a threshold the script gives the users a 2 minute countdown in chat and then does a controlled stop and start.

    You can see "virtmem" in 'top':

    Code:
      PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                               
    10558 sdtd      20   0 2918760 2.220g  23276 R 170.5  9.5  48:23.66 7DaysToDieServer
    RAM usage seems to depend on some combination of the number of users, the amount of new map being discovered and perhaps user exits/user joins. My server stays up anywhere between a couple hours and over 24 hours. In A12 my server stayed up for days without issue.

    I'd *love* to use the 64-bit version but it won't show up in the server browser. Otherwise it seems to work OK.

    Alloc: is the Linux server getting any love in the A14 optimization release? If you want a guinea pig to help profile I certainly volunteer!

  11. #761
    Fun Pimps Staff Alloc's Avatar
    Join Date
    Oct 2013
    Location
    Germany - Darmstadt
    Posts
    3,126
    Rep Power
    1
    Quote Originally Posted by mudfly View Post
    Based on your attitude I picked a license for you! Of course it is meant to be tounge-in-cheek, but perhaps maybe it is appropriate

    http://www.wtfpl.net/
    Heh, interesting one
    More likely gonna go with Apache or BSD though



    Quote Originally Posted by blotavious View Post
    Alloc: is the Linux server getting any love in the A14 optimization release? If you want a guinea pig to help profile I certainly volunteer!
    There's no Linux specific code and thus optimizations (or for that matter for any of the platforms). So whatever is optimized will affect each of the platforms.

  12. #762
    Tracker
    Join Date
    Jan 2015
    Location
    Germany
    Posts
    212
    Rep Power
    0
    Hey Alloc,

    are there any plans adding different icons for different animals/zombies on the map ?

    Greetings,
    Devidian

  13. #763
    Survivor
    Join Date
    May 2014
    Location
    Atlanta, GA - USA
    Posts
    77
    Rep Power
    0
    +1 for BSD, though Apache is good too. Please no GPL nonsense.

  14. #764
    Fun Pimps Staff Alloc's Avatar
    Join Date
    Oct 2013
    Location
    Germany - Darmstadt
    Posts
    3,126
    Rep Power
    1
    Quote Originally Posted by Devidian View Post
    are there any plans adding different icons for different animals/zombies on the map ?
    So far no. I'm far from being a designer or anything like that so I have to search for fitting icons (both in terms of content as well as licensing) or it will end up ugly as hell
    Also: Wrong thread.


    Quote Originally Posted by blotavious View Post
    +1 for BSD, though Apache is good too. Please no GPL nonsense.
    Heh, just because you wanna use it for your own commercial product, right? ;P
    j/k, for this stuff GPL just doesn't make any sense to me either.

  15. #765
    Tracker
    Join Date
    Jan 2015
    Location
    Germany
    Posts
    212
    Rep Power
    0
    Quote Originally Posted by Alloc View Post
    So far no. I'm far from being a designer or anything like that so I have to search for fitting icons (both in terms of content as well as licensing) or it will end up ugly as hell
    Also: Wrong thread.
    Whops, sorry had multiple tabs open
    Ok well, then i'll try myself editing this when i get some free time.

Posting Permissions

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