OSDN Git Service

Update to lfsbook 7.2.ja
[linuxjf/JF.git] / docs / LFS-BOOK / scripts / apds13.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4   <head>
5     <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
6     <title>
7       D.13. /etc/rc.d/init.d/console
8     </title>
9     <link rel="stylesheet" href="../stylesheets/lfs.css" type="text/css" />
10     <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
11     <link rel="stylesheet" href="../stylesheets/lfs-print.css" type=
12     "text/css" media="print" />
13   </head>
14   <body class="lfs" id="lfs-7.2">
15     <div class="navheader">
16       <h4>
17         Linux From Scratch - Version 7.2
18       </h4>
19       <h3>
20         付録 D. ブートスクリプトと sysconfig スクリプト version-20120901
21       </h3>
22       <ul>
23         <li class="prev">
24           <a accesskey="p" href="apds12.html" title=
25           "/etc/rc.d/init.d/cleanfs">前のページ</a>
26           <p>
27             /etc/rc.d/init.d/cleanfs
28           </p>
29         </li>
30         <li class="next">
31           <a accesskey="n" href="apds14.html" title=
32           "/etc/rc.d/init.d/localnet">次のページ</a>
33           <p>
34             /etc/rc.d/init.d/localnet
35           </p>
36         </li>
37         <li class="up">
38           <a accesskey="u" href="scripts.html" title=
39           "付録 D. ブートスクリプトと sysconfig スクリプト version-20120901">上に戻る</a>
40         </li>
41         <li class="home">
42           <a accesskey="h" href="../index.html" title=
43           "Linux From Scratch - Version 7.2">ホーム</a>
44         </li>
45       </ul>
46     </div>
47     <div class="wrap" lang="ja" xml:lang="ja">
48       <h1 class="sect1">
49         <a id="console" name="console"></a>D.13. /etc/rc.d/init.d/console
50       </h1>
51       <pre class="screen">
52 #!/bin/sh
53 ########################################################################
54 # Begin console
55 #
56 # Description : Sets keymap and screen font
57 #
58 # Authors     : Gerard Beekmans - gerard@linuxfromscratch.org
59 #               Alexander E. Patrakov
60 #               DJ Lucas - dj@linuxfromscratch.org
61 # Update      : Bruce Dubbs - bdubbs@linuxfromscratch.org
62 #
63 # Version     : LFS 7.0
64 #
65 ########################################################################
66
67 ### BEGIN INIT INFO
68 # Provides:            console
69 # Required-Start:
70 # Should-Start:        $local_fs
71 # Required-Stop:
72 # Should-Stop:
73 # Default-Start:       S
74 # Default-Stop:
75 # Short-Description:   Sets up a localised console.
76 # Description:         Sets up fonts and language settings for the user's
77 #                      local as defined by /etc/sysconfig/console.
78 # X-LFS-Provided-By:   LFS
79 ### END INIT INFO
80
81 . /lib/lsb/init-functions
82
83 # Native English speakers probably don't have /etc/sysconfig/console at all
84 [ -r /etc/sysconfig/console ] &amp;&amp; . /etc/sysconfig/console
85
86 function is_true() 
87 {
88    [ "$1" = "1" ] || [ "$1" = "yes" ] || [ "$1" = "true" ]
89 }
90
91 failed=0
92
93 case "${1}" in
94    start)
95       # See if we need to do anything
96       if [ -z "${KEYMAP}"         ] &amp;&amp; [ -z "${KEYMAP_CORRECTIONS}" ] &amp;&amp;
97          [ -z "${FONT}"           ] &amp;&amp; [ -z "${LEGACY_CHARSET}"     ] &amp;&amp;     
98          ! is_true "${UNICODE}"; then 
99          exit 0
100       fi
101
102       # There should be no bogus failures below this line!
103       log_info_msg "Setting up Linux console..."
104
105       # Figure out if a framebuffer console is used
106       [ -d /sys/class/graphics/fb0 ] &amp;&amp; use_fb=1 || use_fb=0
107
108       # Figure out the command to set the console into the
109       # desired mode
110       is_true "${UNICODE}" &amp;&amp;
111          MODE_COMMAND="echo -en '\033%G' &amp;&amp; kbd_mode -u" ||
112          MODE_COMMAND="echo -en '\033%@\033(K' &amp;&amp; kbd_mode -a"
113
114       # On framebuffer consoles, font has to be set for each vt in
115       # UTF-8 mode. This doesn't hurt in non-UTF-8 mode also.
116
117       ! is_true "${use_fb}" || [ -z "${FONT}" ] ||
118          MODE_COMMAND="${MODE_COMMAND} &amp;&amp; setfont ${FONT}"
119
120       # Apply that command to all consoles mentioned in
121       # /etc/inittab. Important: in the UTF-8 mode this should
122       # happen before setfont, otherwise a kernel bug will
123       # show up and the unicode map of the font will not be
124       # used.
125
126       for TTY in `grep '^[^#].*respawn:/sbin/agetty' /etc/inittab |
127          grep -o '\btty[[:digit:]]*\b'`
128       do
129          openvt -f -w -c ${TTY#tty} -- \
130             /bin/sh -c "${MODE_COMMAND}" || failed=1
131       done
132
133       # Set the font (if not already set above) and the keymap
134       [ "${use_fb}" == "1" ] || [ -z "${FONT}" ] || setfont $FONT || failed=1
135
136       [ -z "${KEYMAP}" ] ||
137          loadkeys ${KEYMAP} &gt;/dev/null 2&gt;&amp;1 ||
138          failed=1
139       
140       [ -z "${KEYMAP_CORRECTIONS}" ] ||
141          loadkeys ${KEYMAP_CORRECTIONS} &gt;/dev/null 2&gt;&amp;1 ||
142          failed=1
143
144       # Convert the keymap from $LEGACY_CHARSET to UTF-8
145       [ -z "$LEGACY_CHARSET" ] ||
146          dumpkeys -c "$LEGACY_CHARSET" | loadkeys -u &gt;/dev/null 2&gt;&amp;1 ||
147          failed=1
148
149       # If any of the commands above failed, the trap at the
150       # top would set $failed to 1
151       ( exit $failed ) 
152       evaluate_retval
153
154       exit $failed
155       ;;              
156
157    *)                 
158       echo "Usage:  ${0} {start}"
159       exit 1          
160       ;;              
161 esac
162
163 # End console
164 </pre>
165     </div>
166     <div class="navfooter">
167       <ul>
168         <li class="prev">
169           <a accesskey="p" href="apds12.html" title=
170           "/etc/rc.d/init.d/cleanfs">前のページ</a>
171           <p>
172             /etc/rc.d/init.d/cleanfs
173           </p>
174         </li>
175         <li class="next">
176           <a accesskey="n" href="apds14.html" title=
177           "/etc/rc.d/init.d/localnet">次のページ</a>
178           <p>
179             /etc/rc.d/init.d/localnet
180           </p>
181         </li>
182         <li class="up">
183           <a accesskey="u" href="scripts.html" title=
184           "付録 D. ブートスクリプトと sysconfig スクリプト version-20120901">上に戻る</a>
185         </li>
186         <li class="home">
187           <a accesskey="h" href="../index.html" title=
188           "Linux From Scratch - Version 7.2">ホーム</a>
189         </li>
190       </ul>
191     </div>
192   </body>
193 </html>