forked from paxed/dgamelaunch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stresstest_create.sh
executable file
·59 lines (56 loc) · 1.63 KB
/
stresstest_create.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
#!/bin/sh
# stress-test script for creation of new accounts
# current directory must contain the dgamelaunch to be used
# this thing eats pseudo-terminals like hell!
# Be sure to change these variables
conffile="test2.conf"
chrootdir="chroot-2"
hackdir="/usr/local/lib/nethack"
nameprefix="testcreat"
jailuser="dgl"
jailgroup="dgl"
max=40
# clean up previous cruft
#rm -f "$chrootdir"/dgldir/inprogress/*
#rm -f "$chrootdir$hackdir"/save/*[0-9]test[0-9]*
echo -n "Starting processes:"
export conffile i nameprefix delay1 delay2 email
i=1
pidlist=''
while [ $i -le $max ]; do
email="[email protected]"
case "$i" in
*[125]) delay1=0.1 delay2=0.1 ;;
*[368]) delay1=0.1 delay2=0.1 ;;
*[470]) delay1=0.1 delay2=0.1 ;;
*9) delay1=0.1 delay2=0.1 email='' ;;
esac
xterm -e sh -c '{ sleep 1; echo "r$nameprefix$i"; echo aa; echo aa; sleep $delay1; echo "$email"; sleep $delay2; echo -n py i; cat; } | { ./dgamelaunch -f "$conffile"; echo $?; } '&
echo -n " $!"
pidlist="$pidlist $!"
[ $i = 5 ] && sleep 0.1
[ $i = 15 ] && sleep 0.3
[ $i = 25 ] && sleep 1
[ $i = 31 ] && sleep 4
i=$(($i+1))
done
echo
sleep 10
nums=$(sed -n -e "s/^$nameprefix\([0-9]*\):.*:.*:.*/\1/p" $chrootdir/dgl-login |
sort -n | xargs)
allnums=$(jot $max | grep -v 9\$ | xargs)
if [ "$nums" = "$allnums" ]; then
echo "Complete list"
rc=0
else
echo "ERROR: Incomplete list!"
echo "$nums"
rc=1
fi
sed -e "/^$nameprefix\([0-9]*\):.*:.*:.*/d" $chrootdir/dgl-login > $chrootdir/dgl-login.new
mv $chrootdir/dgl-login.new $chrootdir/dgl-login
chown $jailuser:$jailgroup $chrootdir/dgl-login
echo -n "Press return to remove all xterms: "
read x
kill $pidlist 2>/dev/null
exit $rc