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

Contents of /trunk/init.d/localmount

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20