source: scripts/usr/local/lib/7dtd/commands/status.sh@ 67

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

Version 17: Fix display of server name with blanks in status

File size: 1.7 KB
RevLine 
[17]1#!/bin/bash
2
3# Print status of given instance.
4
5sdtdCommandStatus() {
6 if [ $(isValidInstance $1) -eq 0 ]; then
7 echo "No instance given or not a valid instance!"
8 return
9 fi
10
11 line() {
12 printf " %-*s %s\n" 15 "$1" "$2"
13 }
14
15 echo "Instance: $1"
16 echo
17
18 if [ $(isRunning $1) -eq 1 ]; then
19 echo "Status: Running"
20 echo "Open ports:"
21 netstat -nlp | grep $(getInstancePID $1) | sed -r 's/^([^ ]*)\s+.*[^ :]*:([^ ]*).*[^ :]*:[^ ]*.*/ \2 (\1)/g' | sort
22 tel=$(telnetCommand $1 lp)
23 cur=`echo $tel | sed "s/\r/\n/g" | sed "s/^ //g" | grep "Total of " | cut -d\ -f 3`
24 echo "Players: $cur"
25 else
26 echo "Status: NOT running"
27 fi
28
29 echo
30 echo "Game info:"
[58]31 line "Server name:" "$(getConfigValue $1 ServerName)"
32 line "Password:" "$(getConfigValue $1 ServerPassword)"
33 line "Max players:" "$(getConfigValue $1 ServerMaxPlayerCount)"
34 line "World:" "$(getConfigValue $1 GameWorld)"
[17]35
36 echo
37 echo "Network info:"
[58]38 line "Port:" "$(getConfigValue $1 ServerPort)"
39 line "Public:" "$(getConfigValue $1 ServerIsPublic)"
[17]40 if [ "$(getConfigValue $1 ControlPanelEnabled)" = "false" ]; then
41 cp="off"
42 else
43 cp="Port $(getConfigValue $1 ControlPanelPort), Pass $(getConfigValue $1 ControlPanelPassword)"
44 fi
45 line "Control Panel:" "$cp"
46 if [ "$(getConfigValue $1 TelnetEnabled)" = "false" ]; then
47 tn="off"
48 else
49 tn="Port $(getConfigValue $1 TelnetPort), Pass $(getConfigValue $1 TelnetPassword)"
50 fi
51 line "Telnet:" "$tn"
52
53 echo
54}
55
56sdtdCommandStatusHelp() {
57 echo "Usage: $(basename $0) status <instance>"
58 echo
59 echo "Print status information for the given instance."
60}
61
62sdtdCommandStatusDescription() {
63 echo "Print status for the given instance"
64}
65
66sdtdCommandStatusExpects() {
67 case $1 in
68 2)
69 getInstanceList
70 ;;
71 esac
72}
73
Note: See TracBrowser for help on using the repository browser.