Native Linux server (with management scripts)

Yeah, almost looks like that's the issue. I assume Unity requires some newer CPU instruction set extensions on the 64 bit builds, like SSE4 or AVX. Same problem for another old AMD processor is described on this Unity thread. I suppose you're out of luck there with the 64 bit build :(
Finally tracked it down. Latest Unity 64-bit uses SSE4, and my CPU only supports SSE3. If I could find a way to force it to use SSE3 instead, I could get it working.

Can't really afford to drop money on new hardware so I'm living with 32-bit and some hard limitations for a while it looks like.

EDIT: Further digging shows that though the CPU's support SSE3, my cpuinfo file is only showing up to SSE2 support.

 
Last edited by a moderator:
Finally tracked it down. Latest Unity 64-bit uses SSE4, and my CPU only supports SSE3. If I could find a way to force it to use SSE3 instead, I could get it working.
Can't really afford to drop money on new hardware so I'm living with 32-bit and some hard limitations for a while it looks like.

EDIT: Further digging shows that though the CPU's support SSE3, my cpuinfo file is only showing up to SSE2 support.
Yeah, it's too bad things like this happen ... but after all that CPU is 11 years old. Sometimes you just have to drop support for old stuff if you want to improve things ;)

SSE4 is also 10 years old by now so at least not too restrictive.

And most important: You can at least still run it, even though with the 32 bit restriction.

 
Yeah, it's too bad things like this happen ... but after all that CPU is 11 years old. Sometimes you just have to drop support for old stuff if you want to improve things ;) SSE4 is also 10 years old by now so at least not too restrictive.

And most important: You can at least still run it, even though with the 32 bit restriction.
Yep. I've been eyeing some new hardware anyway. Just need funds to throw into a purchase. I'll probably turn this box into a Minecraft server or something then.

I have a couple of newer PC's I could use, but they don't have the RAM I need for it to run smooth with 10 people on each server.

 
As it says: You're missing xmlstarlet (as pointed out in the prerequisites page) ;)

I found the issue. The Linux repositories were down. after switching to a different list I Installed with no problems.

 
Capture response of telnet command in hook script.

I hope this is the correct thread, if not please move it :D

I have a technical question I would like your advice on if possible @Alloc or anyone else :)

I have successfully configured a hook script that calls a PHP page on playerconnect, it sends an IP address to the page and has the continent code returned. It then takes an action based on that return value. The continent code is assigned a variable in the bash script:

The CONT variable is then used with an IF/THEN clause and referenced using "$CONT" in the bash script.

My question is, how do I issue a telnet command (sourcing common.sh) and store the response in a variable to then be used in another telnet command? I have tried:

DATA="`telnetCommand $1 "gt"`"DATA=`telnetCommand $1 "gt"`

DATA="telnetCommand $1 "gt""

DATA=telnetCommand $1 "gt"
The command I would then issue (for example):

telnetCommand $1 "sayplayer $4 \"data: "$DATA" \""
None of the above permutations work, do you have any advice you can offer?

Thanks,

Zig.

 
Last edited by a moderator:
Did you check that DATA actually contains what you expect (just echo DATA for example)? Also, I don't think you want the inner quotes around $DATA in your command, i.e.

Code:
telnetCommand $1 "sayplayer $4 \"data: $DATA\""
 
hello @Alloc are fixes update coming anytime soon?
=) we are missing our rlp function
Wrong thread ;)

Besides that fixing rlp isn't really the highest priority atm as you might guess when looking at things like people unable to even play the game currently ;)

Might be looking into it soon (maybe even later today) but no promises on that part.

 
Wrong thread ;)
The 2 Threads are confusing :D

Just a side question (not important): there is an issue with permanent hostiles on map even if no player is online, do you know about this ? Just saw this again yesterday(today/currently) on my servers map. I noticed this in A11 too but never mentioned this here.

 
Does the scripts support an Auto-restart of a server instance or if someone has a script for it, our server seems to crash randomly and i have to manually restart it.

 
welcome.sh

Did you check that DATA actually contains what you expect (just echo DATA for example)? Also, I don't think you want the inner quotes around $DATA in your command, i.e.
Code:
telnetCommand $1 "sayplayer $4 \"data: $DATA\""
Thanks for the tips Alloc, I got it working :)

