Path : /sbin/ |
|
Current File : //sbin/start_udev |
#!/bin/bash
#
# start_udev
#
# script to initialize /dev by using udev.
#
# Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com>
#
# Released under the GPL v2 only.
#
# This needs to be run at the earliest possible point in the boot
# process.
#
# Based on the udev init.d script
#
# Thanks go out to the Gentoo developers for proving
# that this is possible to do.
#
# Yes, it's very verbose, feel free to turn off all of the echo calls,
# they were there to make me feel better that everything was working
# properly during development...
#
# don't use udev if sysfs is not mounted.
# if we run with systemctl, just wait for settle
if [ -x "$(type -P systemctl)" ]; then
systemctl start udev-settle.service &>/dev/null && exit 0
fi
export TZ=/etc/localtime
[ -d /sys/class ] || exit 1
[ -r /proc/mounts ] || exit 1
[ -x /sbin/udevd ] || exit 1
. /etc/init.d/functions
prog=udev
touch_recursive() {
( cd $1;
for i in *; do
[[ -c "$i" || -b "$i" ]] && touch --no-create "$i"
[ -d "$i" ] && touch_recursive "$i"
done )
return 0
}
ret=0
STRING=$"Starting $prog: "
# propagate /dev from /sys
echo -n "$STRING"
# turn off hotplug binary calling
if ! [ -x /sbin/hotplug ]; then
if [ -e /sys/kernel/uevent_helper ]; then
echo -e '\000\000\000\000' > /sys/kernel/uevent_helper
elif [ -e /proc/sys/kernel/hotplug ]; then
echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug
fi
fi
/sbin/udevd -d
ret=$[$ret + $?]
/sbin/udevadm trigger --type=subsystems --action=add
/sbin/udevadm trigger --type=devices --action=add
/sbin/udevadm settle
ret=$[$ret + $?]
# touch all device files for timezone glitches
# "find" is in /usr/bin and might not be available
if [ -f /etc/sysconfig/clock ]; then
. /etc/sysconfig/clock
[[ "$UTC" == "false" || "$UTC" == "no" ]] \
&& touch_recursive /dev > "/dev/null" 2>&1
fi
[ $ret -eq 0 ] && success $"$STRING" || failure $"$STRING"
echo
exit 0
@KyuuKazami