]>
Commit | Line | Data |
---|---|---|
73d9a908 | 1 | #!/bin/sh |
66c36198 PM |
2 | ############################################################################### |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> # | |
6 | # # | |
7 | # This program is free software: you can redistribute it and/or modify # | |
8 | # it under the terms of the GNU General Public License as published by # | |
9 | # the Free Software Foundation, either version 3 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # This program is distributed in the hope that it will be useful, # | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
15 | # GNU General Public License for more details. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
19 | # # | |
20 | ############################################################################### | |
73d9a908 MT |
21 | |
22 | . /etc/sysconfig/rc | |
23 | . ${rc_functions} | |
24 | ||
25 | # Function to create files/directory on boot. | |
26 | create_files() { | |
27 | # Read in the configuration file. | |
28 | exec 9>&0 < /etc/sysconfig/createfiles | |
29 | while read name type perm usr grp dtype maj min junk | |
30 | do | |
31 | ||
32 | # Ignore comments and blank lines. | |
33 | case "${name}" in | |
34 | ""|\#*) continue ;; | |
35 | esac | |
36 | ||
37 | # Ignore existing files. | |
38 | if [ ! -e "${name}" ]; then | |
39 | # Create stuff based on its type. | |
40 | case "${type}" in | |
41 | dir) | |
42 | mkdir "${name}" | |
43 | ;; | |
44 | file) | |
45 | :> "${name}" | |
46 | ;; | |
47 | dev) | |
48 | case "${dtype}" in | |
49 | char) | |
50 | mknod "${name}" c ${maj} ${min} | |
51 | ;; | |
52 | block) | |
53 | mknod "${name}" b ${maj} ${min} | |
54 | ;; | |
55 | pipe) | |
56 | mknod "${name}" p | |
57 | ;; | |
58 | *) | |
59 | boot_mesg -n "\nUnknown device type: ${dtype}" ${WARNING} | |
60 | boot_mesg "" ${NORMAL} | |
61 | ;; | |
62 | esac | |
63 | ;; | |
64 | *) | |
65 | boot_mesg -n "\nUnknown type: ${type}" ${WARNING} | |
66 | boot_mesg "" ${NORMAL} | |
67 | continue | |
68 | ;; | |
69 | esac | |
70 | ||
71 | # Set up the permissions, too. | |
72 | chown ${usr}:${grp} "${name}" | |
73 | chmod ${perm} "${name}" | |
74 | fi | |
75 | done | |
76 | exec 0>&9 9>&- | |
77 | } | |
78 | ||
79 | case "${1}" in | |
80 | start) | |
5b71042c AF |
81 | if [[ ! -L "/var/run" ]]; then |
82 | boot_mesg "Repair /var/run symlink to /run..." | |
83 | mv -u /var/run/* /run/ 2>&1 > /dev/null | |
84 | rm -rf /var/run | |
85 | ln -s ../run /var/run | |
86 | fi | |
c4a451ee AM |
87 | # |
88 | # create some folders | |
89 | # | |
90 | if [ ! -e /var/lock/subsys ]; then | |
91 | mkdir -p /var/lock/subsys | |
92 | fi | |
93 | if [ ! -e /var/lock/time ]; then | |
94 | mkdir -p /var/lock/time | |
95 | chown nobody.root /var/lock/time | |
96 | fi | |
97 | if [ ! -e /var/run/clamav ]; then | |
98 | mkdir -p /var/run/clamav | |
99 | chown clamav:clamav /var/run/clamav | |
100 | fi | |
101 | if [ ! -e /var/run/cups ]; then | |
102 | mkdir -p /var/run/cups | |
103 | fi | |
104 | if [ ! -e /var/run/dbus ]; then | |
105 | mkdir -p /var/run/dbus | |
106 | fi | |
c4a451ee AM |
107 | if [ ! -e /var/run/saslauthd ]; then |
108 | mkdir -p /var/run/saslauthd | |
109 | fi | |
110 | if [ ! -e /var/log/vnstat ]; then | |
111 | mkdir -p /var/log/vnstat | |
112 | fi | |
73d9a908 MT |
113 | boot_mesg -n "Cleaning file systems:" ${INFO} |
114 | ||
115 | boot_mesg -n " /tmp" ${NORMAL} | |
116 | cd /tmp && | |
117 | find . -xdev -mindepth 1 ! -name lost+found \ | |
118 | -delete || failed=1 | |
119 | ||
55b4c7ed | 120 | boot_mesg -n " /var/ipfire/dhcp" ${NORMAL} |
7f5fdd04 MT |
121 | cd /var/ipfire/dhcpc/ && find . -name "*.pid" -exec rm -f {} \; || failed=1 |
122 | cd /var/ipfire/dhcpc/ && find . -name "*.cache" -exec rm -f {} \; || failed=1 | |
123 | cd /var/ipfire/dhcpc/ && find . -name "*.info" -exec rm -f {} \; || failed=1 | |
55b4c7ed MT |
124 | |
125 | boot_mesg -n " /var/ipfire/red" ${NORMAL} | |
126 | cd /var/ipfire/red/ && find . -name active -exec rm -f {} \; || failed=1 | |
127 | ||
73d9a908 MT |
128 | boot_mesg -n " /var/lock" ${NORMAL} |
129 | cd /var/lock && | |
130 | find . -type f ! -newer /proc -exec rm -f {} \; || failed=1 | |
131 | ||
0aa93f5b DW |
132 | boot_mesg -n " /var/log/updatexlrator" ${NORMAL} |
133 | rm -f /var/log/updatexlrator/checkdeaddl.lck | |
134 | ||
73d9a908 MT |
135 | boot_mesg " /var/run" ${NORMAL} |
136 | cd /var/run && | |
137 | find . ! -type d ! -name utmp ! -newer /proc \ | |
138 | -exec rm -f {} \; || failed=1 | |
139 | > /var/run/utmp | |
140 | if grep -q '^utmp:' /etc/group ; then | |
141 | chmod 664 /var/run/utmp | |
142 | chgrp utmp /var/run/utmp | |
143 | fi | |
144 | ||
145 | (exit ${failed}) | |
146 | evaluate_retval | |
147 | ||
148 | if egrep -qv '^(#|$)' /etc/sysconfig/createfiles 2>/dev/null; then | |
149 | boot_mesg "Creating files and directories..." | |
150 | create_files | |
151 | evaluate_retval | |
152 | fi | |
153 | ;; | |
154 | *) | |
155 | echo "Usage: ${0} {start}" | |
156 | exit 1 | |
157 | ;; | |
158 | esac |