1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
|
#!/bin/sh
#
# This is the boot script for the `console-tools' package.
#
# It loads parameters from /etc/console-tools/config, maybe loads
# default screen-font, screen font-map, and application charset-map,
# and maybe start "vcstime"
#
# (c) 1997 Yann Dirson
if [ -r /etc/console-tools/config ] ; then
. /etc/console-tools/config
fi
if [ -d /etc/console-tools/config.d ]; then
for i in /etc/console-tools/config.d/*; do
. $i
done
fi
PATH=/sbin:/bin:/usr/sbin:/usr/bin
SETFONT="/usr/bin/consolechars"
SETFONT_OPT=""
CHARSET="/usr/bin/charset"
VCSTIME="/usr/sbin/vcstime"
# Different device name for 2.6 kernels and devfs
if [ `uname -r | cut -f 2 -d .` = 6 ] && [ -e /dev/.devfsd ]; then
VCSTIME_OPT="-2 /dev/vcsa0"
else
VCSTIME_OPT=""
fi
# be sure the main program is installed
[ -x "${SETFONT}" ] || exit 0
# set DEVICE_PREFIX depending on devfs/udev
if [ -d /dev/vc ]; then
DEVICE_PREFIX="/dev/vc/"
else
DEVICE_PREFIX="/dev/tty"
fi
reset_vga_palette ()
{
if [ -f /proc/fb ]; then
# They have a framebuffer device.
# That means we have work to do...
echo -n "]R"
fi
}
setup ()
{
VT="no"
# If we can't access the console, quit
CONSOLE_TYPE=`fgconsole 2>/dev/null` || exit 0
if [ ! $CONSOLE_TYPE = "serial" ] ; then
readlink /proc/self/fd/0 | grep -q -e /dev/vc -e '/dev/tty[^p]' -e /dev/console
if [ $? -eq 0 ] ; then
VT="yes"
reset_vga_palette
fi
fi
[ $VT = "no" ] && exit 0
# start vcstime
if [ "${DO_VCSTIME}" = "yes" -a -x ${VCSTIME} ] ; then
echo -n Starting clock on text console: `basename ${VCSTIME}`
${VCSTIME} ${VCSTIME_OPT} &
echo .
fi
# Global default font+sfm
if [ "${SCREEN_FONT}" ]
then
echo -n "Setting up general console font... "
SCREEN_FONT="-f ${SCREEN_FONT}"
# maybe use an external SFM
[ "${SCREEN_FONT_MAP}" ] && SCREEN_FONT_MAP="-u ${SCREEN_FONT_MAP}"
# Set for the first 6 VCs (as they are allocated in /etc/inittab)
NUM_CONSOLES=`fgconsole --next-available`
NUM_CONSOLES=`expr ${NUM_CONSOLES} - 1`
for vc in `seq 0 ${NUM_CONSOLES}`
do
${SETFONT} --tty=${DEVICE_PREFIX}$vc ${SETFONT_OPT} ${SCREEN_FONT} ${SCREEN_FONT_MAP} || { echo " failed."; break; }
if [ "$vc" -eq 6 ]; then echo " done."; fi
done
fi
# Per-VC font+sfm
PERVC_FONTS="`set | grep "^SCREEN_FONT_vc[0-9]*=" | tr -d \' `"
if [ "${PERVC_FONTS}" ]
then
echo -n "Setting up per-VC fonts: "
for font in ${PERVC_FONTS}
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}" ]
then
echo -n "Setting up per-VC ACM's: "
for acm in ${PERVC_ACMS}
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'"
done
echo "done."
fi
# Go to UTF-8 mode as necessary
#
if [ -f /etc/environment ]
then
for var in LANG LC_ALL LC_CTYPE ; do
value=$(egrep "^[^#]*${var}=" /etc/environment | tail -n1 | cut -d= -f2)
eval $var=$value
done
fi
CHARMAP=`LANG=$LANG LC_ALL=$LC_ALL LC_CTYPE=$LC_CTYPE locale charmap`
if test "$CHARMAP" = "UTF-8"
then
/usr/bin/unicode_start 2> /dev/null || true
else
/usr/bin/unicode_stop 2> /dev/null|| true
fi
# screensaver stuff
setterm_args=""
if [ "$BLANK_TIME" ]; then
setterm_args="$setterm_args -blank $BLANK_TIME"
fi
if [ "$BLANK_DPMS" ]; then
setterm_args="$setterm_args -powersave $BLANK_DPMS"
fi
if [ "$POWERDOWN_TIME" ]; then
setterm_args="$setterm_args -powerdown $POWERDOWN_TIME"
fi
if [ "$setterm_args" ]; then
setterm $setterm_args
fi
# Keyboard rate and delay
KBDRATE_ARGS=""
if [ -n "$KEYBOARD_RATE" ]; then
KBDRATE_ARGS="-r $KEYBOARD_RATE"
fi
if [ -n "$KEYBOARD_DELAY" ]; then
KBDRATE_ARGS="$KBDRATE_ARGS -d $KEYBOARD_DELAY"
fi
if [ -n "$KBDRATE_ARGS" ]; then
echo -n "Setting keyboard rate and delay: "
kbdrate -s $KBDRATE_ARGS
echo "done."
fi
# Inform gpm if present, of potential changes.
if [ -f /var/run/gpm.pid ]; then
kill -WINCH `cat /var/run/gpm.pid` 2> /dev/null
fi
# 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
fi
# Set LEDS here
if [ "$LEDS" != "" ]
then
for i in `seq 1 12`
do
setleds -D $LEDS < $DEVICE_PREFIX$i
done
fi
}
case "$1" in
start|reload|restart|force-reload)
setup
;;
stop)
;;
*)
setup
;;
esac
|