diff options
author | Thomas Deutschmann <whissi@gentoo.org> | 2020-08-28 15:16:36 +0200 |
---|---|---|
committer | Thomas Deutschmann <whissi@gentoo.org> | 2020-08-28 18:35:55 +0200 |
commit | 8c19b84644d3a0b7f70b101b9c83931280028eb7 (patch) | |
tree | fe9dca3ddc4f1287a3906f6dc16ff57363659276 /defaults | |
parent | Remove --disklabel option (diff) | |
download | genkernel-8c19b84644d3a0b7f70b101b9c83931280028eb7.tar.gz genkernel-8c19b84644d3a0b7f70b101b9c83931280028eb7.tar.bz2 genkernel-8c19b84644d3a0b7f70b101b9c83931280028eb7.zip |
defaults/linuxrc: Always preserve log
Now that we are using UDEV and have to preserve /run, we can also
use /run to always store log from initramfs.
This will make debugging easier because user don't have to explicit
enable logging (disabling is still possible).
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Diffstat (limited to 'defaults')
-rw-r--r-- | defaults/initrd.defaults | 4 | ||||
-rw-r--r-- | defaults/initrd.scripts | 74 | ||||
-rw-r--r-- | defaults/linuxrc | 39 |
3 files changed, 8 insertions, 109 deletions
diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults index e4c861b..e310f19 100644 --- a/defaults/initrd.defaults +++ b/defaults/initrd.defaults @@ -74,9 +74,7 @@ GK_BOOTFONT_DISABLED=0 GK_DEBUGMODE_STATEFILE="/tmp/debug.enabled" GK_HW_LOAD_ALL_MODULES=0 GK_HW_USE_MODULES_LOAD=0 -GK_INIT_LOG='/tmp/init.log' -GK_INIT_LOG_COPYTO= -GK_INIT_LOG_COPYTO_DEFAULT='/genkernel-boot.log' +GK_INIT_LOG='/run/initramfs/init.log' GK_INIT_LOG_DISABLED='/tmp/no-init.log' GK_INIT_LOG_PREFIX= GK_NET_DHCP_PIDFILE='/var/run/udhcpc.pid' diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index b579e4f..ee7ca2c 100644 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -1177,78 +1177,6 @@ crypt_filter() { fi } -preserve_log() { - is_log_enabled || return - [ ! -s "${GK_INIT_LOG}" ] && return - [ -z "${GK_INIT_LOG_COPYTO}" ] && return - - local have_errors=0 - - local logfile_target="${CHROOT}/${GK_INIT_LOG_COPYTO#/}" - if ! echo "${logfile_target}" | grep -qE '^.*/[A-Za-z0-9._-]+$' - then - # The test above will make sure that a filename was given - # so we can be sure that dirname() will always return a - # path. - warn_msg "gk.log.keep value '${GK_INIT_LOG_COPYTO}' is invalid; Will copy log to '${GK_INIT_LOG_COPYTO_DEFAULT}' instead ..." - logfile_target="${CHROOT}/${GK_INIT_LOG_COPYTO_DEFAULT#/}" - fi - - local fail_msg="Failed to copy '${GK_INIT_LOG}' to '${logfile_target}'" - local logfile_target_dir="$(dirname "${logfile_target}")" - - if [ -z "${logfile_target_dir}" ] - then - bad_msg "${fail_msg}: Failed to determine dirname of '${logfile_target}'!" - return 1 - fi - - log_msg "Determining mountpoint of '${logfile_target}' ..." - - local logfile_mountpoint="${logfile_target_dir}" - while [ true ] - do - if run mountpoint "${logfile_mountpoint}" 1>/dev/null 2>&1 - then - if run mount -o remount,rw "${logfile_mountpoint}" 1>/dev/null 2>&1 - then - break - else - bad_msg "${fail_msg}: 'mount -o remount,rw \"${logfile_mountpoint}\"' failed!" - return 1 - fi - fi - - logfile_mountpoint="$(dirname "${logfile_mountpoint}")" - if [ "${logfile_mountpoint}" = "/" ] - then - # Stop here - bad_msg "${fail_msg}: Failed to determine mountpoint for '${logfile_target}'!" - return 1 - fi - done - - if [ ! -d "${logfile_target_dir}" ] - then - if ! run mkdir -p "${logfile_target_dir}" 2>/dev/null - then - bad_msg "${fail_msg}: Failed to create '${logfile_target_dir}'!" - return 1 - fi - fi - - good_msg "gk.log.keep set; Copying '${GK_INIT_LOG}' to '${logfile_target}' ..." - if ! run cp -f "${GK_INIT_LOG}" "${logfile_target}" 2>/dev/null - then - bad_msg "${fail_msg}!" - fi - - if ! run mount -o remount,ro "${logfile_mountpoint}" 1>/dev/null 2>&1 - then - bad_msg "Failed to re-mount ${logfile_mountpoint} read-only!" - fi -} - process_initramfs_mounts() { local fslist= @@ -2388,7 +2316,7 @@ start_sshd() { run touch /var/log/lastlog good_msg "Starting dropbear sshd ..." ${QUIET} - run dropbear -p ${GK_SSHD_PORT} -R -P "${GK_SSHD_PIDFILE}" 2>/var/log/dropbear.log + run dropbear -p ${GK_SSHD_PORT} -R -P "${GK_SSHD_PIDFILE}" 2>/run/initramfs/dropbear.log if [ $? -eq 0 ] then if [ "${GK_PROMPT_TIMEOUT}" = '0' ] diff --git a/defaults/linuxrc b/defaults/linuxrc index afb91d8..a4ed811 100644 --- a/defaults/linuxrc +++ b/defaults/linuxrc @@ -35,6 +35,12 @@ mount -t proc -o noexec,nosuid,nodev proc /proc >/dev/null 2>&1 mount -o remount,rw / >/dev/null 2>&1 mount -t tmpfs -o rw,nosuid,nodev,relatime,mode=755 none /run 2>&1 +if [ ! -d /run/initramfs ] +then + mkdir -p /run/initramfs + chmod 0750 /run/initramfs +fi + # Prevent superfluous printks from being printed to the console echo 1 > /proc/sys/kernel/printk @@ -306,37 +312,6 @@ do fi unset tmp_disabled ;; - gk.log.keep=*) - case "${x#*=}" in - [Tt][Rr][Uu][Ee]) - GK_INIT_LOG_COPYTO="${GK_INIT_LOG_COPYTO_DEFAULT}" - ;; - [Yy][Ee][Ss]) - GK_INIT_LOG_COPYTO="${GK_INIT_LOG_COPYTO_DEFAULT}" - ;; - [Yy]) - GK_INIT_LOG_COPYTO="${GK_INIT_LOG_COPYTO_DEFAULT}" - ;; - 1) - GK_INIT_LOG_COPYTO="${GK_INIT_LOG_COPYTO_DEFAULT}" - ;; - [Ff][Aa][Ll][Ss][Ee]) - GK_INIT_LOG_COPYTO= - ;; - [Nn][Oo]) - GK_INIT_LOG_COPYTO= - ;; - [Nn]) - GK_INIT_LOG_COPYTO= - ;; - 0) - GK_INIT_LOG_COPYTO= - ;; - *) - GK_INIT_LOG_COPYTO=${x#*=} - ;; - esac - ;; gk.sshd.port=*) tmp_port=${x#*=} if is_int "${tmp_port}" @@ -1338,8 +1313,6 @@ fi # Run debug shell if requested rundebugshell "before entering switch_root" -preserve_log - # init_opts is set in the environment by the kernel when it parses the command line init=${REAL_INIT:-/sbin/init} if ! mountpoint "${CHROOT}" 1>/dev/null 2>&1 |