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

Contents of /trunk/init.d/localmount

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20