But I have another question: Is it possible to chain the telnet commands together?

Code:
EG: telnetCommand $1 "sayplayer player \"message1\""; "sayplayer player \"message 2\""; etc...
To avoid spamming the telnet connection for consecutive 'say commands'.

For anyone else that wants to use it, it displays welcome message, users playtime, days until next 7 day horde. It goes into the 'playerConnect' hooks folder. It uses PM to avoid global spam.

Code:
#!/bin/bash
. /usr/local/lib/7dtd/common.sh

###Strindex - http://stackoverflow.com/questions/5031764
strindex() {  
 x="${1%%$2*}"
 [[ $x = $1 ]] && echo -1 || echo ${#x}
}


###Get current day###
#get telent 'gt' response
sGT="$(telnetCommand $1 "gt")"
#extract day string
sData=$(echo "$sGT" | egrep -o '^Day [0-9]{1,}')
#divide by 7, get remainder
iDay=$( expr ${sData:4} % 7)
#build seven day message
sSDMsg="There are [00FF00]$iDay days[-] until next 7day horde."


###Get player details###
sOut="$(telnetCommand $1 "lkp $3")"
#Find the desired string beginning
iPlNmStrt=$(strindex "$sOut" "1. $3,") 
#Find the desired string end.
iPlNmEnd=$(strindex "$sOut" "Total of ")
#Calculate length
iOutStrLen=$(expr $iPlNmEnd - $iPlNmStrt)
#Grab the string.
sLKPStr="${sOut:$iPlNmStrt:$iOutStrLen-2}"

###Get string parts into array
OIFS=$IFS; 			#store existing sep
IFS="," 			#Change the separator to comma
aLkpArr=($sLKPStr) 	#serialise
IFS=$OIFS 			#return to default sep

###Playtime.
vPlTme="${aLkpArr[5]}"
sPlTme="${vPlTme:10:-2}"

###Build mesages
sMsg1="Welcome [00FF00]$3[-]!"
sMsg2="Playtime: [00FF00]$sPlTme mins[-]"
sMsg4="7 Nights 2 Live is an EU based PVE server. \
No Player killing or Griefing is allowed. \
Server Map: [FFFF00]http://7n2l.com[-]"

###Send messages
telnetCommand $1 "sayplayer $3 \"$sMsg1\""
telnetCommand $1 "sayplayer $3 \"$sMsg2\""
telnetCommand $1 "sayplayer $3 \"$sSDMsg\""
telnetCommand $1 "sayplayer $3 \"$sMsg4\""
- - - Updated - - -

Does the scripts support an Auto-restart of a server instance or if someone has a script for it, our server seems to crash randomly and i have to manually restart it.

What setup do you have? Can you add a cron job? How do you start your server normally?

Need to know setup before can give advice.

 
Hey Alloc, as always, thanks for all your hard work- not sure where this game would be without you.

Running into a little issue that is preventing anyone from joining my server with EAC enabled. Is this a known issue? Got a work around or fix for this?

Code:
2016-04-14T15:03:33 7008.595 INF [NET] PlayerConnected EntityID=-1, PlayerID='', OwnerID='', PlayerName=''
2016-04-14T15:03:33 7008.779 INF PlayerLogin: Carbon/Alpha 14.5
2016-04-14T15:03:33 7008.779 INF Token length: 1368
2016-04-14T15:03:33 7008.779 INF [steamworks.NET] Auth.AuthenticateUser()
2016-04-14T15:03:33 7008.779 INF [steamworks.NET] Authenticating player: Carbon SteamId: XXXXXXXXXXXX TicketLen: 1024 Result: k_EBeginAuthSessionResultOK
2016-04-14T15:03:33 7008.779 INF [EAC] Registering user: id=XXXXXXXXXXXX, owner=XXXXXXXXXXXX
2016-04-14T15:03:33 7008.779 INF Allowing player with id XXXXXXXXXXXX
2016-04-14T15:03:33 7008.790 INF [EAC] UserStatusHandler callback. Status: UserAuthenticated GUID: XXXXXXXXXXXX ReqKick: False Message: EAC Authenticated
2016-04-14T15:03:33 7009.031 INF [steamworks.NET] Authentication callback. ID: XXXXXXXXXXXX, owner: XXXXXXXXXXXX, result: k_EAuthSessionResponseOK
2016-04-14T15:03:34 7009.277 INF [EAC] Log: Backend connection established.
2016-04-14T15:03:35 7010.312 INF RequestToEnterGame: XXXXXXXXXXXX/Carbon
2016-04-14T15:03:35 7010.312 INF PPS RequestToEnterGame sending player list with 1 player(s)
2016-04-14T15:03:35 7010.312 INF XXXXXXXXXXXX -> -1
2016-04-14T15:03:53 7028.216 INF RequestToSpawnPlayer: 171, Carbon, 5
2016-04-14T15:03:53 7028.244 INF Created player with id=171
2016-04-14T15:03:53 7028.244 INF PPS logged in player: XXXXXXXXXXXX -> 171
2016-04-14T15:03:53 7028.245 INF Adding observed entity: 2, (2054.7, 57.4, 1717.4), 5
2016-04-14T15:03:53 7028.245 INF GMSG: Carbon joined the game
2016-04-14T15:03:55 7030.545 INF [EAC] Log: User without EAC connection: XXXXXXXXXXXX. User status: Disconnected.
2016-04-14T15:03:55 7030.556 INF [EAC] UserStatusHandler callback. Status: UserDisconnected GUID: XXXXXXXXXXXX ReqKick: True Message: EAC Disconnected
2016-04-14T15:03:55 7030.556 INF [EAC] Kick player Carbon, status UserDisconnected
2016-04-14T15:03:55 7030.556 INF Kicking player: Kicked by EAC. Please check if you started the game with AntiCheat protection software enabled
2016-04-14T15:03:55 7030.666 INF [NET] PlayerDisconnected EntityID=171, PlayerID='XXXXXXXXXXXX', OwnerID='XXXXXXXXXXXX', PlayerName='Carbon'
2016-04-14T15:03:55 7030.666 INF Player disconnected: EntityID=171, PlayerID='XXXXXXXXXXXX', OwnerID='XXXXXXXXXXXX', PlayerName='Carbon'
2016-04-14T15:03:55 7030.666 INF [EAC] FreeUser (Carbon)
2016-04-14T15:03:55 7030.666 INF [EAC] Log: [unregisterUser] GUID: XXXXXXXXXXXX
2016-04-14T15:03:55 7030.666 INF GMSG: Carbon left the game
2016-04-14T15:03:55 7030.666 INF Removing observed entity 2
2016-04-14T15:03:56 7031.085 ERR DisconnectClient: Player XXXXXXXXXXXX not found
 
Last edited by a moderator:
Does the scripts support an Auto-restart of a server instance or if someone has a script for it, our server seems to crash randomly and i have to manually restart it.
No auto-restart, check the log-lines, my server always crashes when they are between 30k and 40k (AI and physics stop working, forges get buggy) So have an eye on this before it is crashing. The more player you have on your server the time until logs go above 30k can vary, so this may be the "randomly" factor, just a guess.

 
What setup do you have? Can you add a cron job? How do you start your server normally?

Need to know setup before can give advice.
well i have a Ubuntu setup using the scripts from https://7dtd.illy.bz/ im not very good with

cron scripts or how to make it check my instance to see if its running and start it back up.

 
well i have a Ubuntu setup using the scripts from https://7dtd.illy.bz/ im not very good withcron scripts or how to make it check my instance to see if its running and start it back up.
You don't need to check if the instance is running, you can just issue the start command:

Code:
sudo 7dtd.sh start myinstance
If the instance is already running, the command exits gracefully.

You can set a cron job to issue the command every n minutes:

Code:
sudo crontab -e
Then type or paste (ctrl+shift+v) in terminal:

Code:
*/2 * * * * /usr/local/bin/7dtd.sh start myinstance >> /dev/null 2>&1
This will attempt to start the server every two minutes, you can adjust that to what you want, adjust 'myinstance' to the required instance name.

Another thing you can do is restart the server periodically. I have to do this with my Ubuntu VPS on NFO servers, as the linux dedi doesn't run as reliably as the windows version. If you are interested, I use cron to restart every six hours (3am/9am/3pm/9pm):

Code:
0 3,9,15,21 * * * /usr/local/bin/7dtd.sh kill myinstance; /usr/local/bin/7dtd.sh start myinstance
I announce the coming restart for five mins, using a PHP script, but I may use a bash script when I get round to it. I will post it here if I do.

---UPDATED--

I made the bash announce script:

Code:
#!/bin/bash
. /usr/local/lib/7dtd/common.sh


# Check for minute argument, exit if empty.
if [ $# -eq 0 ]
 then
   echo "No minute given, exiting";
   exit;
fi

# get datenow for log
sNow=$(date +%d-%m-%Y_%H:%M:%S_)

# build the message.
case "$1" in

"now")
       sMsg="[00FF00]Server is restarting, you can rejoin in approx [ff0000]1 minute[-]"
	#send the message
	telnetCommand "myinstance" "say \"$sMsg\""
	#save
	telnetCommand "myinstance" "sa"
	#kickall
	telnetCommand "myinstance" "kickall \"RESTARTING SERVER - you can rejoin in approx 1 minute\""
	#shutdown server
	telnetCommand "myinstance" "shutdown"
	;;

*)
	sMsg="[00FF00]Server will restart in [FF0000] $1 MINUTES[-]"
	#send the message
	telnetCommand "myinstance" "say \"$sMsg\""
	;;
