Provide a new console early initscript for console setting with plymouth support (requires kbd and obsoletes its initscript)

This commit is contained in:
Silvan Calarco 2011-11-30 17:08:46 +01:00
parent f13cf13e4a
commit 79c2f0913b
3 changed files with 121 additions and 0 deletions

32
etc/rc.d/init.d/console Executable file
View File

@ -0,0 +1,32 @@
#!/bin/sh
# console - Console init script with plymouth support
. /etc/sysconfig/rc
. $rc_functions
INITTY="0 1 2 3 4 5 6"
[ -c /dev/zero ] || mknod -m 0666 /dev/zero c 1 5
[ -c /dev/ptmx ] || mknod -m 0666 /dev/ptmx c 5 2
for tty in 0 1 2 3 4 5 6; do
[ -c /dev/tty$tty ] || mknod -m 0620 /dev/tty$tty c 4 $tty
done
[ -e /dev/systty ] || ln -s tty0 /dev/systty
[ -c /dev/fb0 ] || mknod -m 0660 /dev/fb0 c 29 0
[ -e /dev/fb ] || ln -s fb0 /dev/fb
echo -n "Setting i18n, keyboard and console: "
for tty in $INITTY; do
/sbin/console_init tty$tty
done
[ -e $PLYMOUTHD ] || exit 0
# do nothing if plymouth was already started in initramfs
pidof $PLYMOUTHD >/dev/null && exit 0
echo -n "Starting plymouth daemon: "
mkdir -m 0755 /run/plymouth
$PLYMOUTHD --attach-to-session --pid-file /run/plymouth/pid
evaluate_retval
echo
$PLYMOUTH show-splash

View File

@ -0,0 +1 @@
../init.d/console

88
sbin/console_init Executable file
View File

@ -0,0 +1,88 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
[ -e /etc/vconsole.conf ] && . /etc/vconsole.conf
DEFAULT_FONT=LatArCyrHeb-16
DEFAULT_KEYMAP=/etc/sysconfig/console/default.kmap
set_keyboard() {
local param
[ "${UNICODE}" = 1 ] && param=-u || param=-a
kbd_mode ${param}
}
set_terminal() {
local dev=$1
if [ "${UNICODE}" = 1 ]; then
printf '\033%%G' >&7
stty -F ${dev} iutf8
else
printf '\033%%@' >&7
fi
}
set_keymap() {
local utf_switch
if [ -z "${KEYMAP}" ]; then
[ -f "${DEFAULT_KEYMAP}" ] && KEYMAP=${DEFAULT_KEYMAP}
fi
[ -n "${KEYMAP}" ] || return 1
[ "${UNICODE}" = 1 ] && utf_switch=-u
loadkeys -q ${utf_switch} ${KEYMAP} ${EXT_KEYMAPS}
}
set_font() {
local dev=$1; local trans=''; local uni=''
[ -z "${FONT}" ] && FONT=${DEFAULT_FONT}
[ -n "${FONT_MAP}" ] && trans="-m ${FONT_MAP}"
[ -n "${FONT_UNIMAP}" ] && uni="-u ${FONT_UNIMAP}"
setfont ${FONT} -C ${dev} ${trans} ${uni}
}
dev_close() {
exec 6>&-
exec 7>&-
}
dev_open() {
local dev=$1
exec 6<${dev} && \
exec 7>>${dev}
}
dev=/dev/${1#/dev/}
devname=${dev#/dev/}
[ -c "${dev}" ] || {
echo "Usage: $0 device" >&2
exit 1
}
dev_open ${dev}
for fd in 6 7; do
if ! [ -t ${fd} ]; then
echo "ERROR: File descriptor not opened: ${fd}" >&2
dev_close
exit 1
fi
done
set_keyboard
set_terminal ${dev}
set_font ${dev}
set_keymap
dev_close