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

Last change on this file since 501 was 483, checked in by alloc, 14 months ago

Scripts

File size: 2.2 KB
RevLine 
[17]1#!/bin/bash
2
[258]3# Copyright 2016 Christian 'Alloc' Illy
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17
18
[17]19# Print status of given instance.
20
21sdtdCommandStatus() {
22 if [ $(isValidInstance $1) -eq 0 ]; then
23 echo "No instance given or not a valid instance!"
24 return
25 fi
26
27 line() {
28 printf " %-*s %s\n" 15 "$1" "$2"
29 }
30
31 echo "Instance: $1"
32 echo
33
34 if [ $(isRunning $1) -eq 1 ]; then
35 echo "Status: Running"
36 echo "Open ports:"
37 netstat -nlp | grep $(getInstancePID $1) | sed -r 's/^([^ ]*)\s+.*[^ :]*:([^ ]*).*[^ :]*:[^ ]*.*/ \2 (\1)/g' | sort
[248]38 cur=$(telnetCommand $1 lp | grep -aE "^\s?Total of " | cut -d\ -f 3)
[17]39 echo "Players: $cur"
40 else
41 echo "Status: NOT running"
42 fi
43
44 echo
45 echo "Game info:"
[58]46 line "Server name:" "$(getConfigValue $1 ServerName)"
47 line "Password:" "$(getConfigValue $1 ServerPassword)"
48 line "Max players:" "$(getConfigValue $1 ServerMaxPlayerCount)"
49 line "World:" "$(getConfigValue $1 GameWorld)"
[17]50
51 echo
52 echo "Network info:"
[58]53 line "Port:" "$(getConfigValue $1 ServerPort)"
54 line "Public:" "$(getConfigValue $1 ServerIsPublic)"
[483]55 if [ "$(getConfigValue $1 WebDashboardEnabled)" = "false" ]; then
56 cp="disabled"
[17]57 else
[483]58 cp="$(getConfigValue $1 WebDashboardPort)"
[17]59 fi
60 line "Control Panel:" "$cp"
61 if [ "$(getConfigValue $1 TelnetEnabled)" = "false" ]; then
62 tn="off"
63 else
[483]64 tn="Port $(getConfigValue $1 TelnetPort), Pass '$(getConfigValue $1 TelnetPassword)'"
[17]65 fi
66 line "Telnet:" "$tn"
67
68 echo
69}
70
71sdtdCommandStatusHelp() {
72 echo "Usage: $(basename $0) status <instance>"
73 echo
74 echo "Print status information for the given instance."
75}
76
77sdtdCommandStatusDescription() {
78 echo "Print status for the given instance"
79}
80
81sdtdCommandStatusExpects() {
82 case $1 in
83 2)
84 getInstanceList
85 ;;
86 esac
87}
88
Note: See TracBrowser for help on using the repository browser.