2010年10月12日 星期二
/LFS-BOOK-6.6-HTML/chapter07/introduction.html
7.1. Introduction
LFS 默认使用的是 System-V 风格的初始化脚本;有人提供了 BSD 风格的初始化设置方法: http://www.linuxfromscratch.org/hints/downloads/files/bsd-init.txt
在 LFS 邮件列表中还可以找到更多的选择。
Ubuntu 好像早已经开始从原来的SysV风格开始向 upstart 的方式全面转换。
todo: 理解和掌握各种初始化方式和脚本编写,能根据需要编写自己的初始化脚本。
2010年10月14日 星期四
/LFS-BOOK-6.6-HTML/chapter07/bootscripts.html
7.2. LFS-Bootscripts-20100124
这些都涉及初始化系统关闭的各种脚本。包括:文件系统(如:checkfs, cleanfs)、网络(如:ifdown, ifup)、设备(如:udev)、模块(如:modules)、系统参数设置(如:modules)等等。
time { make install; } 2>&1 | tee /backup/installlogs/7lfs-bootscripts.install.log
real 0m0.363s
user 0m0.128s
sys 0m0.268s
/LFS-BOOK-6.6-HTML/chapter07/usage.html
7.3. How Do These Bootscripts Work?
Ubuntu 10.04 原来的 SysV 风格(现在转向 upsart 方式)的初始化脚本与书上的有一点区别是不存在 /etc/rc.d 文件夹,而是直接到里面的东西放在了 /etc/ 下面。如: /etc/rc2.d 而不是 /etc/rc.d/rc2.d 。而且,默认的的级别是 2。
2010年10月15日 星期五
/LFS-BOOK-6.6-HTML/chapter07/setclock.html
7.4. Configuring the setclock Script
/etc/sysconfig/rc 是设置默认的公用配置文件路径
todo: 理解 /etc/rc.d/init.d/functions 文件的内容:/LFS-BOOK-6.6-HTML/scripts/apds02.html
2010年10月16日 星期六
/LFS-BOOK-6.6-HTML/chapter07/console.html
7.5. Configuring the Linux Console
english: In UTF-8 mode, the kernel uses the application character map for conversion of composed 8-bit key codes in the keymap to UTF-8, and thus the argument of the "-m" parameter should be set to the encoding of the composed key codes in the keymap.
question: However, in UTF-8 mode it is a problem, e.g., for the Greek language, where one sometimes needs to put an accent on the letter “alpha”.
question: Ubuntu 设置键盘映射和控制台字体是怎样做的?
因为这节里说了,不能在控制台显示和输入中、日、韩等文字。所以无需设置此节,使用无配置文件时的 ascii 字符加美式键盘的默认设置。zhcon 等控制台中文方案是用了另外的方式实现,有需要时再学习此类实现方式。
todo: 理解 /etc/rc.d/init.d/console 文件内容: /LFS-BOOK-6.6-HTML/scripts/apds13.html
2010年10月18日 星期一
/LFS-BOOK-6.6-HTML/scripts/apds02.html
/etc/rc.d/init.d/functions
## Provide an echo that supports -e and -n
# If formatting is needed, $ECHO should be used
case "`echo -e -n test`" in
-[en]*)
ECHO=/bin/echo
;;
*)
ECHO=echo
;;
esac
/abs-guide/x16775.html#BRACKETSREF
“[]“的作用:Brackets -- [...] -- enclose a set of characters to match in a single RE.
/LFS-BOOK-6.6-HTML/scripts/apds13.html
/etc/rc.d/init.d/console
is_true "${UNICODE}" &&
MODE_COMMAND="${ECHO} -en '\033%G' && kbd_mode -u" ||
MODE_COMMAND="${ECHO} -en '\033%@\033(K' && kbd_mode -a"
question: -en 后面的 '\033%G' 是什么意思?
# If any of the commands above failed, the trap at the
# top would set $failed to 1
( exit $failed )
evaluate_retval
;;
( exit $failed )当于一个子脚本,不加()就会导致整个脚本中断
上面脚本的作用是报告小的错误,但使小的错误不会中断整个脚本的运行
/LFS-BOOK-6.6-HTML/scripts/apds02.html
/etc/rc.d/init.d/functions
evaluate_retval()
{
error_value="${?}"
if [ ${error_value} = 0 ]; then
echo_ok
else
echo_failure
fi
# This prevents the 'An Unexpected Error Has Occurred' from trivial
# errors.
return 0
}
${?}
/abs-guide/parameter-substitution.html#PARAMSUBREF
${parameter}
Same as $parameter, i.e., value of the variable parameter. In certain contexts, only the less ambiguous ${parameter} form works.
May be used for concatenating variables with strings.
/LFS-BOOK-6.6-HTML/scripts/apds02.html
/etc/rc.d/init.d/functions
STRING_LENGTH=$((${#1} + 1))
${#1} 第一个字符串参数的长度,
$(()) /abs-guide/arithexp.html The use of backticks (backquotes) in arithmetic expansion has been superseded by double parentheses -- ((...)) and $((...)) -- and also by the very convenient let construction.
question: 为什么要再加上1?
/LFS-BOOK-6.6-HTML/scripts/apds04.html
/etc/rc.d/init.d/consolelog
if [ -r /proc/sys/kernel/printk ]; then
read level line < /proc/sys/kernel/printk
如果 文件 /proc/sys/kernel/printk 具有可读属性;那么
把文件中的第一个空格隔开的字符串赋给 level , 后面的赋给 line
todo: 如有需要学习 read 命令的详细用法( 是 bash 的内建命令 )
man bash: BUILTIN COMMANDS
read [-ers] [-a aname] [-d delim] [-i text] [-n nchars] [-N nchars] [-p
prompt] [-t timeout] [-u fd] [name ...]
One line is read from the standard input, or from the file
descriptor fd supplied as an argument to the -u option, and the
first word is assigned to the first name, the second word to the
second name, and so on, with leftover words and their interven‐
ing separators assigned to the last name. If there are fewer
words read from the input stream than names, the remaining names
are assigned empty values.