Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1562271
  • 博文数量: 290
  • 博客积分: 3468
  • 博客等级: 中校
  • 技术积分: 3461
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-28 22:21
文章分类

全部博文(290)

文章存档

2016年(13)

2015年(3)

2014年(42)

2013年(67)

2012年(90)

2011年(75)

分类: LINUX

2011-05-27 11:39:41

bootsplash 的作用:把我们linux 启动时原本单调的黑底白字的系统信息换成以进度条形式显示的漂亮的启动界面

1.   内核支持:
a)     下载对应的内核补丁; 

提供有 kernel-2.6.10--39 的bootsplash内核补丁
b)   #cd /usr/src/linux-source-2.6.22
c)   #cat bootsplash-3.1.6-2.6.22.diff |patch –p1
d)   选上Device Drivers --->Graphics support --->Bootsplash configuration --->[*] Bootup splash screen
e)     重新编译内核并安装新的kernel
2.   安装bootsplash必备工具:
a)     apt-get install bootsplash bootsplash-theme-debian cramfsprogs dash intltool-debian
3.   自定义主题
a)     更改主题图片, 可直接将想要更新的图片覆盖/etc/bootsplash/themes/current/images/bootsplash-800x600.jpg(文本界面背景图片),及/etc/bootsplash/themes/current/images/silent-800x600.jpg(启动画面图片)。
b)   用附件的rc_bak覆盖/etc/init.d/rc   (进度条)
c)   用附件的splash.sh覆盖/sbin/splash.sh (进度条)
d)   splash –s –f /etc/bootsplash/current/config/bootsplash-1024x768.cfg >> /boot/initrd-1024x768 (以前都是用update-initramfs –u 来生成initrd文件,但是这样生成的文件似乎只能使用1024x768, 或者是我哪里弄错了,所以现在都使用这个来生成)
e)     /boot/grub/menu.lst文件对应的title后面的kernel行末加入vga=788 splash=silent
f)     /boot/grub/menu.lst文件对应的title后面增加一行initrd /boot/initrd-800x600
g)   #reboot 这时启动界面和进度条已经产生作用了。
4.   cfg文件详解,以bootsplash-640x480为例子:
# This is the configuration file for the 640x480 bootsplash picture.
#
# This file is necessary to specify the coordinates of the text box on
# the splash screen.
#
# Comments are welcome by stepan@suse.de


# config file version

version=3


# should the picture be displayed?

state=1


# fgcolor is the text forground color. 文本前置色及后置色,可根据需求来定制

# bgcolor is the text background (i.e. transparent) color.
fgcolor=7
bgcolor=0


# tx,ty为文本窗口起始点坐标

# tw/th 为文本窗口的宽度及高度.
tx=8
ty=72
tw=624
th=400


# jpeg为文本窗口背景图片,silentjpeg为起动画面图片

jpeg=/etc/bootsplash/themes/current/images/bootsplash-640x480.jpg
silentjpeg=/etc/bootsplash/themes/current/images/silent-640x480.jpg


progress_enable=1



# background box silent为在启动画面上画框体,box silent 左上角x坐标 左上角Y坐标 右下角X坐标 右下角Y坐标 #颜色

box silent noover 128 416 512 429 #1b4b93
box silent inter 128 417 128 428 #b77200
box silent   128 417 512 428 #b77200


# black border 画进度条边框

box silent     128 416 512 416 #b5b5b5
box silent     128 429 512 429 #b5b5b5
box silent     128 416 128 429 #b5b5b5
box silent     512 416 512 429 #b5b5b5


# text box (left, top)   box为在文本界面上画框体,用法同box silent

box       3   67 3   473 #313234
box       4   67 633 67 #313234
# (right, bottom)
box       633 68 633 473 #eef4ff
box       4   473 633 473 #eef4ff
# box itself
box noover     4   68 632 472 #04045498


overpaintok=1

5.   结束。

因CSDN不支持图片外其他格式附件故将附件文本直接贴上:

---------------------------------------rc.bak----------------------------------------------------------------------------------------------

#! /bin/bash
#
# rc  This file is responsible for starting/stopping
#  services when the runlevel changes.
#
#  Optimization feature:
#  A startup script is _not_ run when the service was
#  running in the previous runlevel and it wasn't stopped
#  in the runlevel transition (most Debian services don't
#  have K?? links in rc{1,2,3,4,5} )
#
# Author: Miquel van Smoorenburg <>
#  Bruce Perens <>
#
# Edited for bootsplash by Matthew A. Nicholson <>, 2003
#
# Version: @(#)rc  2.78  07-Nov-1999 
#

