Native Linux server (with management scripts)

I would recommend looking at the EXAMPLES section of the sudoers man page. You're looking for something along the lines of...username ALL=/usr/local/bin/7dtd.sh

Or if you want to be more granular...

username ALL=/usr/local/bin/7dtd.sh start,/usr/local/bin/7dtd.sh kill
Hi SeeJayEmm,

that was it!

Big thanks to you!

PS: If someone is interested in a automated CMD-Script for Windows to do some basic control via PLink (PuTTY), please ask :) .

 
Sometimes the server connection fails at start

There is still a small problem. Perhaps someone knows the solution:

It sometimes happens that I can not connect to the server (with the running network game).

The game only returns the error message: "Error: could not connect to server: could not retrieve server information". The log website is not running either.

The server has been started and is also running (shows the status).

The only thing that helped so far was when I edit the instance (save without changing something is usually enough). Only then I can connect again with the network play and the log web page works again.

When i kill the instance this text is coming up:

Code:
Trying to gracefully shutdown...
/usr/local/lib/7dtd/common.sh: line 210: nc: command not found
Waiting for server to shut down...
1/5
2/5
3/5
4/5
5/5
Failed, force closing server...
Done
Unfortunately, I can not say whether this is related, or just coincidence.

 
Last edited by a moderator:
Any working fix for error "Too many open files"?

All limits already increased to maximum.

Can't use web map. It always cause error on maprender and server become unaccessible.

 
Howdy,

Just thought I'd drop by and share another script I created for my server which is based on Alloc's fixes.

Source: http://hammondslegacy.com/forum/viewtopic.php?f=40&t=213&p=508#p508

Here is a horde notification script for players which I tested on Ubuntu Server 16.04 LTS but should work for most other flavors of Linux since it uses Bash.

Create a file such as sdtd-horde-notify.sh and set permissions on it:

Code:
mkdir -p /var/scripts/prod
touch /var/scripts/prod/sdtd-horde-notify.sh
chown root:root /var/scripts/prod/sdtd-horde-notify.sh
chmod 755 /var/scripts/prod/sdtd-horde-notify.sh
Add the following text to the script:

Code:
#!/bin/bash
#############################################################
## Name          : sdtd-horde-notify.sh
## Version       : 1.1
## Date          : 2017-05-25
## Author        : LHammonds
## Purpose       : Notify players once a day about approaching horde night.
##     1. Only process this script if there are players online.
##     2. Only process this script if the time is > 5:00 am in-game.
##     3. Finally, send chat message with how many days until horde night.
## Parameters    : #1 = 7dtd server instance name (required)
## Installation  : Run from crontab every few minutes.
## Compatibility : Verified on Ubuntu Server 14.04 thru 16.04 LTS
##                 7 Days to Die, Alpha 15.2
###################### CHANGE LOG ###########################
## DATE       VER WHO WHAT WAS CHANGED
## ---------- --- --- ---------------------------------------
## 2017-05-08 1.0 LTH Created script.
## 2017-05-25 1.1 LTH Added multi-instance support.
#############################################################

## Import standard variables and functions. ##
source /usr/local/lib/7dtd/common.sh

## 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} HamCraft"
 echo -e "Example 2: ${ScriptName} WalkingDead"
 echo -e "Example 3: ${ScriptName} Vanilla"
 echo -e "Here is a list of valid instances:"
 7dtd.sh instances list
 exit 1
else
 InstanceName="${1}"
fi

TempFile="/tmp/sdtd-gettime-${InstanceName}.txt"
LastRun="/tmp/sdtd-lastrun-${InstanceName}.txt"
Hour2Notify=5

## Send ListPlayers command results to a temporary file.
telnetCommand ${InstanceName} "lp" > ${TempFile}
## Get the last line of the file.  Example: Total of 0 in the game
PlayerCount=`tail -n 1 ${TempFile}`
## Get the 3rd column of the line.  Example: 0
PlayerCount=`echo ${PlayerCount} | cut -d' ' -f3`
## Delete the temporary file.
rm ${TempFile}

