diff options
author | eike-hotplug@sf-tec.de <eike-hotplug@sf-tec.de> | 2004-01-10 01:19:57 -0800 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 21:13:15 -0700 |
commit | e64280b8b30569ad6029e48f23d290e06a28d7ed (patch) | |
tree | 1fa2a1d2793bef21623825d5fed79e7ee71fdd1a /etc/init.d/udev.init.LSB | |
parent | 40041ff4f1153360409ae88f0c0168ad2ee4d224 (diff) |
[PATCH] LSB init script and other stuff
I had too much time during the holidays, so I played a bit with udev. The
changes are like last time mostly on the init stuff. I'm sending you this as
a great diff which is just for comments.
What it does:
-fix a typo in Makefile
-use only one "grep -v" instead of many
-don't include BK-Files into release (shrinks the stuff to 30%!)
-add a new init script which is LSB compliant
-add some flags to choose which one to use
-use /etc/udev/udev.conf in Redhat init script as the source for the udev
directory. If this is not done then the init script may create a directory
which udev itself isn't using (I changed /udev to /Udev to avoid collisions
with /usr and ran into this)
-first check for sysfs_dir before creating udev_root (maybe someone else has
already fixed this, I saw this discussion on lkml)
Diffstat (limited to 'etc/init.d/udev.init.LSB')
-rw-r--r-- | etc/init.d/udev.init.LSB | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/etc/init.d/udev.init.LSB b/etc/init.d/udev.init.LSB new file mode 100644 index 0000000000..0f5881c416 --- /dev/null +++ b/etc/init.d/udev.init.LSB @@ -0,0 +1,133 @@ +#! /bin/sh +# +# Author: Rolf Eike Beer <eike-hotplug@sf-tec.de> +# derived from original RedHat udev init script +# based on the SuSE 9.0 template (c) 1995-2002 SuSE Linux AG +# +# /etc/init.d/udev +# and its symbolic link +# /(usr/)sbin/rcudev +# +# System startup script for udev +# +# LSB compatible service control script; see http://www.linuxbase.org/spec/ +# +### BEGIN INIT INFO +# Provides: udev +# Required-Start: +# Required-Stop: +# Default-Start: 1 2 3 5 +# Default-Stop: 0 6 +# Short-Description: manage user-space device nodes in /udev +# Description: Start udev to create the device files for all +# devices already present in system when script is +# called. All other devices files will be automatically +# created when udev is called via /sbin/hotplug. +# Requires at least a kernel 2.6 to work properly. +### END INIT INFO +# +# Note on script names: +# http://www.linuxbase.org/spec/refspecs/LSB_1.2.0/gLSB/scrptnames.html +# A registry has been set up to manage the init script namespace. +# http://www.lanana.org/ +# Please use the names already registered or register one or use a +# vendor prefix. + + +# Check for missing binaries (stale symlinks should not happen) +UDEV_BIN=/sbin/udev +test -x $UDEV_BIN || exit 5 + +# Check for existence of needed config file and read it +UDEV_CONFIG=/etc/udev/udev.conf +test -r $UDEV_CONFIG || exit 6 +. $UDEV_CONFIG + +# Directory where sysfs is mounted +SYSFS_DIR=/sys + +# Source LSB init functions +. /lib/lsb/init-functions + +run_udev () { + # handle block devices and their partitions + for i in ${SYSFS_DIR}/block/*; do + # add each drive + export DEVPATH=${i#${SYSFS_DIR}} + $UDEV_BIN block & + + # add each partition, on each device + for j in $i/*; do + if [ -f $j/dev ]; then + export DEVPATH=${j#${SYSFS_DIR}} + $UDEV_BIN block & + fi + done + done + # all other device classes + for i in ${SYSFS_DIR}/class/*; do + for j in $i/*; do + if [ -f $j/dev ]; then + export DEVPATH=${j#${SYSFS_DIR}} + CLASS=`echo ${i#${SYSFS_DIR}} | \ + cut --delimiter='/' --fields=3-` + $UDEV_BIN $CLASS & + fi + done + done +} + +case "$1" in + start) + if [ ! -d $SYSFS_DIR ]; then + log_failure_msg "${0}: SYSFS_DIR \"$SYSFS_DIR\" not found" + exit 1 + fi + if [ ! -d $udev_root ]; then + mkdir $udev_root || exit 4 + fi + # propogate /udev from /sys - we only need this while we do not + # have initramfs and an early user-space with which to do early + # device bring up + echo -n "Creating initial udev device nodes: " + export ACTION=add + run_udev + log_success_msg + ;; + stop) + # be careful + echo -n "Removing udev device nodes: " + export ACTION=remove + run_udev + rm -f $udev_db || exit 1 + rmdir $udev_root || exit 1 + log_success_msg + ;; + restart) + $0 stop + $0 start + + exit $? + ;; + force-reload) + echo -n "Reload udev " + $0 stop && $0 start + exit $? + ;; + reload) + exit 3 + ;; + status) + echo -n "Checking for udev root directory: " + if [ -d $udev_root ]; then + log_success_msg found + else + log_warning_msg "not found" + exit 3 + fi + ;; + *) + echo "Usage: $0 {start|stop|status|restart|force-reload|reload}" + exit 1 + ;; +esac |