# Un-comment the following for debugging.
# debug=echo


# source the bootsplash config file
test -f /etc/default/bootsplash && . /etc/default/bootsplash

#
# Update bootsplash stuff. (progress bar, animations...)
#
rc_splash() {
   #test "$SPLASH" != "no" && test "$_rc_splash" -eq 1 && /sbin/splash "$1"
   test "$SPLASH" != "no" && /sbin/splash.sh "$1"

   # make sure we don't add unless we really made progress
   if [ "$1" != "master" -a "$1" != "splash start" -a "$1" != "shutdown" ]
   then
      progress=$(( $progress + 1 ))
   fi
}

#
# Start script or program.
#
startup() {
  case "$1" in
 *.sh)
  $debug sh "$@"
  ;;
 *)
  $debug "$@"
  ;;
  esac
}


  # Ignore CTRL-C only in this shell, so we can interrupt subprocesses.
  trap ":" INT QUIT TSTP

  # Set onlcr to avoid staircase effect.
  stty onlcr 0>&1

  # Now find out what the current and what the previous runlevel are.

  runlevel=$RUNLEVEL

  # Get first argument. Set new runlevel to this argument.
  [ "$1" != "" ] && runlevel=$1
  if [ "$runlevel" = "" ]
  then
 echo "Usage: $0 " >&2
 exit 1
  fi
  previous=$PREVLEVEL
  [ "$previous" = "" ] && previous=N

  export runlevel previous

#
# initialize boosplash progress bar variables
#
runrcS=/etc/rcS.d
runrc=/etc/rc$runlevel.d
prerc=/etc/rc$previous.d