esac

#log action
echo $sNow$sMsg
You need to save that file somewhere on your system.

I use the instance/hooks folder:

Code:
sudo nano /home/sdtd/instances/myinstance/hooks/shellrestart.sh
Copy the above code and paste it into the new file (ctrl+shift+v), save the file (ctrl+o -> enter), exit the editor (ctrl+x).

Make the file executable:

Code:
sudo chmod +x /home/sdtd/instances/myinstance/hooks/shellrestart.sh
Then add the new cron lines (sudo crontab -e):

Code:
54 2,8,14,20 * * * /home/sdtd/instances/myinstance/hooks/shellrestart.sh 5 >> /root/shellrestart.txt 2>&1

55 2,8,14,20 * * * /home/sdtd/instances/myinstance/hooks/shellrestart.sh 4 >> /root/shellrestart.txt 2>&1

56 2,8,14,20 * * * /home/sdtd/instances/myinstance/hooks/shellrestart.sh 3 >> /root/shellrestart.txt 2>&1

57 2,8,14,20 * * * /home/sdtd/instances/myinstance/hooks/shellrestart.sh 2 >> /root/shellrestart.txt 2>&1

58 2,8,14,20 * * * /home/sdtd/instances/myinstance/hooks/shellrestart.sh 1 >> /root/shellrestart.txt 2>&1

