OSDN Git Service

Update to lfsbook 7.2.ja
[linuxjf/JF.git] / docs / LFS-BOOK / scripts / apds12.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.12. /etc/rc.d/init.d/cleanfs
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="apds11.html" title=
25           "/etc/rc.d/init.d/udev_retry">前のページ</a>
26           <p>
27             /etc/rc.d/init.d/udev_retry
28           </p>
29         </li>
30         <li class="next">
31           <a accesskey="n" href="apds13.html" title=
32           "/etc/rc.d/init.d/console">次のページ</a>
33           <p>
34             /etc/rc.d/init.d/console
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="cleanfs" name="cleanfs"></a>D.12. /etc/rc.d/init.d/cleanfs
50       </h1>
51       <pre class="screen">
52 #!/bin/sh
53 ########################################################################
54 # Begin cleanfs
55 #
56 # Description : Clean file system
57 #
58 # Authors     : Gerard Beekmans - gerard@linuxfromscratch.org
59 #               DJ Lucas - dj@linuxfromscratch.org
60 # Update      : Bruce Dubbs - bdubbs@linuxfromscratch.org
61 #
62 # Version     : LFS 7.0
63 #
64 ########################################################################
65
66 ### BEGIN INIT INFO
67 # Provides:            cleanfs
68 # Required-Start:      $local_fs
69 # Should-Start:
70 # Required-Stop:
71 # Should-Stop:
72 # Default-Start:       S
73 # Default-Stop:
74 # Short-Description:   Cleans temporary directories early in the boot process.
75 # Description:         Cleans temporary directories /var/run, /var/lock, and
76 #                      optionally, /tmp.  cleanfs also creates /var/run/utmp 
77 #                      and any files defined in /etc/sysconfig/createfiles.
78 # X-LFS-Provided-By:   LFS
79 ### END INIT INFO
80
81 . /lib/lsb/init-functions
82
83 # Function to create files/directory on boot.
84 create_files() 
85 {
86    # Input to file descriptor 9 and output to stdin (redirection)
87    exec 9&gt;&amp;0 &lt; /etc/sysconfig/createfiles
88
89    while read name type perm usr grp dtype maj min junk
90    do
91       # Ignore comments and blank lines.
92       case "${name}" in
93          ""|\#*) continue ;;
94       esac
95
96       # Ignore existing files.
97       if [ ! -e "${name}" ]; then
98          # Create stuff based on its type.
99          case "${type}" in
100             dir)
101                mkdir "${name}"
102                ;;
103             file)
104                :&gt; "${name}"
105                ;;
106             dev)
107                case "${dtype}" in
108                   char)
109                      mknod "${name}" c ${maj} ${min}
110                      ;;
111                   block)
112                      mknod "${name}" b ${maj} ${min}
113                      ;;
114                   pipe)
115                      mknod "${name}" p
116                      ;;
117                   *) 
118                      log_warning_msg "\nUnknown device type: ${dtype}" 
119                      ;;
120                esac
121                ;;
122             *)
123                log_warning_msg "\nUnknown type: ${type}" 
124                continue
125                ;;
126          esac
127
128          # Set up the permissions, too.
129          chown ${usr}:${grp} "${name}"
130          chmod ${perm} "${name}"
131       fi
132    done
133
134    # Close file descriptor 9 (end redirection)
135    exec 0&gt;&amp;9 9&gt;&amp;-
136    return 0
137 }
138
139 case "${1}" in
140    start)
141       log_info_msg "Cleaning file systems:" 
142
143       if [ "${SKIPTMPCLEAN}" = "" ]; then
144          log_info_msg2 " /tmp" 
145          cd /tmp &amp;&amp;
146          find . -xdev -mindepth 1 ! -name lost+found -delete || failed=1
147       fi
148
149       &gt; /var/run/utmp
150
151       if grep -q '^utmp:' /etc/group ; then
152          chmod 664 /var/run/utmp
153          chgrp utmp /var/run/utmp
154       fi
155
156       (exit ${failed})
157       evaluate_retval
158
159       if egrep -qv '^(#|$)' /etc/sysconfig/createfiles 2&gt;/dev/null; then
160          log_info_msg "Creating files and directories... "
161          create_files      # Always returns 0
162          evaluate_retval
163       fi
164
165       exit $failed
166       ;;
167    *)
168       echo "Usage: ${0} {start}"
169       exit 1
170       ;;
171 esac
172
173 # End cleanfs
174 </pre>
175     </div>
176     <div class="navfooter">
177       <ul>
178         <li class="prev">
179           <a accesskey="p" href="apds11.html" title=
180           "/etc/rc.d/init.d/udev_retry">前のページ</a>
181           <p>
182             /etc/rc.d/init.d/udev_retry
183           </p>
184         </li>
185         <li class="next">
186           <a accesskey="n" href="apds13.html" title=
187           "/etc/rc.d/init.d/console">次のページ</a>
188           <p>
189             /etc/rc.d/init.d/console
190           </p>
191         </li>
192         <li class="up">
193           <a accesskey="u" href="scripts.html" title=
194           "付録 D. ブートスクリプトと sysconfig スクリプト version-20120901">上に戻る</a>
195         </li>
196         <li class="home">
197           <a accesskey="h" href="../index.html" title=
198           "Linux From Scratch - Version 7.2">ホーム</a>
199         </li>
200       </ul>
201     </div>
202   </body>
203 </html>