-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathS99keytest
More file actions
executable file
·133 lines (111 loc) · 3.17 KB
/
S99keytest
File metadata and controls
executable file
·133 lines (111 loc) · 3.17 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#! /bin/sh
### BEGIN INIT INFO
# Provides: keytest
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 1
# Short-Description: Keytest random key press generator and crash logger.
### END INIT INFO
D=8 #DISPLAY
set -e
set -x
. /lib/lsb/init-functions
KT=/mnt/big/keytest
KT=`pwd` # HACK!
TMPFS=$KT/tmpfs
export TMPDIR=$TMPFS
if [ -e ./etc/keytest/rc ]
then
. ./etc/keytest/rc
fi
if [ -e ./etc/keytest/dir ]
then
KT=`cat ./etc/keytest/dir`
fi
rm $KT/tmpfs/nohup.log || true
mkdir -p $TMPFS
chown keytest $TMPFS
chmod g+wx $TMPFS
stop () {
echo stop
sudo -H -u keytest killall Xvfb || true
sleep 1
sudo -H -u keytest $KT/killtest.sh || true
#(cd /mnt/big/xp/images/share/Ubuntu904/keytest &&
(cd $KT &&
sudo -H -u keytest ./store_task_data.sh
)
kill `ps gaux | grep "^keytest " | awk '{print $2}'` || true
sleep 1
sudo -H -u keytest killall -9 Xvfb || true
killall cyclelog.sh || true
kill -9 `ps gaux | grep "^keytest " | awk '{print $2}'` || true
}
start () {
echo start
# We now set TMPDIR, so hopefully we do not create /tmp/.X11-unix/
while false #[ ! -e /tmp/.X11-unix/ ]
do
# We don't want keytest to take ownership of /tmp/.X11-unix/
# Ubuntu 9.10 finds this suspcious and refuses to launch
# Main X server
echo waiting for /tmp/.X11-unix/ to be created
sleep 3
done
if ! mount | grep `readlink -f $TMPFS`
then
echo mount tmpfs $TMPFS tmpfs -o size=400m
mount tmpfs $TMPFS -t tmpfs -o size=400m
fi
echo making tmpfs/CRITICAL as $USER #!!!!!!!!
touch tmpfs/CRITICAL
chown keytest tmpfs/CRITICAL
chgrp keytest tmpfs/CRITICAL
chmod g+rwx tmpfs/CRITICAL
echo DONE
(cd $KT
OUT_NAME=`grep ^OUT_NAME= shared_variables.sh | sed s/^OUT_NAME=//`
sudo -H -u keytest ./setup_out_dir.sh
#The following may be overkill, now use the above instead
#(find $OUT_NAME; find tmpfs/) | while read F
#do
#chgrp keytest "$F" || true
#chmod g+w "$F" || true
#done
mkdir -p "$OUT_NAME"
chgrp keytest "$OUT_NAME" || true
chmod g+w "$OUT_NAME"
echo PWD `pwd`
sudo -H -u keytest ./sanity_check.sh && (
#sudo -H -u keytest nice -19 nohup bash ./initXvfb 1 bash ./main.sh >> /dev/null &
echo STARTING
ps gaux | grep -v grep | grep kill_too_much_mem || ( ./kill_too_much_mem.sh & )
killall cyclelog.sh || true
(sudo -H -u keytest nice -19 ionice -c 3 nohup bash ./initXvfb 8 bash ./main.sh | ./cyclelog.sh tmpfs/nohup.log) 2> /dev/null > /devnull &
#sudo -H -u keytest nice -19 ionice -c 3 nohup bash ./initXvfb 8 bash ./main.sh > tmpfs/nohup.log &
)
#sudo -H -u keytest nice -19 ionice -c 3 nohup bash ./initXvfb 1 bash ./main.sh >> tmpfs/nohup.log &
)
}
case "$1" in
start)
#log_daemon_msg "Starting Keytest" "keytest"
stop #should maybe just do nothing if already started but definitly do not want two running
start
;;
stop)
#log_daemon_msg "Stopping Keytest" "keytest"
stop
;;
reload|force-reload|restart|try-restart)
stop
start
;;
#status)
*)
#log_action_msg "Usage: $0 {start|stop|reload|force-reload|restart|try-restart|status}"
log_action_msg "Usage: $0 {start|stop|reload|force-reload|restart|try-restart}"
exit 1
esac
exit 0