-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmux
executable file
·48 lines (43 loc) · 1012 Bytes
/
mux
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
#! /bin/sh
. functions
while getopts 'ht:p:' OPTION ; do
case "$OPTION" in
h) help=$((1));;
t) start=$((1))
amount=$OPTARG;;
p) stop=$((1))
amount=$OPTARG;;
esac
done
if [ $help ]; then
echo '\n-t $number - starts $number bots\n'
echo '-p $number - stops $number bots\n'
echo '-h - shows this help\n'
elif [ $start ]; then
list="0 1 2 3 4 5 6 7 8 9 10 11"
counter=$((1))
once=$((0))
for i in $list; do
if [ "$amount" != "" ] && [ "$counter" -le "$amount" ]; then
screen -mdS newtonwars$i python newtonwars -r
#i=$(echo $!)
#echo "$i"
counter=$((counter + 1))
#echo $counter
elif [ "$amount" = "" ] && [ "$once" -eq 0 ]; then
echo "please specify the number of bots to be started"
once=$((1))
fi
done
screen -ls
elif [ $stop ]; then
counter=$((1))
screen=$(screen -ls | grep -oE "[0-9]*.newtonwars[0-9]*" | grep -oE "^[0-9]*")
for i in $screen; do
if [ "$counter" -le "$amount" ]; then
kill ${i}
counter=$((counter + 1))
fi
done
screen -ls
fi