if [[ ${PlayerCount} == 0 ]]; then
 ## No active players online.  No need to send in-game message.
 echo "[iNFO] No players online, aborting script."
 ## Remove last run file to allow next person online to get the message.
 if [ -f ${LastRun} ]; then
   rm ${LastRun}
 fi
 exit 0
else
 echo "[iNFO] ${PlayerCount} players online."
fi

## Send gettime command results to a temporary file.
telnetCommand ${InstanceName} "gettime" > ${TempFile}

## Get the last line of the file.  Example: Day 115, 05:22
DayLine=`tail -n 1 ${TempFile}`

## Get the 2nd column of the line.  Example: 115,
CurrentDay=`echo ${DayLine} | cut -d' ' -f2`

## Remove the comma.  Example: 115
CurrentDay="${CurrentDay//,}"

## Get the in-game time.  Example: 05:22
CurrentTime=`echo ${DayLine} | cut -d' ' -f3`

## Get the in-game hour.  Example: 05
CurrentHour=`echo ${CurrentTime} | cut -d':' -f1`

## Force number to decimal (base 10) by removing any leading zeroes. Example: 5
CurrentHour=$((10#${CurrentHour}))

## Get the remainder from dividing by 7.  Example: 3
Remainder=`expr ${CurrentDay} % 7`

## Subtract the remainder from 7 to get how many days until the 7th night.
DaysToHorde=`expr 7 - ${Remainder}`

if [[ ${DaysToHorde} == 1 ]]; then
 DayPlural="day"
else
 DayPlural="days"
fi

if [[ ${CurrentHour} -gt ${Hour2Notify} ]]; then
 ## It is not too early in the day to send the notification.
 if [ -f ${LastRun} ]; then
   ## If last message sent was today, abort script.
   PriorDay=`tail -n 1 ${LastRun}`
   if [[ ${PriorDay} == ${CurrentDay} ]]; then
     ## Message already sent today, abort script.
     exit 0
   else
     ## We are in a new day.
     if [[ ${Remainder} == 0 ]]; then
       telnetCommand ${InstanceName} "say \"[ffff00][iNFO] [00ff00]Horde night tonight!\""
     else
       telnetCommand ${InstanceName} "say \"[ffff00][iNFO] [00ff00]${DaysToHorde} ${DayPlural} until horde night.\""
     fi
     ## Create last run file with date when message was sent.
     echo ${CurrentDay} > ${LastRun}
   fi
 else
   ## Messasge not sent today, send the chat message.
   if [[ ${Remainder} == 0 ]]; then
     telnetCommand ${InstanceName} "say \"[ffff00][iNFO] [00ff00]Horde night tonight!\""
   else
     telnetCommand ${InstanceName} "say \"[ffff00][iNFO] [00ff00]${DaysToHorde} ${DayPlural} until horde night.\""
   fi

   ## Create last run file with date when message was sent.
   echo ${CurrentDay} > ${LastRun}
 fi
else
 ## Too early in the morning to message players, abort script.
 exit 0
fi

## Delete the temporary file.
rm ${TempFile}
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: Notify players each in-game day about approaching horde night
#
*/5 * * * * /var/scripts/prod/sdtd-horde-notify.sh HamCraft > /dev/null 2>&1
*/5 * * * * /var/scripts/prod/sdtd-horde-notify.sh WalkingDead > /dev/null 2>&1
*/5 * * * * /var/scripts/prod/sdtd-horde-notify.sh Vanilla > /dev/null 2>&1
Summary of what it is doing:

The schedule is configured to run the script every 5 minutes for instances of servers called "HamCraft", "WalkingDead" and "Vanilla"

Even though it runs often, it will only generate an in-game message once per day shortly after the desired hour...which is set to 5am in the script via the "Hour2Notify" variable.

Here are all the possible messages players will see in the game:

[iNFO] 6 days until horde night.

[iNFO] 5 days until horde night.

[iNFO] 4 days until horde night.

[iNFO] 3 days until horde night.

[iNFO] 2 days until horde night.

[iNFO] 1 day until horde night.

[iNFO] Horde night tonight!

 
Any working fix for error "Too many open files"?
All limits already increased to maximum.

Can't use web map. It always cause error on maprender and server become unaccessible.
I had this same error forever ago, Sylen or Alloc helped me fix it. I'll have to go back through my posts to find it, but I started using the dynamic map and not rendering the map and it eliminates that issue. I'm at work, give me time and I'll find the post.

It was Sylen. Here's a link he shared with me:

https://7daystodie.com/forums/showthread.php?40772-SUPPORT-FAQ-Information-and-Common-Solutions#post429948

 
Last edited by a moderator:
I just setup a new Ubuntu 16.04 server and I noticed this message below when I was running bootstrap.sh. I've installed all the prerequisites. Did I do something wrong? Does this message mean anything?

Code:
Downloading and installing management scripts

2017-06-05 20:35:41 URL:[url]http://illy.bz/fi/7dtd/management_scripts.tar.gz[/url] [32851/32851] -> "/tmp/management_scripts.tar.gz" [1]
insserv: pushd() can not change to directory /etc/init.d: No such file or directory
update-rc.d: error: insserv rejected the script header

Compiling start-stop-daemon
I also notice that if I try to use the bash auto completion I don't get the results that I get on another server that I setup that's running the scripts. Here's what I get when I type 7dtd.sh [Tab]

Code:
root@ns544969:~# 7dtd.sh
.bash_history  .bashrc        .cache/        .email         .mdg           .profile       .ssh/          .steam/        Steam/
root@ns544969:~# 7dtd.sh
Here's what I am expecting to get. It's what I get on my other server. Any help is appreciated.

Code:
root@ns532637:~# 7dtd.sh
about          help           kill           status         updatefixes
backup         instances      start          updateengine   updatescripts
root@ns532637:~# 7dtd.sh
 
Last edited by a moderator:
Any working fix for error "Too many open files"?
All limits already increased to maximum.

Can't use web map. It always cause error on maprender and server become unaccessible.
Is it still really giving you that error or are you just having issues with the web map?

I'd bet it's safe to say that if you're really hitting the open files limit you either haven't increased the limit enough or you did something wrong with that.

I just setup a new Ubuntu 16.04 server and I noticed this message below when I was running bootstrap.sh. I've installed all the prerequisites. Did I do something wrong? Does this message mean anything?

Code:
insserv: pushd() can not change to directory /etc/init.d: No such file or directory
update-rc.d: error: insserv rejected the script header
Looks like the installation failed as there was an issue with /etc/init.d not existing. I suppose that's due to the switch to systemd. In the end it shouldn't matter a lot though, it just means it won't auto start any instances during system boot.

I also notice that if I try to use the bash auto completion I don't get the results that I get on another server that I setup that's running the scripts.
Most likely bash-completion is not installed or activated for root.

 
For the bash-completion, you probably have a symlink from /bin/sh to /bin/dash, rather than /bin/bash

You can change it back to bash by doing this as root:

rm -f /bin/sh

ln -s /bin/bash /bin/sh

 
Just some a16 Experimental Updates....

The script does not create the following items in the config file.

Code:
  <property name="BedrollDeadZoneSize"  value="15"/>     
 <property name="BloodMoonEnemyCount"  value="8" />     
 <property name="HideCommandExecutionLog"    value="0"/>   
 <property name="MaxUncoveredMapChunksPerPlayer"  value="131072"/>     
 <property name="ServerAdminSlots"   value="0"/>    
 <property name="ServerAdminSlotsPermission" value="0"/>      
 <property name="ServerDisabledNetworkProtocols" value="UNET"/>      
 <property name="ServerReservedSlots"  value="0"/>     
 <property name="ServerReservedSlotsPermission" value="100"/>
The following line is removed.

Code:
  <property name="EnemySenseMemory" value="60"/>
Also, just a general note on changes...

Default server port has been 26900 for ages, but script still uses 25000.

LandClaim Size default is now 41. I think the script uses either 30 or 7. I can never remember.

Almost forgot, EnemySenseMemory will prevent your server from starting.

OOh, found another one. EnemySpawnMode is not 0-5 or whatever it was. It's True or False. Again, incorrect input will prevent it from starting.

 
Last edited by a moderator:
Just some a16 Experimental Updates....
The script does not create the following items in the config file.

Code:
  <property name="BedrollDeadZoneSize"  value="15"/>     
 <property name="BloodMoonEnemyCount"  value="8" />     
 <property name="HideCommandExecutionLog"    value="0"/>   
 <property name="MaxUncoveredMapChunksPerPlayer"  value="131072"/>     
 <property name="ServerAdminSlots"   value="0"/>    
 <property name="ServerAdminSlotsPermission" value="0"/>      
 <property name="ServerDisabledNetworkProtocols" value="UNET"/>      
 <property name="ServerReservedSlots"  value="0"/>     
 <property name="ServerReservedSlotsPermission" value="100"/>
The following line is removed.

Code:
  <property name="EnemySenseMemory" value="60"/>
Also, just a general note on changes...

Default server port has been 26900 for ages, but script still uses 25000.

LandClaim Size default is now 41. I think the script uses either 30 or 7. I can never remember.

Almost forgot, EnemySenseMemory will prevent your server from starting.

OOh, found another one. EnemySpawnMode is not 0-5 or whatever it was. It's True or False. Again, incorrect input will prevent it from starting.
Yep, can confirm. server starts and runs fine now.

 
Last edited by a moderator:
I've been using this script for a while now and it's worked well, but at this point it should probably be forked onto github or somewhere where we can all collaboratively keep it more up to date. I'm not even sure what changes need to be done to get this up to a16. Also, there were some major changes this alpha to things like max number of zombies, and this script still uses the "50%-200%" sort of system.

 
Just some a16 Experimental Updates....
....
Thanks Sylen :)

Was aware of those changes (of course, some even came from my side ;) ), just had more critical stuff to work on. I'll try to finally get the scripts updated these days.

 
@Alloc:

