|
|
|
@ -2,6 +2,113 @@
|
|
|
|
|
|
|
|
|
|
. /etc/initrd.defaults
|
|
|
|
|
|
|
|
|
|
splash() {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
is_fbsplash && . "${INITRD_SPLASH}"
|
|
|
|
|
|
|
|
|
|
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}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
modules_load() {
|
|
|
|
|
for module in $*
|
|
|
|
|
do
|
|
|
|
@ -408,7 +515,7 @@ bad_msg() {
|
|
|
|
|
msg_string="${msg_string:-...}"
|
|
|
|
|
if [ "$2" != 1 ]
|
|
|
|
|
then
|
|
|
|
|
splash 'verbose' > /dev/null &
|
|
|
|
|
splashcmd verbose
|
|
|
|
|
echo -e "${BAD}!!${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
@ -419,19 +526,101 @@ warn_msg() {
|
|
|
|
|
[ "$2" != 1 ] && echo -e "${WARN}**${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
crypt_filter() {
|
|
|
|
|
if [ "${CRYPT_SILENT}" = '1' ]
|
|
|
|
|
# Courtesy of dracut. Licensed under GPL-2.
|
|
|
|
|
# Taken from: dracut/modules.d/90crypt/crypt-lib.sh
|
|
|
|
|
# ask_for_password
|
|
|
|
|
#
|
|
|
|
|
# Wraps around plymouth ask-for-password and adds fallback to tty password ask
|
|
|
|
|
# if plymouth is not present.
|
|
|
|
|
#
|
|
|
|
|
# --cmd command
|
|
|
|
|
# Command to execute. Required.
|
|
|
|
|
# --prompt prompt
|
|
|
|
|
# Password prompt. Note that function already adds ':' at the end.
|
|
|
|
|
# Recommended.
|
|
|
|
|
# --tries n
|
|
|
|
|
# How many times repeat command on its failure. Default is 3.
|
|
|
|
|
# --ply-[cmd|prompt|tries]
|
|
|
|
|
# Command/prompt/tries specific for plymouth password ask only.
|
|
|
|
|
# --tty-[cmd|prompt|tries]
|
|
|
|
|
# Command/prompt/tries specific for tty password ask only.
|
|
|
|
|
# --tty-echo-off
|
|
|
|
|
# Turn off input echo before tty command is executed and turn on after.
|
|
|
|
|
# It's useful when password is read from stdin.
|
|
|
|
|
ask_for_password() {
|
|
|
|
|
local cmd; local prompt; local tries=3
|
|
|
|
|
local ply_cmd; local ply_prompt; local ply_tries=3
|
|
|
|
|
local tty_cmd; local tty_prompt; local tty_tries=3
|
|
|
|
|
local ret
|
|
|
|
|
|
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
|
case "$1" in
|
|
|
|
|
--cmd) ply_cmd="$2"; tty_cmd="$2" shift;;
|
|
|
|
|
--ply-cmd) ply_cmd="$2"; shift;;
|
|
|
|
|
--tty-cmd) tty_cmd="$2"; shift;;
|
|
|
|
|
--prompt) ply_prompt="$2"; tty_prompt="$2" shift;;
|
|
|
|
|
--ply-prompt) ply_prompt="$2"; shift;;
|
|
|
|
|
--tty-prompt) tty_prompt="$2"; shift;;
|
|
|
|
|
--tries) ply_tries="$2"; tty_tries="$2"; shift;;
|
|
|
|
|
--ply-tries) ply_tries="$2"; shift;;
|
|
|
|
|
--tty-tries) tty_tries="$2"; shift;;
|
|
|
|
|
--tty-echo-off) tty_echo_off=yes;;
|
|
|
|
|
esac
|
|
|
|
|
shift
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
{ flock -s 9;
|
|
|
|
|
# Prompt for password with plymouth, if installed and running.
|
|
|
|
|
if is_plymouth_started
|
|
|
|
|
then
|
|
|
|
|
eval $1 >/dev/null 2>/dev/null
|
|
|
|
|
"${PLYMOUTH_BIN}" ask-for-password \
|
|
|
|
|
--prompt "$ply_prompt" \
|
|
|
|
|
--number-of-tries=$ply_tries \
|
|
|
|
|
--command="$ply_cmd"
|
|
|
|
|
ret=$?
|
|
|
|
|
else
|
|
|
|
|
splash 'verbose' > /dev/null &
|
|
|
|
|
eval $1
|
|
|
|
|
res=$?
|
|
|
|
|
if [ ${res} -eq 0 ]
|
|
|
|
|
splashcmd verbose
|
|
|
|
|
if [ "$tty_echo_off" = yes ]; then
|
|
|
|
|
stty_orig="$(stty -g)"
|
|
|
|
|
stty -echo
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
local i=1
|
|
|
|
|
while [ $i -le $tty_tries ]; do
|
|
|
|
|
[ -n "$tty_prompt" ] && \
|
|
|
|
|
printf "$tty_prompt [$i/$tty_tries]:" >&2
|
|
|
|
|
eval "$tty_cmd" && ret=0 && break
|
|
|
|
|
ret=$?
|
|
|
|
|
i=$(($i+1))
|
|
|
|
|
[ -n "$tty_prompt" ] && printf '\n' >&2
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
[ "$tty_echo_off" = yes ] && stty $stty_orig
|
|
|
|
|
|
|
|
|
|
# no need for: splashcmd quiet
|
|
|
|
|
# since fbsplash does not support it
|
|
|
|
|
if [ $ret -ne 0 ] && is_fbsplash
|
|
|
|
|
then
|
|
|
|
|
splash set_msg 'Disk unlocked.'
|
|
|
|
|
splashcmd set_msg 'Disk unlocked.'
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
return ${res}
|
|
|
|
|
} 9>/.console_lock
|
|
|
|
|
|
|
|
|
|
[ $ret -ne 0 ] && bad_msg "Wrong password"
|
|
|
|
|
return $ret
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
crypt_exec() {
|
|
|
|
|
if [ "${CRYPT_SILENT}" = '1' ]
|
|
|
|
|
then
|
|
|
|
|
eval ${1} >/dev/null 2>/dev/null
|
|
|
|
|
else
|
|
|
|
|
ask_for_password --ply-tries 1 \
|
|
|
|
|
--ply-cmd "${1}" \
|
|
|
|
|
--ply-prompt "Password (${LUKS_DEVICE})" \
|
|
|
|
|
--tty-tries 1 \
|
|
|
|
|
--tty-cmd "${1}" || return 1
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -448,6 +637,7 @@ prompt_user(){
|
|
|
|
|
bad_msg "Please file a bug report with this message" && exit 1
|
|
|
|
|
[ -n "${3}" ] && local explnt=" or : ${3}" || local explnt="."
|
|
|
|
|
|
|
|
|
|
splashcmd verbose
|
|
|
|
|
bad_msg "Could not find the ${2} in ${oldvalue}${explnt}"
|
|
|
|
|
bad_msg "Please specify another value or:"
|
|
|
|
|
bad_msg "- press Enter for the same"
|
|
|
|
@ -470,6 +660,7 @@ prompt_user(){
|
|
|
|
|
eval ${1}'='${oldvalue}
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
splashcmd quiet
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cmdline_hwopts() {
|
|
|
|
@ -558,7 +749,7 @@ chooseKeymap() {
|
|
|
|
|
good_msg "Loading keymaps"
|
|
|
|
|
if [ -z "${keymap}" ]
|
|
|
|
|
then
|
|
|
|
|
splash 'verbose' > /dev/null &
|
|
|
|
|
splashcmd verbose
|
|
|
|
|
cat /lib/keymaps/keymapList
|
|
|
|
|
read -t 10 -p '<< Load keymap (Enter for default): ' keymap
|
|
|
|
|
case ${keymap} in
|
|
|
|
@ -613,12 +804,12 @@ chooseKeymap() {
|
|
|
|
|
loadkmap < /lib/keymaps/${keymap}.map
|
|
|
|
|
mkdir -p /etc/sysconfig
|
|
|
|
|
echo "XKEYBOARD=${keymap}" > /etc/sysconfig/keyboard
|
|
|
|
|
splash set_msg "Set keymap to ${keymap}"
|
|
|
|
|
splashcmd set_msg "Set keymap to ${keymap}"
|
|
|
|
|
elif [ -z "${keymap}" ]
|
|
|
|
|
then
|
|
|
|
|
good_msg
|
|
|
|
|
good_msg "Keeping default keymap"
|
|
|
|
|
splash set_msg "Keeping default keymap"
|
|
|
|
|
splashcmd set_msg "Keeping default keymap"
|
|
|
|
|
else
|
|
|
|
|
bad_msg "Sorry, but keymap ''${keymap}'' is invalid!"
|
|
|
|
|
unset keymap
|
|
|
|
@ -939,14 +1130,14 @@ openLUKS() {
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
# At this point, keyfile or not, we're ready!
|
|
|
|
|
crypt_filter "${gpg_cmd}cryptsetup ${cryptsetup_options} luksOpen ${LUKS_DEVICE} ${LUKS_NAME}"
|
|
|
|
|
crypt_filter_ret=$?
|
|
|
|
|
crypt_exec "${gpg_cmd}cryptsetup ${cryptsetup_options} luksOpen ${LUKS_DEVICE} ${LUKS_NAME}"
|
|
|
|
|
crypt_exec_ret=$?
|
|
|
|
|
|
|
|
|
|
[ -e /dev/tty.org ] \
|
|
|
|
|
&& rm -f /dev/tty \
|
|
|
|
|
&& mv /dev/tty.org /dev/tty
|
|
|
|
|
|
|
|
|
|
if [ ${crypt_filter_ret} -eq 0 ]
|
|
|
|
|
if [ ${crypt_exec_ret} -eq 0 ]
|
|
|
|
|
then
|
|
|
|
|
good_msg "LUKS device ${LUKS_DEVICE} opened" ${CRYPT_SILENT}
|
|
|
|
|
break
|
|
|
|
@ -1061,8 +1252,10 @@ setup_md_device() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
do_rundebugshell() {
|
|
|
|
|
splashcmd verbose
|
|
|
|
|
good_msg 'Type "exit" to continue with normal bootup.'
|
|
|
|
|
[ -x /bin/sh ] && /bin/sh || /bin/ash
|
|
|
|
|
splashcmd quiet
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rundebugshell() {
|
|
|
|
|