-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlauncher.sh
More file actions
executable file
·59 lines (51 loc) · 1.05 KB
/
launcher.sh
File metadata and controls
executable file
·59 lines (51 loc) · 1.05 KB
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
#!/bin/bash
agents=5
ipbyagent=0
hostname="mickael"
lcount=$(cat config-save | wc -w)
cp config-save config.tmp
echo -n "password : "
read -s input
echo ""
if [ $agents -lt $lcount ]
then
ipbyagent=$((($lcount)/($agents)))
else
ipbyagent=1
fi
for i in $(seq $agents)
do
cp analyze.sh "$i-analyze.tmp.sh"
ips=$(cat config.tmp | wc -w)
if [ $i -eq $agents ] && [ $ips -gt $ipbyagent ]
then
ipbyagent=$(($ipbyagent+1))
fi
for z in $(seq $ipbyagent)
do
ips=$(cat config.tmp | wc -w)
if [ $ips -ne 0 ]
then
if [ $ips -gt 1 ]
then
rline=$((($RANDOM%($ips))+1))
else
rline=1
fi
#echo "ips=$ips;rline=$rline"
ip=$(sed -n $rline"p" config.tmp)
sed -i $rline"d" config.tmp
echo "$hostname@$ip"
#echo "$hostname@$ip" >> "$i-config.tmp"
fi
done
#(./agent.sh $i $input $hostname > /dev/null) &
pids[${i}]=$!
echo "Launching agent $i at $(date +'%H:%M:%S') PID=$!"
done
echo "Waiting for processes to finish..."
for pid in ${pids[*]}
do
wait $pid
done
rm config.tmp