blob: 0f799386f4a6c2c2acf380f79749c6a2ae25ed5c (
plain)
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
|
# larch handlers for rc. script hooks
# 2010.10.14
sysinit_premount_larch() {
# status "larch sysinit_premount hook"
# # Rebuild /etc/mtab
# grep "^aufs */ " /proc/mounts >/etc/mtab.new
# grep "^tmpfs */.livesys " /proc/mounts >>/etc/mtab.new
# if [ -d /.livesys/medium/larch ]; then
# grep " /.livesys/medium " /proc/mounts >>/etc/mtab.new
# fi
# grep -v "^rootfs " /etc/mtab >>/etc/mtab.new
# mv /etc/mtab.new /etc/mtab
# Add disk partitions to /etc/fstab
x10d_fstab
}
#add_hook sysinit_premount sysinit_premount_larch
sysinit_end_larch() {
# Allow setting up of xorg.conf before xorg is started
#status "larch sysinit_end hook"
[ -x /etc/X11/xinit/xorg.conf.set ] && /etc/X11/xinit/xorg.conf.set
}
add_hook sysinit_end sysinit_end_larch
shutdown_postkillall_larch() {
#status "larch shutdown_postkillall hook"
if ! [ -f /.livesys/saveclock ]; then
# This will prevent the hardware clock from being set
HARDWARECLOCK='LIVE'
fi
}
add_hook shutdown_postkillall shutdown_postkillall_larch
shutdown_poweroff_larch() {
#status "larch shutdown_poweroff hook"
# This shouldn't be needed, but better safe than sorry?
sync
# Eject CD/DVD
############################# Deal with ejecting
# See if boot device still mounted and ejectable (CD/DVD)
bootdev=$( cat /.livesys/bootdevice )
if [ -f /proc/sys/dev/cdrom/info ]; then
cdroms=$( cat /proc/sys/dev/cdrom/info | { while read a b c; do
if [ "${a}" = "drive" -a "${b}" = "name:" ]; then
echo "${c}"
break
fi
done
} )
for d in ${cdroms}; do
if [ "/dev/${d}" = "${bootdev}" ]; then
# booted from CD/DVD
if grep "^${bootdev} " /proc/mounts &>/dev/null; then
# it needs to be ejected
doeject ${bootdev}
fi
break
fi
done
fi
}
add_hook shutdown_poweroff shutdown_poweroff_larch
doeject ()
{
echo "Ejecting live CD"
mount -n -o remount,rw /
# Remove the boot medium from /etc/mtab so that eject works
sed "/ \/.livesys\/medium / d" -i /etc/mtab
eject $1
mount -n -o remount,ro /
# echo "========================================"
# echo "It's safe to switch the computer off now"
# echo -ne "Press Enter to continue"
# read junk
for i in 10 9 8 7 6 5 4 3 2 1
do
read -t 1 -p "press any key to continue ($i): "
if [ $? = 0 ]
then
break
fi
printf "\r"
done
eject -t $1
}
|