Changeset 67 for scripts


Ignore:
Timestamp:
Jul 10, 2014, 9:59:02 PM (10 years ago)
Author:
alloc
Message:

v25: Fixes #22, #23. Also adds new serverconfig options

Location:
scripts
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • scripts/etc/7dtd.conf

    r52 r67  
    1010# Backup options
    1111export SDTD_BACKUP_ROOT=/home/sdtd/backup
     12export SDTD_BACKUP_SAVEWORLD=true
    1213export SDTD_BACKUP_MIN_BACKUPS_KEEP=
    1314export SDTD_BACKUP_MAX_BACKUPS=
  • scripts/home/sdtd/templates/admins.xml

    r19 r67  
    5959        <permission cmd="cc" permission_level="0" />
    6060        <permission cmd="sc" permission_level="0" />
     61        <permission cmd="saveworld" permission_level="0" />
    6162    </permissions>
    6263
  • scripts/usr/local/lib/7dtd/VERSION

    r66 r67  
    1 Version: 24
    2 Release: 2014-07-08
     1Version: 25
     2Release: 2014-07-10
  • scripts/usr/local/lib/7dtd/commands/backup.sh

    r61 r67  
    99        if [ ! -d "$SDTD_BASE/instances" ]; then
    1010                return
     11        fi
     12
     13        if [ "$SDTD_BACKUP_SAVEWORLD" == "true" ]; then
     14                for I in $(getInstanceList); do
     15                        if [ $(isRunning $I) -eq 1 ]; then
     16                                telnetCommand $I saveworld 2
     17                        fi
     18                done
    1119        fi
    1220
  • scripts/usr/local/lib/7dtd/commands/start.sh

    r66 r67  
    2626                fi
    2727               
    28                 setAllPlayersOffline $1
    29                 rm -f $(getInstancePath $1)/output_log.txt
     28                if [ ! -d "$(getInstancePath $1)/logs" ]; then
     29                        mkdir "$(getInstancePath $1)/logs"
     30                fi
     31                rm -f $(getInstancePath $1)/logs/output_log.txt
    3032               
    3133                for H in $(getHooksFor serverPreStart); do
     
    3638                SSD_DAEMON="--background --no-close"
    3739                SSD_USER="--chuid $SDTD_USER:$SDTD_GROUP --user $SDTD_USER"
    38                 OPTS="-logfile $(getInstancePath $1)/output_log.txt -configfile=$(getInstancePath $1)/config.xml -dedicated"
     40                OPTS="-logfile $(getInstancePath $1)/logs/output_log.txt -configfile=$(getInstancePath $1)/config.xml -dedicated"
    3941               
    40                 LD_LIBRARY_PATH=$SDTD_BASE/linux_files $SSD --start $SSD_PID $SSD_DAEMON $SSD_USER --chdir $SDTD_BASE/engine --exec $SDTD_BASE/engine/7DaysToDie.x86 -- $OPTS > $(getInstancePath $1)/stdout.log 2>&1
     42                LD_LIBRARY_PATH=$SDTD_BASE/linux_files $SSD --start $SSD_PID $SSD_DAEMON $SSD_USER --chdir $SDTD_BASE/engine --exec $SDTD_BASE/engine/7DaysToDie.x86 -- $OPTS > $(getInstancePath $1)/logs/stdout.log 2>&1
    4143                sleep 1
    4244
  • scripts/usr/local/lib/7dtd/common.sh

    r64 r67  
    299299
    300300. /usr/local/lib/7dtd/help.sh
    301 . /usr/local/lib/7dtd/playerlog.sh
    302301. /usr/local/lib/7dtd/serverconfig.sh
    303302for M in /usr/local/lib/7dtd/commands/*.sh; do
  • scripts/usr/local/lib/7dtd/monitor-log.sh

    r64 r67  
    22
    33. /usr/local/lib/7dtd/common.sh
     4. /usr/local/lib/7dtd/playerlog.sh
    45
    56if [ $(isValidInstance $1) -eq 0 ]; then
     
    910
    1011INSTANCE=$1
    11 LOG=$(getInstancePath $INSTANCE)/output.log
    12 CHATLOG=$(getInstancePath $INSTANCE)/chat.log
     12LOG=$(getInstancePath $INSTANCE)/logs/$(date '+%Y-%m-%d_%H-%M-%S')_output.log
     13CHATLOG=$(getInstancePath $INSTANCE)/logs/$(date '+%Y-%m-%d_%H-%M-%S')_chat.log
    1314
    1415timestamp() {
     
    4950}
    5051
     52if [ ! -d "$(getInstancePath $INSTANCE)/logs" ]; then
     53        mkdir "$(getInstancePath $INSTANCE)/logs"
     54fi
     55
     56setAllPlayersOffline
     57
    5158echo >> $LOG
    5259echo >> $LOG
     
    6269$NOBUF tr -d '\r' |
    6370$NOBUF grep -v "^(Filename: " |
     71$NOBUF sed -r 's/^[0-9]+,[0-9]+ (.*)$/\1/' |
    6472while read line ; do
    6573        if [ -n "$line" ]; then
  • scripts/usr/local/lib/7dtd/playerlog.sh

    r63 r67  
    11#!/bin/bash
     2
     3PLAYERSXML=$(getInstancePath $1)/players.xml
     4PLAYERSLOG=$(getInstancePath $1)/logs/$(date '+%Y-%m-%d_%H-%M-%S')_players.log
    25
    36timestamp() {
     
    69
    710# Create empty player list if not existing
    8 # Params:
    9 #   1: Instance name
    1011createPlayerList() {
    11         PLAYERLIST=$(getInstancePath $1)/players.xml
    12         if [ ! -f $PLAYERLIST ]; then
    13                 echo "<Players/>" > $PLAYERLIST
     12        if [ ! -f $PLAYERSXML ]; then
     13                echo "<Players/>" > $PLAYERSXML
    1414        fi
    1515}
    1616
    1717# Set all players for an instance to offline (on startup/shutdown)
    18 # Params:
    19 #   1: Instance name
    2018setAllPlayersOffline() {
    21         PLAYERLIST=$(getInstancePath $1)/players.xml
    22         createPlayerList "$1"
     19        createPlayerList
    2320        $XMLSTARLET ed -L \
    2421                -u "/Players/Player/@online" -v "false" \
    25                 $PLAYERLIST
     22                $PLAYERSXML
    2623}
    2724
     
    3330#   4: Nick name
    3431logPlayerConnect() {
    35         PLAYERLOG=$(getInstancePath $1)/players.log
    36         PLAYERLIST=$(getInstancePath $1)/players.xml
    3732        ENTITYID="$2"
    3833        STEAMID="$3"
    3934        NICKNAME="$4"
    4035
    41         echo "$(timestamp) +++ $ENTITYID $NICKNAME $STEAMID" >> $PLAYERLOG
     36        echo "$(timestamp) +++ $ENTITYID $NICKNAME $STEAMID" >> $PLAYERSLOG
    4237
    43         createPlayerList "$1"
     38        createPlayerList
    4439       
    4540        XPATHBASE="/Players/Player[@steamid='$STEAMID']"
    4641
    47         if [ -z $($XMLSTARLET sel -t -v "$XPATHBASE/@steamid" $PLAYERLIST) ]; then
     42        if [ -z $($XMLSTARLET sel -t -v "$XPATHBASE/@steamid" $PLAYERSXML) ]; then
    4843                $XMLSTARLET ed -L \
    4944                        -s "/Players" -t elem -n "Player" -v "" \
     
    5550                        -i "$XPATHBASE" -t attr -n "online" -v "true" \
    5651                        -i "$XPATHBASE" -t attr -n "entityid" -v "$ENTITYID" \
    57                         $PLAYERLIST
     52                        $PLAYERSXML
    5853        else
    59                 LOGINS=$($XMLSTARLET sel -t -v "$XPATHBASE/@logins" $PLAYERLIST)
     54                LOGINS=$($XMLSTARLET sel -t -v "$XPATHBASE/@logins" $PLAYERSXML)
    6055                (( LOGINS++ ))
    6156                $XMLSTARLET ed -L \
     
    6459                        -u "$XPATHBASE/@entityid" -v "$ENTITYID" \
    6560                        -u "$XPATHBASE/@logins" -v "$LOGINS" \
    66                         $PLAYERLIST
     61                        $PLAYERSXML
    6762        fi
    6863}
     
    7368#   2: Entity ID
    7469logPlayerDisconnect() {
    75         PLAYERLOG=$(getInstancePath $1)/players.log
    76         PLAYERLIST=$(getInstancePath $1)/players.xml
    7770        ENTITYID="$2"
    7871
    79         createPlayerList "$1"
     72        createPlayerList
    8073
    8174        XPATHBASE="/Players/Player[@entityid='$ENTITYID'][@online='true']"
    8275
    83         if [ -f $PLAYERLIST ]; then
    84                 if [ ! -z $($XMLSTARLET sel -t -v "$XPATHBASE/@steamid" $PLAYERLIST) ]; then
    85                         NICKNAME=$($XMLSTARLET sel -t -v "$XPATHBASE/@nick" $PLAYERLIST)
    86                         STEAMID=$($XMLSTARLET sel -t -v "$XPATHBASE/@steamid" $PLAYERLIST)
    87                         LOGINTIME=$($XMLSTARLET sel -t -v "$XPATHBASE/@lastlogin" $PLAYERLIST)
    88                         PLAYTIME=$($XMLSTARLET sel -t -v "$XPATHBASE/@playtime" $PLAYERLIST)
     76        if [ -f $PLAYERSXML ]; then
     77                if [ ! -z $($XMLSTARLET sel -t -v "$XPATHBASE/@steamid" $PLAYERSXML) ]; then
     78                        NICKNAME=$($XMLSTARLET sel -t -v "$XPATHBASE/@nick" $PLAYERSXML)
     79                        STEAMID=$($XMLSTARLET sel -t -v "$XPATHBASE/@steamid" $PLAYERSXML)
     80                        LOGINTIME=$($XMLSTARLET sel -t -v "$XPATHBASE/@lastlogin" $PLAYERSXML)
     81                        PLAYTIME=$($XMLSTARLET sel -t -v "$XPATHBASE/@playtime" $PLAYERSXML)
    8982                        NOW=$(date '+%s')
    9083                        PLAYTIME=$(( PLAYTIME + NOW - LOGINTIME ))
     
    9285                                -u "$XPATHBASE/@playtime" -v "$PLAYTIME" \
    9386                                -u "$XPATHBASE/@online" -v "false" \
    94                                 $PLAYERLIST
     87                                $PLAYERSXML
    9588                fi
    9689        fi
    9790
    98         echo "$(timestamp) --- $ENTITYID $NICKNAME $STEAMID" >> $PLAYERLOG
     91        echo "$(timestamp) --- $ENTITYID $NICKNAME $STEAMID" >> $PLAYERSLOG
    9992}
    10093
  • scripts/usr/local/lib/7dtd/serverconfig.sh

    r45 r67  
    684684
    685685
     686serverconfig_MaxSpawnedZombies_QueryName() {
     687        echo "Maximum number of concurrent zombies"
     688}
     689serverconfig_MaxSpawnedZombies_Type() {
     690        echo "number"
     691}
     692serverconfig_MaxSpawnedZombies_Default() {
     693        echo "60"
     694}
     695
     696
     697serverconfig_VACEnabled_QueryName() {
     698        echo "Enable Valve Anti Cheat"
     699}
     700serverconfig_VACEnabled_Type() {
     701        echo "boolean"
     702}
     703serverconfig_VACEnabled_Default() {
     704        echo "true"
     705}
     706serverconfig_VACEnabled_ErrorMessage() {
     707        echo "Not a valid boolean given (true/false or yes/no or y/n)."
     708}
     709
     710
    686711
    687712
     
    696721        for CV in \
    697722                        ServerName ServerPassword ServerIsPublic ServerPort ServerMaxPlayerCount \
    698                         DisableNAT \
     723                        DisableNAT VACEnabled MaxSpawnedZombies \
    699724                        ; do
    700725                $1 $CV
Note: See TracChangeset for help on using the changeset viewer.