From 4c13b46126d2bdf1413fdb482dddc56eade82af1 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 1 Mar 2017 15:26:50 +0100 Subject: [PATCH] saving uncommitted changes in /etc prior to emerge run --- .etckeeper | 7 ++- conf.d/udev | 38 -------------- conf.d/udev-settle | 5 ++ conf.d/udev-trigger | 32 ++++++++++++ init.d/udev | 124 ++++++-------------------------------------- init.d/udev-settle | 19 +++++++ init.d/udev-trigger | 96 ++++++++++++++++++++++++++++++++++ 7 files changed, 175 insertions(+), 146 deletions(-) create mode 100644 conf.d/udev-settle create mode 100644 conf.d/udev-trigger create mode 100755 init.d/udev-settle create mode 100755 init.d/udev-trigger diff --git a/.etckeeper b/.etckeeper index b80aec2..a2357ec 100755 --- a/.etckeeper +++ b/.etckeeper @@ -153,6 +153,8 @@ maybe chmod 0644 'conf.d/svnserve' maybe chmod 0644 'conf.d/swap' maybe chmod 0644 'conf.d/tmpfiles' maybe chmod 0644 'conf.d/udev' +maybe chmod 0644 'conf.d/udev-settle' +maybe chmod 0644 'conf.d/udev-trigger' maybe chmod 0644 'conf.d/urandom' maybe chmod 0700 'config-archive' maybe chmod 0755 'config-archive/etc' @@ -479,6 +481,8 @@ maybe chmod 0755 'init.d/termencoding' maybe chmod 0755 'init.d/tmpfiles.dev' maybe chmod 0755 'init.d/tmpfiles.setup' maybe chmod 0755 'init.d/udev' +maybe chmod 0755 'init.d/udev-settle' +maybe chmod 0755 'init.d/udev-trigger' maybe chmod 0755 'init.d/urandom' maybe chmod 0644 'initramfs.mounts' maybe chmod 0644 'inittab' @@ -615,7 +619,8 @@ maybe chmod 0644 'openldap/schema/rfc2307bis.schema' maybe chmod 0644 'openldap/schema/sudo.schema' maybe chgrp 'ldap' 'openldap/slapd.conf' maybe chmod 0640 'openldap/slapd.conf' -maybe chmod 0600 'openldap/slapd.conf.default' +maybe chgrp 'ldap' 'openldap/slapd.conf.default' +maybe chmod 0640 'openldap/slapd.conf.default' maybe chmod 0600 'openldap/slapd.ldif' maybe chmod 0600 'openldap/slapd.ldif.default' maybe chmod 0755 'openldap/ssl' diff --git a/conf.d/udev b/conf.d/udev index 41f6b9b..a714032 100644 --- a/conf.d/udev +++ b/conf.d/udev @@ -1,31 +1,5 @@ # /etc/conf.d/udev: config file for udev -# udev can trigger coldplug events which cause services to start and -# kernel modules to be loaded. -# Services are deferred to start in the boot runlevel. -# Set rc_coldplug="NO" if you don't want this. -# If you want module coldplugging but not coldplugging of services then you -# can disable service coldplugging in baselayout/openrc config files. -# The setting is named different in different versions. -# in /etc/rc.conf: rc_hotplug="!*" or -# in /etc/conf.d/rc: rc_plug_services="!*" -#rc_coldplug="YES" - -# We can create a /dev/root symbolic link to point to the root device in -# some situations. This is on by default because some software relies on -# it,. However, this software should be fixed to not do this. -# For more information, see -# https://bugs.gentoo.org/show_bug.cgi?id=438380. -# If you are not using any affected software, you do not need this, so -# feel free to turn it off. -#rc_dev_root_symlink="YES" - -# Expert options: - -# Timeout in seconds to wait for processing of uevents at boot. -# There should be no need to change this. -#udev_settle_timeout="60" - # Add extra command line options to udevd, use with care # udevd --help for possible values #udev_opts="" @@ -33,15 +7,3 @@ # Run udevd --debug and write output to /run/udevdebug.log # Should not be kept on as it fills diskspace slowly #udev_debug="YES" - -# Run udevadmin monitor to get a log of all events -# in /run/udevmonitor.log -#udev_monitor="YES" - -# Keep udevmonitor running after populating /dev. -#udev_monitor_keep_running="no" - -# Set cmdline options for udevmonitor. -# could be some of --env --kernel --udev -#udev_monitor_opts="--env" - diff --git a/conf.d/udev-settle b/conf.d/udev-settle new file mode 100644 index 0000000..cb995e4 --- /dev/null +++ b/conf.d/udev-settle @@ -0,0 +1,5 @@ +# /etc/conf.d/udev-settle: config file for udev-settle + +# Timeout in seconds to wait for processing of uevents at boot. +# There should be no need to change this. +#udev_settle_timeout=120 diff --git a/conf.d/udev-trigger b/conf.d/udev-trigger new file mode 100644 index 0000000..5850b8b --- /dev/null +++ b/conf.d/udev-trigger @@ -0,0 +1,32 @@ +# /etc/conf.d/udev-trigger: config file for udev-trigger + +# udev can trigger coldplug events which cause services to start and +# kernel modules to be loaded. +# Services are deferred to start in the boot runlevel. +# Set rc_coldplug="NO" if you don't want this. +# If you want module coldplugging but not coldplugging of services then you +# can disable service coldplugging in baselayout/openrc config files. +# The setting is named different in different versions. +# in /etc/rc.conf: rc_hotplug="!*" or +# in /etc/conf.d/rc: rc_plug_services="!*" +#rc_coldplug="YES" + +# We can create a /dev/root symbolic link to point to the root device in +# some situations. This is on by default because some software relies on +# it,. However, this software should be fixed to not do this. +# For more information, see +# https://bugs.gentoo.org/show_bug.cgi?id=438380. +# If you are not using any affected software, you do not need this, so +# feel free to turn it off. +#rc_dev_root_symlink="YES" + +# Run udevadmin monitor to get a log of all events +# in /run/udevmonitor.log +#udev_monitor="YES" + +# Keep udevmonitor running after populating /dev. +#udev_monitor_keep_running="no" + +# Set cmdline options for udevmonitor. +# could be some of --env --kernel --udev +#udev_monitor_opts="--env" diff --git a/init.d/udev b/init.d/udev index 72b2be2..6ff21b2 100755 --- a/init.d/udev +++ b/init.d/udev @@ -1,4 +1,4 @@ -#!/sbin/runscript +#!/sbin/openrc-run # Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 @@ -7,18 +7,24 @@ description="udev manages device permissions and symbolic links in /dev" extra_started_commands="reload" description_reload="Reload the udev rules and databases" -udev_monitor="${udev_monitor:-no}" -udevmonitor_log=/run/udevmonitor.log -udevmonitor_pid=/run/udevmonitor.pid - depend() { - provide dev need sysfs dev-mount before checkfs fsck + keyword -lxc -systemd-nspawn -vserver +} - # udev does not work inside vservers - keyword -vserver -lxc +get_udevd_binary() { + local bins="/sbin/udevd /lib/systemd/systemd-udevd /usr/lib/systemd/systemd-udevd" + for f in ${bins}; do + if [ -x "$f" -a ! -L "$f" ]; then + command="$f" + fi + done + if [ -z "$command" ]; then + eerror "Unable to find udev executable." + return 1 + fi } start_pre() @@ -52,16 +58,7 @@ start_pre() fi fi - bins="/sbin/udevd /lib/systemd/systemd-udevd /usr/lib/systemd/systemd-udevd" - for f in ${bins}; do - if [ -x "$f" -a ! -L "$f" ]; then - command="$f" - fi - done - if [ -z "$command" ]; then - eerror "Unable to find udev executable." - return 1 - fi + get_udevd_binary || return 1 if [ -e /proc/sys/kernel/hotplug ]; then echo "" >/proc/sys/kernel/hotplug @@ -74,94 +71,6 @@ start_pre() return 0 } -start_udevmonitor() -{ - yesno "${udev_monitor}" || return 0 - - einfo "udev: Running udevadm monitor ${udev_monitor_opts} to log all events" - start-stop-daemon --start --stdout "${udevmonitor_log}" \ - --make-pidfile --pidfile "${udevmonitor_pid}" \ - --background --exec /bin/udevadm -- monitor ${udev_monitor_opts} -} - -# This is here because some software expects /dev/root to exist. -# For more information, see this bug: -# https://bugs.gentoo.org/show_bug.cgi?id=438380 -dev_root_link() -{ - local RULESDIR=/run/udev/rules.d - [ -d $RULESDIR ] || mkdir -p $RULESDIR - eval $(udevadm info --export --export-prefix=ROOT_ --device-id-of-file=/ || - true) - [ "$ROOT_MAJOR" -a "$ROOT_MINOR" ] || return 0 - - # btrfs filesystems have bogus major/minor numbers - [ "$ROOT_MAJOR" != 0 ] || return 0 - - echo 'ACTION=="add|change", SUBSYSTEM=="block", ENV{MAJOR}=="'$ROOT_MAJOR'", ENV{MINOR}=="'$ROOT_MINOR'", SYMLINK+="root"' > $RULESDIR/61-dev-root-link.rules -} - -populate_dev() -{ - if yesno ${rc_dev_root_symlink:-yes}; then - ebegin "Generating a rule to create a /dev/root symlink" - dev_root_link - eend $? - fi - - get_bootparam "nocoldplug" && rc_coldplug="no" - if ! yesno ${rc_coldplug:-${RC_COLDPLUG:-yes}}; then - einfo "Setting /dev permissions and symbolic links" - udevadm trigger --attr-match=dev --action=add - udevadm trigger --subsystem-match=net --action=add - ewarn "Skipping udev coldplug sequence" - return 0 - fi - - ebegin "Populating /dev with existing devices through uevents" - udevadm trigger --type=subsystems --action=add - udevadm trigger --type=devices --action=add - eend $? - - ebegin "Waiting for uevents to be processed" - udevadm settle --timeout=${udev_settle_timeout:-60} - eend $? - return 0 -} - -stop_udevmonitor() -{ - yesno "${udev_monitor}" || return 0 - - if yesno "${udev_monitor_keep_running:-no}"; then - ewarn "udev: udevmonitor is still running and writing into ${udevmonitor_log}" - else - einfo "udev: Stopping udevmonitor: Log is in ${udevmonitor_log}" - start-stop-daemon --stop --pidfile "${udevmonitor_pid}" --exec /bin/udevadm - fi -} - -display_hotplugged_services() -{ - local svcfile= svc= services= - for svcfile in "${RC_SVCDIR}"/hotplugged/*; do - svc="${svcfile##*/}" - [ -x "${svcfile}" ] || continue - - services="${services} ${svc}" - done - [ -n "${services}" ] && einfo "Device initiated services:${HILITE}${services}${NORMAL}" -} - -start_post() -{ - start_udevmonitor - populate_dev - stop_udevmonitor - display_hotplugged_services - return 0 -} - stop() { local rc=0 @@ -170,8 +79,9 @@ stop() rc=$? if [ $rc -ne 0 ]; then eend $rc "Failed to stop $RC_SVCNAME using udevadm" + get_udevd_binary || return 1 ebegin "Trying with start-stop-daemon" - start-stop-daemon --stop --exec /sbin/udevd + start-stop-daemon --stop --exec ${command} rc=$? fi eend $rc "Failed to stop $RC_SVCNAME" diff --git a/init.d/udev-settle b/init.d/udev-settle new file mode 100755 index 0000000..c495769 --- /dev/null +++ b/init.d/udev-settle @@ -0,0 +1,19 @@ +#!/sbin/openrc-run +# Copyright 2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +depend() +{ + need udev + after udev-trigger + provide dev-settle + keyword -lxc -systemd-nspawn -vserver +} + +start() +{ + ebegin "Waiting for uevents to be processed" + udevadm settle \ + ${udev_settle_timeout:+--timeout=}$udev_settle_timeout + eend $? +} diff --git a/init.d/udev-trigger b/init.d/udev-trigger new file mode 100755 index 0000000..bdd4884 --- /dev/null +++ b/init.d/udev-trigger @@ -0,0 +1,96 @@ +#!/sbin/openrc-run +# Copyright 2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +description="udev Coldplug all Devices" + +udevmonitor_log=/run/udevmonitor.log +udevmonitor_pid=/run/udevmonitor.pid + +depend() +{ + need udev + provide dev + keyword -lxc -systemd-nspawn -vserver +} + +start_pre() +{ + if yesno "${udev_monitor:-no}"; then + einfo "Running udevadm monitor ${udev_monitor_opts} to log all events" + start-stop-daemon --start --stdout "${udevmonitor_log}" \ + --make-pidfile --pidfile "${udevmonitor_pid}" \ + --background --exec /bin/udevadm -- monitor ${udev_monitor_opts} + fi + return 0 +} + +display_hotplugged_services() +{ + local svcfile= svc= services= + for svcfile in "${RC_SVCDIR}"/hotplugged/*; do + svc="${svcfile##*/}" + [ -x "${svcfile}" ] || continue + + services="${services} ${svc}" + done + [ -n "${services}" ] && einfo "Device initiated services:${HILITE}${services}${NORMAL}" + return 0 +} + +start_post() +{ + if yesno "${udev_monitor:-no}"; then + if yesno "${udev_monitor_keep_running:-no}"; then + ewarn "udevmonitor is still writing into ${udevmonitor_log}" + else + einfo "Stopping udevmonitor: Log is in ${udevmonitor_log}" + start-stop-daemon --stop --pidfile "${udevmonitor_pid}" \ + --exec /bin/udevadm + fi + fi + display_hotplugged_services + return 0 +} + +# This is here because some software expects /dev/root to exist. +# For more information, see this bug: +# https://bugs.gentoo.org/show_bug.cgi?id=438380 +dev_root_link() +{ + local RULESDIR=/run/udev/rules.d + [ -d $RULESDIR ] || mkdir -p $RULESDIR + eval $(udevadm info --export --export-prefix=ROOT_ --device-id-of-file=/ || + true) + [ "$ROOT_MAJOR" -a "$ROOT_MINOR" ] || return 0 + + # btrfs filesystems have bogus major/minor numbers + [ "$ROOT_MAJOR" != 0 ] || return 0 + + echo 'ACTION=="add|change", SUBSYSTEM=="block", ENV{MAJOR}=="'$ROOT_MAJOR'", ENV{MINOR}=="'$ROOT_MINOR'", SYMLINK+="root"' > $RULESDIR/61-dev-root-link.rules + return 0 +} + +start() +{ + if yesno ${rc_dev_root_symlink:-yes}; then + ebegin "Generating a rule to create a /dev/root symlink" + dev_root_link + eend $? + fi + + get_bootparam "nocoldplug" && rc_coldplug="no" + if ! yesno ${rc_coldplug:-${RC_COLDPLUG:-yes}}; then + einfo "Setting /dev permissions and symbolic links" + udevadm trigger --attr-match=dev --action=add + udevadm trigger --subsystem-match=net --action=add + rc=$? + ewarn "Skipping udev coldplug sequence" + return $rc + fi + + ebegin "Populating /dev with existing devices through uevents" + udevadm trigger --type=subsystems --action=add + udevadm trigger --type=devices --action=add + eend $? +} -- 2.39.5