/[baselayout]/trunk/init.d/localmount
Gentoo

Contents of /trunk/init.d/localmount

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2794 - (show annotations) (download)
Wed Jul 25 20:58:23 2007 UTC (7 years, 1 month ago) by uberlord
File size: 6415 byte(s)
Merge some of reb's OpenBSD fixes in
1 #!/sbin/runscript
2 # Copyright 1999-2007 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 description="Mounts disks and swap according to /etc/fstab."
6 [ -e /proc/filessystems ] && description="${description} Also mounts various filesystems in /proc."
7 [ -x /sbin/dumpon ] && description="${description} Also configures saving kernel dumps to swap."
8
9 depend() {
10 need checkfs
11 }
12
13 start() {
14 # Mount local filesystems in /etc/fstab.
15 local types="noproc" x=
16 for x in ${RC_NET_FS_LIST} ; do
17 types="${types},${x}"
18 done
19
20 ebegin "Mounting local filesystems"
21 mount -at "${types}"
22 eend $? "Some local filesystem failed to mount"
23
24 # Change the mount options of already mounted partitions
25 # This is needed when /usr is separate and coming back from single user
26 if [ "${RC_UNAME}" = "FreeBSD" ] ; then
27 mount -uao fstab -t "${types},linprocfs"
28 fi
29
30 if [ -x /sbin/savecore ] ; then
31 local dumpdir=${KERNEL_DUMP_DIR:-/var/crash}
32 if ! [ -d "${dumpdir}" ]; then
33 mkdir -p "${dumpdir}"
34 chmod 700 "${dumpdir}"
35 fi
36
37 if [ "${RC_UNAME}" = "FreeBSD" ] ; then
38 # Don't quote ${KERNEL_DUMP_DEVICE}, so that if it's unset,
39 # savecore will check on the partitions listed in fstab
40 # without errors in the output
41 savecore -C "${dumpdir}" ${KERNEL_DUMP_DEVICE} >/dev/null
42 else
43 ls "${dumpdir}"/bsd* > /dev/null 2>&1
44 fi
45 if [ $? = 0 ] ; then
46 local sopts="${dumpdir} ${KERNEL_DUMP_DEVICE}"
47 [ "${KERNEL_DUMP_COMPRESS}" = "yes" ] && sopts="-z ${sopts}"
48 ebegin "Saving kernel core dump in" "${dumpdir}"
49 savecore ${savecoreopts} >/dev/null
50 eend $?
51 fi
52 fi
53
54 # Sync bootlog now as /var should be mounted
55 if type bootlog >/dev/null 2>/dev/null ; then
56 bootlog sync 2>/dev/null
57 fi
58
59 # Make sure we insert usbcore if its a module
60 if [ -f /proc/modules -a ! -d /proc/bus/usb ] ; then
61 modprobe -q usbcore
62 fi
63
64 if [ -e /proc/filesystems ] ; then
65 # Check what USB fs the kernel support. Currently
66 # 2.5+ kernels, and later 2.4 kernels have 'usbfs',
67 # while older kernels have 'usbdevfs'.
68 if [ -d /proc/bus/usb -a ! -e /proc/bus/usb/devices ] ; then
69 local usbfs=$(grep -Fow usbfs /proc/filesystems ||
70 grep -Fow usbdevfs /proc/filesystems)
71
72 if [ -n "${usbfs}" ] ; then
73 ebegin "Mounting USB device filesystem (${usbfs})"
74 local usbgid="$(getent group usb | \
75 sed -e 's/.*:.*:\(.*\):.*/\1/')"
76 mount -t ${usbfs} \
77 -o ${usbgid:+devmode=0664,devgid=${usbgid},}noexec,nosuid \
78 usbfs /proc/bus/usb
79 eend $?
80 fi
81 fi
82
83 # Setup Kernel Support for the NFS daemon status
84 if [ -d /proc/fs/nfsd ] && ! mountinfo /proc/fs/nfsd >/dev/null ; then
85 if grep -qs nfsd /proc/filesystems ; then
86 ebegin "Mounting nfsd filesystem"
87 mount -t nfsd -o nodev,noexec,nosuid \
88 nfsd /proc/fs/nfsd
89 eend $?
90 fi
91 fi
92
93 # Setup Kernel Support for miscellaneous Binary Formats
94 if [ -d /proc/sys/fs/binfmt_misc ] && ! mountinfo /proc/sys/fs/binfmt_misc >/dev/null ; then
95 if grep -qs binfmt_misc /proc/filesystems ; then
96 ebegin "Mounting misc binary format filesystem"
97 mount -t binfmt_misc -o nodev,noexec,nosuid \
98 binfmt_misc /proc/sys/fs/binfmt_misc
99 eend $?
100 fi
101 fi
102
103 # Setup Kernel Support for securityfs
104 if [ -d /sys/kernel/security ] && ! mountinfo /sys/kernel/security >/dev/null ; then
105 if grep -qs securityfs /proc/filesystems ; then
106 ebegin "Mounting security filesystem"
107 mount -t securityfs securityfs /sys/kernel/security \
108 -o nodev,noexec,nosuid
109 eend $?
110 fi
111 fi
112
113 # Setup Kernel Support for debugfs
114 if [ -d /sys/kernel/debug ] && ! mountinfo /sys/kernel/debug >/dev/null ; then
115 if grep -qs debugfs /proc/filesystems ; then
116 ebegin "Mounting debug filesystem"
117 mount -t debugfs debugfs /sys/kernel/debug \
118 -o nodev,noexec,nosuid
119 eend $?
120 fi
121 fi
122
123 # Setup Kernel Support for SELinux
124 if [ -d /selinux ] && ! mountinfo /selinux >/dev/null ; then
125 if grep -qs selinuxfs /proc/filesystems ; then
126 ebegin "Mounting SELinux filesystem"
127 mount -t selinuxfs selinuxfs /selinux
128 eend $?
129 fi
130 fi
131 fi
132
133 # We do our swapping here instead of rc so we can get urandom started
134 # before us for people that like an encrypted swap.
135 ebegin "Activating (possible) swap"
136 swapon -a >/dev/null
137 eend 0 # If swapon has nothing todo it errors, so always return 0
138
139 # Setup any user requested dump device
140 if [ -x /sbin/dumpon -a -n "${KERNEL_DUMP_DEVICE}" ] ; then
141 ebegin "Activating kernel core dump device" "(${KERNEL_DUMP_DEVICE})"
142 dumpon "${KERNEL_DUMP_DEVICE}"
143 eend $?
144 fi
145
146 # Always return 0 - some local mounts may not be critical for boot
147 return 0
148 }
149
150 stop() {
151 # Don't unmount anything for VPS systems
152 [ "${RC_SYS}" = "VPS" ] && return 0
153
154 # We never unmount / or /dev or $RC_LIBDIR
155 local x= no_umounts="/|/dev|${RC_SVCDIR}"
156
157 # NO_UMOUNTS is taken from /etc/conf.d/localmount
158 # RC_NO_UMOUNTS is taken from /etc/conf.d/rc and can also be
159 # set by plugins
160 OIFS=${IFS} SIFS=${IFS-y}
161 IFS=$IFS:
162 for x in ${NO_UMOUNTS} ${RC_NO_UMOUNTS} ; do
163 no_umounts="${no_umounts}|${x}"
164 done
165 if [ "${SIFS}" = "y" ] ; then
166 IFS=$OIFS
167 else
168 unset IFS
169 fi
170
171 if [ "${RC_UNAME}" = "Linux" ] ; then
172 no_umounts="${no_umounts}|/dev/pts|/dev/shm|/proc|/proc/.*|/sys"
173 fi
174 no_umounts="^(${no_umounts})$"
175
176 # Flush all pending disk writes now
177 sync ; sync
178
179 # Try to unmount all tmpfs filesystems not in use, else a deadlock may
180 # occure, bug #13599.
181 # As $RC_SVCDIR may also be tmpfs we cd to it to lock it
182 cd "${RC_SVCDIR}"
183 umount -a -t tmpfs 2>/dev/null
184
185 # As we're turning off swap below, we need to disable kernel dumps
186 [ -x /sbin/dumpon ] && dumpon off
187
188 local swap_list=
189 # Turn off swap
190 if [ -r /proc/swaps ] ;then
191 swap_list=$(sed -e '1d' /proc/swaps)
192 else
193 swap_list=$(swapctl -l 2>/dev/null | sed -e '1d')
194 fi
195 if [ -n "${swap_list}" ] ; then
196 ebegin "Deactivating swap"
197 swapoff -a >/dev/null
198 eend $?
199 fi
200
201 . "${RC_LIBDIR}"/sh/rc-mount.sh
202
203 # Umount loopback devices
204 einfo "Unmounting loopback devices"
205 eindent
206 do_unmount "umount -d" "${no_umounts}" "^/dev/loop"
207 eoutdent
208
209 # Now everything else, except network filesystems as the
210 # network should be down by this point.
211 einfo "Unmounting filesystems"
212 eindent
213 local fs=
214 for x in ${RC_NET_FS_LIST} ; do
215 fs="${fs}${fs:+|}${x}"
216 done
217 [ -n "${fs}" ] && fs="^(${fs})$"
218 do_unmount "umount" "${no_umounts}" "" "" "${fs}"
219 eoutdent
220
221 return 0
222 }
223
224 # vim: set ts=4 :

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20