Update cleanfs bootscript to not clean /var/run or /var/lock because
[linux_from_scratch.git] / bootscripts / lfs / init.d / cleanfs
blobe88ea5bacb83b03bb0561e62d0e3a67f67aa4a46
1 #!/bin/sh
2 ########################################################################
3 # Begin $rc_base/init.d/cleanfs
5 # Description : Clean file system
7 # Authors : Gerard Beekmans - gerard@linuxfromscratch.org
9 # Version : 00.00
11 # Notes :
13 ########################################################################
15 . /etc/sysconfig/rc
16 . ${rc_functions}
18 # Function to create files/directory on boot.
19 create_files() {
20 # Read in the configuration file.
21 exec 9>&0 < /etc/sysconfig/createfiles
22 while read name type perm usr grp dtype maj min junk
25 # Ignore comments and blank lines.
26 case "${name}" in
27 ""|\#*) continue ;;
28 esac
30 # Ignore existing files.
31 if [ ! -e "${name}" ]; then
32 # Create stuff based on its type.
33 case "${type}" in
34 dir)
35 mkdir "${name}"
37 file)
38 :> "${name}"
40 dev)
41 case "${dtype}" in
42 char)
43 mknod "${name}" c ${maj} ${min}
45 block)
46 mknod "${name}" b ${maj} ${min}
48 pipe)
49 mknod "${name}" p
51 *)
52 boot_mesg -n "\nUnknown device type: ${dtype}" ${WARNING}
53 boot_mesg "" ${NORMAL}
55 esac
58 boot_mesg -n "\nUnknown type: ${type}" ${WARNING}
59 boot_mesg "" ${NORMAL}
60 continue
62 esac
64 # Set up the permissions, too.
65 chown ${usr}:${grp} "${name}"
66 chmod ${perm} "${name}"
68 done
69 exec 0>&9 9>&-
72 case "${1}" in
73 start)
74 boot_mesg -n "Cleaning file systems:" ${INFO}
76 boot_mesg -n " /tmp" ${NORMAL}
77 cd /tmp &&
78 find . -xdev -mindepth 1 ! -name lost+found \
79 -delete || failed=1
81 > /var/run/utmp
83 if grep -q '^utmp:' /etc/group ; then
84 chmod 664 /var/run/utmp
85 chgrp utmp /var/run/utmp
88 (exit ${failed})
89 evaluate_retval
91 if egrep -qv '^(#|$)' /etc/sysconfig/createfiles 2>/dev/null; then
92 boot_mesg "Creating files and directories..."
93 create_files
94 evaluate_retval
98 echo "Usage: ${0} {start}"
99 exit 1
101 esac
103 # End $rc_base/init.d/cleanfs