source: scripts/usr/local/bin/7dtd-instances.sh @ 10

Last change on this file since 10 was 10, checked in by alloc, 9 years ago

Version 1

  • Property svn:executable set to *
File size: 651 bytes
Line 
1#!/bin/bash
2# Version 1
3
4# Lists available 7dtd instances.
5# Returns:
6#  0
7. /usr/local/bin/7dtd-common.sh
8checkRootLoadConf
9
10printf "%-*s | %-*s | %-*s\n" 20 "Instance name" 8 "Running" 7 "Players"
11printf -v line "%*s-+-%*s-+-%*s\n" 20 " " 8 " " 7 " "
12echo ${line// /-}
13for I in $SDTD_BASE/instances/*; do
14        ins=`basename $I`
15        run=$(isRunning $ins)
16        if [ $run -eq 1 ]; then
17                run="yes"
18        else
19                run="no"
20        fi
21
22        tel=$(telnetCommand $ins lp)
23        max=$(getConfigValue $ins ServerMaxPlayerCount)
24        cur=`echo $tel | sed "s/\r/\n/g" | sed "s/^ //g" | grep "Total of " | cut -d\  -f 3`
25       
26        printf "%-*s | %*s |   %2d/%2d\n" 20 "$ins" 8 "$run" $cur $max
27done
28exit 0
Note: See TracBrowser for help on using the repository browser.