59 2,8,14,20 * * * /home/sdtd/instances/myinstance/hooks/shellrestart.sh now >> /root/shellrestart.txt 2>&1

0 3,9,15,21 * * * /usr/local/bin/7dtd.sh kill myinstance; /usr/local/bin/7dtd.sh start myinstance >> /root/shellrestart.txt 2>&1
Change 'myinstance' to suit, and the server will restart every six hours as before, but will announce with a five minute countdown. It will log it's behaviour to '/root/cronrestart.log, you can change that to fit your requirements. Let me know if you have any problems.

 
Last edited by a moderator:
Change 'myinstance' to suit, and the server will restart every six hours as before, but will announce with a five minute countdown. It will log it's behaviour to '/root/cronrestart.log, you can change that to fit your requirements. Let me know if you have any problems.
Wow thats an awesome setup for the scripts, iu went thru it and i forced a shellrestart now, but my cron doesnt seem to be working on my end, not restarting the server in a min as ive been watching for the log to appear in /root and by monitoring ps aux for the server to come up, like i mentioned earlier not too good with crontabs this is how mines looks now

Code:
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
54 2,8,14,20 * * * /home/sdtd/shellrestart.sh 5 >> /root/shellrestart.txt 2>&1

55 2,8,14,20 * * * /home/sdtd/shellrestart.sh 4 >> /root/shellrestart.txt 2>&1

56 2,8,14,20 * * * /home/sdtd/shellrestart.sh 3 >> /root/shellrestart.txt 2>&1