I'v set up a linux server on the experimental branch A16 b119 and your server tools work great. But what about the server fixes? I dit not test them because the release notes are from 2017-01-03 and they say nothing about A16. Do they work?

 
ipv6 issue?

First of all, thanks for all of the work it took (and still takes) providing this great set of tools.

This is my first time using the server scripts and for the most part, all went well once I got a handle on the config file changes that were keeping the server from running. I'm still seeing one issue that I don't think is harming anything, but shich is annoying. When running 7dtd.sh status <instance>, I get something like this:

Status: Running

Open ports:

26900 (tcp)

26900 (udp)

26901 (udp)

26902 (udp)

8080 (tcp)

8081 (tcp)

8082 (tcp)

(udp6)

/usr/local/lib/7dtd/common.sh: line 201: 24947 Killed nc 127.0.0.1 $TEL_PORT 0<&3

It also shows up in 7dtd.sh instance list:

Instance name | Running | Players | Port

---------------------+----------+---------+------

/usr/local/lib/7dtd/common.sh: line 201: 3420 Killed nc 127.0.0.1 $TEL_PORT 0<&3

<instance> | yes | 0/ 4 | 26900

It looks like it has to do with ipv6 but I have that turned off in the kernel on this system.

Any ideas?

<edit>

CentOS 7, Dell PE1950, 8 Cores, 24GB RAM

7dtd Branch latest_experimental

</edit>

 
Last edited by a moderator:
...When running 7dtd.sh status <instance>, I get something like this:

...

/usr/local/lib/7dtd/common.sh: line 201: 24947 Killed nc 127.0.0.1 $TEL_PORT 0<&3
I'll have a look. What locale is your system set to?

 
I'll have a look. What locale is your system set to?
[ds1 sdtd]# locale

LANG=en_US.UTF-8

LC_CTYPE="en_US.UTF-8"

LC_NUMERIC="en_US.UTF-8"

LC_TIME="en_US.UTF-8"

LC_COLLATE="en_US.UTF-8"

LC_MONETARY="en_US.UTF-8"

LC_MESSAGES="en_US.UTF-8"

LC_PAPER="en_US.UTF-8"

LC_NAME="en_US.UTF-8"

LC_ADDRESS="en_US.UTF-8"

LC_TELEPHONE="en_US.UTF-8"

LC_MEASUREMENT="en_US.UTF-8"

LC_IDENTIFICATION="en_US.UTF-8"

LC_ALL=

 
Back
Top