Changeset 14 for scripts/usr
- Timestamp:
- May 17, 2014, 6:01:31 PM (11 years ago)
- Location:
- scripts/usr/local/bin
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
scripts/usr/local/bin/7dtd-backup.sh
r10 r14 1 1 #!/bin/bash 2 # Version 12 # Version 3 3 3 . /etc/7dtd.conf 4 4 -
scripts/usr/local/bin/7dtd-common.sh
r13 r14 1 1 #!/bin/bash 2 # Version 22 # Version 3 3 3 4 4 # Provides common functions for 7dtd-scripts. Not intended to be run directly. … … 23 23 24 24 # Check if the given instance name is an existing instance 25 # On failure exit the script!26 25 # Params: 27 26 # 1: Instance name 28 checkInstance() { 27 # Returns: 28 # 0/1 instance not valid/valid 29 isValidInstance() { 29 30 if [ -z $1 ]; then 30 echo "No instance given!" 31 exit 2 31 echo 0 32 else 33 if [ ! -d $(getInstancePath $1) ]; then 34 echo 0 35 else 36 if [ ! -f $(getInstancePath $1)/config.xml ]; then 37 echo 0 38 else 39 echo 1 40 fi 41 fi 32 42 fi 33 if [ ! -d $(getInstancePath $1) ]; then 34 echo "Instance $1 does not exist!" 35 exit 3 43 } 44 45 # Check if the given instance is valid, exit the script otherwise 46 # Params: 47 # 1: instance name 48 checkInstanceValid() { 49 if [ -z $1 ]; then 50 echo "Missing parameter <instance>" 51 exit 1 52 fi 53 if [ $(isValidInstance $1) -eq 0 ]; then 54 echo "'$1' is not a valid instance" 55 exit 1 36 56 fi 37 57 } … … 50 70 echo 0 51 71 fi 72 } 73 74 # Get list of defined instances 75 # Returns: 76 # List of instances 77 getInstanceList() { 78 for IF in $SDTD_BASE/instances/*; do 79 I=`basename $IF` 80 if [ $(isValidInstance $I) -eq 1 ]; then 81 echo $I 82 fi 83 done 52 84 } 53 85 … … 74 106 # Property value 75 107 getConfigValue() { 76 CONF=$(getInstancePath $1)/ serverconfig.xml77 xml lint --xpath "string(/ServerSettings/property[@name='$2']/@value)" $CONF108 CONF=$(getInstancePath $1)/config.xml 109 xmlstarlet sel -t -v "/ServerSettings/property[@name='$2']/@value" $CONF 78 110 } 79 111 -
scripts/usr/local/bin/7dtd-instances.sh
r13 r14 1 1 #!/bin/bash 2 # Version 22 # Version 3 3 3 4 4 # Lists available 7dtd instances. … … 13 13 printf -v line "%*s-+-%*s-+-%*s-+-%*s\n" 20 " " 8 " " 7 " " 5 " " 14 14 echo ${line// /-} 15 for I in $SDTD_BASE/instances/*; do 16 ins=`basename $I` 17 run=$(isRunning $ins) 15 for I in $(getInstanceList); do 16 run=$(isRunning $I) 18 17 if [ $run -eq 1 ]; then 19 18 run="yes" 20 tel=$(telnetCommand $ inslp)19 tel=$(telnetCommand $I lp) 21 20 cur=`echo $tel | sed "s/\r/\n/g" | sed "s/^ //g" | grep "Total of " | cut -d\ -f 3` 22 21 else 23 22 run="no" 24 cur= 023 cur="-" 25 24 fi 26 25 27 max=$(getConfigValue $ insServerMaxPlayerCount)28 port=$(getConfigValue $ insServerPort)26 max=$(getConfigValue $I ServerMaxPlayerCount) 27 port=$(getConfigValue $I ServerPort) 29 28 30 printf "%-*s | %*s | %2 d/%2d | %5d\n" 20 "$ins" 8 "$run" $cur $max $port29 printf "%-*s | %*s | %2s/%2d | %5d\n" 20 "$I" 8 "$run" $cur $max $port 31 30 done 32 31 exit 0 … … 34 33 35 34 showInfo() { 36 if [ -z $1 ]; then 37 echo "Missing parameter <instance>" 38 exit 1 39 fi 40 checkInstance $1 35 checkInstanceValid $1 41 36 42 37 line() { -
scripts/usr/local/bin/7dtd-kill.sh
r11 r14 1 1 #!/bin/bash 2 # Version 12 # Version 3 3 3 4 4 # Tries to stop the 7dtd instance given as first parameter. … … 12 12 checkRootLoadConf 13 13 14 checkInstance $114 checkInstanceValid $1 15 15 16 16 res=$(isRunning $1) 17 17 if [ $res -eq 1 ]; then 18 telnetCommand $1 shutdown 19 sleep 1 20 res=$(isRunning $1) 21 if [ $res -eq 1 ]; then 18 echo "Trying to gracefully shutdown..." 19 tmp=$(telnetCommand $1 shutdown) 20 echo "Waiting for server to shut down..." 21 22 waittime=0 23 maxwait=5 24 until [ $(isRunning $1) -eq 0 ] || [ $waittime -eq $maxwait ]; do 25 (( waittime++ )) 26 sleep 1 27 echo $waittime/$maxwait 28 done 29 30 if [ $(isRunning $1) -eq 1 ]; then 31 echo "Failed, force closing server..." 22 32 start-stop-daemon --stop --pidfile $(getInstancePath $1)/7dtd.pid 23 33 fi -
scripts/usr/local/bin/7dtd-running.sh
r10 r14 1 1 #!/bin/bash 2 # Version 12 # Version 3 3 3 4 4 # Checks if the 7dtd instance given as first parameter is running. … … 12 12 checkRootLoadConf 13 13 14 checkInstance $114 checkInstanceValid $1 15 15 16 16 res=$(isRunning $1) -
scripts/usr/local/bin/7dtd-start.sh
r12 r14 1 1 #!/bin/bash 2 # Version 12 # Version 3 3 3 4 4 # Tries to start the 7dtd instance given as first parameter. … … 13 13 checkRootLoadConf 14 14 15 checkInstance $115 checkInstanceValid $1 16 16 17 17 res=$(isRunning $1) … … 27 27 SSD_DAEMON="--background --no-close" 28 28 SSD_USER="--chuid $SDTD_USER:$SDTD_GROUP --user $SDTD_USER" 29 OPTS="-quit -batchmode -nographics -configfile=$(getInstancePath $1)/ serverconfig.xml -dedicated"29 OPTS="-quit -batchmode -nographics -configfile=$(getInstancePath $1)/config.xml -dedicated" 30 30 31 31 start-stop-daemon --start $SSD_PID $SSD_DAEMON $SSD_USER --chdir $SDTD_ROOT --exec $WINE -- $SDTD_ROOT/7DaysToDie.exe $OPTS > $(getInstancePath $1)/stdout.log 2>&1 -
scripts/usr/local/bin/7dtd-update.sh
r10 r14 1 1 #!/bin/bash 2 # Version 12 # Version 3 3 3 4 4 . /usr/local/bin/7dtd-common.sh
Note:
See TracChangeset
for help on using the changeset viewer.