57 2,8,14,20 * * * /home/sdtd/shellrestart.sh 2 >> /root/shellrestart.txt 2>&1

58 2,8,14,20 * * * /home/sdtd/shellrestart.sh 1 >> /root/shellrestart.txt 2>&1

59 2,8,14,20 * * * /home/sdtd/shellrestart.sh now >> /root/shellrestart.txt 2>&1

0 3,9,15,21 * * * /usr/local/bin/7dtd.sh kill Hawaii; /usr/local/bin/7dtd.sh start Hawaii >> /root/shellrestart.txt 2>&1
using sudo crontab -e or by su'ing in to root and doing it from there... So im suspecting my cron not working, i have Ubuntu 14.04 64-bit and ive always thought ubuntu to have a strange cron setup vs Slackware i used in the past.

 
Wow thats an awesome setup for the scripts, iu went thru it and i forced a shellrestart now, but my cron doesnt seem to be working on my end, not restarting the server in a min as ive been watching for the log to appear in /root and by monitoring ps aux for the server to come up...using sudo crontab -e or by su'ing in to root and doing it from there... So im suspecting my cron not working, i have Ubuntu 14.04 64-bit and ive always thought ubuntu to have a strange cron setup vs Slackware i used in the past.
I've not known cron to fail before, it's integral to the system from what I understand. To troubleshoot this problem, I would try running the commands directly to see if they still fail. While you are in game on your server, run the 'sudo /home/sdtd/shellrestart.sh 5' command from a terminal and see if the message comes through. To test the writing to shellrestart.txt you could 'sudo echo test >> /root/shellrestart.txt'. Check the restart.txt is writable (chmod +w), and that the scripts are executable (chmod +x). Did you try cron as a regular user? My name is the same on steam if you would like to add me. Good luck :)

 
I think the only cron implementation I've seen so far that does not have a user column was with Busybox.

Normally you have the column user between dow and command. Maybe try adding "root" there and see if that works.

@zigstum: Careful about combining sudo with pipes / redirects ;)

Running "sudo echo test >> /root/shellrestart.txt" as non-root probably won't work as only the command invocation (echo test) will be run within sudo, the redirect is not affected iirc.

 
@zigstum: Careful about combining sudo with pipes / redirects ;)

Running "sudo echo test >> /root/shellrestart.txt" as non-root probably won't work as only the command invocation (echo test) will be run within sudo, the redirect is not affected iirc.
Ah, that makes sense :D

Thanks for the heads-up.

I noticed you implemented the 'per-instance' hooks, good job! I will check it over later and make sure it is not too hacky ^^

Do you know if there has been any progress reducing resource usage on the dedi, especially under linux? I'm currently having to cap my 4XCore/8GB Ubuntu 15 VPS to 16 slots, with a 6hr restart to keep lag to a minimum. It seems from the few things I have read, that Windows is much more stable and less piggy than the linux dedi, but I don't know anything concrete.

Also, is there a way to chain commands together in the user scripts, eg:

Code:
telnetCommand $1 "say \"msg 1\""; "say \""msg2\""
Also, is there a way to get newlines into a 'say' command, or do I need to use multiple say commands to get multiple lines of text sent to the server?

Also... nah, that's it for now :)

Thanks for your time Mr Alloc.

Zig.

 
Last edited by a moderator:
Hey Alloc, another question for you :)

I'm currently trying to add some session control to the map, as I want only users logged into the community site to see the map. I had initially just loaded the webmap into a frame on my existing site, but when I moved server, the authentication started failing, and as my site header takes up too much real estate, I wanted to lose the frame and add a custom header to the index.html contained in the home/sdtd/engine/Mods/Allocs_WebAndMapRendering/webserver/ folder.

I configured the proxy reverse for the webmap and it works fine, however the profile ID I am passing (map.mydomain.com?id=111) is removed from the URL by the time it reaches map.mydomain.com/static/index.html. On the index.html I have a JS function that tries to retrieve the profile ID and will send an ajax request to see if that user is logged into the website. If they are, it will allow access to the page, if not, redirect them back to my site with a message telling them to log in.

So, the question; what's happening to the profile ID in the URL and how can I save it for use when /static/index.html is actually loaded?

Thanks for your time, as always :)

 
Back
Top