-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathalpine.conf
61 lines (51 loc) · 1.51 KB
/
alpine.conf
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
pre-start script
echo "Log from $(date)" > /mnt/us/alpine.log
exec >>/mnt/us/alpine.log 2>&1
echo "# Alpine ::: pre-start script"
echo "Starting alpine linux"
mkdir -p /tmp/alpine
mount -o loop,noatime -t ext3 /mnt/base-us/alpine.ext3 /tmp/alpine
mount -o bind /dev /tmp/alpine/dev
mount -o bind /dev/pts /tmp/alpine/dev/pts
mount -o bind /proc /tmp/alpine/proc
mount -o bind /sys /tmp/alpine/sys
mount -o bind /var/run/dbus/ /tmp/alpine/run/dbus/
cp /etc/hosts /tmp/alpine/etc/hosts
chmod a+w /dev/shm
end script
script
exec >>/mnt/us/alpine.log 2>&1
echo "# Alpine ::: script"
sleep 1
stop lab126_gui
su -c "chroot /tmp/alpine /startgui.sh"
kill $(pgrep Xephyr)
kill -9 $(lsof -t /var/tmp/alpine/)
end script
post-stop script
exec >>/mnt/us/alpine.log 2>&1
echo "# Alpine ::: post-stop script"
echo "Unmounting Alpine rootfs"
LOOPDEV="$(mount | grep loop | grep /tmp/alpine | cut -d" " -f1)"
umount /tmp/alpine/run/dbus/
umount /tmp/alpine/sys
sleep 1
umount /tmp/alpine/proc
umount /tmp/alpine/dev/pts
umount /tmp/alpine/dev
# Sync beforehand so umount doesn't fail due to the device being busy still
sync
umount /tmp/alpine || true
# Sometimes it fails still and only works by trying again
while [ "$(mount | grep /tmp/alpine)" ]
do
echo "Alpine is still mounted, trying again shortly.."
sleep 3
umount /tmp/alpine || true
done
echo "Alpine unmounted"
echo "Disassociating loop device >>$LOOPDEV<<"
losetup -d $LOOPDEV
echo "All done, starting kindle's gui."
start lab126_gui
end script