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

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

Version 5. Fixes #9, #11

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