### BEGIN INIT INFO
# Provides: udev
# Required-Start: mountkernfs
-# Required-Stop:
+# Required-Stop: umountroot
# Default-Start: S
-# Default-Stop:
+# Default-Stop: 0 6
# Short-Description: Start systemd-udevd, populate /dev and load drivers.
### END INIT INFO
+PATH="/sbin:/bin"
+NAME="systemd-udevd"
+DAEMON="/lib/systemd/systemd-udevd"
+DESC="hotplug events dispatcher"
+PIDFILE="/run/udev.pid"
+CTRLFILE="/run/udev/control"
+OMITDIR="/run/sendsigs.omit.d"
+
# we need to unmount /dev/pts/ and remount it later over the devtmpfs
unmount_devpts() {
if mountpoint -q /dev/pts/; then
fi
}
-supported_kernel() {
- case "$(uname -r)" in
- 2.[012345].*|2.6.[0-9]|2.6.[0-9][!0-9]*) return 1 ;;
- 2.6.[12][0-9]|2.6.[12][0-9][!0-9]*) return 1 ;;
- 2.6.3[0-1]|2.6.3[0-1][!0-9]*) return 1 ;;
- esac
- return 0
-}
-
# shell version of /usr/bin/tty
my_tty() {
[ -x /bin/readlink ] || return 0
##############################################################################
-PATH="/sbin:/bin"
-NAME="systemd-udevd"
-DAEMON="/lib/systemd/systemd-udevd"
-DESC="the hotplug events dispatcher"
[ -x $DAEMON ] || exit 0
. /lib/lsb/init-functions
-if ! supported_kernel; then
- log_failure_msg "udev requires a kernel >= 2.6.32, not started"
- log_end_msg 1
-fi
-
if [ ! -e /proc/filesystems ]; then
log_failure_msg "udev requires a mounted procfs, not started"
log_end_msg 1
case "$1" in
start)
if [ ! -e "/run/udev/" ]; then
- warn_if_interactive
+ warn_if_interactive
fi
if [ -w /sys/kernel/uevent_helper ]; then
- echo > /sys/kernel/uevent_helper
+ echo > /sys/kernel/uevent_helper
fi
if ! mountpoint -q /dev/; then
- unmount_devpts
- mount_devtmpfs
- [ -d /proc/1 ] || mount -n /proc
+ unmount_devpts
+ mount_devtmpfs
+ [ -d /proc/1 ] || mount -n /proc
fi
make_static_nodes
[ -x /sbin/restorecon ] && /sbin/restorecon -R /dev
log_daemon_msg "Starting $DESC" "$NAME"
- if $DAEMON --daemon; then
- log_end_msg $?
+ if start-stop-daemon --start --name $NAME --user root --quiet \
+ --pidfile $PIDFILE --exec $DAEMON --background --make-pidfile; then
+ # prevents udevd to be killed by sendsigs (see #791944)
+ mkdir -p $OMITDIR
+ ln -sf $PIDFILE $OMITDIR/$NAME
+ log_end_msg $?
else
- log_warning_msg $?
- log_warning_msg "Waiting 15 seconds and trying to continue anyway"
- sleep 15
+ log_warning_msg $?
+ log_warning_msg "Waiting 15 seconds and trying to continue anyway"
+ sleep 15
fi
log_action_begin_msg "Synthesizing the initial hotplug events"
if udevadm trigger --action=add; then
- log_action_end_msg $?
+ log_action_end_msg $?
else
- log_action_end_msg $?
+ log_action_end_msg $?
fi
create_dev_makedev
# wait for the systemd-udevd childs to finish
log_action_begin_msg "Waiting for /dev to be fully populated"
if udevadm settle; then
- log_action_end_msg 0
+ log_action_end_msg 0
else
- log_action_end_msg 0 'timeout'
+ log_action_end_msg 0 'timeout'
fi
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
- if start-stop-daemon --stop --name $NAME --user root --quiet --oknodo --retry 5; then
- log_end_msg $?
+ if start-stop-daemon --stop --name $NAME --user root --quiet \
+ --pidfile $PIDFILE --remove-pidfile --oknodo --retry 5; then
+ # prevents cryptsetup/dmsetup hangs (see #791944)
+ rm -f $CTRLFILE
+ log_end_msg $?
else
- log_end_msg $?
+ log_end_msg $?
fi
;;
restart)
log_daemon_msg "Stopping $DESC" "$NAME"
- if start-stop-daemon --stop --name $NAME --user root --quiet --oknodo --retry 5; then
- log_end_msg $?
+ if start-stop-daemon --stop --name $NAME --user root --quiet \
+ --pidfile $PIDFILE --remove-pidfile --oknodo --retry 5; then
+ # prevents cryptsetup/dmsetup hangs (see #791944)
+ rm -f $CTRLFILE
+ log_end_msg $?
else
- log_end_msg $? || true
+ log_end_msg $? || true
fi
log_daemon_msg "Starting $DESC" "$NAME"
- if $DAEMON --daemon; then
- log_end_msg $?
+ if start-stop-daemon --start --name $NAME --user root --quiet \
+ --pidfile $PIDFILE --exec $DAEMON --background --make-pidfile; then
+ # prevents udevd to be killed by sendsigs (see #791944)
+ mkdir -p $OMITDIR
+ ln -sf $PIDFILE $OMITDIR/$NAME
+ log_end_msg $?
else
- log_end_msg $?
+ log_end_msg $?
fi
;;