Skip to content

Commit dc06450

Browse files
author
BuildTools
committed
Vesion 2.2 Log functions added
1 parent 8e40ca8 commit dc06450

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

server.sh

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
#
44
# Server startscript
55
#
6-
# ver 2.1
6+
# ver 2.2
77
#
88
#########################
99

1010
WHITE='\033[0;37m'
1111
GREEN='\033[0;32m'
1212
LRED='\033[1;31m'
1313

14+
PARAM2=$2
15+
1416
# config file for wait to stop server
1517
if [ -e "srv_cfg_stopsec.dat" ]; then
1618
STOPSEC=`cat srv_cfg_stopsec.dat | awk ' {print $1 }' | grep '^[0-9]'`
@@ -100,6 +102,41 @@ if [ -e /proc/$pid ]; then
100102
fi
101103
}
102104

105+
log(){
106+
if [ -e "$SZERVER.log" ]; then
107+
printf "${GREEN}"
108+
printf "Listing actual log file:\n"
109+
case "$PARAM2" in
110+
f)
111+
printf "Mode: follow, exit with ctrl\+c\n"
112+
printf "${WHITE}"
113+
tail -n40 -f $SZERVER.log
114+
exit 1
115+
;;
116+
t)
117+
printf "Mode: tail\n"
118+
printf "${WHITE}"
119+
tail -n40 $SZERVER.log
120+
exit 1
121+
;;
122+
*)
123+
# cat log file
124+
printf "Mode: tail\n"
125+
cat "$SZERVER.log"
126+
printf "${WHITE}"
127+
printf "\n"
128+
;;
129+
esac
130+
131+
else
132+
printf "${GREEN}"
133+
printf "Error: \"$SZERVER.log\" missing.\nExiting.\n\n"
134+
printf "${WHITE}"
135+
exit 1
136+
fi
137+
}
138+
139+
103140

104141
case "$1" in
105142
start)
@@ -115,8 +152,13 @@ fi
115152
debug)
116153
debug
117154
;;
155+
log)
156+
157+
log $2
158+
;;
118159
*)
119-
printf "${GREEN}Usage: $0 {start|stop|restart|debug}${WHITE}"
160+
printf "${GREEN}Usage: $0 {start|stop|restart|debug|log [f|t]}\n"
161+
printf "${WHITE}"
120162
exit 1
121163
;;
122164

0 commit comments

Comments
 (0)