2 ########################################################################
3 # Begin $rc_base/init.d/cleanfs
5 # Description : Clean file system
7 # Authors : Gerard Beekmans - gerard@linuxfromscratch.org
13 ########################################################################
18 # Function to create files/directory on boot.
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.
30 # Ignore existing files.
31 if [ ! -e "${name}" ]; then
32 # Create stuff based on its type.
43 mknod
"${name}" c ${maj} ${min}
46 mknod "${name}" b ${maj} ${min}
52 boot_mesg
-n "\nUnknown device type: ${dtype}" ${WARNING}
53 boot_mesg
"" ${NORMAL}
58 boot_mesg
-n "\nUnknown type: ${type}" ${WARNING}
59 boot_mesg
"" ${NORMAL}
64 # Set up the permissions, too.
65 chown
${usr}:${grp} "${name}"
66 chmod ${perm} "${name}"
74 boot_mesg -n "Cleaning
file systems
:" ${INFO}
76 boot_mesg -n " /tmp
" ${NORMAL}
78 find . -xdev -mindepth 1 ! -name lost+found \
81 boot_mesg -n " /var
/ipfire
/dhcp
" ${NORMAL}
82 cd /var/ipfire/dhcpc/ && find . -name "*.pid
" -exec rm -f {} \; || failed=1
83 cd /var/ipfire/dhcpc/ && find . -name "*.cache
" -exec rm -f {} \; || failed=1
84 cd /var/ipfire/dhcpc/ && find . -name "*.info
" -exec rm -f {} \; || failed=1
86 boot_mesg -n " /var
/ipfire
/red
" ${NORMAL}
87 cd /var/ipfire/red/ && find . -name active -exec rm -f {} \; || failed=1
89 boot_mesg -n " /var
/lock
" ${NORMAL}
91 find . -type f ! -newer /proc -exec rm -f {} \; || failed=1
93 boot_mesg " /var
/run
" ${NORMAL}
95 find . ! -type d ! -name utmp ! -newer /proc \
96 -exec rm -f {} \; || failed=1
98 if grep -q '^utmp:' /etc/group ; then
99 chmod 664 /var/run/utmp
100 chgrp utmp /var/run/utmp
106 if egrep -qv '^(#|$)' /etc/sysconfig/createfiles 2>/dev/null; then
107 boot_mesg "Creating files and directories...
"
113 echo "Usage
: ${0} {start
}"
118 # End $rc_base/init.d/cleanfs