Thank you for this patch. I will include it in the next release (within
the week, I hope).
I shall be keeping the '.. done' for the moment, as I believe it is
useful when running
init scripts in parallel, and do not wish to experiment with this at
this stage of
release preparations, but the overall startup is a good improvement.
Regards
Alastair
Karol Lewandowski wrote:
> Package: console-tools
> Version: 1:0.2.3dbs-64
> Severity: normal
> Tags: patch
>
> console-screen.sh init script spawns many really unncessary processes.
> I'm providing patch along with commentary to fix this.
>
> --- console-screen.sh.orig 2006-08-09 02:04:35.000000000 +0200
> +++ console-screen.sh 2006-08-09 02:02:38.000000000 +0200
> @@ -82,16 +82,15 @@
>
> # start vcstime
> if [ "${DO_VCSTIME}" = "yes" -a -x ${VCSTIME} ] ; then
> - echo -n Starting clock on text console: `basename ${VCSTIME}`
> + echo Starting clock on text console: ${VCSTIME}
>
> Spawning process to canoncalize executable name seems unncessary for me...
>
> ${VCSTIME} ${VCSTIME_OPT} &
> - echo .
>
> Style... I really don't like "echo -n"; ...; echo "done" combo.
> This is just personal thing, "echo" is shell built-in so it doesn't do
> harm, please ignore this if you like different way. (and it seems you
> do :)
>
> fi
>
>
> # Global default font+sfm
> if [ "${SCREEN_FONT}" ]
> then
> - echo -n "Setting up general console font... "
> + echo "Setting up general console font."
> SCREEN_FONT="-f ${SCREEN_FONT}"
>
> # maybe use an external SFM
> @@ -101,76 +100,56 @@
> # _before_ getty and so only one console running. So,
> # Set for the first 6 VCs (as they are allocated in /etc/inittab)
> NUM_CONSOLES=`fgconsole --next-available`
> - NUM_CONSOLES=`expr ${NUM_CONSOLES} - 1`
> + NUM_CONSOLES=$(($NUM_CONSOLES - 1))
>
> $((expression)) works with dash/ash, no need for expr.
>
>
> [ ${NUM_CONSOLES} -eq 1 ] && NUM_CONSOLES=6
> - for vc in `seq 0 ${NUM_CONSOLES}`
> + i=0
> + while [ $i -lt $NUM_CONSOLES ]
> do
> - ${SETFONT} --tty=${DEVICE_PREFIX}$vc ${SETFONT_OPT} ${SCREEN_FONT}
> ${SCREEN_FONT_MAP} || { echo " failed."; break; }
> - if [ "$vc" -eq ${NUM_CONSOLES} ]; then echo " done."; fi
> + ${SETFONT} --tty=${DEVICE_PREFIX}$i ${SETFONT_OPT} ${SCREEN_FONT}
> ${SCREEN_FONT_MAP} || { echo "$i failed."; break; }
> + i=$(($i + 1))
> done
> fi
>
> seq of course spawns process... "[" and "$((expression))" is built-in.
>
>
> Here goes tricky part, I wont explain this -- I dont use SFMs so I
> fixed ACMs and copied changes here... I haven't tested font+sfm
> part! (It should work, though.)
>
> - # Per-VC font+sfm
> - PERVC_FONTS="`set | grep "^SCREEN_FONT_vc[0-9]*=" | tr -d \' `"
> - if [ "${PERVC_FONTS}" ]
> + # Per-VC SFMs
> + VCS="`set | grep '^SCREEN_FONT_vc[0-9]*=' | sed -e 's/^SCREEN_FONT_vc//'
> -e 's/=.*//'`"
> + if [ "${VCS}" ]
> then
> - echo -n "Setting up per-VC fonts: "
> - for font in ${PERVC_FONTS}
> + echo "Setting up per-VC fonts."
> + for vc in ${VCS}
> do
> - # extract VC and FONTNAME info from variable setting
> - vc=`echo $font | cut -b15- | cut -d= -f1`
> eval font=\$SCREEN_FONT_vc$vc
> - if [ X"$QUIET_PERVC" != X1 ] ; then
> - echo -n "${DEVICE_PREFIX}${vc}, "
> - fi
> - # eventually find an associated SFM
> eval sfm=\${SCREEN_FONT_MAP_vc${vc}}
> [ "$sfm" ] && sfm="-u $sfm"
> -
> ${SETFONT} --tty=${DEVICE_PREFIX}$vc ${SETFONT_OPT} -f $font $sfm
> done
> - echo "done."
> fi
>
>
> -
> # Global ACM
> [ "${APP_CHARSET_MAP}" ] && ${CHARSET} G0 ${APP_CHARSET_MAP}
>
> ACMs start here:
>
> -
> # Per-VC ACMs
> - PERVC_ACMS="`set | grep "^APP_CHARSET_MAP_vc[0-9]*=" | tr -d \' `"
> - if [ "${PERVC_ACMS}" ]
> + VCS="`set | grep '^APP_CHARSET_MAP_vc[0-9]*=' | sed -e
> 's/^APP_CHARSET_MAP_vc//' -e 's/=.*//'`"
>
>
> Here, by use of different construct I got list of numbers instead of
> APP_CHARSET_MAP_vc-thing that need to be parsed in every iteration of loop.
>
>
> + if [ "${VCS}" ]
> then
> - echo -n "Setting up per-VC ACM's: "
> - for acm in ${PERVC_ACMS}
> + echo "Setting up per-VC ACM's."
> + for vc in ${VCS}
> do
> - # extract VC and FONTNAME info from variable setting
> - vc=`echo $acm | cut -b19- | cut -d= -f1`
>
> That saves many processess per iteration...
>
> eval acm=\$APP_CHARSET_MAP_vc$vc
>
> - if [ X"$QUIET_PERVC" != X1 ] ; then
> - echo -n "${DEVICE_PREFIX}${vc} ($acm), "
> - fi
>
> Personal style... sorry for that. ;)
>
> - eval "${CHARSET} --tty='${DEVICE_PREFIX}$vc' G0 '$acm'"
> + ${CHARSET} --tty="${DEVICE_PREFIX}$vc" G0 "$acm"
>
> eval wasn't needed there, was it?
>
> done
> - echo "done."
> fi
>
>
> # Go to UTF-8 mode as necessary
> #
> - ENV_FILE="/dev/null"
> + ENV_FILE=''
> [ -r /etc/environment ] && ENV_FILE="/etc/environment"
> [ -r /etc/default/locale ] && ENV_FILE="/etc/default/locale"
> - for var in LANG LC_ALL LC_CTYPE ; do
> - value=$(egrep "^\s*${var}=" $ENV_FILE | tail -n1 | cut -d= -f2)
> - eval $var=$value
> - done
> - CHARMAP=`LANG=$LANG LC_ALL=$LC_ALL LC_CTYPE=$LC_CTYPE locale charmap`
> - if test "$CHARMAP" = "UTF-8"
> + [ "$ENV_FILE" ] && CHARMAP=$(set -a && . "$ENV_FILE" && locale charmap)
>
> This is fast -- by use of auto export shell option this work
> flawlessly (I hope).
>
> + if test "$CHARMAP" = "UTF-8"
> then
> unicode_start 2> /dev/null || true
> -
> else
> unicode_stop 2> /dev/null|| true
> fi
> @@ -212,14 +191,16 @@
> # Allow user to remap keys on the console
> if [ -r /etc/console-tools/remap ]
> then
> - dumpkeys < ${DEVICE_PREFIX}1 |sed -f /etc/console-tools/remap |loadkeys
> --quiet
> + dumpkeys < ${DEVICE_PREFIX}1 | sed -f /etc/console-tools/remap |
> loadkeys --quiet
>
> Couldn't resist.
>
> fi
> # Set LEDS here
> if [ "$LEDS" != "" ]
> then
> - for i in `seq 1 ${NUM_CONSOLES}`
> + i=1
> + while [ $i -lt $NUM_CONSOLES ]
> do
> setleds -D $LEDS < $DEVICE_PREFIX$i
> + i=$(($i + 1))
> done
>
> Yet another remove-seq, use-builtins fixes.
>
> fi
> }
>
>
> These changes save about 90 pids! Main offenders are now consolechars
> and charset by itself ("consolechars -f font -m acm" spawns 7 pids).
>
> Please consider using parts (non-cosmetic ones) of my patch.
>
> Thanks for your work!
>
>
> Here goes patch without commentary:
>
> --- console-screen.sh.orig 2006-08-09 02:04:35.000000000 +0200
> +++ console-screen.sh 2006-08-09 02:02:38.000000000 +0200
> @@ -82,16 +82,15 @@
>
> # start vcstime
> if [ "${DO_VCSTIME}" = "yes" -a -x ${VCSTIME} ] ; then
> - echo -n Starting clock on text console: `basename ${VCSTIME}`
> + echo Starting clock on text console: ${VCSTIME}
> ${VCSTIME} ${VCSTIME_OPT} &
> - echo .
> fi
>
>
> # Global default font+sfm
> if [ "${SCREEN_FONT}" ]
> then
> - echo -n "Setting up general console font... "
> + echo "Setting up general console font."
> SCREEN_FONT="-f ${SCREEN_FONT}"
>
> # maybe use an external SFM
> @@ -101,76 +100,56 @@
> # _before_ getty and so only one console running. So,
> # Set for the first 6 VCs (as they are allocated in /etc/inittab)
> NUM_CONSOLES=`fgconsole --next-available`
> - NUM_CONSOLES=`expr ${NUM_CONSOLES} - 1`
> + NUM_CONSOLES=$(($NUM_CONSOLES - 1))
> [ ${NUM_CONSOLES} -eq 1 ] && NUM_CONSOLES=6
> - for vc in `seq 0 ${NUM_CONSOLES}`
> + i=0
> + while [ $i -lt $NUM_CONSOLES ]
> do
> - ${SETFONT} --tty=${DEVICE_PREFIX}$vc ${SETFONT_OPT} ${SCREEN_FONT}
> ${SCREEN_FONT_MAP} || { echo " failed."; break; }
> - if [ "$vc" -eq ${NUM_CONSOLES} ]; then echo " done."; fi
> + ${SETFONT} --tty=${DEVICE_PREFIX}$i ${SETFONT_OPT} ${SCREEN_FONT}
> ${SCREEN_FONT_MAP} || { echo "$i failed."; break; }
> + i=$(($i + 1))
> done
> fi
>
>
> - # Per-VC font+sfm
> - PERVC_FONTS="`set | grep "^SCREEN_FONT_vc[0-9]*=" | tr -d \' `"
> - if [ "${PERVC_FONTS}" ]
> + # Per-VC SFMs
> + VCS="`set | grep '^SCREEN_FONT_vc[0-9]*=' | sed -e 's/^SCREEN_FONT_vc//'
> -e 's/=.*//'`"
> + if [ "${VCS}" ]
> then
> - echo -n "Setting up per-VC fonts: "
> - for font in ${PERVC_FONTS}
> + echo "Setting up per-VC fonts."
> + for vc in ${VCS}
> do
> - # extract VC and FONTNAME info from variable setting
> - vc=`echo $font | cut -b15- | cut -d= -f1`
> eval font=\$SCREEN_FONT_vc$vc
> - if [ X"$QUIET_PERVC" != X1 ] ; then
> - echo -n "${DEVICE_PREFIX}${vc}, "
> - fi
> - # eventually find an associated SFM
> eval sfm=\${SCREEN_FONT_MAP_vc${vc}}
> [ "$sfm" ] && sfm="-u $sfm"
> -
> ${SETFONT} --tty=${DEVICE_PREFIX}$vc ${SETFONT_OPT} -f $font $sfm
> done
> - echo "done."
> fi
>
> -
> # Global ACM
> [ "${APP_CHARSET_MAP}" ] && ${CHARSET} G0 ${APP_CHARSET_MAP}
>
> -
> # Per-VC ACMs
> - PERVC_ACMS="`set | grep "^APP_CHARSET_MAP_vc[0-9]*=" | tr -d \' `"
> - if [ "${PERVC_ACMS}" ]
> + VCS="`set | grep '^APP_CHARSET_MAP_vc[0-9]*=' | sed -e
> 's/^APP_CHARSET_MAP_vc//' -e 's/=.*//'`"
> + if [ "${VCS}" ]
> then
> - echo -n "Setting up per-VC ACM's: "
> - for acm in ${PERVC_ACMS}
> + echo "Setting up per-VC ACM's."
> + for vc in ${VCS}
> do
> - # extract VC and FONTNAME info from variable setting
> - vc=`echo $acm | cut -b19- | cut -d= -f1`
> eval acm=\$APP_CHARSET_MAP_vc$vc
> - if [ X"$QUIET_PERVC" != X1 ] ; then
> - echo -n "${DEVICE_PREFIX}${vc} ($acm), "
> - fi
> - eval "${CHARSET} --tty='${DEVICE_PREFIX}$vc' G0 '$acm'"
> + ${CHARSET} --tty="${DEVICE_PREFIX}$vc" G0 "$acm"
> done
> - echo "done."
> fi
>
>
> # Go to UTF-8 mode as necessary
> #
> - ENV_FILE="/dev/null"
> + ENV_FILE=''
> [ -r /etc/environment ] && ENV_FILE="/etc/environment"
> [ -r /etc/default/locale ] && ENV_FILE="/etc/default/locale"
> - for var in LANG LC_ALL LC_CTYPE ; do
> - value=$(egrep "^\s*${var}=" $ENV_FILE | tail -n1 | cut -d= -f2)
> - eval $var=$value
> - done
> - CHARMAP=`LANG=$LANG LC_ALL=$LC_ALL LC_CTYPE=$LC_CTYPE locale charmap`
> - if test "$CHARMAP" = "UTF-8"
> + [ "$ENV_FILE" ] && CHARMAP=$(set -a && . "$ENV_FILE" && locale charmap)
> + if test "$CHARMAP" = "UTF-8"
> then
> unicode_start 2> /dev/null || true
> -
> else
> unicode_stop 2> /dev/null|| true
> fi
> @@ -212,14 +191,16 @@
> # Allow user to remap keys on the console
> if [ -r /etc/console-tools/remap ]
> then
> - dumpkeys < ${DEVICE_PREFIX}1 |sed -f /etc/console-tools/remap |loadkeys
> --quiet
> + dumpkeys < ${DEVICE_PREFIX}1 | sed -f /etc/console-tools/remap |
> loadkeys --quiet
> fi
> # Set LEDS here
> if [ "$LEDS" != "" ]
> then
> - for i in `seq 1 ${NUM_CONSOLES}`
> + i=1
> + while [ $i -lt $NUM_CONSOLES ]
> do
> setleds -D $LEDS < $DEVICE_PREFIX$i
> + i=$(($i + 1))
> done
> fi
> }
>
>
> -- System Information:
> Debian Release: testing/unstable
> APT prefers testing
> APT policy: (500, 'testing'), (10, 'unstable')
> Architecture: i386 (i686)
> Shell: /bin/sh linked to /bin/dash
> Kernel: Linux 2.6.17-riddly3
> Locale: LANG=C, LC_CTYPE=pl_PL (charmap=ISO-8859-2)
>
> Versions of packages console-tools depends on:
> ii debconf [debconf-2.0] 1.5.2 Debian configuration management
> sy
> ii libc6 2.3.6-15 GNU C Library: Shared libraries
> ii libconsole 1:0.2.3dbs-64 Shared libraries for Linux
> console
> ii sysvinit 2.86.ds1-15 System-V-like init utilities
>
> Versions of packages console-tools recommends:
> ii console-common 0.7.60 Basic infrastructure for text
> cons
> ii console-data 2:1.0-2 Keymaps, fonts, charset maps,
> fall
>
> -- no debconf information
>
>
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]