From 7f89f73e4044457eece39ec4779b28f8ecac9230 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Mon, 11 Jan 2010 18:35:03 +0000 Subject: [PATCH 1/2] Recalc columns after module loading Due to KMS, the bootup tends to get out of whack sometimes. To remedy this, we'll try to recalculate the column width after each operation that has potential to change the display mode Signed-off-by: Aaron Griffin --- functions | 32 ++++++++++++++++++-------------- rc.multi | 8 ++++++-- rc.sysinit | 4 ++++ 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/functions b/functions index 909b756..4870883 100644 --- a/functions +++ b/functions @@ -5,25 +5,29 @@ # width: STAT_COL=80 -if [[ ! -t 1 ]]; then +calc_columns() { + if [ ! -t 1 ]; then USECOLOR="" -elif [[ -t 0 ]]; then - # stty will fail when stdin isn't a terminal + # stty will fail when stdin isn't a terminal + elif [ -t 0 ]; then STAT_COL="$(/bin/stty size)" # stty gives "rows cols"; strip the rows number, we just want columns STAT_COL="${STAT_COL##* }" -elif /bin/tput cols &>/dev/null; then - # is /usr/share/terminfo already mounted, and TERM recognized? - STAT_COL=$(/bin/tput cols) -fi -if ((STAT_COL==0)); then - # if output was 0 (serial console), set default width to 80 - STAT_COL=80 - USECOLOR="" -fi + elif /bin/tput cols &>/dev/null; then + # is /usr/share/terminfo already mounted, and TERM recognized? + STAT_COL=$(/bin/tput cols) + fi + if ((STAT_COL==0)); then + # if output was 0 (serial console), set default width to 80 + STAT_COL=80 + USECOLOR="" + fi + + # we use 13 characters for our own stuff + STAT_COL=$(($STAT_COL - 13)) +} -# we use 13 characters for our own stuff -STAT_COL=$(($STAT_COL - 13)) +calc_columns # disable colors on broken terminals TERM_COLORS="$(/bin/tput colors 2>/dev/null)" diff --git a/rc.multi b/rc.multi index 660f649..a66e779 100755 --- a/rc.multi +++ b/rc.multi @@ -15,8 +15,12 @@ run_hook multi_start for daemon in "${DAEMONS[@]}"; do case ${daemon:0:1} in '!') continue;; # Skip this daemon. - '@') start_daemon_bkgd "${daemon#@}";; - *) start_daemon "$daemon";; + '@') + start_daemon_bkgd "${daemon#@}" + calc_columns;; + *) + start_daemon "$daemon" + calc_columns;; esac done diff --git a/rc.sysinit b/rc.sysinit index 44c3eac..fc561d6 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -76,6 +76,7 @@ echo > /proc/sys/kernel/hotplug stat_busy "Starting UDev Daemon" /sbin/udevd --daemon +calc_columns stat_done run_hook sysinit_udevlaunched @@ -86,6 +87,7 @@ if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then /sbin/udevadm control --property=STARTUP=1 /sbin/udevadm trigger --action=add --type=devices /sbin/udevadm trigger --action=add --type=subsystems + calc_columns stat_done fi @@ -94,6 +96,7 @@ mods=${MODULES[@]/!*/} if [[ $load_modules != off && -f /proc/modules && $mods ]]; then stat_busy "Loading Modules" /sbin/modprobe --all $mods + calc_columns stat_done fi unset mods @@ -103,6 +106,7 @@ if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then stat_busy "Waiting for UDev uevents to be processed" /sbin/udevadm settle /sbin/udevadm control --property=STARTUP= + calc_columns stat_done fi -- 1.7.4.1