SSC=($(echo $runrc/S*))
case "$SSC" in
*\*) sscripts=0 ;;
*) sscripts=${#SSC[*]} ;;
esac

if [ "$previous" != "N" ]; then
KSC=($(echo $runrc/K*))
   case "$KSC" in
      *\*)
      kscripts=0
      ;;

      *)
      kscripts=${#KSC[*]}
      ;;
   esac
fi

if [ "$previous" = "N" ]; then
SSC=($(echo $runrcS/S*))
   case "$SSC" in
      *\*)
      sscripts=0
      ;;

      *)
      progress=${#SSC[*]}
      sscripts=$((${#SSC[*]} + $sscripts))
      ;;
   esac
else
   progress=0
fi

export sscripts progress kscripts


#
# let bootsplash know if we are shutting down
#
if [ "$runlevel" = "0" -o "$runlevel" = "6" ]
then
   rc_splash "splash start"
   rc_splash "shutdown"
fi

  # Is there an rc directory for this new runlevel?
  if [ -d /etc/rc$runlevel.d ]
  then
 # First, run the KILL scripts.
 if [ $previous != N ]
 then
  for i in /etc/rc$runlevel.d/K[0-9][0-9]*
  do
   # Check if the script is there.
   [ ! -f $i ] && continue

   # Stop the service.
   startup $i stop
   rc_splash "$i stop"          # handle bootsplash stuff
  done
 fi
 # Now run the START scripts for this runlevel.
 for i in /etc/rc$runlevel.d/S*
 do
  [ ! -f $i ] && continue

  if [ $previous != N ] && [ $previous != S ]
  then
   #
   # Find start script in previous runlevel and
   # stop script in this runlevel.
   #
   suffix=${i#/etc/rc$runlevel.d/S[0-9][0-9]}
   stop=/etc/rc$runlevel.d/K[0-9][0-9]$suffix
   previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix
   #
   # If there is a start script in the previous level
   # and _no_ stop script in this level, we don't
   # have to re-start the service.
   #
   [ -f $previous_start ] && [ ! -f $stop ] && continue
  fi
  case "$runlevel" in
   0|6)
    startup $i stop
    rc_splash "$i stop"           # handle bootsplash stuff
    ;;
   *)
    startup $i start
    rc_splash "$i start"           # handle bootsplash stuff
    ;;
  esac
  if [ "$runlevel" != "0" -a "$runlevel" != "6" ]
  then
   rc_splash "master"
  fi
 done
 fi

rc_splash "master"   # finish up bootsplash

# eof /etc/init.d/rc

--------------------rc.bak结束---------------------------------------------------------------------------

--------------------splash.sh---------------------------------------------------------------------------

#!/bin/bash
#
# splash.sh - This shell script triggers bootsplash actions during
# system boot/shutdown. It can be run by the init scripts repeatedly
# specifying the currently executed system script.
#
# This script is used to play animations/sounds/show text/move the
# progress bar, etc.
#
# We call this function from /etc/rc.status:rc_splash()
#
# This program is free software; you may redistribute it under
# the terms of the GNU General Public License. This program has
# absolutely no warranty.
#
# written 2002-2003 Stefan Reinauer, <>
# Debianized 2004 by Sascha Schroeder, <>
# with modifications from Matthew A. Nicholson, <>
#
# this script expects the following environment variables for an operable
# progress bar:
#
#  sscripts = number of start scripts to be executed for runlevel change
#  kscripts = number of stop scripts to be executed for runlevel change
#  progress = number of currently executed start/stop script
#  RUNLEVEL = runlevel to be reached.
#
# To play animations, it's advised that you have an animations.cfg in your
# theme's config directory specifying the initscript name for an event and
# the command to be executed:
#
#   fsck start:bootanim start bounce.mng
#   master:bootanim stop
#
# See for more information.
#

_procsplash="`cat /proc/splash 2>/dev/null`"

THEME="No bootsplash theme selected"
test -f /etc/default/bootsplash && . /etc/default/bootsplash
test ! -d "/etc/bootsplash/themes/$THEME" && exit 0

# parse animations.cfg. This part should not be handled by the
# splash binary.

if [ -f /etc/bootsplash/themes/$THEME/config/animations.cfg ]; then
#  COMMAND="`cat /etc/bootsplash/themes/$THEME/config/animations.cfg | grep "^$1" | cut -f2 -d\:`"
  COMMAND="`cat /etc/bootsplash/themes/$THEME/config/animations.cfg | grep "^$1" | sed -e 's/^.*\://g;'`"
  eval $COMMAND
fi

# assertions
test -r /proc/splash || exit 0
test -z "$progress" -a -z "$num" && exit 0
test -z "`echo $_procsplash | grep on`" && exit 0
# This probably won't happen in Debian ...
#test "$1" == "bootnetwork stop" -o "$1" == "YaST" && exit 0 # no progress

# We chose verbose in grub
test "`cat /proc/cmdline | grep \"splash=silent\"`" == "" && exit 0

if [ "$PREVLEVEL" == "3" -o "$PREVLEVEL" == "5" ] ; then
  if [ "$RUNLEVEL"  = "3" -o "$RUNLEVEL" == "5" ] ; then
    exit 0
  fi
fi

# acquire data
#
#num=$(( $sscripts + 2 ))
num=$(( $sscripts ))
_shutdown="no"
_silent="no"
test "`cat /proc/splash | grep silent`" && _silent="yes"
test "$RUNLEVEL" == "6" -o "$RUNLEVEL" == "0" && _shutdown="yes"
#test "$_shutdown" == "yes" && num=$(( $kscripts + 2 ))
test "$_shutdown" == "yes" && num=$(( $kscripts ))

function box() { true; } # ignore box descriptions in the config file

test -f "/etc/bootsplash/themes/$THEME/config/bootsplash-`fbresolution`.cfg" && \
  . /etc/bootsplash/themes/$THEME/config/bootsplash-`fbresolution`.cfg

#
# Print text string. (Booting/Shutting down the system. Press
# F2 for verbose mode)
#

if [ "$progress" == 5 -o "$1" == "splash start" ]; then
  if [ x$_shutdown == xyes ]; then
     echo "silent" > /proc/splash
   chvt 1
   _msg=$MSG_SHUTDOWN; # may be defined in /etc/default/bootsplash
   [ -z "$_msg" ] && _msg="Shutting down the system... Press F2 for verbose mode"
  else
   _msg=$MSG_BOOT; # may be defined in /etc/default/bootsplash
   [ -z "$_msg" ] && _msg="Booting the system... Press F2 for verbose mode"
  fi

  if [ "$text_x" != "" -a "$text_y" != "" \
       -a "$text_color" != "" -a "$text_size" != "" -a "$_silent" == "yes" ];
  then
 case "$USE_STATIC_FBT" in
  [Yy]*)
   fbtruetype="fbtruetype.static"
   ;;
  *)
   fbtruetype="fbtruetype"
   ;;
 esac
 $fbtruetype -x $text_x -y $text_y -t $text_color -s $text_size "$_msg"
  fi
fi

#
# Now paint the progressbar. This is done via the proc
# interface of the bootsplash.
#

#test -z "$progress_enable" && exit 0
#test -z "$progress_enable" && exit 0
#echo "show $(( 65534 * ( $progress + 1 ) / $num ))" > /proc/splash
if [ $num -eq 0 ]
then
   echo "show 65534" > /proc/splash
else
   echo "show $(( 65534 * ( $progress ) / $num ))" > /proc/splash
fi

-----------------------------splash.sh结束
阅读(1469) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~