1 |
commit: e7735c6b2e2cbfb44ce550fa8e7f4359ab5f073c |
2 |
Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Aug 6 17:45:19 2019 +0000 |
4 |
Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Aug 7 15:03:40 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=e7735c6b |
7 |
|
8 |
linuxrc: Log initramfs output/commands |
9 |
|
10 |
By default, any {bad,good,warn}_msg output and external command calls |
11 |
will now be logged to /tmp/init.log in initramfs. This can be turned |
12 |
off via gk.log.disabled={1,yes} kernel command-line argument. |
13 |
|
14 |
This is especially helpful when working with remote servers when you |
15 |
can access initramfs system through SSH. |
16 |
|
17 |
In addition, initramfs' log file can be preserved, i.e. copied to |
18 |
real system just before switch_root call. This can be controlled |
19 |
via gk.log.keep kernel command-line argument: When just enabled, |
20 |
initramfs will copy log to $NEWROOT/genkernel-boot.log. Keep in my |
21 |
that the file path must be accessible for initramfs and by default, |
22 |
initramfs will only mount / as $NEWROOT and no additional mountpoints. |
23 |
|
24 |
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org> |
25 |
|
26 |
defaults/initrd.defaults | 4 + |
27 |
defaults/initrd.scripts | 535 ++++++++++++++++++++++++++++++++--------------- |
28 |
defaults/linuxrc | 142 ++++++++----- |
29 |
defaults/login-remote.sh | 27 ++- |
30 |
defaults/unlock-luks.sh | 18 +- |
31 |
doc/genkernel.8.txt | 16 ++ |
32 |
6 files changed, 522 insertions(+), 220 deletions(-) |
33 |
|
34 |
diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults |
35 |
index fdf948e..553600d 100644 |
36 |
--- a/defaults/initrd.defaults |
37 |
+++ b/defaults/initrd.defaults |
38 |
@@ -71,6 +71,10 @@ VERIFY=0 |
39 |
|
40 |
IP='dhcp' |
41 |
GK_DEBUGMODE_STATEFILE="/tmp/debug.enabled" |
42 |
+GK_INIT_LOG='/tmp/init.log' |
43 |
+GK_INIT_LOG_COPYTO= |
44 |
+GK_INIT_LOG_DISABLED='/tmp/no-init.log' |
45 |
+GK_INIT_LOG_PREFIX= |
46 |
GK_NET_DHCP_PIDFILE='/var/run/udhcpc.pid' |
47 |
GK_NET_DHCP_RETRIES=3 |
48 |
GK_NET_GW= |
49 |
|
50 |
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts |
51 |
index 6f7530f..f95f434 100644 |
52 |
--- a/defaults/initrd.scripts |
53 |
+++ b/defaults/initrd.scripts |
54 |
@@ -34,6 +34,17 @@ modules_scan() { |
55 |
[ -n "${MODS}" ] && [ -z "${QUIET}" ] && \ |
56 |
printf "%b" "${BOLD} ::${NORMAL} Loading from ${1}: " |
57 |
|
58 |
+ if [ -z "${MODULES_SCAN_WARNING_SHOWN}" ] |
59 |
+ then |
60 |
+ local note_msg="NOTE: Due to how genkernel auto-detects your" |
61 |
+ note_msg="${note_msg} hardware you will now see a lot of failed modprobe" \ |
62 |
+ note_msg="${note_msg} attempts which you can ignore:" |
63 |
+ |
64 |
+ log_msg "${note_msg}" |
65 |
+ |
66 |
+ MODULES_SCAN_WARNING_SHOWN=yes |
67 |
+ fi |
68 |
+ |
69 |
for x in ${MODS} |
70 |
do |
71 |
MLOAD=$(echo ${MLIST} | sed -e "s/.*${x}.*/${x}/") |
72 |
@@ -55,7 +66,7 @@ modules_scan() { |
73 |
printf "%b" "Scanning for ${x} ..." |
74 |
fi |
75 |
|
76 |
- modprobe ${x} >/dev/null 2>&1 |
77 |
+ run modprobe ${x} >/dev/null 2>&1 |
78 |
loaded=${?} |
79 |
|
80 |
is_debug && [ "${loaded}" = "0" ] && \ |
81 |
@@ -79,7 +90,6 @@ uppercase() { |
82 |
echo $1 | tr 'a-z' 'A-Z' |
83 |
} |
84 |
|
85 |
- |
86 |
findmediamount() { |
87 |
# $1 = mount dir name / media name |
88 |
# $2 = recognition file |
89 |
@@ -130,14 +140,14 @@ findmediamount() { |
90 |
fi |
91 |
good_msg "Attempting to mount media: ${x}" ${CRYPT_SILENT} |
92 |
|
93 |
- mount -t ${CDROOT_TYPE} ${x} ${mntcddir} >/dev/null 2>&1 |
94 |
+ run mount -t ${CDROOT_TYPE} ${x} ${mntcddir} >/dev/null 2>&1 |
95 |
if [ $? -eq 0 ] |
96 |
then |
97 |
if [ -n "${ISOBOOT}" ] |
98 |
then |
99 |
if [ -f "${mntcddir}/${ISOBOOT}" ] |
100 |
then |
101 |
- mount -o loop "${mntcddir}/${ISOBOOT}" "${mntdir}" |
102 |
+ run mount -o loop "${mntcddir}/${ISOBOOT}" "${mntdir}" |
103 |
if [ $? -eq 0 ] |
104 |
then |
105 |
good_msg "iso mounted on ${mntdir}" |
106 |
@@ -153,7 +163,7 @@ findmediamount() { |
107 |
good_msg "Media found on ${x}" ${CRYPT_SILENT} |
108 |
break |
109 |
else |
110 |
- umount ${mntcddir} |
111 |
+ run umount ${mntcddir} |
112 |
fi |
113 |
fi |
114 |
fi |
115 |
@@ -203,37 +213,37 @@ bootstrapFS() { |
116 |
aufs_branch=${aufs_memory}/aufs-rw-branch/${aufs_dev_uid} |
117 |
fi |
118 |
|
119 |
- mkdir -p ${aufs_memory} ${aufs_union} ${aufs_dev_mnt} |
120 |
+ run mkdir -p ${aufs_memory} ${aufs_union} ${aufs_dev_mnt} |
121 |
else |
122 |
# Legacy SquashFS implementation |
123 |
good_msg "Making tmpfs for ${NEW_ROOT}" |
124 |
- mount -n -t tmpfs tmpfs ${NEW_ROOT} |
125 |
+ run mount -n -t tmpfs tmpfs ${NEW_ROOT} |
126 |
fi |
127 |
|
128 |
# Setup the filesystem nodes and directories |
129 |
for i in ${CDROOT_PATH} /mnt/livecd /mnt/key /mnt/gentoo /tmp /tmp/.initrd /dev /proc /run /sys; do |
130 |
- mkdir -p "${NEW_ROOT}${i}" |
131 |
- chmod 755 "${NEW_ROOT}${i}" |
132 |
+ run mkdir -p "${NEW_ROOT}${i}" |
133 |
+ run chmod 755 "${NEW_ROOT}${i}" |
134 |
done |
135 |
|
136 |
- [ ! -d "${CDROOT_PATH}" ] && mkdir -p "${CDROOT_PATH}" |
137 |
- [ ! -e "${NEW_ROOT}/dev/null" ] && mknod -m 666 "${NEW_ROOT}"/dev/null c 1 3 |
138 |
- [ ! -e "${NEW_ROOT}/dev/zero" ] && mknod -m 666 "${NEW_ROOT}"/dev/zero c 1 5 |
139 |
- [ ! -e "${NEW_ROOT}/dev/console" ] && mknod -m 600 "${NEW_ROOT}"/dev/console c 5 1 |
140 |
- [ ! -e "${NEW_ROOT}/dev/ttyS0" ] && mknod -m 660 "${NEW_ROOT}"/dev/ttyS0 c 4 64 |
141 |
+ [ ! -d "${CDROOT_PATH}" ] && run mkdir -p "${CDROOT_PATH}" |
142 |
+ [ ! -e "${NEW_ROOT}/dev/null" ] && run mknod -m 666 "${NEW_ROOT}"/dev/null c 1 3 |
143 |
+ [ ! -e "${NEW_ROOT}/dev/zero" ] && run mknod -m 666 "${NEW_ROOT}"/dev/zero c 1 5 |
144 |
+ [ ! -e "${NEW_ROOT}/dev/console" ] && run mknod -m 600 "${NEW_ROOT}"/dev/console c 5 1 |
145 |
+ [ ! -e "${NEW_ROOT}/dev/ttyS0" ] && run mknod -m 660 "${NEW_ROOT}"/dev/ttyS0 c 4 64 |
146 |
|
147 |
# For SGI LiveCDs |
148 |
if [ "${LOOPTYPE}" = "sgimips" ] |
149 |
then |
150 |
- [ ! -e "${NEW_ROOT}/dev/sr0" ] && mknod "${NEW_ROOT}/dev/sr0" b 11 0 |
151 |
- [ ! -e "${NEW_ROOT}/dev/loop0" ] && mknod "${NEW_ROOT}/dev/loop0" b 7 0 |
152 |
+ [ ! -e "${NEW_ROOT}/dev/sr0" ] && run mknod "${NEW_ROOT}/dev/sr0" b 11 0 |
153 |
+ [ ! -e "${NEW_ROOT}/dev/loop0" ] && run mknod "${NEW_ROOT}/dev/loop0" b 7 0 |
154 |
fi |
155 |
|
156 |
# Required for splash to work. Not an issue with the initrd as this |
157 |
# device isn't created there and is not needed. |
158 |
for minor in 0 1 |
159 |
do |
160 |
- [ ! -e "${NEW_ROOT}/dev/${minor}" ] && mknod -m 600 "${NEW_ROOT}/dev/tty${minor}" c 4 ${minor} |
161 |
+ [ ! -e "${NEW_ROOT}/dev/${minor}" ] && run mknod -m 600 "${NEW_ROOT}/dev/tty${minor}" c 4 ${minor} |
162 |
done |
163 |
} |
164 |
|
165 |
@@ -254,11 +264,11 @@ bootstrapCD() { |
166 |
if [ -f isoroot_checksums ] |
167 |
then |
168 |
good_msg "Verifying checksums, this may take some time ..." |
169 |
- if ! busybox sha512sum -c isoroot_checksums |
170 |
+ if ! run sha512sum -c isoroot_checksums |
171 |
then |
172 |
bad_msg "Some checksums failed, press any key to poweroff ..." |
173 |
read -n1 -s |
174 |
- busybox poweroff -f |
175 |
+ poweroff -f |
176 |
else |
177 |
good_msg "Checksums all valid, continuing boot ..." |
178 |
fi |
179 |
@@ -294,23 +304,25 @@ cache_cd_contents() { |
180 |
# echo ${z} |
181 |
good_msg "Copying loop file for caching ..." |
182 |
# Verify that the needed directory exists |
183 |
- mkdir -p "$(dirname ${NEW_ROOT}/mnt/${LOOP})" |
184 |
- cp -a ${CDROOT_PATH}/${LOOP} ${NEW_ROOT}/mnt/${LOOP} |
185 |
+ run mkdir -p "$(dirname ${NEW_ROOT}/mnt/${LOOP})" |
186 |
+ run cp -a ${CDROOT_PATH}/${LOOP} ${NEW_ROOT}/mnt/${LOOP} |
187 |
if [ $? -ne 0 ] |
188 |
then |
189 |
warn_msg "Failed to cache the loop file! Lack of RAM?" |
190 |
- rm -rf ${NEW_ROOT}/mnt/${LOOP} 2>/dev/null |
191 |
- rm -rf ${NEW_ROOT}/mnt/livecd.* 2>/dev/null |
192 |
- rm -rf ${NEW_ROOT}/mnt/image.* 2>/dev/null |
193 |
- rm -rf ${NEW_ROOT}/mnt/zisofs 2>/dev/null |
194 |
+ run rm -rf ${NEW_ROOT}/mnt/${LOOP} 2>/dev/null |
195 |
+ run rm -rf ${NEW_ROOT}/mnt/livecd.* 2>/dev/null |
196 |
+ run rm -rf ${NEW_ROOT}/mnt/image.* 2>/dev/null |
197 |
+ run rm -rf ${NEW_ROOT}/mnt/zisofs 2>/dev/null |
198 |
fi |
199 |
fi |
200 |
fi |
201 |
} |
202 |
|
203 |
mount_sysfs() { |
204 |
- mount -t sysfs sysfs /sys -o noexec,nosuid,nodev >/dev/null 2>&1 |
205 |
- [ $? -eq 0 ] || bad_msg "Failed to mount /sys!" |
206 |
+ if ! run mount -t sysfs sysfs /sys -o noexec,nosuid,nodev >/dev/null 2>&1 |
207 |
+ then |
208 |
+ bad_msg "Failed to mount /sys!" |
209 |
+ fi |
210 |
} |
211 |
|
212 |
# Check support for both aufs and overlayfs |
213 |
@@ -345,8 +357,8 @@ is_union_modules() { |
214 |
else |
215 |
warn_msg "Adding all modules in ${mod_dir}" |
216 |
|
217 |
- mkdir /mnt/modules |
218 |
- mount "${mod_dir}" /mnt/modules |
219 |
+ run mkdir /mnt/modules |
220 |
+ run mount "${mod_dir}" /mnt/modules |
221 |
union_insert_modules /mnt/modules |
222 |
fi |
223 |
fi |
224 |
@@ -361,7 +373,7 @@ is_union_modules() { |
225 |
# |
226 |
aufs_insert_dir() { |
227 |
# Always mount it over the precedent (add:1:) |
228 |
- if mount -n -o "remount,add:1:$2=rr" aufs "$1" |
229 |
+ if run mount -n -o "remount,add:1:$2=rr" aufs "$1" |
230 |
then |
231 |
good_msg "Addition of $2 to $1 successful" |
232 |
fi |
233 |
@@ -409,18 +421,18 @@ union_mod() { |
234 |
then |
235 |
if [ ! -d "${aufs_union}"/mnt/"${mod}" ] |
236 |
then |
237 |
- mkdir -p "${aufs_union}"/mnt/modules/"${mod}" || return |
238 |
+ run mkdir -p "${aufs_union}"/mnt/modules/"${mod}" || return |
239 |
fi |
240 |
|
241 |
- mount -o loop,ro "$2" "${aufs_union}"/mnt/modules/"${mod}" |
242 |
+ run mount -o loop,ro "$2" "${aufs_union}"/mnt/modules/"${mod}" |
243 |
aufs_insert_dir "${aufs_union}" "${aufs_union}"/mnt/modules/"${mod}" |
244 |
else |
245 |
if [ ! -d "${mod_dir}/.${mod}" ] |
246 |
then |
247 |
- mkdir -p "${mod_dir}/.${mod}" || return |
248 |
+ run mkdir -p "${mod_dir}/.${mod}" || return |
249 |
fi |
250 |
|
251 |
- mount -o loop,ro "$2" "${mod_dir}/.${mod}" |
252 |
+ run mount -o loop,ro "$2" "${mod_dir}/.${mod}" |
253 |
fi |
254 |
} |
255 |
|
256 |
@@ -450,7 +462,7 @@ conf_rc_no_umounts() { |
257 |
|
258 |
if [ -n "${cmd}" ] |
259 |
then |
260 |
- sed -i "${cmd%;}" ${conf} |
261 |
+ run sed -i "${cmd%;}" ${conf} |
262 |
test_success "Unable to edit /etc/conf.d/localmount" |
263 |
fi |
264 |
fi |
265 |
@@ -486,6 +498,39 @@ is_int() { |
266 |
done |
267 |
} |
268 |
|
269 |
+is_log_enabled() { |
270 |
+ if [ -z "${GK_INIT_LOG}" ] |
271 |
+ then |
272 |
+ return 1 |
273 |
+ elif [ -f "${GK_INIT_LOG_DISABLED}" ] |
274 |
+ then |
275 |
+ return 1 |
276 |
+ fi |
277 |
+ |
278 |
+ return 0 |
279 |
+} |
280 |
+ |
281 |
+is_true() { |
282 |
+ case "$1" in |
283 |
+ [Tt][Rr][Uu][Ee]) |
284 |
+ return 0 |
285 |
+ ;; |
286 |
+ [Tt]) |
287 |
+ return 0 |
288 |
+ ;; |
289 |
+ [Yy][Ee][Ss]) |
290 |
+ return 0 |
291 |
+ ;; |
292 |
+ [Yy]) |
293 |
+ return 0 |
294 |
+ ;; |
295 |
+ 1) |
296 |
+ return 0 |
297 |
+ ;; |
298 |
+ esac |
299 |
+ return 1 |
300 |
+} |
301 |
+ |
302 |
# Function to create an ext2 fs on $aufs_dev, $aufs_dev_mnt mountpoint |
303 |
create_changefs() { |
304 |
local size |
305 |
@@ -504,13 +549,13 @@ create_changefs() { |
306 |
then |
307 |
bad_msg "Please give a size of at least 16 Megabytes" |
308 |
else |
309 |
- if dd if=/dev/zero "of=${aufs_dev_mnt}${aufs_union_file}" bs=1 seek="${size}"M count=0 >/dev/null 2>&1 |
310 |
+ if run dd if=/dev/zero "of=${aufs_dev_mnt}${aufs_union_file}" bs=1 seek="${size}"M count=0 >/dev/null 2>&1 |
311 |
then |
312 |
good_msg "Creation of ${aufs_union_file}, ${size}MB on ${aufs_dev successful}, formatting it ext2" |
313 |
- mke2fs -F "${aufs_dev_mnt}${aufs_union_file}" >/dev/null 2>&1 |
314 |
+ run mke2fs -F "${aufs_dev_mnt}${aufs_union_file}" >/dev/null 2>&1 |
315 |
break |
316 |
else |
317 |
- rm "${aufs_dev_mnt}${aufs_union_file}" |
318 |
+ run rm "${aufs_dev_mnt}${aufs_union_file}" |
319 |
bad_msg "Unable to create ${aufs_union_file#*/} on ${aufs_dev} of ${size}MB" |
320 |
bad_msg "Ensure your disk is not full or read-only" |
321 |
|
322 |
@@ -518,7 +563,7 @@ create_changefs() { |
323 |
if [ "${doabort}" = 'a' ] |
324 |
then |
325 |
bad_msg "Aborting creation of ${aufs_union_file}!" |
326 |
- umount "${aufs_dev}" && rmdir "${aufs_dev_mnt}" |
327 |
+ run umount "${aufs_dev}" && rmdir "${aufs_dev_mnt}" |
328 |
return 1 |
329 |
fi |
330 |
fi |
331 |
@@ -562,7 +607,7 @@ setup_aufs() { |
332 |
then |
333 |
good_msg "Mounting ${aufs_dev} to ${aufs_memory} for aufs support" |
334 |
|
335 |
- if ! mount -t auto "${aufs_dev}" "${aufs_dev_mnt}" >/dev/null 2>&1 |
336 |
+ if ! run mount -t auto "${aufs_dev}" "${aufs_dev_mnt}" >/dev/null 2>&1 |
337 |
then |
338 |
bad_msg "Mount of ${aufs_dev} failed, falling back to ramdisk based aufs" |
339 |
unset aufs_dev |
340 |
@@ -572,12 +617,12 @@ setup_aufs() { |
341 |
# Check and attempt to create the AUFS union file |
342 |
if [ ! -e ${aufs_dev_mnt}${aufs_union_file} ] && [ -n "${aufs_dev}" ] |
343 |
then |
344 |
- create_changefs && mount -t auto "${aufs_dev_mnt}${aufs_union_file}" "${aufs_memory}" |
345 |
+ create_changefs && run mount -t auto "${aufs_dev_mnt}${aufs_union_file}" "${aufs_memory}" |
346 |
elif [ -n "${aufs_dev}" ] |
347 |
then |
348 |
while :; |
349 |
do |
350 |
- if mount -t auto "${aufs_dev_mnt}${aufs_union_file}" "${aufs_memory}" >/dev/null 2>&1 |
351 |
+ if run mount -t auto "${aufs_dev_mnt}${aufs_union_file}" "${aufs_memory}" >/dev/null 2>&1 |
352 |
then |
353 |
if [ "${aufs_union_file}" = "/casper-rw" ] |
354 |
then |
355 |
@@ -592,18 +637,18 @@ setup_aufs() { |
356 |
bad_msg "/sbin/e2fsck not found! aborting filesystem check" |
357 |
bad_msg "Moving ${aufs_union_file#*/} to ${aufs_union_file#*/}.bad" |
358 |
|
359 |
- mv "${aufs_dev_mnt}${aufs_union_file}" "${aufs_dev_mnt}${aufs_union_file}.bad" |
360 |
+ run mv "${aufs_dev_mnt}${aufs_union_file}" "${aufs_dev_mnt}${aufs_union_file}.bad" |
361 |
break |
362 |
fi |
363 |
|
364 |
- if e2fsck "${aufs_dev_mnt}${aufs_union_file}" >/dev/null 2>&1 |
365 |
+ if run e2fsck "${aufs_dev_mnt}${aufs_union_file}" >/dev/null 2>&1 |
366 |
then |
367 |
good_msg "e2fsck ran successfully. Please verify data after bootup" |
368 |
else |
369 |
bad_msg "Your ${aufs_union_file#*/} image might be corrupted" |
370 |
bad_msg "moving ${aufs_union_file#*/} to ${aufs_union_file#*/}.bad" |
371 |
|
372 |
- mv "${aufs_dev_mnt}${aufs_union_file}" "${aufs_dev_mnt}${aufs_union_file}.bad" |
373 |
+ run mv "${aufs_dev_mnt}${aufs_union_file}" "${aufs_dev_mnt}${aufs_union_file}.bad" |
374 |
break |
375 |
fi |
376 |
fi |
377 |
@@ -628,22 +673,22 @@ setup_aufs() { |
378 |
bad_msg "Falling back to ramdisk based aufs" |
379 |
good_msg "Mounting ramdisk to ${aufs_memory} for aufs support" |
380 |
|
381 |
- mount -t tmpfs tmpfs "${aufs_memory}" |
382 |
+ run mount -t tmpfs tmpfs "${aufs_memory}" |
383 |
else |
384 |
aufs_xino=${aufs_memory}/xino |
385 |
|
386 |
- mkdir -p "${aufs_xino}" |
387 |
- mount -t tmpfs aufs-xino "${aufs_xino}" |
388 |
+ run mkdir -p "${aufs_xino}" |
389 |
+ run mount -t tmpfs aufs-xino "${aufs_xino}" |
390 |
fi |
391 |
else |
392 |
aufs_xino=${aufs_memory} |
393 |
|
394 |
good_msg "Mounting ramdisk to ${aufs_memory} for aufs support" |
395 |
- mount -t tmpfs tmpfs "${aufs_memory}" |
396 |
+ run mount -t tmpfs tmpfs "${aufs_memory}" |
397 |
fi |
398 |
|
399 |
- mkdir -p "${aufs_branch}" |
400 |
- if ! mount -t aufs -n -o "nowarn_perm,udba=none,xino=${aufs_xino}/.aufs.xino,br:${aufs_branch}=rw" aufs "${aufs_union}" |
401 |
+ run mkdir -p "${aufs_branch}" |
402 |
+ if ! run mount -t aufs -n -o "nowarn_perm,udba=none,xino=${aufs_xino}/.aufs.xino,br:${aufs_branch}=rw" aufs "${aufs_union}" |
403 |
then |
404 |
bad_msg "Can't setup union ${aufs_union} in directory!" |
405 |
aufs=0 |
406 |
@@ -660,11 +705,11 @@ setup_overlayfs() { |
407 |
rundebugshell overlayfs |
408 |
for i in "${overlay}" "${static}" |
409 |
do |
410 |
- [ ! -d "${i}" ] && mkdir -p "${i}" |
411 |
+ [ ! -d "${i}" ] && run mkdir -p "${i}" |
412 |
done |
413 |
|
414 |
good_msg "Loading overlayfs" |
415 |
- modprobe overlay >/dev/null 2>&1 |
416 |
+ run modprobe overlay >/dev/null 2>&1 |
417 |
checkfs overlay |
418 |
|
419 |
mount -t squashfs -o loop,ro "${CDROOT_PATH}/${LOOPEXT}${LOOP}" "${static}" |
420 |
@@ -672,7 +717,7 @@ setup_overlayfs() { |
421 |
mkdir "${upperdir}" "${workdir}" |
422 |
|
423 |
is_union_modules overlayfs |
424 |
- mount -t overlay overlay -o lowerdir="${static}${mod_path}",upperdir="${upperdir}",workdir="${workdir}" "${NEW_ROOT}" |
425 |
+ run mount -t overlay overlay -o lowerdir="${static}${mod_path}",upperdir="${upperdir}",workdir="${workdir}" "${NEW_ROOT}" |
426 |
|
427 |
[ ! -d "${NEW_ROOT}${overlay}" ] && mkdir -p "${NEW_ROOT}${overlay}" |
428 |
[ ! -d "${NEW_ROOT}${static}" ] && mkdir -p "${NEW_ROOT}${static}" |
429 |
@@ -681,7 +726,7 @@ setup_overlayfs() { |
430 |
|
431 |
for i in "${overlay}" "${static}" |
432 |
do |
433 |
- mount --bind "${i}" "${NEW_ROOT}${i}" |
434 |
+ run mount --bind "${i}" "${NEW_ROOT}${i}" |
435 |
done |
436 |
|
437 |
# Did we populate the overlayfs modules path locations variable? |
438 |
@@ -689,7 +734,7 @@ setup_overlayfs() { |
439 |
then |
440 |
for i in ${mods} |
441 |
do |
442 |
- mount --bind "${overlay}/.${i}" "${NEW_ROOT}/${overlay}/.${i}" |
443 |
+ run mount --bind "${overlay}/.${i}" "${NEW_ROOT}/${overlay}/.${i}" |
444 |
done |
445 |
fi |
446 |
} |
447 |
@@ -747,7 +792,7 @@ findnfsmount() { |
448 |
if [ "${CDROOT}" != '0' ] |
449 |
then |
450 |
good_msg "Attempting to mount NFS CD image on ${NFSROOT} with options ${NFSOPTIONS}" |
451 |
- mount -t nfs -o ${NFSOPTIONS} ${NFSROOT} ${CDROOT_PATH} |
452 |
+ run mount -t nfs -o ${NFSOPTIONS} ${NFSROOT} ${CDROOT_PATH} |
453 |
if [ $? -eq 0 ] |
454 |
then |
455 |
REAL_ROOT="/dev/nfs" |
456 |
@@ -757,7 +802,7 @@ findnfsmount() { |
457 |
fi |
458 |
else |
459 |
good_msg "Attempting to mount NFS root on ${NFSROOT} with options ${NFSOPTIONS}" |
460 |
- mount -t nfs -o ${NFSOPTIONS} ${NFSROOT} ${NEW_ROOT} |
461 |
+ run mount -t nfs -o ${NFSOPTIONS} ${NFSROOT} ${NEW_ROOT} |
462 |
if [ $? -eq 0 ] |
463 |
then |
464 |
REAL_ROOT="/dev/nfs" |
465 |
@@ -815,10 +860,24 @@ check_loop() { |
466 |
fi |
467 |
} |
468 |
|
469 |
+run() { |
470 |
+ local retval |
471 |
+ |
472 |
+ if "$@"; then |
473 |
+ retval=$? |
474 |
+ log_msg "Executed: '$*'" |
475 |
+ else |
476 |
+ retval=$? |
477 |
+ log_msg "Failed (${retval}): '$*'" |
478 |
+ fi |
479 |
+ |
480 |
+ return ${retval} |
481 |
+} |
482 |
+ |
483 |
run_shell() { |
484 |
[ -x /bin/sh ] && SH=/bin/sh || SH=/bin/ash |
485 |
|
486 |
- touch "${GK_SHELL_LOCKFILE}" |
487 |
+ run touch "${GK_SHELL_LOCKFILE}" |
488 |
|
489 |
export PS1='rescueshell \w \# ' |
490 |
|
491 |
@@ -834,14 +893,18 @@ run_shell() { |
492 |
&& [ "${CONSOLE}" != "/dev/tty0" ] \ |
493 |
&& [ -c "${CONSOLE}" ] |
494 |
then |
495 |
+ log_msg "Opening rescue shell on ${CONSOLE} ..." |
496 |
setsid ${SH} -c "exec sh --login <${CONSOLE} >${CONSOLE} 2>&1" |
497 |
elif command -v cttyhack 1>/dev/null 2>&1 |
498 |
then |
499 |
+ log_msg "Opening rescue shell using cttyhack ..." |
500 |
setsid cttyhack ${SH} --login |
501 |
elif [ -c '/dev/tty1' ] |
502 |
then |
503 |
+ log_msg "Opening rescue shell on /dev/tty1 fallback ..." |
504 |
setsid ${SH} -c 'exec sh --login </dev/tty1 >/dev/tty1 2>&1' |
505 |
else |
506 |
+ log_msg "Opening rescue shell (last resort) ..." |
507 |
${SH} --login |
508 |
fi |
509 |
|
510 |
@@ -872,15 +935,15 @@ mount_devfs() { |
511 |
# Options copied from /etc/init.d/udev-mount, should probably be kept in sync |
512 |
if ! fs_type_in_use devtmpfs |
513 |
then |
514 |
- mount -t ${devfs} -o "exec,nosuid,mode=0755,size=10M" udev /dev \ |
515 |
+ run mount -t ${devfs} -o "exec,nosuid,mode=0755,size=10M" udev /dev \ |
516 |
|| bad_msg "Failed to mount /dev as ${devfs}" |
517 |
fi |
518 |
|
519 |
# http://git.busybox.net/busybox/plain/docs/mdev.txt |
520 |
if ! fs_type_in_use devpts |
521 |
then |
522 |
- mkdir -m 0755 /dev/pts |
523 |
- mount -t devpts -o gid=5,mode=0620 devpts /dev/pts || bad_msg "Failed to mount /dev/pts" |
524 |
+ run mkdir -m 0755 /dev/pts |
525 |
+ run mount -t devpts -o gid=5,mode=0620 devpts /dev/pts || bad_msg "Failed to mount /dev/pts" |
526 |
fi |
527 |
} |
528 |
|
529 |
@@ -896,6 +959,28 @@ test_success() { |
530 |
fi |
531 |
} |
532 |
|
533 |
+log_msg() { |
534 |
+ is_log_enabled || return |
535 |
+ |
536 |
+ if [ ! -f "${GK_INIT_LOG}" ] |
537 |
+ then |
538 |
+ touch "${GK_INIT_LOG}" |
539 |
+ fi |
540 |
+ |
541 |
+ local log_prefix= |
542 |
+ [ -n "${GK_INIT_LOG_PREFIX}" ] && log_prefix="${GK_INIT_LOG_PREFIX}: " |
543 |
+ |
544 |
+ local msg=${1} |
545 |
+ |
546 |
+ # Cannot use substitution because $msg could contain infinite color |
547 |
+ # codes and substitution can't be greedy. |
548 |
+ # Because Busybox's sed cannot deal with control characters, we |
549 |
+ # have to get rid of all non-printable characters like "^[" first... |
550 |
+ LANG=C echo "${log_prefix}${msg}" | sed \ |
551 |
+ -e "s,[^[:print:]],,g" \ |
552 |
+ -e 's,\(\\033\)\?\[[0-9;]\+m,,g' \ |
553 |
+ | ts '[%Y-%m-%d %H:%M:%S]' >> "${GK_INIT_LOG}" |
554 |
+} |
555 |
|
556 |
# msg functions arguments |
557 |
# $1 string |
558 |
@@ -904,22 +989,31 @@ test_success() { |
559 |
good_msg() { |
560 |
[ -n "${QUIET}" ] && ! is_debug && return 0 |
561 |
|
562 |
- msg_string=${1} |
563 |
+ local msg_string=${1} |
564 |
msg_string="${msg_string:-...}" |
565 |
+ |
566 |
+ log_msg "[OK] ${msg_string}" |
567 |
+ |
568 |
[ "$2" != '1' ] && printf "%b\n" "${GOOD}>>${NORMAL}${BOLD} ${msg_string} ${NORMAL}" |
569 |
} |
570 |
|
571 |
good_msg_n() { |
572 |
[ -n "${QUIET}" ] && ! is_debug && return 0 |
573 |
|
574 |
- msg_string=${1} |
575 |
+ local msg_string=${1} |
576 |
msg_string="${msg_string:-...}" |
577 |
+ |
578 |
+ log_msg "[OK] ${msg_string}" |
579 |
+ |
580 |
[ "$2" != '1' ] && printf "%b" "${GOOD}>>${NORMAL}${BOLD} ${msg_string}" |
581 |
} |
582 |
|
583 |
bad_msg() { |
584 |
- msg_string=${1} |
585 |
+ local msg_string=${1} |
586 |
msg_string="${msg_string:-...}" |
587 |
+ |
588 |
+ log_msg "[!!] ${msg_string}" |
589 |
+ |
590 |
if [ "$2" != '1' ] |
591 |
then |
592 |
splash 'verbose' >/dev/null & |
593 |
@@ -928,18 +1022,21 @@ bad_msg() { |
594 |
} |
595 |
|
596 |
warn_msg() { |
597 |
- msg_string=${1} |
598 |
+ local msg_string=${1} |
599 |
msg_string="${msg_string:-...}" |
600 |
+ |
601 |
+ log_msg "[**] ${msg_string}" |
602 |
+ |
603 |
[ "$2" != '1' ] && printf "%b\n" "${WARN}**${NORMAL}${BOLD} ${msg_string} ${NORMAL}" |
604 |
} |
605 |
|
606 |
crypt_filter() { |
607 |
if [ "${CRYPT_SILENT}" = '1' ] |
608 |
then |
609 |
- eval $1 >/dev/null 2>&1 |
610 |
+ eval run ${1} >/dev/null 2>&1 |
611 |
else |
612 |
splash 'verbose' >/dev/null & |
613 |
- eval $1 |
614 |
+ eval run ${1} |
615 |
res=$? |
616 |
if [ ${res} -eq 0 ] |
617 |
then |
618 |
@@ -949,6 +1046,46 @@ crypt_filter() { |
619 |
fi |
620 |
} |
621 |
|
622 |
+preserve_log() { |
623 |
+ is_log_enabled || return |
624 |
+ [ ! -s "${GK_INIT_LOG}" ] && return |
625 |
+ [ -z "${GK_INIT_LOG_COPYTO}" ] && return |
626 |
+ |
627 |
+ local have_errors=0 |
628 |
+ local logfile_target="${CHROOT}/${GK_INIT_LOG_COPYTO#/}" |
629 |
+ local logfile_target_dir="$(dirname "${logfile_target}")" |
630 |
+ local fail_msg="Failed to copy '${GK_INIT_LOG}' to '${logfile_target}'" |
631 |
+ |
632 |
+ if run mount -o remount,rw ${CHROOT} |
633 |
+ then |
634 |
+ if [ -z "${logfile_target_dir}" ] |
635 |
+ then |
636 |
+ have_errors=1 |
637 |
+ bad_msg "${fail_msg}: Failed to determine dirname of '${logfile_target}'!" |
638 |
+ elif [ ! -d "${logfile_target_dir}" ] |
639 |
+ then |
640 |
+ if ! run mkdir -p "${logfile_target_dir}" 2>/dev/null |
641 |
+ then |
642 |
+ have_errors=1 |
643 |
+ bad_msg "${fail_msg}: Failed to create '${logfile_target_dir}'!" |
644 |
+ fi |
645 |
+ fi |
646 |
+ |
647 |
+ if [ ${have_errors} = 0 ] |
648 |
+ then |
649 |
+ good_msg "gk.log.keep set; Copying '${GK_INIT_LOG}' to '${logfile_target}' ..." |
650 |
+ if ! cp "${GK_INIT_LOG}" "${logfile_target}" 2>/dev/null |
651 |
+ then |
652 |
+ bad_msg "${fail_msg}!" |
653 |
+ fi |
654 |
+ fi |
655 |
+ |
656 |
+ mount -o remount,ro ${CHROOT} |
657 |
+ else |
658 |
+ bad_msg "${fail_msg}: 'mount -o remount,rw ${CHROOT}' failed!" |
659 |
+ fi |
660 |
+} |
661 |
+ |
662 |
prompt_user() { |
663 |
# $1 = variable whose value is the path (examples: "REAL_ROOT", |
664 |
# "LUKS_KEYDEV") |
665 |
@@ -1043,7 +1180,7 @@ load_modules() { |
666 |
# kernel version |
667 |
if [ -d "/lib/modules/${KV}" ] |
668 |
then |
669 |
- good_msg 'Loading modules' |
670 |
+ good_msg 'Loading modules ...' |
671 |
# Load appropriate kernel modules |
672 |
for modules in ${MY_HWOPTS} |
673 |
do |
674 |
@@ -1060,13 +1197,12 @@ setup_keymap() { |
675 |
if [ ! -e /dev/vc/0 -a ! -e /dev/tty0 ] |
676 |
then |
677 |
DEVBIND=1 |
678 |
- mount -o bind ${NEW_ROOT}/dev /dev |
679 |
+ run mount -o bind ${NEW_ROOT}/dev /dev |
680 |
fi |
681 |
- [ ! -e /dev/tty0 ] && ln -s /dev/tty1 /dev/tty0 |
682 |
|
683 |
[ -f /lib/keymaps/keymapList ] && chooseKeymap |
684 |
|
685 |
- [ "${DEVBIND}" = '1' ] && umount /dev |
686 |
+ [ "${DEVBIND}" = '1' ] && run umount /dev |
687 |
fi |
688 |
} |
689 |
|
690 |
@@ -1082,7 +1218,7 @@ chooseKeymap() { |
691 |
if [ -z "${keymap}" ] |
692 |
then |
693 |
splash 'verbose' >/dev/null & |
694 |
- cat /lib/keymaps/keymapList |
695 |
+ run cat /lib/keymaps/keymapList |
696 |
read -t 10 -p '<< Load keymap (Enter for default): ' keymap |
697 |
case ${keymap} in |
698 |
1|azerty) keymap=azerty ;; |
699 |
@@ -1135,9 +1271,9 @@ chooseKeymap() { |
700 |
if [ -e /lib/keymaps/${keymap}.map ] |
701 |
then |
702 |
good_msg "Loading the '${keymap}' keymap ..." |
703 |
- loadkmap < /lib/keymaps/${keymap}.map |
704 |
+ run loadkmap < /lib/keymaps/${keymap}.map |
705 |
|
706 |
- mkdir -p /etc/sysconfig |
707 |
+ run mkdir -p /etc/sysconfig |
708 |
echo "XKEYBOARD=${keymap}" > /etc/sysconfig/keyboard |
709 |
splash set_msg "Set keymap to '${keymap}'" |
710 |
elif [ -z "${keymap}" ] |
711 |
@@ -1158,8 +1294,8 @@ chooseKeymap() { |
712 |
copyKeymap() { |
713 |
if [ -e /etc/sysconfig/keyboard -a ${CDROOT} -eq 1 ] |
714 |
then |
715 |
- [ ! -d ${NEW_ROOT}/etc/sysconfig ] && mkdir -p ${NEW_ROOT}/etc/sysconfig |
716 |
- cp /etc/sysconfig/keyboard ${NEW_ROOT}/etc/sysconfig/keyboard |
717 |
+ [ ! -d ${NEW_ROOT}/etc/sysconfig ] && run mkdir -p ${NEW_ROOT}/etc/sysconfig |
718 |
+ run cp /etc/sysconfig/keyboard ${NEW_ROOT}/etc/sysconfig/keyboard |
719 |
fi |
720 |
} |
721 |
|
722 |
@@ -1183,18 +1319,23 @@ start_volumes() { |
723 |
# a symlink, which should hopefully fix bug #142775 and bug #147015 |
724 |
if [ -e /dev/device-mapper ] && [ ! -e /dev/mapper/control ] |
725 |
then |
726 |
- mkdir -p /dev/mapper |
727 |
- ln -sf /dev/device-mapper /dev/mapper/control |
728 |
+ run mkdir -p /dev/mapper |
729 |
+ run ln -sf /dev/device-mapper /dev/mapper/control |
730 |
fi |
731 |
|
732 |
if [ "${USE_MDADM}" = '1' ] |
733 |
then |
734 |
if [ -x '/sbin/mdadm' ] |
735 |
then |
736 |
- /sbin/mdadm --assemble --scan |
737 |
+ local mdadm_cmd="run /sbin/mdadm --assemble --scan 2>&1" |
738 |
+ is_log_enabled && mdadm_cmd="${mdadm_cmd} | tee -a '${GK_INIT_LOG}'" |
739 |
+ eval "${mdadm_cmd}" |
740 |
+ |
741 |
#Intel Matrix RAID (and possibly others) have a container layer above the actual volumes, |
742 |
#So we have to look for volumes that haven't been activated. |
743 |
- /sbin/mdadm -IRs |
744 |
+ mdadm_cmd="run /sbin/mdadm -IRs 2>&1" |
745 |
+ is_log_enabled && mdadm_cmd="${mdadm_cmd} | tee -a '${GK_INIT_LOG}'" |
746 |
+ eval "${mdadm_cmd}" |
747 |
else |
748 |
bad_msg "domdadm invoked but /sbin/mdadm not found; Skipping mdadm raid assembly ..." |
749 |
fi |
750 |
@@ -1226,19 +1367,24 @@ start_volumes() { |
751 |
then |
752 |
good_msg "Scanning for multipath devices" |
753 |
good_msg ":: Populating scsi_id info for libudev queries" |
754 |
- mkdir -p /run/udev/data |
755 |
+ run mkdir -p /run/udev/data |
756 |
|
757 |
local ech |
758 |
for ech in /sys/block/* |
759 |
do |
760 |
local tgtfile=b$(cat ${ech}/dev) |
761 |
- /lib/udev/scsi_id -g -x /dev/${ech##*/} |sed -e 's/^/E:/' >/run/udev/data/${tgtfile} |
762 |
+ run /lib/udev/scsi_id -g -x /dev/${ech##*/} | sed -e 's/^/E:/' >/run/udev/data/${tgtfile} |
763 |
done |
764 |
|
765 |
- ${multipath_path} -v 0 |
766 |
+ local multipath_cmd="run ${multipath_path} -v 0 2>&1" |
767 |
+ is_log_enabled && multipath_cmd="${multipath_cmd} | tee -a '${GK_INIT_LOG}'" |
768 |
+ eval "${multipath_cmd}" |
769 |
sleep 2 |
770 |
- good_msg "Activating multipath devices" |
771 |
- ${dmsetup_path} ls --target multipath --exec "${kpartx_path} -a -v" |
772 |
+ |
773 |
+ good_msg "Activating multipath devices ..." |
774 |
+ multipath_cmd="run ${dmsetup_path} ls --target multipath --exec '${kpartx_path} -a -v' 2>&1" |
775 |
+ is_log_enabled && multipath_cmd="${multipath_cmd} | tee -a '${GK_INIT_LOG}'" |
776 |
+ eval "${multipath_cmd}" |
777 |
fi |
778 |
fi |
779 |
|
780 |
@@ -1246,14 +1392,23 @@ start_volumes() { |
781 |
then |
782 |
if [ -x '/sbin/dmraid' ] |
783 |
then |
784 |
- good_msg "Activating Device-Mapper RAID(s)" |
785 |
+ good_msg "Activating Device-Mapper RAID(s) ..." |
786 |
+ local dmraid_cmd="run /sbin/dmraid -ay" |
787 |
if [ -z "${DMRAID_OPTS}" ] |
788 |
then |
789 |
- /sbin/dmraid -ay |
790 |
+ dmraid_cmd="${dmraid_cmd} 2>&1" |
791 |
else |
792 |
- /sbin/dmraid -ay ${DMRAID_OPTS} |
793 |
+ dmraid_cmd="${dmraid_cmd} ${DMRAID_OPTS} 2>&1" |
794 |
+ fi |
795 |
+ is_log_enabled && dmraid_cmd="${dmraid_cmd} | tee -a '${GK_INIT_LOG}'" |
796 |
+ eval "${dmraid_cmd}" |
797 |
+ |
798 |
+ if [ -x '/sbin/kpartx' ] |
799 |
+ then |
800 |
+ dmraid_cmd="run /sbin/dmsetup ls --exec '/sbin/kpartx -a -s' 2>&1" |
801 |
+ is_log_enabled && dmraid_cmd="${dmraid_cmd} | tee -a '${GK_INIT_LOG}'" |
802 |
+ eval "${dmraid_cmd}" |
803 |
fi |
804 |
- [ -x '/sbin/kpartx' ] && /sbin/dmsetup ls --exec '/sbin/kpartx -a -s' |
805 |
else |
806 |
bad_msg "dodmraid invoked but /sbin/dmraid not found; Skipping dmraid activation ..." |
807 |
fi |
808 |
@@ -1275,23 +1430,30 @@ start_volumes() { |
809 |
setup_md_device "${dev}" |
810 |
done |
811 |
|
812 |
- # This is needed for LVM to accept the following logic |
813 |
- lvm_commands="#! ${lvm_path}" |
814 |
+ local lvm_cmd |
815 |
|
816 |
# If there is a cache, update it. Unbreak at least dmcrypt |
817 |
- [ -d /etc/lvm/cache ] && lvm_commands="${lvm_commands} \nvgscan" |
818 |
+ if [ -d /etc/lvm/cache ] |
819 |
+ then |
820 |
+ good_msg "Scanning for volume groups ..." |
821 |
+ lvm_cmd="run ${lvm_path} vgscan 2>&1" |
822 |
+ is_log_enabled && lvm_cmd="${lvm_cmd} | tee -a '${GK_INIT_LOG}'" |
823 |
+ eval "${lvm_cmd}" |
824 |
+ fi |
825 |
+ |
826 |
+ good_msg "Activating volume groups ..." |
827 |
|
828 |
# To activate volumegroups on all devices in the cache |
829 |
- lvm_commands="${lvm_commands} \nvgchange -ay --sysinit" |
830 |
+ local lvm_cmd="run ${lvm_path} vgchange -ay --sysinit 2>&1" |
831 |
+ is_log_enabled && lvm_cmd="${lvm_cmd} | tee -a '${GK_INIT_LOG}'" |
832 |
+ eval "${lvm_cmd}" |
833 |
|
834 |
- # To create symlinks so users can use real_root=/dev/vg/root |
835 |
+ # To create symlinks so users can use root=/dev/vg/root |
836 |
# This needs to run after vgchange, using vgchange --mknodes is too |
837 |
# early. |
838 |
- lvm_commands="${lvm_commands} \nvgmknodes --ignorelockingfailure" |
839 |
- |
840 |
- # And finally execute it all (/proc/... needed if lvm is compiled without readline) |
841 |
- good_msg "Scanning for and activating Volume Groups" |
842 |
- printf "%b\n" "${lvm_commands}" | ${lvm_path} /proc/self/fd/0 |
843 |
+ local lvm_cmd="run ${lvm_path} vgmknodes --ignorelockingfailure 2>&1" |
844 |
+ is_log_enabled && lvm_cmd="${lvm_cmd} | tee -a '${GK_INIT_LOG}'" |
845 |
+ eval "${lvm_cmd}" |
846 |
fi |
847 |
fi |
848 |
|
849 |
@@ -1308,6 +1470,7 @@ start_volumes() { |
850 |
then |
851 |
# Push all the block devices to register_quiet |
852 |
# If its bcache, it will bring it up, if not, it will simply ignore it. |
853 |
+ log_msg "COMMAND: 'echo \"/dev/${i}\" >/sys/fs/bcache/register_quiet'" |
854 |
echo "/dev/${i}" >/sys/fs/bcache/register_quiet 2>/dev/null |
855 |
else |
856 |
warn_msg "'/dev/${i}' should exist but is missing; Ignoring ..." |
857 |
@@ -1320,7 +1483,10 @@ start_volumes() { |
858 |
then |
859 |
if [ -x '/sbin/btrfs' ] |
860 |
then |
861 |
- /sbin/btrfs device scan |
862 |
+ local btrfs_cmd="run /sbin/btrfs device scan 2>&1" |
863 |
+ is_log_enabled && btrfs_cmd="${btrfs_cmd} | tee -a '${GK_INIT_LOG}'" |
864 |
+ |
865 |
+ eval "${btrfs_cmd}" |
866 |
else |
867 |
bad_msg "dobtrfs invoked but /sbin/btrfs not found; Skipping btrfs device scanning ..." |
868 |
fi |
869 |
@@ -1334,14 +1500,16 @@ start_volumes() { |
870 |
bad_msg "Cannot import ZFS pool because /dev/zfs is missing" |
871 |
elif [ -z "${ZFS_POOL}" ] |
872 |
then |
873 |
- good_msg "Importing ZFS pools" |
874 |
+ good_msg "Importing ZFS pools ..." |
875 |
|
876 |
- /sbin/zpool import -N -a ${ZPOOL_CACHE} ${ZPOOL_FORCE} |
877 |
+ local zfs_cmd="run /sbin/zpool import -N -a ${ZPOOL_CACHE} ${ZPOOL_FORCE} 2>&1" |
878 |
+ is_log_enabled && zfs_cmd="${zfs_cmd} | tee -a '${GK_INIT_LOG}'" |
879 |
+ eval "${zfs_cmd}" |
880 |
if [ $? -eq 0 ] |
881 |
then |
882 |
- good_msg "Importing ZFS pools succeeded" |
883 |
+ good_msg "Importing ZFS pools succeeded!" |
884 |
else |
885 |
- bad_msg "Imported ZFS pools failed" |
886 |
+ bad_msg "Imported ZFS pools failed!" |
887 |
fi |
888 |
else |
889 |
|
890 |
@@ -1351,19 +1519,27 @@ start_volumes() { |
891 |
|
892 |
if [ -n "${CRYPT_ROOT}" -o -n "${CRYPT_SWAP}" ] |
893 |
then |
894 |
- good_msg "LUKS detected. Reimporting ${ZFS_POOL}" |
895 |
- /sbin/zpool export -f "${ZFS_POOL}" |
896 |
- /sbin/zpool import -N ${ZPOOL_CACHE} ${ZPOOL_FORCE} "${ZFS_POOL}" |
897 |
+ good_msg "LUKS detected. Reimporting ${ZFS_POOL} ..." |
898 |
+ |
899 |
+ local zfs_cmd="run /sbin/zpool export -f '${ZFS_POOL}' 2>&1" |
900 |
+ is_log_enabled && zfs_cmd="${zfs_cmd} | tee -a '${GK_INIT_LOG}'" |
901 |
+ eval "${zfs_cmd}" |
902 |
+ |
903 |
+ zfs_cmd="run /sbin/zpool import -N ${ZPOOL_CACHE} ${ZPOOL_FORCE} '${ZFS_POOL}' 2>&1" |
904 |
+ is_log_enabled && zfs_cmd="${zfs_cmd} | tee -a '${GK_INIT_LOG}'" |
905 |
+ eval "${zfs_cmd}" |
906 |
fi |
907 |
else |
908 |
- good_msg "Importing ZFS pool ${ZFS_POOL}" |
909 |
+ good_msg "Importing ZFS pool ${ZFS_POOL} ..." |
910 |
|
911 |
- /sbin/zpool import -N ${ZPOOL_CACHE} ${ZPOOL_FORCE} "${ZFS_POOL}" |
912 |
+ local zfs_cmd="run /sbin/zpool import -N ${ZPOOL_CACHE} ${ZPOOL_FORCE} '${ZFS_POOL}' 2>&1" |
913 |
+ is_log_enabled && zfs_cmd="${zfs_cmd} | tee -a '${GK_INIT_LOG}'" |
914 |
+ eval "${zfs_cmd}" |
915 |
if [ $? -eq 0 ] |
916 |
then |
917 |
- good_msg "Import of ${ZFS_POOL} succeeded" |
918 |
+ good_msg "Import of ${ZFS_POOL} succeeded!" |
919 |
else |
920 |
- bad_msg "Import of ${ZFS_POOL} failed" |
921 |
+ bad_msg "Import of ${ZFS_POOL} failed!" |
922 |
fi |
923 |
fi |
924 |
fi |
925 |
@@ -1371,10 +1547,15 @@ start_volumes() { |
926 |
} |
927 |
|
928 |
start_iscsi() { |
929 |
+ local iscsi_cmd |
930 |
+ |
931 |
if [ ! -n "${ISCSI_NOIBFT}" ] |
932 |
then |
933 |
- good_msg "Activating iSCSI via iBFT" |
934 |
- iscsistart -b |
935 |
+ good_msg "Activating iSCSI via iBFT ..." |
936 |
+ |
937 |
+ iscsi_cmd="run iscsistart -b 2>&1" |
938 |
+ is_log_enabled && iscsi_cmd="${iscsi_cmd} | tee -a '${GK_INIT_LOG}'" |
939 |
+ eval "${iscsi_cmd}" |
940 |
fi |
941 |
|
942 |
if [ -n "${ISCSI_INITIATORNAME}" ] && [ -n "${ISCSI_TARGET}" ] && [ -n "${ISCSI_ADDRESS}" ] |
943 |
@@ -1418,7 +1599,9 @@ start_iscsi() { |
944 |
ADDITIONAL="${ADDITIONAL} -d ${ISCSI_DEBUG}" |
945 |
fi |
946 |
|
947 |
- iscsistart -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" -a "${ISCSI_ADDRESS}" ${ADDITIONAL} |
948 |
+ iscsi_cmd="run iscsistart -i '${ISCSI_INITIATORNAME}' -t '${ISCSI_TARGET}' -a '${ISCSI_ADDRESS}' ${ADDITIONAL} 2>&1" |
949 |
+ is_log_enabled && iscsi_cmd="${iscsi_cmd} | tee -a '${GK_INIT_LOG}'" |
950 |
+ eval "${iscsi_cmd}" |
951 |
fi |
952 |
} |
953 |
|
954 |
@@ -1481,8 +1664,7 @@ openLUKS() { |
955 |
fi |
956 |
|
957 |
setup_md_device ${LUKS_DEVICE} |
958 |
- cryptsetup isLuks ${LUKS_DEVICE} |
959 |
- if [ $? -ne 0 ] |
960 |
+ if ! run cryptsetup isLuks ${LUKS_DEVICE} |
961 |
then |
962 |
bad_msg "The LUKS device ${LUKS_DEVICE} does not contain a LUKS header" ${CRYPT_SILENT} |
963 |
DEV_ERROR=1 |
964 |
@@ -1538,8 +1720,7 @@ openLUKS() { |
965 |
# At this point a device was recognized, now let's see if the key is there |
966 |
[ ! -d "${mntkey}" ] && mkdir -p "${mntkey}" >/dev/null 2>&1 |
967 |
|
968 |
- mount -n -o ro ${REAL_LUKS_KEYDEV} ${mntkey} >/dev/null 2>&1 |
969 |
- if [ "$?" != '0' ] |
970 |
+ if ! run mount -n -o ro ${REAL_LUKS_KEYDEV} ${mntkey} >/dev/null 2>&1 |
971 |
then |
972 |
KEYDEV_ERROR=1 |
973 |
bad_msg "Mounting of device ${REAL_LUKS_KEYDEV} failed." ${CRYPT_SILENT} |
974 |
@@ -1550,7 +1731,7 @@ openLUKS() { |
975 |
# keyfile exists? |
976 |
if [ ! -e "${mntkey}${LUKS_KEY}" ] |
977 |
then |
978 |
- umount -n "${mntkey}" >/dev/null 2>&1 |
979 |
+ run umount -n "${mntkey}" >/dev/null 2>&1 |
980 |
KEY_ERROR=1 |
981 |
KEYDEV_ERROR=1 |
982 |
bad_msg "Key {LUKS_KEY} on device ${REAL_LUKS_KEYDEV} not found." ${CRYPT_SILENT} |
983 |
@@ -1568,8 +1749,8 @@ openLUKS() { |
984 |
bad_msg "GPG-encrypted key file provided but gpg program is missing. Was initramfs built without --gpg parameter?" |
985 |
bad_msg "Falling back to passphrase usage!" |
986 |
else |
987 |
- [ -e /dev/tty ] && mv /dev/tty /dev/tty.org |
988 |
- mknod /dev/tty c 5 1 |
989 |
+ [ -e /dev/tty ] && run mv /dev/tty /dev/tty.org |
990 |
+ run mknod /dev/tty c 5 1 |
991 |
cryptsetup_options="${cryptsetup_options} -d -" |
992 |
gpg_cmd="/sbin/gpg --logger-file /dev/null --quiet --decrypt ${mntkey}${LUKS_KEY} |" |
993 |
fi |
994 |
@@ -1582,12 +1763,12 @@ openLUKS() { |
995 |
crypt_filter_ret=$? |
996 |
|
997 |
[ -e /dev/tty.org ] \ |
998 |
- && rm -f /dev/tty \ |
999 |
- && mv /dev/tty.org /dev/tty |
1000 |
+ && run rm -f /dev/tty \ |
1001 |
+ && run mv /dev/tty.org /dev/tty |
1002 |
|
1003 |
if [ ${crypt_filter_ret} -eq 0 ] |
1004 |
then |
1005 |
- touch "${OPENED_LOCKFILE}" |
1006 |
+ run touch "${OPENED_LOCKFILE}" |
1007 |
good_msg "LUKS device ${LUKS_DEVICE} opened" ${CRYPT_SILENT} |
1008 |
break |
1009 |
elif [ ! -e "${OPENED_LOCKFILE}" ] |
1010 |
@@ -1600,8 +1781,13 @@ openLUKS() { |
1011 |
fi |
1012 |
fi |
1013 |
done |
1014 |
- umount "${mntkey}" >/dev/null 2>&1 |
1015 |
- rmdir -p "${mntkey}" >/dev/null 2>&1 |
1016 |
+ |
1017 |
+ if run mountpoint "${mntkey}" >/dev/null 2>&1 |
1018 |
+ then |
1019 |
+ run umount "${mntkey}" >/dev/null 2>&1 |
1020 |
+ fi |
1021 |
+ |
1022 |
+ [ -d "${mntkey}" ] run rmdir -p "${mntkey}" >/dev/null 2>&1 |
1023 |
} |
1024 |
|
1025 |
iface_name() { |
1026 |
@@ -1771,12 +1957,15 @@ start_network() { |
1027 |
# network for us. Really no need re-run dhcp... |
1028 |
warn_msg "Interface ${GK_NET_IFACE} is already up." |
1029 |
warn_msg "Skipping network setup; Will use existing network configuration ..." |
1030 |
- touch "${GK_NET_LOCKFILE}" |
1031 |
+ run touch "${GK_NET_LOCKFILE}" |
1032 |
return 0 |
1033 |
fi |
1034 |
|
1035 |
+ local udhcpc_cmd="run udhcpc -i '${GK_NET_IFACE}' -n -t ${GK_NET_DHCP_RETRIES} -T ${GK_NET_TIMEOUT_DHCP} -R -p '${GK_NET_DHCP_PIDFILE}' 2>&1" |
1036 |
+ is_log_enabled && udhcpc_cmd="${udhcpc_cmd} | tee -a '${GK_INIT_LOG}'" |
1037 |
+ |
1038 |
good_msg "Bringing up interface ${GK_NET_IFACE} using dhcp ..." ${QUIET} |
1039 |
- busybox udhcpc -i "${GK_NET_IFACE}" -n -t ${GK_NET_DHCP_RETRIES} -T ${GK_NET_TIMEOUT_DHCP} -R -p "${GK_NET_DHCP_PIDFILE}" |
1040 |
+ eval "${udhcpc_cmd}" |
1041 |
if [ $? -ne 0 ] |
1042 |
then |
1043 |
bad_msg "Failed to start udhcpc for interface ${GK_NET_IFACE}!" |
1044 |
@@ -1793,10 +1982,10 @@ start_network() { |
1045 |
fi |
1046 |
|
1047 |
good_msg "Bringing up interface ${GK_NET_IFACE} ..." ${QUIET} |
1048 |
- ip link set "${GK_NET_IFACE}" up |
1049 |
+ run ip link set "${GK_NET_IFACE}" up |
1050 |
|
1051 |
good_msg "Setting address '${IP}' on ${GK_NET_IFACE} ..." ${QUIET} |
1052 |
- ip addr add "${IP}" dev "${GK_NET_IFACE}" |
1053 |
+ run ip addr add "${IP}" dev "${GK_NET_IFACE}" |
1054 |
|
1055 |
if [ -n "${GK_NET_ROUTES}" ] |
1056 |
then |
1057 |
@@ -1804,25 +1993,25 @@ start_network() { |
1058 |
for route in ${GK_NET_ROUTES} |
1059 |
do |
1060 |
good_msg "Adding additional route '${route}' on ${GK_NET_IFACE} ..." ${QUIET} |
1061 |
- ip route add "${route}" dev "${GK_NET_IFACE}" |
1062 |
+ run ip route add "${route}" dev "${GK_NET_IFACE}" |
1063 |
done |
1064 |
fi |
1065 |
|
1066 |
if [ -n "${GK_NET_GW}" ] |
1067 |
then |
1068 |
good_msg "Adding default route via '${GK_NET_GW}' on ${GK_NET_IFACE} ..." ${QUIET} |
1069 |
- ip route add default via "${GK_NET_GW}" dev "${GK_NET_IFACE}" |
1070 |
+ run ip route add default via "${GK_NET_GW}" dev "${GK_NET_IFACE}" |
1071 |
fi |
1072 |
fi |
1073 |
|
1074 |
- touch "${GK_NET_LOCKFILE}" |
1075 |
+ run touch "${GK_NET_LOCKFILE}" |
1076 |
} |
1077 |
|
1078 |
kill_network() { |
1079 |
if [ -s "${GK_NET_DHCP_PIDFILE}" ] |
1080 |
then |
1081 |
good_msg "Stopping udhcpc ..." |
1082 |
- kill $(cat "${GK_NET_DHCP_PIDFILE}") |
1083 |
+ run kill $(cat "${GK_NET_DHCP_PIDFILE}") |
1084 |
fi |
1085 |
|
1086 |
if [ ! -d "/sys/class/net/${GK_NET_IFACE}" ] |
1087 |
@@ -1867,9 +2056,9 @@ kill_network() { |
1088 |
local deconfiguration_timeout=${GK_NET_TIMEOUT_DECONFIGURATION} |
1089 |
while [ ${deconfiguration_timeout} -gt 0 ] |
1090 |
do |
1091 |
- ip addr flush dev "${GK_NET_IFACE}" |
1092 |
- ip route flush dev "${GK_NET_IFACE}" |
1093 |
- ip link set "${GK_NET_IFACE}" down |
1094 |
+ run ip addr flush dev "${GK_NET_IFACE}" |
1095 |
+ run ip route flush dev "${GK_NET_IFACE}" |
1096 |
+ run ip link set "${GK_NET_IFACE}" down |
1097 |
if grep -q "down" "/sys/class/net/${GK_NET_IFACE}/operstate" 2>/dev/null |
1098 |
then |
1099 |
break |
1100 |
@@ -1888,7 +2077,7 @@ kill_network() { |
1101 |
return |
1102 |
fi |
1103 |
|
1104 |
- [ -f "${GK_NET_LOCKFILE}" ] && rm "${GK_NET_LOCKFILE}" |
1105 |
+ [ -f "${GK_NET_LOCKFILE}" ] && run rm "${GK_NET_LOCKFILE}" |
1106 |
} |
1107 |
|
1108 |
is_interface_up() { |
1109 |
@@ -1964,17 +2153,17 @@ start_sshd() { |
1110 |
|
1111 |
# setup environment variables for the ssh login shell |
1112 |
local varname= varvalue= |
1113 |
- touch "${CRYPT_ENV_FILE}" |
1114 |
+ run touch "${CRYPT_ENV_FILE}" |
1115 |
for varname in CRYPT_ROOT CRYPT_ROOT_TRIM CRYPT_SILENT CRYPT_SWAP |
1116 |
do |
1117 |
eval varvalue=\$${varname} |
1118 |
echo "${varname}=${varvalue}" >> "${CRYPT_ENV_FILE}" |
1119 |
done |
1120 |
|
1121 |
- touch /var/log/lastlog |
1122 |
+ run touch /var/log/lastlog |
1123 |
|
1124 |
good_msg "Starting dropbear sshd ..." ${QUIET} |
1125 |
- /usr/sbin/dropbear -p ${GK_SSHD_PORT} -R -P "${GK_SSHD_PIDFILE}" 2>/var/log/dropbear.log |
1126 |
+ run /usr/sbin/dropbear -p ${GK_SSHD_PORT} -R -P "${GK_SSHD_PIDFILE}" 2>/var/log/dropbear.log |
1127 |
test_success "Failed to start dropbear" |
1128 |
} |
1129 |
|
1130 |
@@ -1991,13 +2180,16 @@ wait_sshd() { |
1131 |
|
1132 |
printf "%b" "${GOOD}>>${NORMAL}${BOLD} gk.sshd.wait set; Waiting ${GK_SSHD_WAIT} seconds for SSH connection ${NORMAL}..." |
1133 |
|
1134 |
+ local last_cmd="run last -W 2>/dev/null | head -n 3" |
1135 |
+ is_log_enabled && last_cmd="${last_cmd} | tee -a '${GK_INIT_LOG}'" |
1136 |
+ |
1137 |
local ssh_timeout=${GK_SSHD_WAIT} |
1138 |
while [ ${ssh_timeout} -gt 0 ] |
1139 |
do |
1140 |
if [ -f "${GK_SSHD_LOCKFILE}" ] |
1141 |
then |
1142 |
echo "" |
1143 |
- last -W | head -n 3 2>/dev/null |
1144 |
+ eval "${last_cmd}" |
1145 |
break |
1146 |
fi |
1147 |
sleep 1 |
1148 |
@@ -2012,7 +2204,7 @@ kill_sshd() { |
1149 |
if [ -s "${GK_SSHD_PIDFILE}" ] |
1150 |
then |
1151 |
good_msg "Stopping dropbear sshd ..." ${QUIET} |
1152 |
- kill $(cat "${GK_SSHD_PIDFILE}") |
1153 |
+ run kill $(cat "${GK_SSHD_PIDFILE}") |
1154 |
fi |
1155 |
} |
1156 |
|
1157 |
@@ -2038,7 +2230,10 @@ cleanup() { |
1158 |
kill_sshd |
1159 |
|
1160 |
# Ensure that we terminated any existing connection |
1161 |
- pkill -9 dropbear >/dev/null 2>&1 |
1162 |
+ if pgrep dropbear >/dev/null 2>&1 |
1163 |
+ then |
1164 |
+ run pkill -9 dropbear >/dev/null 2>&1 |
1165 |
+ fi |
1166 |
|
1167 |
if [ -f "${GK_NET_LOCKFILE}" ] |
1168 |
then |
1169 |
@@ -2055,7 +2250,7 @@ sdelay() { |
1170 |
# Sleep a specific number of seconds if SDELAY is set |
1171 |
if [ -n "${SDELAY}" ] |
1172 |
then |
1173 |
- good_msg_n "Waiting ${SDELAY} seconds ..." |
1174 |
+ good_msg_n "scandelay set; Waiting ${SDELAY} seconds ..." |
1175 |
while [ ${SDELAY} -gt 0 ] |
1176 |
do |
1177 |
let SDELAY=${SDELAY}-1 |
1178 |
@@ -2071,12 +2266,20 @@ sdelay() { |
1179 |
|
1180 |
quiet_kmsg() { |
1181 |
# if QUIET is set make the kernel less chatty |
1182 |
- [ -n "${QUIET}" ] && echo '0' > /proc/sys/kernel/printk |
1183 |
+ if [ -n "${QUIET}" ] |
1184 |
+ then |
1185 |
+ echo '0' > /proc/sys/kernel/printk \ |
1186 |
+ && log_msg "COMMAND: 'echo \"0\" > /proc/sys/kernel/printk'" |
1187 |
+ fi |
1188 |
} |
1189 |
|
1190 |
verbose_kmsg() { |
1191 |
# if QUIET is set make the kernel less chatty |
1192 |
- [ -n "${QUIET}" ] && echo '6' > /proc/sys/kernel/printk |
1193 |
+ if [ -n "${QUIET}" ] |
1194 |
+ then |
1195 |
+ echo '6' > /proc/sys/kernel/printk \ |
1196 |
+ && log_msg "COMMAND: 'echo \"6\" > /proc/sys/kernel/printk'" |
1197 |
+ fi |
1198 |
} |
1199 |
|
1200 |
cdupdate() { |
1201 |
@@ -2091,7 +2294,7 @@ cdupdate() { |
1202 |
if [ -n "${cdupdate_path}" ] |
1203 |
then |
1204 |
good_msg "Running cdupdate.sh (${cdupdate_path})" |
1205 |
- ${cdupdate_path} |
1206 |
+ run ${cdupdate_path} |
1207 |
if [ "$?" != '0' ] |
1208 |
then |
1209 |
bad_msg "Executing cdupdate.sh failed!" |
1210 |
@@ -2105,7 +2308,13 @@ cdupdate() { |
1211 |
|
1212 |
setup_btrfsctl() { |
1213 |
# start BTRFS volume detection, if available |
1214 |
- [ -x /sbin/btrfsctl ] && /sbin/btrfsctl -a |
1215 |
+ if [ -x /sbin/btrfsctl ] |
1216 |
+ then |
1217 |
+ local btrfs_cmd="run /sbin/btrfsctl -a 2>&1" |
1218 |
+ is_log_enabled && btrfs_cmd="${btrfs_cmd} | tee -a '${GK_INIT_LOG}'" |
1219 |
+ |
1220 |
+ eval "${btrfs_cmd}" |
1221 |
+ fi |
1222 |
} |
1223 |
|
1224 |
setup_md_device() { |
1225 |
@@ -2120,10 +2329,10 @@ setup_md_device() { |
1226 |
MD_NUMBER=$(echo ${device}|sed -e 's#\(luks:\)\?/dev/md\([[:digit:]]\+\)#\2#') |
1227 |
if [ ! -e /dev/md${MD_NUMBER} ] |
1228 |
then |
1229 |
- mknod /dev/md${MD_NUMBER} b 9 ${MD_NUMBER} >/dev/null 2>&1 |
1230 |
+ run mknod /dev/md${MD_NUMBER} b 9 ${MD_NUMBER} >/dev/null 2>&1 |
1231 |
[ $? -ne 0 ] && bad_msg "Creation of /dev/md${MD_NUMBER} failed ..." |
1232 |
fi |
1233 |
- mdstart ${MDPART} /dev/md${MD_NUMBER} |
1234 |
+ run mdstart ${MDPART} /dev/md${MD_NUMBER} |
1235 |
fi |
1236 |
} |
1237 |
|
1238 |
@@ -2242,16 +2451,16 @@ setup_squashfs_aufs() { |
1239 |
|
1240 |
for dir in ${aufs_rw_branch} ${aufs_ro_branch} |
1241 |
do |
1242 |
- [ ! -d "${dir}" ] && mkdir -p "${dir}" |
1243 |
+ [ ! -d "${dir}" ] && run mkdir -p "${dir}" |
1244 |
done |
1245 |
|
1246 |
good_msg "Loading aufs module ..." |
1247 |
- modprobe aufs >/dev/null 2>&1 |
1248 |
+ run modprobe aufs >/dev/null 2>&1 |
1249 |
checkfs aufs |
1250 |
|
1251 |
- mount -t squashfs -o loop,ro "${CDROOT_PATH}/${LOOPEXT}${LOOP}" "${aufs_ro_branch}" |
1252 |
- mount -t tmpfs none "${aufs_rw_branch}" |
1253 |
- mount -t aufs -o "br:${aufs_rw_branch}:${aufs_ro_branch}" aufs "${NEW_ROOT}" |
1254 |
+ run mount -t squashfs -o loop,ro "${CDROOT_PATH}/${LOOPEXT}${LOOP}" "${aufs_ro_branch}" |
1255 |
+ run mount -t tmpfs none "${aufs_rw_branch}" |
1256 |
+ run mount -t aufs -o "br:${aufs_rw_branch}:${aufs_ro_branch}" aufs "${NEW_ROOT}" |
1257 |
} |
1258 |
|
1259 |
setup_unionfs() { |
1260 |
@@ -2270,9 +2479,9 @@ setup_unionfs() { |
1261 |
# fi |
1262 |
|
1263 |
# mkdir -p ${MEMORY} |
1264 |
- mkdir -p ${UNION} |
1265 |
+ run mkdir -p ${UNION} |
1266 |
good_msg "Loading fuse module" |
1267 |
- modprobe fuse >/dev/null 2>&1 |
1268 |
+ run modprobe fuse >/dev/null 2>&1 |
1269 |
# if [ -n "${UNIONFS}" ] |
1270 |
# then |
1271 |
# CHANGESDEV=${UNIONFS} |
1272 |
@@ -2299,12 +2508,12 @@ setup_unionfs() { |
1273 |
# mount -t tmpfs tmpfs ${MEMORY} |
1274 |
# fi |
1275 |
|
1276 |
- mkdir /tmp |
1277 |
- mkdir -p ${UNION} |
1278 |
+ run mkdir /tmp |
1279 |
+ run mkdir -p ${UNION} |
1280 |
# mkdir -p ${CHANGES} |
1281 |
# mount -t unionfs -o dirs=${CHANGES}=rw unionfs ${UNION} |
1282 |
good_msg "Creating union mount" |
1283 |
- unionfs -o allow_other,cow,noinitgroups,suid,dev,default_permissions,use_ino ${rw_dir}=RW:${ro_dir}=RO ${UNION} 2>/dev/null |
1284 |
+ run unionfs -o allow_other,cow,noinitgroups,suid,dev,default_permissions,use_ino ${rw_dir}=RW:${ro_dir}=RO ${UNION} 2>/dev/null |
1285 |
ret=$? |
1286 |
if [ ${ret} -ne 0 ] |
1287 |
then |
1288 |
@@ -2312,7 +2521,7 @@ setup_unionfs() { |
1289 |
USE_UNIONFS_NORMAL=0 |
1290 |
fi |
1291 |
[ ! -d "${NEW_ROOT}${CDROOT_PATH}" ] && mkdir -p "${NEW_ROOT}${CDROOT_PATH}" |
1292 |
- mount --bind "${CDROOT_PATH}" "${NEW_ROOT}${CDROOT_PATH}" |
1293 |
+ run mount --bind "${CDROOT_PATH}" "${NEW_ROOT}${CDROOT_PATH}" |
1294 |
else |
1295 |
USE_UNIONFS_NORMAL=0 |
1296 |
fi |
1297 |
|
1298 |
diff --git a/defaults/linuxrc b/defaults/linuxrc |
1299 |
index e3d5a2b..6e01209 100644 |
1300 |
--- a/defaults/linuxrc |
1301 |
+++ b/defaults/linuxrc |
1302 |
@@ -28,7 +28,7 @@ then |
1303 |
exit 1 |
1304 |
fi |
1305 |
|
1306 |
-mount -t proc -o noexec,nosuid,nodev proc /proc >/dev/null 2>&1 |
1307 |
+run mount -t proc -o noexec,nosuid,nodev proc /proc >/dev/null 2>&1 |
1308 |
mount -o remount,rw / >/dev/null 2>&1 |
1309 |
|
1310 |
# Prevent superfluous printks from being printed to the console |
1311 |
@@ -37,11 +37,11 @@ echo 1 > /proc/sys/kernel/printk |
1312 |
if [ ! -s /etc/ld.so.cache ] |
1313 |
then |
1314 |
# Looks like we were unable to run ldconfig during initramfs generation |
1315 |
- [ -x /sbin/ldconfig ] && /sbin/ldconfig |
1316 |
+ [ -x /sbin/ldconfig ] && run /sbin/ldconfig |
1317 |
fi |
1318 |
|
1319 |
# Set up symlinks |
1320 |
-/bin/busybox --install -s |
1321 |
+run /bin/busybox --install -s |
1322 |
|
1323 |
gk_ver="$(cat /etc/build_id)" |
1324 |
gk_build_date="$(cat /etc/build_date)" |
1325 |
@@ -51,7 +51,7 @@ good_msg "${gk_ver} (${gk_build_date}). Linux kernel ${kernel_ver}" |
1326 |
|
1327 |
if [ "$0" = '/init' ] |
1328 |
then |
1329 |
- [ -e /linuxrc ] && rm /linuxrc |
1330 |
+ [ -e /linuxrc ] && run rm /linuxrc |
1331 |
fi |
1332 |
|
1333 |
CMDLINE=$(cat /proc/cmdline) |
1334 |
@@ -63,7 +63,7 @@ ROOTFSTYPE='auto' |
1335 |
CRYPT_SILENT=0 |
1336 |
QUIET='' |
1337 |
|
1338 |
-mkdir -p /etc/cmdline /etc/modprobe.d |
1339 |
+run mkdir -p /etc/cmdline /etc/modprobe.d |
1340 |
for x in ${CMDLINE} |
1341 |
do |
1342 |
case "${x}" in |
1343 |
@@ -155,7 +155,7 @@ do |
1344 |
;; |
1345 |
# Debug Options |
1346 |
debug) |
1347 |
- touch "${GK_DEBUGMODE_STATEFILE}" |
1348 |
+ run touch "${GK_DEBUGMODE_STATEFILE}" |
1349 |
;; |
1350 |
# Scan delay options |
1351 |
scandelay=*) |
1352 |
@@ -275,6 +275,47 @@ do |
1353 |
dosshd) |
1354 |
USE_SSH=1 |
1355 |
;; |
1356 |
+ gk.log.disabled=*) |
1357 |
+ tmp_disabled=${x#*=} |
1358 |
+ if is_true "${tmp_disabled}" |
1359 |
+ then |
1360 |
+ [ -f "${GK_INIT_LOG}" ] && rm "${GK_INIT_LOG}" |
1361 |
+ GK_INIT_LOG= |
1362 |
+ touch "${GK_INIT_LOG_DISABLED}" |
1363 |
+ fi |
1364 |
+ unset tmp_disabled |
1365 |
+ ;; |
1366 |
+ gk.log.keep=*) |
1367 |
+ case "${x#*=}" in |
1368 |
+ [Tt][Rr][Uu][Ee]) |
1369 |
+ GK_INIT_LOG_COPYTO=/genkernel-boot.log |
1370 |
+ ;; |
1371 |
+ [Yy][Ee][Ss]) |
1372 |
+ GK_INIT_LOG_COPYTO=/genkernel-boot.log |
1373 |
+ ;; |
1374 |
+ [Yy]) |
1375 |
+ GK_INIT_LOG_COPYTO=/genkernel-boot.log |
1376 |
+ ;; |
1377 |
+ 1) |
1378 |
+ GK_INIT_LOG_COPYTO=/genkernel-boot.log |
1379 |
+ ;; |
1380 |
+ [Ff][Aa][Ll][Ss][Ee]) |
1381 |
+ GK_INIT_LOG_COPYTO= |
1382 |
+ ;; |
1383 |
+ [Nn][Oo]) |
1384 |
+ GK_INIT_LOG_COPYTO= |
1385 |
+ ;; |
1386 |
+ [Nn]) |
1387 |
+ GK_INIT_LOG_COPYTO= |
1388 |
+ ;; |
1389 |
+ 0) |
1390 |
+ GK_INIT_LOG_COPYTO= |
1391 |
+ ;; |
1392 |
+ *) |
1393 |
+ GK_INIT_LOG_COPYTO=${x#*=} |
1394 |
+ ;; |
1395 |
+ esac |
1396 |
+ ;; |
1397 |
gk.sshd.port=*) |
1398 |
tmp_port=${x#*=} |
1399 |
if is_int "${tmp_port}" |
1400 |
@@ -442,14 +483,15 @@ mount_devfs |
1401 |
mount_sysfs |
1402 |
|
1403 |
# Initialize mdev |
1404 |
-good_msg 'Activating mdev' |
1405 |
+good_msg 'Activating mdev ...' |
1406 |
|
1407 |
# Serialize hotplug events |
1408 |
-touch /dev/mdev.seq |
1409 |
+run touch /dev/mdev.seq |
1410 |
|
1411 |
# Setup hotplugging for firmware loading |
1412 |
if [ -f "/proc/sys/kernel/hotplug" ] |
1413 |
then |
1414 |
+ log_msg "COMMAND: 'echo /sbin/mdev > /proc/sys/kernel/hotplug'" |
1415 |
echo /sbin/mdev > /proc/sys/kernel/hotplug |
1416 |
fi |
1417 |
|
1418 |
@@ -459,7 +501,7 @@ then |
1419 |
good_msg 'Skipping module load; disabled via commandline' |
1420 |
elif [ -d "/lib/modules/${KV}" ] |
1421 |
then |
1422 |
- good_msg 'Loading modules' |
1423 |
+ good_msg 'Loading modules ...' |
1424 |
if [ -n "${FIRSTMODS}" ] |
1425 |
then |
1426 |
# try these modules first -- detected modules for root device: |
1427 |
@@ -481,7 +523,7 @@ else |
1428 |
fi |
1429 |
|
1430 |
# Ensure that device nodes are properly configured |
1431 |
-mdev -s || bad_msg "mdev -s failed" |
1432 |
+run mdev -s || bad_msg "mdev -s failed" |
1433 |
|
1434 |
cd / |
1435 |
|
1436 |
@@ -561,7 +603,7 @@ then |
1437 |
fi |
1438 |
fi |
1439 |
|
1440 |
-mkdir -p "${NEW_ROOT}" |
1441 |
+run mkdir -p "${NEW_ROOT}" |
1442 |
CHROOT="${NEW_ROOT}" |
1443 |
|
1444 |
# Run debug shell if requested |
1445 |
@@ -603,12 +645,12 @@ then |
1446 |
if [ "${REAL_ROOT}" = '' ] && [ "${got_good_root}" != '1' ] |
1447 |
then |
1448 |
# Undo stuff |
1449 |
- umount "${NEW_ROOT}/dev" 2>/dev/null |
1450 |
- umount "${NEW_ROOT}/sys" 2>/dev/null |
1451 |
- umount /sys 2>/dev/null |
1452 |
+ run umount "${NEW_ROOT}/dev" 2>/dev/null |
1453 |
+ run umount "${NEW_ROOT}/sys" 2>/dev/null |
1454 |
+ run umount /sys 2>/dev/null |
1455 |
|
1456 |
- umount "${NEW_ROOT}" |
1457 |
- rm -rf "${NEW_ROOT}/*" |
1458 |
+ run umount "${NEW_ROOT}" |
1459 |
+ run rm -rf "${NEW_ROOT}/*" |
1460 |
|
1461 |
bad_msg 'Could not find CD to boot, something else needed!' |
1462 |
CDROOT=0 |
1463 |
@@ -621,7 +663,7 @@ ROOTDELAY_TIME_WAITED=0 |
1464 |
[ -n "${ROOTDELAY}" -a ${ROOTDELAY} -gt 0 ] && let ROOTDELAY_TIMEOUT=${ROOTDELAY_TIMEOUT}+${ROOTDELAY}-1 |
1465 |
while true |
1466 |
do |
1467 |
- good_msg_n 'Determining root device ...' |
1468 |
+ good_msg_n "Determining root device (trying ${REAL_ROOT}) ..." |
1469 |
|
1470 |
while [ "${got_good_root}" != '1' ] |
1471 |
do |
1472 |
@@ -650,7 +692,7 @@ do |
1473 |
got_good_root=1 |
1474 |
REAL_ROOT="${ROOT_DEV}" |
1475 |
echo |
1476 |
- good_msg "Detected real_root=${ROOT_DEV}" |
1477 |
+ good_msg "Root device detected as ${REAL_ROOT}!" |
1478 |
break |
1479 |
fi |
1480 |
;; |
1481 |
@@ -664,20 +706,20 @@ do |
1482 |
ROOT_DEV="${REAL_ROOT#*=}" |
1483 |
if [ "${ROOT_DEV}" != 'ZFS' ] |
1484 |
then |
1485 |
- if [ "$(zfs get type -o value -H ${ROOT_DEV})" = 'filesystem' ] |
1486 |
+ if [ "$(zfs get type -o value -H ${ROOT_DEV} 2>/dev/null)" = 'filesystem' ] |
1487 |
then |
1488 |
got_good_root=1 |
1489 |
REAL_ROOT=${ROOT_DEV} |
1490 |
ROOTFSTYPE=zfs |
1491 |
echo |
1492 |
- good_msg "Detected real_root=${ROOT_DEV}" |
1493 |
+ good_msg "Root device detected as ${REAL_ROOT}!" |
1494 |
break |
1495 |
else |
1496 |
bad_msg "${ROOT_DEV} is not a filesystem" |
1497 |
continue |
1498 |
fi |
1499 |
else |
1500 |
- BOOTFS=$(/sbin/zpool list -H -o bootfs) |
1501 |
+ BOOTFS=$(/sbin/zpool list -H -o bootfs 2>/dev/null) |
1502 |
if [ "${BOOTFS}" != '-' ] |
1503 |
then |
1504 |
for i in ${BOOTFS} |
1505 |
@@ -689,7 +731,7 @@ do |
1506 |
REAL_ROOT=${i} |
1507 |
ROOTFSTYPE=zfs |
1508 |
echo |
1509 |
- good_msg "Detected real_root=${ROOT_DEV}" |
1510 |
+ good_msg "Root device detected as ${REAL_ROOT}!" |
1511 |
break |
1512 |
fi |
1513 |
done |
1514 |
@@ -701,7 +743,7 @@ do |
1515 |
then |
1516 |
got_good_root=1 |
1517 |
echo |
1518 |
- good_msg "Detected real_root=${REAL_ROOT}" |
1519 |
+ good_msg "Root device detected as ${REAL_ROOT}!" |
1520 |
break |
1521 |
fi |
1522 |
;; |
1523 |
@@ -732,10 +774,10 @@ do |
1524 |
then |
1525 |
# at this point we determined dataset and are ready to mount |
1526 |
# let's check if this dataset is encrypted and ask for passphrase |
1527 |
- if [ "$(zpool list -H -o feature@encryption "${REAL_ROOT%%/*}")" = 'active' ] |
1528 |
+ if [ "$(zpool list -H -o feature@encryption "${REAL_ROOT%%/*}" 2>/dev/null)" = 'active' ] |
1529 |
then |
1530 |
- ZFS_KEYSTATUS="$(zfs get -H -o value keystatus "${REAL_ROOT}")" |
1531 |
- ZFS_ENCRYPTIONROOT="$(zfs get -H -o value encryptionroot "${REAL_ROOT}")" |
1532 |
+ ZFS_KEYSTATUS="$(zfs get -H -o value keystatus "${REAL_ROOT}" 2>/dev/null)" |
1533 |
+ ZFS_ENCRYPTIONROOT="$(zfs get -H -o value encryptionroot "${REAL_ROOT}" 2>/dev/null)" |
1534 |
if ! [ "${ZFS_ENCRYPTIONROOT}" = '-' ] || [ "${ZFS_KEYSTATUS}" = 'available' ] |
1535 |
then |
1536 |
good_msg "Detected ZFS encryption, asking for key" |
1537 |
@@ -796,11 +838,11 @@ do |
1538 |
if [ "${REAL_ROOTFLAGS}" = '' ] |
1539 |
then |
1540 |
good_msg "Using mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE} ${REAL_ROOT} ${NEW_ROOT}" |
1541 |
- mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE} ${REAL_ROOT} ${NEW_ROOT} |
1542 |
+ run mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE} ${REAL_ROOT} ${NEW_ROOT} |
1543 |
mountret=$? |
1544 |
else |
1545 |
good_msg "Using mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE},${REAL_ROOTFLAGS} ${REAL_ROOT} ${NEW_ROOT}" |
1546 |
- mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE},${REAL_ROOTFLAGS} ${REAL_ROOT} ${NEW_ROOT} |
1547 |
+ run mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE},${REAL_ROOTFLAGS} ${REAL_ROOT} ${NEW_ROOT} |
1548 |
mountret=$? |
1549 |
fi |
1550 |
fi |
1551 |
@@ -852,7 +894,7 @@ do |
1552 |
then |
1553 |
if mountpoint "${NEW_ROOT}" 1>/dev/null 2>&1 |
1554 |
then |
1555 |
- umount "${NEW_ROOT}" 1>/dev/null 2>&1 |
1556 |
+ run umount "${NEW_ROOT}" 1>/dev/null 2>&1 |
1557 |
if [ $? -ne 0 ] |
1558 |
then |
1559 |
echo |
1560 |
@@ -904,7 +946,7 @@ then |
1561 |
MOUNTTYPE="${LOOPTYPE}" |
1562 |
;; |
1563 |
esac |
1564 |
- mount -t "${MOUNTTYPE}" -o ro /dev/mapper/root "${NEW_ROOT}/mnt/livecd" |
1565 |
+ run mount -t "${MOUNTTYPE}" -o ro /dev/mapper/root "${NEW_ROOT}/mnt/livecd" |
1566 |
test_success 'Mount filesystem' |
1567 |
FS_LOCATION='mnt/livecd' |
1568 |
# Setup the loopback mounts, if unencrypted |
1569 |
@@ -912,7 +954,7 @@ then |
1570 |
if [ "${LOOPTYPE}" = 'normal' ] |
1571 |
then |
1572 |
good_msg 'Mounting loop filesystem' |
1573 |
- mount -t ext2 -o loop,ro "${CDROOT_PATH}/${LOOPEXT}${LOOP}" "${NEW_ROOT}/mnt/livecd" |
1574 |
+ run mount -t ext2 -o loop,ro "${CDROOT_PATH}/${LOOPEXT}${LOOP}" "${NEW_ROOT}/mnt/livecd" |
1575 |
test_success 'Mount filesystem' |
1576 |
FS_LOCATION='mnt/livecd' |
1577 |
elif [ "${LOOPTYPE}" = 'squashfs' ] |
1578 |
@@ -951,7 +993,7 @@ then |
1579 |
echo ' ' | losetup -E 19 -e ucl-0 -p0 "${NEW_ROOT}/dev/loop0" "${CDROOT_PATH}/${LOOPEXT}${LOOP}" |
1580 |
test_success 'losetup the loop device' |
1581 |
|
1582 |
- mount -t ext2 -o ro "${NEW_ROOT}/dev/loop0" "${NEW_ROOT}/mnt/livecd" |
1583 |
+ run mount -t ext2 -o ro "${NEW_ROOT}/dev/loop0" "${NEW_ROOT}/mnt/livecd" |
1584 |
test_success 'Mount the losetup loop device' |
1585 |
FS_LOCATION='mnt/livecd' |
1586 |
elif [ "${LOOPTYPE}" = 'zisofs' ] |
1587 |
@@ -979,7 +1021,7 @@ then |
1588 |
test_success 'losetup /dev/sr0 /dev/loop0' |
1589 |
|
1590 |
good_msg 'Mounting the Root Partition' |
1591 |
- mount -t squashfs -o ro "${NEW_ROOT}${CDROOT_DEV}" "${NEW_ROOT}/mnt/livecd" |
1592 |
+ run mount -t squashfs -o ro "${NEW_ROOT}${CDROOT_DEV}" "${NEW_ROOT}/mnt/livecd" |
1593 |
test_success 'mount /dev/loop0 /' |
1594 |
FS_LOCATION='mnt/livecd' |
1595 |
fi |
1596 |
@@ -997,7 +1039,7 @@ then |
1597 |
then |
1598 |
for dir in /var/tmp /tmp |
1599 |
do |
1600 |
- [ ! -d ${CHROOT}${dir} ] && mkdir -p "${CHROOT}${dir}" |
1601 |
+ [ ! -d ${CHROOT}${dir} ] && run mkdir -p "${CHROOT}${dir}" |
1602 |
done |
1603 |
|
1604 |
cat > "${CHROOT}/etc/fstab" << FSTAB |
1605 |
@@ -1020,8 +1062,8 @@ FSTAB |
1606 |
# Check to see if we successfully mounted $aufs_dev |
1607 |
if [ -n "${aufs_dev}" ] && grep ${aufs_dev} /etc/mtab 1>/dev/null |
1608 |
then |
1609 |
- [ ! -d ${CHROOT}${aufs_dev_mnt} ] && mkdir -p "${CHROOT}${aufs_dev_mnt}" |
1610 |
- mount --move "${aufs_dev_mnt}" "${CHROOT}${aufs_dev_mnt}" |
1611 |
+ [ ! -d ${CHROOT}${aufs_dev_mnt} ] && run mkdir -p "${CHROOT}${aufs_dev_mnt}" |
1612 |
+ run mount --move "${aufs_dev_mnt}" "${CHROOT}${aufs_dev_mnt}" |
1613 |
fi |
1614 |
fi |
1615 |
|
1616 |
@@ -1111,10 +1153,10 @@ FSTAB |
1617 |
if [ "${aufs}" = '1' ] |
1618 |
then |
1619 |
[ ! -d "${CHROOT}${CDROOT_PATH}" ] && mkdir "${CHROOT}${CDROOT_PATH}" |
1620 |
- mount --move "${CDROOT_PATH}" "${CHROOT}${CDROOT_PATH}" |
1621 |
+ run mount --move "${CDROOT_PATH}" "${CHROOT}${CDROOT_PATH}" |
1622 |
else |
1623 |
[ ! -d "${NEW_ROOT}${CDROOT_PATH}" ] && mkdir -p "${NEW_ROOT}${CDROOT_PATH}" |
1624 |
- mount --move "${CDROOT_PATH}" "${NEW_ROOT}${CDROOT_PATH}" |
1625 |
+ run mount --move "${CDROOT_PATH}" "${NEW_ROOT}${CDROOT_PATH}" |
1626 |
fi |
1627 |
|
1628 |
# Let Init scripts know that we booted from CD |
1629 |
@@ -1123,14 +1165,14 @@ FSTAB |
1630 |
else |
1631 |
if [ "${USE_UNIONFS_NORMAL}" = '1' ] |
1632 |
then |
1633 |
- mkdir /union_changes |
1634 |
- mount -t tmpfs tmpfs /union_changes |
1635 |
+ run mkdir /union_changes |
1636 |
+ run mount -t tmpfs tmpfs /union_changes |
1637 |
setup_unionfs /union_changes ${NEW_ROOT} |
1638 |
- mkdir -p ${UNION}/tmp/.initrd |
1639 |
+ run mkdir -p ${UNION}/tmp/.initrd |
1640 |
elif [ "${aufs}" = '1' ] |
1641 |
then |
1642 |
aufs_insert_dir "${aufs_union}" "${NEW_ROOT}" |
1643 |
- mkdir -p "${aufs_union}/tmp/.initrd" |
1644 |
+ run mkdir -p "${aufs_union}/tmp/.initrd" |
1645 |
fi |
1646 |
fi # if [ "${CDROOT}" = '1' ] |
1647 |
|
1648 |
@@ -1184,19 +1226,19 @@ if [ "${aufs}" = '1' ] |
1649 |
then |
1650 |
aufs_union_memory=${CHROOT}/.unions/memory |
1651 |
|
1652 |
- mkdir -p "${aufs_union_memory}" |
1653 |
- mount --move "${aufs_memory}" "${aufs_union_memory}" |
1654 |
+ run mkdir -p "${aufs_union_memory}" |
1655 |
+ run mount --move "${aufs_memory}" "${aufs_union_memory}" |
1656 |
test_success "Failed to move aufs ${aufs_memory} into the system root" |
1657 |
|
1658 |
for dir in /mnt/gentoo ${aufs_rw_branch} ${aufs_ro_branch} |
1659 |
do |
1660 |
- mkdir -p "${CHROOT}${dir}" |
1661 |
- chmod 755 "${CHROOT}${dir}" |
1662 |
+ run mkdir -p "${CHROOT}${dir}" |
1663 |
+ run chmod 755 "${CHROOT}${dir}" |
1664 |
done |
1665 |
|
1666 |
for mount in ${aufs_rw_branch} ${aufs_ro_branch} |
1667 |
do |
1668 |
- mount --move "${mount}" "${CHROOT}${mount}" |
1669 |
+ run mount --move "${mount}" "${CHROOT}${mount}" |
1670 |
done |
1671 |
fi |
1672 |
|
1673 |
@@ -1225,9 +1267,9 @@ for fs in /dev /sys /proc |
1674 |
do |
1675 |
if grep -qs "${fs}" /proc/mounts |
1676 |
then |
1677 |
- if ! mount -o move ${fs} "${CHROOT}"${fs} |
1678 |
+ if ! run mount -o move ${fs} "${CHROOT}"${fs} |
1679 |
then |
1680 |
- umount ${fs} || \ |
1681 |
+ run umount ${fs} || \ |
1682 |
bad_msg "Failed to move and unmount the ramdisk ${fs}!" |
1683 |
fi |
1684 |
fi |
1685 |
@@ -1244,6 +1286,8 @@ fi |
1686 |
# Run debug shell if requested |
1687 |
rundebugshell "before entering switch_root" |
1688 |
|
1689 |
+preserve_log |
1690 |
+ |
1691 |
# init_opts is set in the environment by the kernel when it parses the command line |
1692 |
init=${REAL_INIT:-/sbin/init} |
1693 |
if ! mountpoint "${CHROOT}" 1>/dev/null 2>&1 |
1694 |
|
1695 |
diff --git a/defaults/login-remote.sh b/defaults/login-remote.sh |
1696 |
index 12596b9..588504f 100644 |
1697 |
--- a/defaults/login-remote.sh |
1698 |
+++ b/defaults/login-remote.sh |
1699 |
@@ -7,6 +7,20 @@ |
1700 |
|
1701 |
[ -e /etc/initrd.splash ] && . /etc/initrd.splash |
1702 |
|
1703 |
+GK_INIT_LOG_PREFIX=${0} |
1704 |
+if [ -n "${SSH_CLIENT}" ] |
1705 |
+then |
1706 |
+ SSH_CLIENT_IP=$(echo "${SSH_CLIENT}" | awk '{ print $1 }') |
1707 |
+ SSH_CLIENT_PORT=$(echo "${SSH_CLIENT}" | awk '{ print $2 }') |
1708 |
+ |
1709 |
+ if [ -n "${SSH_CLIENT_IP}" ] && [ -n "${SSH_CLIENT_PORT}" ] |
1710 |
+ then |
1711 |
+ GK_INIT_LOG_PREFIX="${0}[${SSH_CLIENT_IP}:${SSH_CLIENT_PORT}]" |
1712 |
+ export SSH_CLIENT_IP |
1713 |
+ export SSH_CLIENT_PORT |
1714 |
+ fi |
1715 |
+fi |
1716 |
+ |
1717 |
receivefile() { |
1718 |
case ${1} in |
1719 |
root) |
1720 |
@@ -62,12 +76,16 @@ then |
1721 |
exit 1 |
1722 |
esac |
1723 |
else |
1724 |
+ run touch "${GK_SSHD_LOCKFILE}" |
1725 |
+ |
1726 |
+ # Don't log further remote shell output |
1727 |
+ GK_INIT_LOG= |
1728 |
+ |
1729 |
gk_ver="$(cat /etc/build_id)" |
1730 |
gk_build_date="$(cat /etc/build_date)" |
1731 |
kernel_ver="$(uname -r)" |
1732 |
|
1733 |
export PS1='remote rescueshell \w \# ' |
1734 |
- touch "${GK_SSHD_LOCKFILE}" |
1735 |
|
1736 |
GOOD=${BLUE} good_msg "${NORMAL}Welcome to ${BOLD}${gk_ver}${NORMAL} (${gk_build_date}) ${BOLD}remote rescue shell${NORMAL}!" |
1737 |
GOOD=${BLUE} good_msg "${NORMAL}...running Linux kernel ${BOLD}${kernel_ver}${NORMAL}" |
1738 |
@@ -90,7 +108,12 @@ else |
1739 |
echo |
1740 |
|
1741 |
[ -x /bin/sh ] && SH=/bin/sh || SH=/bin/ash |
1742 |
- exec ${SH} --login |
1743 |
+ |
1744 |
+ exec \ |
1745 |
+ env \ |
1746 |
+ SSH_CLIENT_IP="${SSH_CLIENT_IP}" \ |
1747 |
+ SSH_CLIENT_PORT="${SSH_CLIENT_PORT}" \ |
1748 |
+ ${SH} --login |
1749 |
fi |
1750 |
|
1751 |
exit 0 |
1752 |
|
1753 |
diff --git a/defaults/unlock-luks.sh b/defaults/unlock-luks.sh |
1754 |
index ebcd2ca..457aa54 100644 |
1755 |
--- a/defaults/unlock-luks.sh |
1756 |
+++ b/defaults/unlock-luks.sh |
1757 |
@@ -30,6 +30,12 @@ esac |
1758 |
. /etc/initrd.scripts |
1759 |
. "${CRYPT_ENV_FILE}" |
1760 |
|
1761 |
+GK_INIT_LOG_PREFIX=${0} |
1762 |
+if [ -n "${SSH_CLIENT_IP}" ] && [ -n "${SSH_CLIENT_PORT}" ] |
1763 |
+then |
1764 |
+ GK_INIT_LOG_PREFIX="${0}[${SSH_CLIENT_IP}:${SSH_CLIENT_PORT}]" |
1765 |
+fi |
1766 |
+ |
1767 |
main() { |
1768 |
if [ ! -x /sbin/cryptsetup ] |
1769 |
then |
1770 |
@@ -58,7 +64,7 @@ main() { |
1771 |
fi |
1772 |
|
1773 |
setup_md_device "${LUKS_DEVICE}" |
1774 |
- if ! cryptsetup isLuks "${LUKS_DEVICE}" |
1775 |
+ if ! run cryptsetup isLuks "${LUKS_DEVICE}" |
1776 |
then |
1777 |
bad_msg "The LUKS device ${LUKS_DEVICE} does not contain a LUKS header" "${CRYPT_SILENT}" |
1778 |
|
1779 |
@@ -84,12 +90,12 @@ main() { |
1780 |
crypt_filter_ret=$? |
1781 |
|
1782 |
[ -e /dev/tty.org ] \ |
1783 |
- && rm -f /dev/tty \ |
1784 |
- && mv /dev/tty.org /dev/tty |
1785 |
+ && run rm -f /dev/tty \ |
1786 |
+ && run mv /dev/tty.org /dev/tty |
1787 |
|
1788 |
if [ ${crypt_filter_ret} -eq 0 ] |
1789 |
then |
1790 |
- touch "${OPENED_LOCKFILE}" |
1791 |
+ run touch "${OPENED_LOCKFILE}" |
1792 |
good_msg "LUKS device ${LUKS_DEVICE} opened" "${CRYPT_SILENT}" |
1793 |
break |
1794 |
else |
1795 |
@@ -107,7 +113,7 @@ main() { |
1796 |
then |
1797 |
if ! is_debug |
1798 |
then |
1799 |
- rm -f "${LUKS_KEY}" |
1800 |
+ run rm -f "${LUKS_KEY}" |
1801 |
else |
1802 |
warn_msg "LUKS key file '${LUKS_KEY}' not deleted because DEBUG mode is enabled!" |
1803 |
fi |
1804 |
@@ -117,7 +123,7 @@ main() { |
1805 |
then |
1806 |
# Kill any running cryptsetup prompt for this device. |
1807 |
# But SIGINT only to keep shell functional. |
1808 |
- pkill -2 -f "luksOpen.*${LUKS_NAME}\$" >/dev/null 2>&1 |
1809 |
+ run pkill -2 -f "luksOpen.*${LUKS_NAME}\$" >/dev/null 2>&1 |
1810 |
fi |
1811 |
} |
1812 |
|
1813 |
|
1814 |
diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt |
1815 |
index f5f877d..3ab28ce 100644 |
1816 |
--- a/doc/genkernel.8.txt |
1817 |
+++ b/doc/genkernel.8.txt |
1818 |
@@ -760,6 +760,22 @@ recognized by the kernel itself. |
1819 |
*debug*:: |
1820 |
Drop into a debug shell early in the process. |
1821 |
|
1822 |
+*gk.log.disabled*=<...>:: |
1823 |
+ By default, any shown message and external command calls will be logged |
1824 |
+ to '/tmp/init.log' in initramfs. This boolean option allows you to |
1825 |
+ disable logging for some reason. |
1826 |
+ |
1827 |
+*gk.log.keep*=<...>:: |
1828 |
+When set to a boolean value, genkernel will preserve '/tmp/init.log', |
1829 |
+see above, and copy file to '/genkernel-boot.log' on *root* device. |
1830 |
+You can also set your own file like '/root/my-genkernel-boot.log' to |
1831 |
+copy log to a custom path. |
1832 |
+ |
1833 |
+NOTE: The default file '/genkernel-boot.log' on *root* was chosen because |
1834 |
+genkernel's initramfs will only mount root filesystem by default. If you |
1835 |
+want to store the log file in '/var/log/genkernel-boot.log' for example |
1836 |
+make sure that this mountpoint is accessible, see *initramfs.mounts*. |
1837 |
+ |
1838 |
*noload*=<...>:: |
1839 |
List of modules to skip loading. |
1840 |
Separate using commas or spaces. |