]> git.xonotic.org Git - xonotic/darkplaces.git/blob - crypto-keygen-standalone-brute.sh
Add cvar to disable engine stats >= 220. Suppresses warnings in Xonotic
[xonotic/darkplaces.git] / crypto-keygen-standalone-brute.sh
1 #!/bin/sh
2
3 outfile=$1; shift
4 hosts=$1; shift
5
6 on()
7 {
8         case "$1" in
9                 localhost)
10                         shift
11                         exec "$@"
12                         ;;
13                 *)
14                         exec ssh "$@"
15                         ;;
16         esac
17 }
18
19 pids=
20 mainpid=$$
21 trap 'kill $pids' EXIT
22 trap 'exit 1' INT USR1
23
24 n=0
25 for h in $hosts; do
26         nn=`on "$h" cat /proc/cpuinfo | grep -c '^processor[    :]'`
27         n=$(($nn + $n))
28 done
29
30 rm -f bruteforce-*
31 i=0
32 for h in $hosts; do
33         nn=`on "$h" cat /proc/cpuinfo | grep -c '^processor[    :]'`
34         ii=$(($nn + $i))
35         while [ $i -lt $ii ]; do
36                 i=$(($i+1))
37                 (
38                         on "$h" ./crypto-keygen-standalone -n $n -o /dev/stdout "$@" > bruteforce-$i &
39                         pid=$!
40                         trap 'kill $pid' TERM
41                         wait
42                         if [ -s "bruteforce-$i" ]; then
43                                 trap - TERM
44                                 mv "bruteforce-$i" "$outfile"
45                                 kill -USR1 $mainpid
46                         else
47                                 rm -f "bruteforce-$i"
48                         fi
49                 ) &
50                 pids="$pids $!"
51         done
52 done
53 wait