* Merged newxml into HEAD
[linux_from_scratch.git] / bootscripts / lfs / init.d / cleanfs
blob1a5f997886615c235e4cdb60f0237d8bdd60cdf0
1 #!/bin/sh
2 # Begin $rc_base/init.d/cleanfs - Clean file system
4 # Written by Gerard Beekmans - gerard@linuxfromscratch.org
6 . /etc/sysconfig/rc
7 . $rc_functions
9 # Function to create files/directory on boot.
10 create_files() {
11 # Read in the configuration file.
12 exec 9>&0 < /etc/sysconfig/createfiles
13 while read name type perm usr grp dtype maj min junk ; do
15 # Ignore comments and blank lines.
16 case "$name" in
17 ""|\#*) continue ;;
18 esac
20 # Ignore existing files.
21 if [ ! -e "$name" ]; then
22 # Create stuff based on its type.
23 case "$type" in
24 dir) mkdir "$name" ;;
25 file) :> "$name" ;;
26 dev) case "$dtype" in
27 char) mknod "$name" c $maj $min ;;
28 block) mknod "$name" b $maj $min ;;
29 pipe) mknod "$name" p ;;
30 esac ;;
31 *) echo "Unknown type: $type" >&2
32 continue ;;
33 esac
35 # Set up the permissions, too.
36 chown $usr:$grp "$name"
37 chmod $perm "$name"
39 done
40 exec 0>&9 9>&-
43 case "$1" in
44 start)
45 echo "Removing /var/run/* and /var/lock/*"
46 rm -rf /var/run/* /var/lock/*
47 evaluate_retval
49 echo "Creating new /var/run/utmp..."
50 > /var/run/utmp && chmod 644 /var/run/utmp
51 evaluate_retval
53 echo "Removing possible /etc/nologin /fastboot and /forcefsck..."
54 rm -f /etc/nologin /fastboot /forcefsck
55 evaluate_retval
57 echo "Removing /tmp/*"
58 find /tmp -xdev -mindepth 1 -depth ! -path '/tmp/lost+found*' \
59 -exec rm -rf {} \;
60 evaluate_retval
62 if [ -r /etc/sysconfig/createfiles ]; then
63 echo "Creating files and directories..."
64 create_files
65 evaluate_retval
69 echo "Usage: $0 {start}"
70 exit 1
72 esac
74 # End $rc_base/init.d/cleanfs