5973d2002f48e532c026332da6287ac4008332be
[live-boot-grml.git] / hooks / live
1 #!/bin/sh
2
3 # initramfs hook for live-initramfs (Debian Live)
4
5 set -e
6
7 # initramfs-tools header
8
9 PREREQ=""
10
11 prereqs()
12 {
13         echo "${PREREQ}"
14 }
15
16 case "${1}" in
17         prereqs)
18                 prereqs
19                 exit 0
20                 ;;
21 esac
22
23 . /usr/share/initramfs-tools/hook-functions
24
25 # live-initramfs hook
26
27 # Handling live-initramfs
28
29 # Configuration
30 if [ -r /etc/live.conf ]
31 then
32         . /etc/live.conf
33
34         mkdir -p "${DESTDIR}"/etc
35         cp /etc/live.conf "${DESTDIR}"/etc
36 fi
37
38 mkdir -p "${DESTDIR}"/usr/share/live-initramfs
39 cp /usr/share/live-initramfs/languagelist "${DESTDIR}"/usr/share/live-initramfs
40
41 # Directories
42 mkdir -p "${DESTDIR}"/lib/live-initramfs
43
44 # Executables
45 copy_exec /usr/share/live-initramfs/live-reconfigure /bin
46 copy_exec /usr/share/live-initramfs/live-preseed /bin
47
48 # Scripts
49 cp /usr/share/initramfs-tools/scripts/live-functions "${DESTDIR}"/scripts
50 cp /usr/share/initramfs-tools/scripts/live-helpers "${DESTDIR}"/scripts
51
52 # klibc dependencies
53 for FILE in /lib/libacl* /lib/libblkid* /lib/libuuid* /lib/libdevmapper* /lib/libattr*
54 do
55         if [ ! -e "${DESTDIR}"/"${FILE}" ]
56         then
57                 cp -a "${FILE}" "${DESTDIR}"/"${FILE}"
58         fi
59 done
60
61 # udev dependencies (squeeze and newer)
62 for FILE in /lib/udev/*_id
63 do
64         if [ ! -e "${DESTDIR}/${FILE}" ]
65         then
66                 mkdir -p "${DESTDIR}/lib/udev"
67                 copy_exec "${FILE}" /lib/udev
68         fi
69 done
70
71 # Handling other stuff
72
73 # Configuration: keymap (usefull when using encryption)
74 if [ -x /bin/loadkeys ] && [ -r /etc/console/boottime.kmap.gz ]
75 then
76         copy_exec /bin/loadkeys /bin
77
78         mkdir -p "${DESTDIR}"/etc
79         cp /etc/console/boottime.kmap.gz "${DESTDIR}"/etc
80 fi
81
82 # Configuration: Unique ID
83 if [ -n "${LIVE_GENERATE_UUID}" ]
84 then
85         mkdir -p "${DESTDIR}"/conf
86         uuidgen -r > "${DESTDIR}"/conf/uuid.conf
87 fi
88
89 # Filesystem: cifs
90 if [ -x /sbin/mount.cifs ]
91 then
92         copy_exec /sbin/mount.cifs /sbin
93         manual_add_modules cifs
94 fi
95
96 # Filesystem: ext3/ext4
97 manual_add_modules ext3
98 manual_add_modules ext4
99
100 # Filesystem: jffs2
101 manual_add_modules jffs2
102
103 if [ -x /usr/bin/rsync ]
104 then
105         copy_exec /usr/bin/rsync /bin
106 fi
107
108 # Filesystem: squashfs
109 copy_exec /sbin/losetup /sbin
110 manual_add_modules loop
111 manual_add_modules squashfs
112 manual_add_modules sqlzma
113 manual_add_modules unlzma
114
115 # Filesystem: aufs/unionfs
116 manual_add_modules aufs
117 manual_add_modules unionfs
118
119 # Filesystem: unionfs-fuse
120 if [ -x /usr/bin/unionfs-fuse ]
121 then
122         copy_exec /usr/bin/unionfs-fuse /bin
123 fi
124
125 # Filesystem: vfat
126 manual_add_modules nls_cp437
127 manual_add_modules nls_iso8859-1
128 manual_add_modules nls_utf8
129 manual_add_modules vfat
130
131 # Filesystem: ntfs
132 manual_add_modules ntfs
133
134 # Hardware: cdrom
135 manual_add_modules ide-cd
136 manual_add_modules ide-generic
137 manual_add_modules ohci1394
138 manual_add_modules sbp2
139 manual_add_modules sr_mod
140
141 # Hardware: usb
142 manual_add_modules sd_mod
143
144 # Hardware: network
145 auto_add_modules net
146
147 # Program: eject
148 if [ -x /usr/bin/eject ]
149 then
150         copy_exec /usr/bin/eject /bin
151 fi
152
153 # Program: md5sum
154 copy_exec /usr/bin/md5sum /bin
155
156 # Program: cpio
157 # busybox and klibc lacks --no-absolute-filenames and --sparse, needed for snapshots
158 if [ -e "${DESTDIR}/bin/cpio" ]
159 then
160         # Override already present cpio's, mostly klibc's
161         rm "${DESTDIR}/bin/cpio"
162 fi
163 copy_exec /bin/cpio /bin
164
165 # Program: udev
166 if [ -x /sbin/udevadm ]
167 then
168         # lenny
169         copy_exec /sbin/udevadm /sbin
170 else
171         # etch
172         copy_exec /sbin/udevtrigger /sbin
173         copy_exec /sbin/udevsettle /sbin
174 fi
175 if [ -x /usr/bin/udevinfo ]
176 then
177         copy_exec /usr/bin/udevinfo /bin
178 fi
179
180 # Program: wget
181 if [ -x /usr/bin/wget ]
182 then
183         copy_exec /usr/bin/wget /bin
184 fi
185
186 # Program: blockdev
187 if [ -x /sbin/blockdev ]
188 then
189         copy_exec /sbin/blockdev /sbin
190 fi
191
192 # FUSE kernel module
193 manual_add_modules fuse
194
195 # FUSE filesystem: httpfs2
196 if [ -x /usr/bin/httpfs2_ssl ]
197 then
198         copy_exec /usr/bin/httpfs2_ssl /bin/httpfs
199 elif [ -x /usr/bin/httpfs2 ]
200 then
201         copy_exec /usr/bin/httpfs2 /bin/httpfs
202 fi
203
204 # FUSE filesystem: curlftpfs
205 if [ -x /usr/bin/curlftpfs ]
206 then
207         copy_exec /usr/bin/curlftpfs /bin
208 fi