This repository was archived by the owner on Jul 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartup
executable file
·78 lines (64 loc) · 1.8 KB
/
startup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
#
#SWRiP startup script
#
# Set the port number.
port=7000
if [ -n "$1" ]; then
port=$1;
fi
# Obtain SWR base directory.
swrdir=.
if [ -n "$2" ]; then
swrdir=$2;
fi
# Check that startup script or game binary isn't already running.
[ -e $swrdir/log/startup.pid ] && if [ /proc/`cat $swrdir/log/startup.pid`/exe \
-ef $swrdir/startup ]; then
echo Error: Startup script already running.
exit 1
fi
[ -e $swrdir/log/current.log ] && if [ /proc/`sed "2,\\$d;s/^.*PID: //" \
$swrdir/log/current.log`/exe -ef $swrdir/swrip ]; then
echo Error: Game binary already running.
exit 1
fi
ulimit -s 1024
ulimit -c unlimited
rm -f shutdown.txt
# Write startup PID file.
echo $$ > ./log/startup.pid
(
until [ -e shutdown.txt ]; do
# If you want to have logs in a different directory,
# change the 'logfile=' line to reflect the directory name.
index=1000
while
logfile=./log/$index.log
[ -e $logfile ]
do
if [ $index -lt 1100 ]; then
let index=index+1
else
rm -f $logfile
fi
done
ln -sf $logfile ./log/current.log
# Record starting time
date > $logfile
date > ./log/boot.txt
# Run game.
nohup ./swrip $port >& $logfile
# make back up of bug log and start fresh
if [ -e $swrdir/data/bugs.txt ]; then
if [ -e $swrdir/data/bugs.txt.bak ]; then
rm $swrdir/data/bugs.txt.bak;
fi
mv $swrdir/data/bugs.txt $swrdir/data/bugs.txt.bak
touch $swrdir/data/bugs.txt
fi
# Restart, giving old connections a chance to die.
sleep 15
done
rm -f shutdown.txt ./log/current.log ./log/current.log.size ./log/startup.pid
)&