diff --git a/defaults/initrd.d/00-splash.sh b/defaults/initrd.d/00-splash.sh new file mode 100755 index 0000000..29f4a0c --- /dev/null +++ b/defaults/initrd.d/00-splash.sh @@ -0,0 +1,116 @@ +#!/bin/sh + +splash() { + return 0 +} + +[ -e "${INITRD_SPLASH}" ] && . "${INITRD_SPLASH}" + +is_fbsplash() { + if [ -e "${INITRD_SPLASH}" ] && [ "${FBSPLASH}" = '1' ] + then + return 0 + fi + return 1 +} + +is_plymouth() { + if [ "${PLYMOUTH}" = '1' ] && [ "${QUIET}" = '1' ] \ + && [ -e "${PLYMOUTHD_BIN}" ] + then + return 0 + fi + return 1 +} + +is_plymouth_started() { + [ -n "${PLYMOUTH_FAILURE}" ] && return 1 + is_plymouth && "${PLYMOUTH_BIN}" --ping 2>/dev/null && return 0 + return 1 +} + +splashcmd() { + # plymouth support + local cmd="${1}" + shift + + case "${cmd}" in + init) + is_fbsplash && splash init + is_plymouth && plymouth_init + ;; + + verbose) + is_fbsplash && splash verbose + plymouth_hide + ;; + + quiet) + # no fbsplash support + plymouth_show + ;; + + set_msg) + is_fbsplash && splash set_msg "${1}" + plymouth_message "${1}" + ;; + + hasroot) + # no fbsplash support + plymouth_newroot "${1}" + ;; + esac +} + +plymouth_init() { + good_msg "Enabling Plymouth" + mkdir -p /run/plymouth || return 1 + + # Make sure that udev is done loading tty and drm + if is_udev + then + udevadm trigger --action=add --attr-match=class=0x030000 \ + >/dev/null 2>&1 + udevadm trigger --action=add --subsystem-match=graphics \ + --subsystem-match=drm --subsystem-match=tty \ + >/dev/null 2>&1 + udevadm settle + fi + + local consoledev= + local other= + read consoledev other < /sys/class/tty/console/active + consoledev=${consoledev:-tty0} + "${PLYMOUTHD_BIN}" --attach-to-session --pid-file /run/plymouth/pid \ + || { + bad_msg "Plymouth load error"; + PLYMOUTH_FAILURE=1 + return 1; + } + plymouth_show + good_msg "Plymouth enabled" +} + +plymouth_hide() { + is_plymouth_started && "${PLYMOUTH_BIN}" --hide-splash +} + +plymouth_show() { + is_plymouth_started && "${PLYMOUTH_BIN}" --show-splash +} + +plymouth_message() { + is_plymouth_started && "${PLYMOUTH_BIN}" --update="${1}" +} + +plymouth_newroot() { + is_plymouth_started && "${PLYMOUTH_BIN}" --newroot="${1}" +} + +splash_init() { + if is_udev; then + # if udev, we can load the splash earlier + # In the plymouth case, udev will load KMS automatically + splashcmd init + fi +} \ No newline at end of file diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index a7711e5..6abc5d3 100755 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -1,121 +1,8 @@ #!/bin/sh . /etc/initrd.defaults +. /etc/initrd.d/00-splash.sh -splash() { - return 0 -} - -[ -e "${INITRD_SPLASH}" ] && . "${INITRD_SPLASH}" - -is_fbsplash() { - if [ -e "${INITRD_SPLASH}" ] && [ "${FBSPLASH}" = '1' ] - then - return 0 - fi - return 1 -} - -is_plymouth() { - if [ "${PLYMOUTH}" = '1' ] && [ "${QUIET}" = '1' ] \ - && [ -e "${PLYMOUTHD_BIN}" ] - then - return 0 - fi - return 1 -} - -is_plymouth_started() { - [ -n "${PLYMOUTH_FAILURE}" ] && return 1 - is_plymouth && "${PLYMOUTH_BIN}" --ping 2>/dev/null && return 0 - return 1 -} - -splashcmd() { - # plymouth support - local cmd="${1}" - shift - - case "${cmd}" in - init) - is_fbsplash && splash init - is_plymouth && plymouth_init - ;; - - verbose) - is_fbsplash && splash verbose - plymouth_hide - ;; - - quiet) - # no fbsplash support - plymouth_show - ;; - - set_msg) - is_fbsplash && splash set_msg "${1}" - plymouth_message "${1}" - ;; - - hasroot) - # no fbsplash support - plymouth_newroot "${1}" - ;; - esac -} - -plymouth_init() { - good_msg "Enabling Plymouth" - mkdir -p /run/plymouth || return 1 - - # Make sure that udev is done loading tty and drm - if is_udev - then - udevadm trigger --action=add --attr-match=class=0x030000 \ - >/dev/null 2>&1 - udevadm trigger --action=add --subsystem-match=graphics \ - --subsystem-match=drm --subsystem-match=tty \ - >/dev/null 2>&1 - udevadm settle - fi - - local consoledev= - local other= - read consoledev other < /sys/class/tty/console/active - consoledev=${consoledev:-tty0} - "${PLYMOUTHD_BIN}" --attach-to-session --pid-file /run/plymouth/pid \ - || { - bad_msg "Plymouth load error"; - PLYMOUTH_FAILURE=1 - return 1; - } - plymouth_show - good_msg "Plymouth enabled" -} - -plymouth_hide() { - is_plymouth_started && "${PLYMOUTH_BIN}" --hide-splash -} - -plymouth_show() { - is_plymouth_started && "${PLYMOUTH_BIN}" --show-splash -} - -plymouth_message() { - is_plymouth_started && "${PLYMOUTH_BIN}" --update="${1}" -} - -plymouth_newroot() { - is_plymouth_started && "${PLYMOUTH_BIN}" --newroot="${1}" -} - -splash_init() { - if is_udev; then - # if udev, we can load the splash earlier - # In the plymouth case, udev will load KMS automatically - splashcmd init - fi -} call_func_timeout() { local func=$1 timeout=$2 pid watcher diff --git a/gen_initramfs.sh b/gen_initramfs.sh index 5330190..f136614 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -843,6 +843,15 @@ append_auxilary() { cp "${GK_SHARE}/defaults/initrd.scripts" "${TEMP}/initramfs-aux-temp/etc/initrd.scripts" fi + if [ -d "${GK_SHARE}/arch/${ARCH}/initrd.d" ] + then + cp -r "${GK_SHARE}/arch/${ARCH}/initrd.d" \ + "${TEMP}/initramfs-aux-temp/etc/" + else + cp -r "${GK_SHARE}/defaults/initrd.d" \ + "${TEMP}/initramfs-aux-temp/etc/" + fi + if [ -f "${GK_SHARE}/arch/${ARCH}/initrd.defaults" ] then cp "${GK_SHARE}/arch/${ARCH}/initrd.defaults" "${TEMP}/initramfs-aux-temp/etc/initrd.defaults" @@ -879,6 +888,7 @@ append_auxilary() { chmod +x "${TEMP}/initramfs-aux-temp/init" chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.scripts" chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.defaults" + chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.d/"* if isTrue ${NETBOOT} then