-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbaobab.firefox.script
executable file
·69 lines (58 loc) · 1.99 KB
/
baobab.firefox.script
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
#!/bin/bash
IP=$1
FIREFOX_DIR="/home/firefox"
FIREFOX_PROFILE_DIR="/home/firefox/.mozilla/firefox"
childfinished() {
child=1
}
while /bin/true; do
# set display
export DISPLAY=${IP}:0.0
#cleanup existing profile
rm -rf $FIREFOX_PROFILE_DIR/${IP}
mkdir -p $FIREFOX_PROFILE_DIR/${IP}
#Create profile
tar -zxf $FIREFOX_DIR/default.profile.tgz -C $FIREFOX_PROFILE_DIR/${IP}
# rewrite profile.ini
echo "[General]" > $FIREFOX_PROFILE_DIR/profiles.ini
echo "StartWithLastProfile=1" >> $FIREFOX_PROFILE_DIR/profiles.ini
echo "" >> $FIREFOX_PROFILE_DIR/profiles.ini
echo "[Profile0]" >> $FIREFOX_PROFILE_DIR/profiles.ini
echo "Name=default" >> $FIREFOX_PROFILE_DIR/profiles.ini
echo "IsRelative=1" >> $FIREFOX_PROFILE_DIR/profiles.ini
echo "Path=none" >> $FIREFOX_PROFILE_DIR/profiles.ini
echo "" >> $FIREFOX_PROFILE_DIR/profiles.ini
echo "[Profile1]" >> $FIREFOX_PROFILE_DIR/profiles.ini
echo "IsRelative=1" >> $FIREFOX_PROFILE_DIR/profiles.ini
echo "Default=1" >> $FIREFOX_PROFILE_DIR/profiles.ini
echo "Path=${IP}" >> $FIREFOX_PROFILE_DIR/profiles.ini
echo "Name=${IP}" >> $FIREFOX_PROFILE_DIR/profiles.ini
set -bm
done=0
child=0
trap 'childfinished' SIGCHLD
/usr/bin/firefox -fullscreen -P ${IP} &
while (( done == 0 )); do
if (( child == 1 )); then
done=1;
else
# ping machine to see if it's still there
# (firefox crash)
results=`ping -w 3 ${IP} | grep "0 received"`
if [ -n "results" ]; then
exit
fi
fi
done;
#cleanup existing profile
rm -rf $FIREFOX_PROFILE_DIR/${IP}
# ping machine to see if it's still there
# (firefox crash)
results=`ping -w 3 ${IP} | grep "0 received"`
# if string not empty (nonzero)
if [ -n "$results" ]; then
pid=`ps aux | grep firefox | grep ${IP} | sed 's/ */ /g' | cut -f2 -d' '`
kill -9 ${pid}
exit
fi
done;