1 |
zzam 08/02/01 14:52:45 |
2 |
|
3 |
Added: udev-start-118-r1.sh net-118-r1.sh |
4 |
Log: |
5 |
Do not start net-init-scripts if coldplug=no, Bug #206518. Do not log missing init-script message, Bug #205687. |
6 |
(Portage version: 2.1.4.1) |
7 |
|
8 |
Revision Changes Path |
9 |
1.1 sys-fs/udev/files/udev-start-118-r1.sh |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/udev-start-118-r1.sh?rev=1.1&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/udev-start-118-r1.sh?rev=1.1&content-type=text/plain |
13 |
|
14 |
Index: udev-start-118-r1.sh |
15 |
=================================================================== |
16 |
# Copyright 1999-2007 Gentoo Foundation |
17 |
# Distributed under the terms of the GNU General Public License v2 |
18 |
|
19 |
tmpfs_size="10M" |
20 |
|
21 |
[ -e /etc/udev/udev.conf ] && . /etc/udev/udev.conf |
22 |
|
23 |
mount_dev_directory() { |
24 |
# Setup temporary storage for /dev |
25 |
ebegin "Mounting /dev for udev" |
26 |
if [ "${RC_USE_FSTAB}" = "yes" ] ; then |
27 |
mntcmd=$(get_mount_fstab /dev) |
28 |
else |
29 |
unset mntcmd |
30 |
fi |
31 |
if [ -n "${mntcmd}" ] ; then |
32 |
try mount -n ${mntcmd} |
33 |
else |
34 |
# many video drivers require exec access in /dev #92921 |
35 |
mntopts="exec,nosuid,mode=0755,size=${tmpfs_size}" |
36 |
[ -n "${tmpfs_inodes}" ] && mntopts="${mntopts},nr_inodes=${tmpfs_inodes}" |
37 |
if grep -Eq "[[:space:]]+tmpfs$" /proc/filesystems ; then |
38 |
mntcmd="tmpfs" |
39 |
else |
40 |
mntcmd="ramfs" |
41 |
fi |
42 |
try mount -n -t "${mntcmd}" -o "${mntopts}" udev /dev |
43 |
fi |
44 |
eend $? |
45 |
} |
46 |
|
47 |
# populate /dev with devices already found by the kernel |
48 |
populate_udev() { |
49 |
if get_bootparam "nocoldplug" ; then |
50 |
RC_COLDPLUG="no" |
51 |
ewarn "Skipping udev coldplug as requested in kernel cmdline" |
52 |
fi |
53 |
|
54 |
# at this point we are already sure to use kernel 2.6.15 or newer |
55 |
ebegin "Populating /dev with existing devices through uevents" |
56 |
if [ "${RC_COLDPLUG}" = "yes" ]; then |
57 |
/sbin/udevtrigger |
58 |
else |
59 |
# Do not run any init-scripts, Bug #206518 |
60 |
udevadm control --env do_not_run_plug_service=1 |
61 |
|
62 |
# only create device nodes |
63 |
/sbin/udevtrigger --attr-match=dev |
64 |
|
65 |
# run persistent-net stuff, bug 191466 |
66 |
/sbin/udevtrigger --subsystem-match=net |
67 |
fi |
68 |
eend $? |
69 |
|
70 |
# loop until everything is finished |
71 |
# there's gotta be a better way... |
72 |
ebegin "Letting udev process events" |
73 |
/sbin/udevsettle --timeout=60 |
74 |
eend $? |
75 |
|
76 |
udevadm control --env do_not_run_plug_service= |
77 |
return 0 |
78 |
} |
79 |
|
80 |
seed_dev() { |
81 |
# Seed /dev with some things that we know we need |
82 |
ebegin "Seeding /dev with needed nodes" |
83 |
|
84 |
# creating /dev/console and /dev/tty1 to be able to write |
85 |
# to $CONSOLE with/without bootsplash before udevd creates it |
86 |
[ ! -c /dev/console ] && mknod /dev/console c 5 1 |
87 |
[ ! -c /dev/tty1 ] && mknod /dev/tty1 c 4 1 |
88 |
|
89 |
# udevd will dup its stdin/stdout/stderr to /dev/null |
90 |
# and we do not want a file which gets buffered in ram |
91 |
[ ! -c /dev/null ] && mknod /dev/null c 1 3 |
92 |
|
93 |
# copy over any persistant things |
94 |
if [ -d /lib/udev/devices ] ; then |
95 |
cp --preserve=all --recursive --update /lib/udev/devices/* /dev 2>/dev/null |
96 |
fi |
97 |
|
98 |
# Not provided by sysfs but needed |
99 |
ln -snf /proc/self/fd /dev/fd |
100 |
ln -snf fd/0 /dev/stdin |
101 |
ln -snf fd/1 /dev/stdout |
102 |
ln -snf fd/2 /dev/stderr |
103 |
[ -e /proc/kcore ] && ln -snf /proc/kcore /dev/core |
104 |
|
105 |
# Create problematic directories |
106 |
mkdir -p /dev/pts /dev/shm |
107 |
eend 0 |
108 |
} |
109 |
|
110 |
unpack_device_tarball() { |
111 |
# Actually get udev rolling |
112 |
if [ "${RC_DEVICE_TARBALL}" = "yes" ] && \ |
113 |
[ -s /lib/udev/state/devices.tar.bz2 ] ; then |
114 |
ebegin "Populating /dev with saved device nodes" |
115 |
try tar -jxpf /lib/udev/state/devices.tar.bz2 -C /dev |
116 |
eend $? |
117 |
fi |
118 |
} |
119 |
|
120 |
check_persistent_net() { |
121 |
# check if there are problems with persistent-net |
122 |
local syspath= |
123 |
local devs= |
124 |
local problem_found=0 |
125 |
for syspath in /sys/class/net/*_rename*; do |
126 |
if [ -d "${syspath}" ]; then |
127 |
devs="${devs} ${syspath##*/}" |
128 |
problem_found=1 |
129 |
fi |
130 |
done |
131 |
|
132 |
[ "${problem_found}" = 0 ] && return 0 |
133 |
|
134 |
eerror "UDEV: Your system has a problem assigning persistent names" |
135 |
eerror "to these network interfaces: ${devs}" |
136 |
|
137 |
einfo "Checking persistent-net rules:" |
138 |
# the sed-expression lists all duplicate lines |
139 |
# from the input, like "uniq -d" does, but uniq |
140 |
# is installed into /usr/bin and not available at boot. |
141 |
dups=$( |
142 |
RULES_FILE='/etc/udev/rules.d/70-persistent-net.rules' |
143 |
. /lib/udev/rule_generator.functions |
144 |
find_all_rules 'NAME=' '.*'|tr ' ' '\n'|sort|sed '$!N; s/^\(.*\)\n\1$/\1/; t; D' |
145 |
) |
146 |
if [ -n "${dups}" ]; then |
147 |
ewarn "The rules create multiple entries assigning these names:" |
148 |
eindent |
149 |
ewarn "${dups}" |
150 |
eoutdent |
151 |
else |
152 |
ewarn "Found no duplicate names in persistent-net rules," |
153 |
ewarn "there must be some other problem!" |
154 |
fi |
155 |
return 1 |
156 |
} |
157 |
|
158 |
main() { |
159 |
if [ $(get_KV) -le $(KV_to_int '2.6.14') ] ; then |
160 |
eerror "Your kernel is too old to work with this version of udev." |
161 |
eerror "Current udev only supports Linux kernel 2.6.15 and newer." |
162 |
return 1 |
163 |
fi |
164 |
|
165 |
mount_dev_directory |
166 |
|
167 |
# Create a file so that our rc system knows it's still in sysinit. |
168 |
# Existance means init scripts will not directly run. |
169 |
# rc will remove the file when done with sysinit. |
170 |
touch /dev/.rcsysinit |
171 |
|
172 |
# Selinux lovin; /selinux should be mounted by selinux-patched init |
173 |
if [ -x /sbin/restorecon -a -c /selinux/null ] ; then |
174 |
restorecon /dev > /selinux/null |
175 |
fi |
176 |
|
177 |
unpack_device_tarball |
178 |
seed_dev |
179 |
|
180 |
if [ -e /proc/sys/kernel/hotplug ] ; then |
181 |
echo "" > /proc/sys/kernel/hotplug |
182 |
fi |
183 |
|
184 |
ebegin "Starting udevd" |
185 |
/sbin/udevd --daemon |
186 |
eend $? |
187 |
|
188 |
/lib/udev/write_root_link_rule |
189 |
populate_udev |
190 |
|
191 |
# Only do this for baselayout-1* |
192 |
if [ ! -e /lib/librc.so ]; then |
193 |
|
194 |
# Create nodes that udev can't |
195 |
ebegin "Finalizing udev configuration" |
196 |
[ -x /sbin/lvm ] && \ |
197 |
/sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null |
198 |
# Running evms_activate on a LiveCD causes lots of headaches |
199 |
[ -z "${CDBOOT}" -a -x /sbin/evms_activate ] && \ |
200 |
/sbin/evms_activate -q &>/dev/null |
201 |
eend 0 |
202 |
fi |
203 |
|
204 |
check_persistent_net |
205 |
|
206 |
# trigger executing initscript when /etc is writable |
207 |
IN_HOTPLUG=1 /etc/init.d/udev-postmount start >/dev/null 2>/dev/null |
208 |
|
209 |
# udev started successfully |
210 |
return 0 |
211 |
} |
212 |
|
213 |
main |
214 |
|
215 |
# vim:ts=4 |
216 |
|
217 |
|
218 |
|
219 |
1.1 sys-fs/udev/files/net-118-r1.sh |
220 |
|
221 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/net-118-r1.sh?rev=1.1&view=markup |
222 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/net-118-r1.sh?rev=1.1&content-type=text/plain |
223 |
|
224 |
Index: net-118-r1.sh |
225 |
=================================================================== |
226 |
#!/bin/sh |
227 |
# |
228 |
# net.sh: udev external RUN script |
229 |
# |
230 |
# Copyright 2007 Roy Marples <uberlord@g.o> |
231 |
# Distributed under the terms of the GNU General Public License v2 |
232 |
|
233 |
IFACE=$1 |
234 |
ACTION=$2 |
235 |
|
236 |
SCRIPT=/etc/init.d/net.$IFACE |
237 |
|
238 |
# ignore interfaces that are registered after being "up" (?) |
239 |
case ${IFACE} in |
240 |
ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|tun*|tap*) |
241 |
exit 0 ;; |
242 |
esac |
243 |
|
244 |
# stop here if coldplug is disabled, Bug #206518 |
245 |
if [ "${do_not_run_plug_service}" = 1 ]; then |
246 |
exit 0 |
247 |
fi |
248 |
|
249 |
if [ ! -x "${SCRIPT}" ] ; then |
250 |
#do not flood log with messages, bug #205687 |
251 |
#logger -t udev-net.sh "${SCRIPT}: does not exist or is not executable" |
252 |
exit 1 |
253 |
fi |
254 |
|
255 |
# If we're stopping then sleep for a bit in-case a daemon is monitoring |
256 |
# the interface. This to try and ensure we stop after they do. |
257 |
[ "${ACTION}" == "stop" ] && sleep 2 |
258 |
|
259 |
IN_HOTPLUG=1 "${SCRIPT}" --quiet "${ACTION}" |
260 |
|
261 |
|
262 |
|
263 |
-- |
264 |
gentoo-commits@l.g.o mailing list |