* updated init script
@ 2004-02-21 22:20 Marco d'Itri
2004-02-22 9:25 ` John L Fjellstad
0 siblings, 1 reply; 2+ messages in thread
From: Marco d'Itri @ 2004-02-21 22:20 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 756 bytes --]
I'm attaching the new init script I wrote for the debian package[1], in
the hope it will be useful to other distributions (again, please do not
just distribute it with the package, it will do not good to debian users).
I introduced a new config file which lists symlinks, directories and
devices which cannot be created by udev (a notable example being
/dev/ppp and probably the tun/tap devices).
The script will also bind-mount the old /dev somewhere else, to allow
MAKEDEV to still update it. (I think this will be needed at least until
udev will continue to be an optional component of the distribution.)
[1] which is currently waiting to be approved by the ftpmasters before
entering the distribution, FYI.
--
ciao, |
Marco | [4698 pryzWZsHITiM6]
[-- Attachment #2: udev --]
[-- Type: text/plain, Size: 3154 bytes --]
#!/bin/sh -e
PATH="/sbin:/bin"
UDEV=/sbin/udev
. /etc/udev/udev.conf
[ -x $UDEV ] || exit 0
case "$(uname -r)" in
2.[012345].*)
echo "udev requires a 2.6.x kernel, not started."
exit 0
;;
esac
export UDEV_NO_SLEEP=1
export ACTION DEVPATH
##############################################################################
# FIXME see README.Debian
mount_sysfs() {
[ -d /sys ] || mkdir /sys
[ -d /sys/class ] || mount -t sysfs sysfs: /sys
[ -d /proc/1 ] || mount -n /proc
}
# FIXME see README.Debian
umount_proc() {
umount -n /proc
}
mount_ramfs() {
if grep -E -q "^none /u?dev ramfs" /proc/mounts; then
return 0
fi
mkdir -p /etc/udev/.dev
mount --bind /dev /etc/udev/.dev
echo -n "Mounting ramfs over $udev_root..."
mount -n -t ramfs none $udev_root
echo "done."
}
# We must manually create /dev/null because the shell needs it for "&".
# If we were using initramfs the kernel would create it for us.
create_dev_null() {
[ -c $udev_root/null ] || mknod --mode=666 $udev_root/null c 1 3
}
synthesize_events() {
# add tty devices and all other device classes
for i in /sys/class/*; do
[ -d "$i" ] || continue
for j in $i/*; do
[ -f "$j/dev" ] || continue
DEVPATH=${j#/sys}
class=${DEVPATH#/class/}
class=${class%/*}
# echo -n " $DEVPATH($class)"
$UDEV $class || echo -n " failed: $DEVPATH"
done
done
# add block devices and their partitions
for i in /sys/block/*; do
[ -d "$i" ] || continue
DEVPATH=${i#/sys}
# echo -n " $DEVPATH"
$UDEV block || echo -n " failed: $DEVPATH"
for j in $i/*; do
[ -f "$j/dev" ] || continue
DEVPATH=${j#/sys}
# echo -n " $DEVPATH"
$UDEV block || echo -n " failed: $DEVPATH"
done
done
return 0
}
make_extra_nodes () {
grep '^[^#]' /etc/udev/links.conf | \
while read type name arg1; do
[ "$type" -a "$name" \
-a ! -e "$udev_root/$name" -a ! -L "$udev_root/$name" ] || continue
case "$type" in
L)
ln -s $arg1 $udev_root/$name
;;
D)
mkdir -p $udev_root/$name
;;
M)
cd /dev
/sbin/MAKEDEV $name
;;
*)
echo "unparseable line ($type $name $arg1)"
;;
esac
done
}
##############################################################################
case "$1" in
start)
mount_sysfs
mount_ramfs
create_dev_null
# We want to start udevd ourselves if it isn't already running.
# This lets udevd run at a sane nice level...
udevd &
ACTION=add
echo -n "Creating initial udev device nodes..."
synthesize_events
make_extra_nodes
umount_proc
echo "done."
;;
stop)
# ACTION=remove
# echo -n "Removing udev device nodes..."
# synthesize_events
# echo "done."
# XXX users are not supposed to run this
killall udevd
umount /etc/udev/.dev
umount /dev
;;
restart|force-reload)
echo -n "Creating again udev device nodes..."
ACTION=add
synthesize_events
make_extra_nodes
echo "done."
;;
*)
echo "Usage: /etc/init.d/udev {start|stop|restart|force-reload}"
exit 1
;;
esac
exit 0
[-- Attachment #3: links.conf --]
[-- Type: text/plain, Size: 364 bytes --]
# This file contains a list of symbolic links and directories which need
# to be created in /dev/.
L fd /proc/self/fd
L stdin /proc/self/fd/0
L stdout /proc/self/fd/1
L stderr /proc/self/fd/2
L core /proc/kcore
L sndstat /proc/asound/oss/sndstat
L MAKEDEV /sbin/MAKEDEV-wrapper
D pts
D shm
# I know, this is ugly, but I do not have a better solution.
M ppp
[-- Attachment #4: MAKEDEV-wrapper --]
[-- Type: text/plain, Size: 201 bytes --]
#!/bin/sh -e
# make /dev/MAKEDEV operate on the real /dev
# credits for this hack goes to ElectricElf
if [ "`pwd`" = /dev -a -d /etc/udev/.dev ]; then
cd /etc/udev/.dev
fi
exec /sbin/MAKEDEV "$*"
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: updated init script
2004-02-21 22:20 updated init script Marco d'Itri
@ 2004-02-22 9:25 ` John L Fjellstad
0 siblings, 0 replies; 2+ messages in thread
From: John L Fjellstad @ 2004-02-22 9:25 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1.1: Type: text/plain, Size: 620 bytes --]
On Sat, Feb 21, 2004 at 11:20:36PM +0100, Marco d'Itri wrote:
> I'm attaching the new init script I wrote for the debian package[1], in
> the hope it will be useful to other distributions (again, please do not
> just distribute it with the package, it will do not good to debian users).
I'm wondering why you think these scripts won't be useful for debian
users?
I added a patch against your script, so that admins can decide whether
they want to use udev or not. Kinda what Debian currently does with
devfs.
--
John L. Fjellstad
web: http://www.fjellstad.org/ Quis custodiet ipsos custodes
[-- Attachment #1.2: udev.patch --]
[-- Type: text/plain, Size: 317 bytes --]
--- udev.orig 2004-02-22 10:18:23.000000000 +0100
+++ udev 2004-02-22 10:19:14.000000000 +0100
@@ -8,6 +8,12 @@
[ -x $UDEV ] || exit 0
+. /etc/default/udev
+
+if [ $mount == "no" ]; then
+ exit 0
+fi
+
case "$(uname -r)" in
2.[012345].*)
echo "udev requires a 2.6.x kernel, not started."
[-- Attachment #1.3: default-udev --]
[-- Type: text/plain, Size: 67 bytes --]
# file get copied to /etc/default/udev
# mount on boot?
MOUNT=yes
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-02-22 9:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-21 22:20 updated init script Marco d'Itri
2004-02-22 9:25 ` John L Fjellstad
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).