home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / etc / init.d / console-screen.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2006-06-30  |  5.9 KB  |  240 lines

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