| 1 | #!/bin/bash
 | 
|---|
| 2 | 
 | 
|---|
| 3 | # Print status of given instance.
 | 
|---|
| 4 | 
 | 
|---|
| 5 | sdtdCommandStatus() {
 | 
|---|
| 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 |                 cur=$(telnetCommand $1 lp | grep -aE "^\s?Total of " | cut -d\  -f 3)
 | 
|---|
| 23 |                 echo "Players: $cur"
 | 
|---|
| 24 |         else
 | 
|---|
| 25 |                 echo "Status: NOT running"
 | 
|---|
| 26 |         fi
 | 
|---|
| 27 | 
 | 
|---|
| 28 |         echo
 | 
|---|
| 29 |         echo "Game info:"
 | 
|---|
| 30 |         line "Server name:" "$(getConfigValue $1 ServerName)"
 | 
|---|
| 31 |         line "Password:" "$(getConfigValue $1 ServerPassword)"
 | 
|---|
| 32 |         line "Max players:" "$(getConfigValue $1 ServerMaxPlayerCount)"
 | 
|---|
| 33 |         line "World:" "$(getConfigValue $1 GameWorld)"
 | 
|---|
| 34 | 
 | 
|---|
| 35 |         echo
 | 
|---|
| 36 |         echo "Network info:"
 | 
|---|
| 37 |         line "Port:" "$(getConfigValue $1 ServerPort)"
 | 
|---|
| 38 |         line "Public:" "$(getConfigValue $1 ServerIsPublic)"
 | 
|---|
| 39 |         if [ "$(getConfigValue $1 ControlPanelEnabled)" = "false" ]; then
 | 
|---|
| 40 |                 cp="off"
 | 
|---|
| 41 |         else
 | 
|---|
| 42 |                 cp="Port $(getConfigValue $1 ControlPanelPort), Pass $(getConfigValue $1 ControlPanelPassword)"
 | 
|---|
| 43 |         fi
 | 
|---|
| 44 |         line "Control Panel:" "$cp"
 | 
|---|
| 45 |         if [ "$(getConfigValue $1 TelnetEnabled)" = "false" ]; then
 | 
|---|
| 46 |                 tn="off"
 | 
|---|
| 47 |         else
 | 
|---|
| 48 |                 tn="Port $(getConfigValue $1 TelnetPort), Pass $(getConfigValue $1 TelnetPassword)"
 | 
|---|
| 49 |         fi
 | 
|---|
| 50 |         line "Telnet:" "$tn"
 | 
|---|
| 51 | 
 | 
|---|
| 52 |         echo
 | 
|---|
| 53 | }
 | 
|---|
| 54 | 
 | 
|---|
| 55 | sdtdCommandStatusHelp() {
 | 
|---|
| 56 |         echo "Usage: $(basename $0) status <instance>"
 | 
|---|
| 57 |         echo
 | 
|---|
| 58 |         echo "Print status information for the given instance."
 | 
|---|
| 59 | }
 | 
|---|
| 60 | 
 | 
|---|
| 61 | sdtdCommandStatusDescription() {
 | 
|---|
| 62 |         echo "Print status for the given instance"
 | 
|---|
| 63 | }
 | 
|---|
| 64 | 
 | 
|---|
| 65 | sdtdCommandStatusExpects() {
 | 
|---|
| 66 |         case $1 in
 | 
|---|
| 67 |                 2)
 | 
|---|
| 68 |                         getInstanceList
 | 
|---|
| 69 |                         ;;
 | 
|---|
| 70 |         esac
 | 
|---|
| 71 | }
 | 
|---|
| 72 | 
 | 
|---|