]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/initscripts/init.d/cleanfs
core81: set need reboot flag and restart apache.
[people/teissler/ipfire-2.x.git] / src / initscripts / init.d / cleanfs
1 #!/bin/sh
2 ########################################################################
3 # Begin $rc_base/init.d/cleanfs
4 #
5 # Description : Clean file system
6 #
7 # Authors : Gerard Beekmans - gerard@linuxfromscratch.org
8 #
9 # Version : 00.00
10 #
11 # Notes :
12 #
13 ########################################################################
14
15 . /etc/sysconfig/rc
16 . ${rc_functions}
17
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
23 do
24
25 # Ignore comments and blank lines.
26 case "${name}" in
27 ""|\#*) continue ;;
28 esac
29
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}"
36 ;;
37 file)
38 :> "${name}"
39 ;;
40 dev)
41 case "${dtype}" in
42 char)
43 mknod "${name}" c ${maj} ${min}
44 ;;
45 block)
46 mknod "${name}" b ${maj} ${min}
47 ;;
48 pipe)
49 mknod "${name}" p
50 ;;
51 *)
52 boot_mesg -n "\nUnknown device type: ${dtype}" ${WARNING}
53 boot_mesg "" ${NORMAL}
54 ;;
55 esac
56 ;;
57 *)
58 boot_mesg -n "\nUnknown type: ${type}" ${WARNING}
59 boot_mesg "" ${NORMAL}
60 continue
61 ;;
62 esac
63
64 # Set up the permissions, too.
65 chown ${usr}:${grp} "${name}"
66 chmod ${perm} "${name}"
67 fi
68 done
69 exec 0>&9 9>&-
70 }
71
72 case "${1}" in
73 start)
74 if [[ ! -L "/var/run" ]]; then
75 boot_mesg "Repair /var/run symlink to /run..."
76 mv -u /var/run/* /run/ 2>&1 > /dev/null
77 rm -rf /var/run
78 ln -s ../run /var/run
79 fi
80
81 boot_mesg -n "Cleaning file systems:" ${INFO}
82
83 boot_mesg -n " /tmp" ${NORMAL}
84 cd /tmp &&
85 find . -xdev -mindepth 1 ! -name lost+found \
86 -delete || failed=1
87
88 boot_mesg -n " /var/ipfire/dhcp" ${NORMAL}
89 cd /var/ipfire/dhcpc/ && find . -name "*.pid" -exec rm -f {} \; || failed=1
90 cd /var/ipfire/dhcpc/ && find . -name "*.cache" -exec rm -f {} \; || failed=1
91 cd /var/ipfire/dhcpc/ && find . -name "*.info" -exec rm -f {} \; || failed=1
92
93 boot_mesg -n " /var/ipfire/red" ${NORMAL}
94 cd /var/ipfire/red/ && find . -name active -exec rm -f {} \; || failed=1
95
96 boot_mesg -n " /var/lock" ${NORMAL}
97 cd /var/lock &&
98 find . -type f ! -newer /proc -exec rm -f {} \; || failed=1
99
100 boot_mesg -n " /var/log/updatexlrator" ${NORMAL}
101 rm -f /var/log/updatexlrator/checkdeaddl.lck
102
103 boot_mesg " /var/run" ${NORMAL}
104 cd /var/run &&
105 find . ! -type d ! -name utmp ! -newer /proc \
106 -exec rm -f {} \; || failed=1
107 > /var/run/utmp
108 if grep -q '^utmp:' /etc/group ; then
109 chmod 664 /var/run/utmp
110 chgrp utmp /var/run/utmp
111 fi
112
113 (exit ${failed})
114 evaluate_retval
115
116 if egrep -qv '^(#|$)' /etc/sysconfig/createfiles 2>/dev/null; then
117 boot_mesg "Creating files and directories..."
118 create_files
119 evaluate_retval
120 fi
121 ;;
122 *)
123 echo "Usage: ${0} {start}"
124 exit 1
125 ;;
126 esac
127
128 # End $rc_base/init.d/cleanfs