-
Notifications
You must be signed in to change notification settings - Fork 7
/
servers.sh
executable file
·74 lines (59 loc) · 1.58 KB
/
servers.sh
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
#!/bin/bash
# This script will start a given number of Tweak Battle servers
# You can customize the nr of servers to run and the starting
# range of the TCP/IP ports. ps: 48 is nice since we have 16 levels.
# usage: bash servers.sh
# or: bash servers.sh preserve
#
# preservation flag will make sure the servers that are already running
# will keep running
if [ "$1" != "preserve" ]; then
# Kill all running servers
killall -9 smashbattle
# Wait for it ...
sleep 2
fi
# Number of servers we want to start
servercount=32
# Define a starting port
port=2000
# Define array of maps
levels=(
"TRAINING DOJO"
"PLATFORM ALLEY"
"PITTFALL"
"DUCK'N'HUNT"
"COMMON GROUNDS"
"POGOSTICK"
"LA MOUSTACHE"
"THE FUNNEL"
"BLAST BOWL"
"PIT OF DEATH"
"RABBIT HOLE"
"STAY HIGH"
"PIE PIT"
"SLIP'N'SLIDE"
"BOULDERDASH"
"SNOW FIGHT"
)
# Counter to display nr of servers
count=0
# Reset counter for levels array
levelcount=0
while [ $count -lt $servercount ]; do
# Launch a server
printf "Starting Tweak Battle Server #$count \n"
if [ "$1" != "preserve" ]; then
(daemon -- smashbattle -s "${levels[$levelcount]}" $port "${levels[$levelcount]}" > /var/log/smashbattle/server-${count}) &
else
check_running=$(ps axufw |grep daemon|grep smashbattle|grep " $port ")
if [ "$check_running" == "" ]; then
(daemon -- smashbattle -s "${levels[$levelcount]}" $port "${levels[$levelcount]}" >> /var/log/smashbattle/server-${count}) &
fi
fi
sleep 1
# Increment port, loopcount and count
port=$((port+1))
count=$((count+1))
levelcount=$(((levelcount+1) % 16))
done