postmarketos-initramfs: always save logs (MR 4646)
Always write logs to the ramdisk, adjust setup_log() to spawn "tail" to pipe the log to the console device when PMOS_NO_OUTPUT_REDIRECT is set. This is necessary to ensure that the initramfs logs can be extracted on a failed boot. Signed-off-by: Caleb Connolly <caleb@connolly.tech>
This commit is contained in:
parent
190860eb5f
commit
241ade087f
1 changed files with 15 additions and 9 deletions
|
@ -7,20 +7,26 @@ PMOS_ROOT=""
|
||||||
|
|
||||||
# Redirect stdout and stderr to logfile
|
# Redirect stdout and stderr to logfile
|
||||||
setup_log() {
|
setup_log() {
|
||||||
# Bail out if PMOS_NO_OUTPUT_REDIRECT is set
|
local log_to_console=""
|
||||||
|
|
||||||
|
grep -q PMOS_NO_OUTPUT_REDIRECT /proc/cmdline && log_to_console="true"
|
||||||
|
|
||||||
echo "### postmarketOS initramfs ###"
|
echo "### postmarketOS initramfs ###"
|
||||||
grep -q PMOS_NO_OUTPUT_REDIRECT /proc/cmdline && return
|
|
||||||
|
|
||||||
# Print a message about what is going on to the normal output
|
if [ -z "$log_to_console" ]; then
|
||||||
echo "NOTE: All output from the initramfs gets redirected to:"
|
echo "Add PMOS_NO_OUTPUT_REDIRECT to your kernel command line"
|
||||||
echo "/pmOS_init.log"
|
echo "to enable initramfs logging to console (e.g. for serial)."
|
||||||
echo "If you want to disable this behavior (e.g. because you're"
|
fi
|
||||||
echo "debugging over serial), please add this to your kernel"
|
|
||||||
echo "command line: PMOS_NO_OUTPUT_REDIRECT"
|
|
||||||
|
|
||||||
# Start redirect, print the first line again
|
# Start redirect
|
||||||
exec >/pmOS_init.log 2>&1
|
exec >/pmOS_init.log 2>&1
|
||||||
echo "### postmarketOS initramfs ###"
|
echo "### postmarketOS initramfs ###"
|
||||||
|
|
||||||
|
# Pipe logs to console if PMOS_NO_OUTPUT_REDIRECT is set
|
||||||
|
if [ -n "$log_to_console" ]; then
|
||||||
|
tail -f /pmOS_init.log > /dev/console &
|
||||||
|
return
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
mount_proc_sys_dev() {
|
mount_proc_sys_dev() {
|
||||||
|
|
Loading…
Reference in a new issue