move device managers to hooks
This commit is contained in:
24
hooks/eudev/eudev
Normal file
24
hooks/eudev/eudev
Normal file
@@ -0,0 +1,24 @@
|
||||
# vim: set ft=sh:
|
||||
# shellcheck shell=sh
|
||||
#
|
||||
# false positive
|
||||
# shellcheck disable=2154
|
||||
#
|
||||
# handle_eudev()
|
||||
{
|
||||
print "configuring eudev"
|
||||
|
||||
for _binary in udevd udevadm; do
|
||||
copy_binary "$_binary"
|
||||
done
|
||||
|
||||
mkdir -p "${tmpdir}/lib/udev/rules.d"
|
||||
|
||||
printf "%s\n" \
|
||||
'SUBSYSTEMS=="block", ACTION=="add", RUN+="/bin/device-helper"' \
|
||||
> "${tmpdir}/lib/udev/rules.d/device-helper.rules"
|
||||
|
||||
[ "$monolith" = 1 ] || printf "%s\n" \
|
||||
'ENV{MODALIAS}=="?*", ACTION=="add", RUN+="/bin/modprobe %E{MODALIAS}"' \
|
||||
>> "${tmpdir}/lib/udev/rules.d/device-helper.rules"
|
||||
}
|
15
hooks/eudev/eudev.init
Normal file
15
hooks/eudev/eudev.init
Normal file
@@ -0,0 +1,15 @@
|
||||
# vim: set ft=sh:
|
||||
# shellcheck shell=sh
|
||||
#
|
||||
# false positive
|
||||
# shellcheck disable=2154,2034
|
||||
#
|
||||
# run_eudev()
|
||||
{
|
||||
[ "$break" = devmgr ] && { print "break before run_eudev()"; sh; }
|
||||
|
||||
udevd -N never & eudev_pid="$!"
|
||||
udevadm trigger -c add -t subsystems
|
||||
udevadm trigger -c add -t devices
|
||||
udevadm settle
|
||||
}
|
10
hooks/eudev/eudev.init.late
Normal file
10
hooks/eudev/eudev.init.late
Normal file
@@ -0,0 +1,10 @@
|
||||
# vim: set ft=sh:
|
||||
# shellcheck shell=sh
|
||||
#
|
||||
# false positive
|
||||
# shellcheck disable=2154
|
||||
#
|
||||
# stop_eudev()
|
||||
{
|
||||
kill "$eudev_pid"
|
||||
}
|
22
hooks/mdev/mdev
Normal file
22
hooks/mdev/mdev
Normal file
@@ -0,0 +1,22 @@
|
||||
# vim: set ft=sh:
|
||||
# shellcheck shell=sh
|
||||
#
|
||||
# false positive
|
||||
# shellcheck disable=2154,2016
|
||||
#
|
||||
# handle_mdev()
|
||||
{
|
||||
print "configuring mdev"
|
||||
|
||||
for _binary in mdev find; do
|
||||
copy_binary "$_binary"
|
||||
done
|
||||
|
||||
printf "%s\n" \
|
||||
'SUBSYSTEM=block;.* 0:0 660 @device-helper' \
|
||||
> "${tmpdir}/etc/mdev.conf"
|
||||
|
||||
[ "$monolith" = 1 ] || printf "%s\n" \
|
||||
'$MODALIAS=.* 0:0 660 @modprobe "$MODALIAS"' \
|
||||
>> "${tmpdir}/etc/mdev.conf"
|
||||
}
|
19
hooks/mdev/mdev.init
Normal file
19
hooks/mdev/mdev.init
Normal file
@@ -0,0 +1,19 @@
|
||||
# vim: set ft=sh:
|
||||
# shellcheck shell=sh
|
||||
#
|
||||
# false positive
|
||||
# shellcheck disable=2154,2034
|
||||
#
|
||||
# run_mdev()
|
||||
{
|
||||
[ "$break" = devmgr ] && { print "break before run_mdev()"; sh; }
|
||||
|
||||
mdev -s
|
||||
mdev -df 2> /dev/null & mdev_pid="$!"
|
||||
|
||||
find /sys/devices -name uevent |
|
||||
|
||||
while read -r uevent; do
|
||||
printf add > "$uevent"
|
||||
done 2> /dev/null
|
||||
}
|
10
hooks/mdev/mdev.init.late
Normal file
10
hooks/mdev/mdev.init.late
Normal file
@@ -0,0 +1,10 @@
|
||||
# vim: set ft=sh:
|
||||
# shellcheck shell=sh
|
||||
#
|
||||
# false positive
|
||||
# shellcheck disable=2154
|
||||
#
|
||||
# stop_mdev()
|
||||
{
|
||||
kill "$mdev_pid"
|
||||
}
|
22
hooks/mdevd/mdevd
Normal file
22
hooks/mdevd/mdevd
Normal file
@@ -0,0 +1,22 @@
|
||||
# vim: set ft=sh:
|
||||
# shellcheck shell=sh
|
||||
#
|
||||
# false positive
|
||||
# shellcheck disable=2154,2016
|
||||
#
|
||||
# handle_mdevd()
|
||||
{
|
||||
print "configuring mdevd"
|
||||
|
||||
for _binary in mdevd mdevd-coldplug; do
|
||||
copy_binary "$_binary"
|
||||
done
|
||||
|
||||
printf "%s\n" \
|
||||
'SUBSYSTEM=block;.* 0:0 660 @device-helper' \
|
||||
> "${tmpdir}/etc/mdev.conf"
|
||||
|
||||
[ "$monolith" = 1 ] || printf "%s\n" \
|
||||
'$MODALIAS=.* 0:0 660 @modprobe "$MODALIAS"' \
|
||||
>> "${tmpdir}/etc/mdev.conf"
|
||||
}
|
13
hooks/mdevd/mdevd.init
Normal file
13
hooks/mdevd/mdevd.init
Normal file
@@ -0,0 +1,13 @@
|
||||
# vim: set ft=sh:
|
||||
# shellcheck shell=sh
|
||||
#
|
||||
# false positive
|
||||
# shellcheck disable=2154,2034
|
||||
#
|
||||
# run_mdevd()
|
||||
{
|
||||
[ "$break" = devmgr ] && { print "break before run_mdevd()"; sh; }
|
||||
|
||||
mdevd 2> /dev/null & mdevd_pid="$!"
|
||||
mdevd-coldplug
|
||||
}
|
10
hooks/mdevd/mdevd.init.late
Normal file
10
hooks/mdevd/mdevd.init.late
Normal file
@@ -0,0 +1,10 @@
|
||||
# vim: set ft=sh:
|
||||
# shellcheck shell=sh
|
||||
#
|
||||
# false positive
|
||||
# shellcheck disable=2154
|
||||
#
|
||||
# stop_mdevd()
|
||||
{
|
||||
kill "$mdevd_pid"
|
||||
}
|
9
hooks/proc/proc
Normal file
9
hooks/proc/proc
Normal file
@@ -0,0 +1,9 @@
|
||||
# vim: set ft=sh:
|
||||
# shellcheck shell=sh
|
||||
#
|
||||
# handle_proc()
|
||||
{
|
||||
print "configuring /proc hotplugger"
|
||||
|
||||
copy_binary find
|
||||
}
|
19
hooks/proc/proc.init
Normal file
19
hooks/proc/proc.init
Normal file
@@ -0,0 +1,19 @@
|
||||
# vim: set ft=sh:
|
||||
# shellcheck shell=sh
|
||||
#
|
||||
# false positive
|
||||
# shellcheck disable=2154
|
||||
#
|
||||
# run_proc()
|
||||
{
|
||||
[ "$break" = devmgr ] && { print "break before run_proc()"; sh; }
|
||||
|
||||
command -v device-helper > /proc/sys/kernel/hotplug
|
||||
|
||||
# get ready for fork bomb. kek
|
||||
find /sys/devices -name uevent |
|
||||
|
||||
while read -r uevent; do
|
||||
printf add > "$uevent"
|
||||
done 2> /dev/null
|
||||
}
|
7
hooks/proc/proc.init.late
Normal file
7
hooks/proc/proc.init.late
Normal file
@@ -0,0 +1,7 @@
|
||||
# vim: set ft=sh:
|
||||
# shellcheck shell=sh
|
||||
#
|
||||
# stop_proc()
|
||||
{
|
||||
printf '\n' > /proc/sys/kernel/hotplug
|
||||
}
|
24
hooks/systemd-udevd/systemd-udevd
Normal file
24
hooks/systemd-udevd/systemd-udevd
Normal file
@@ -0,0 +1,24 @@
|
||||
# vim: set ft=sh:
|
||||
# shellcheck shell=sh
|
||||
#
|
||||
# false positive
|
||||
# shellcheck disable=2154
|
||||
#
|
||||
# handle_systemd_udevd()
|
||||
{
|
||||
print "configuring systemd-udevd"
|
||||
|
||||
for _binary in /lib/systemd/systemd-udevd udevadm; do
|
||||
copy_binary "$_binary"
|
||||
done
|
||||
|
||||
mkdir -p "${tmpdir}/lib/udev/rules.d"
|
||||
|
||||
printf "%s\n" \
|
||||
'SUBSYSTEMS=="block", ACTION=="add", RUN+="/bin/device-helper"' \
|
||||
> "${tmpdir}/lib/udev/rules.d/device-helper.rules"
|
||||
|
||||
[ "$monolith" = 1 ] || printf "%s\n" \
|
||||
'ENV{MODALIAS}=="?*", ACTION=="add", RUN+="/bin/modprobe %E{MODALIAS}"' \
|
||||
>> "${tmpdir}/lib/udev/rules.d/device-helper.rules"
|
||||
}
|
15
hooks/systemd-udevd/systemd-udevd.init
Normal file
15
hooks/systemd-udevd/systemd-udevd.init
Normal file
@@ -0,0 +1,15 @@
|
||||
# vim: set ft=sh:
|
||||
# shellcheck shell=sh
|
||||
#
|
||||
# false positive
|
||||
# shellcheck disable=2154,2034
|
||||
#
|
||||
# run_systemd_udevd()
|
||||
{
|
||||
[ "$break" = devmgr ] && { print "break before run_systemd_udevd()"; sh; }
|
||||
|
||||
/lib/systemd/systemd-udevd -N never & systemd_udevd_pid="$!"
|
||||
udevadm trigger -c add -t subsystems
|
||||
udevadm trigger -c add -t devices
|
||||
udevadm settle
|
||||
}
|
10
hooks/systemd-udevd/systemd-udevd.init.late
Normal file
10
hooks/systemd-udevd/systemd-udevd.init.late
Normal file
@@ -0,0 +1,10 @@
|
||||
# vim: set ft=sh:
|
||||
# shellcheck shell=sh
|
||||
#
|
||||
# false positive
|
||||
# shellcheck disable=2154
|
||||
#
|
||||
# stop_systemd_udevd()
|
||||
{
|
||||
kill "$systemd_udevd_pid"
|
||||
}
|
Reference in New Issue
Block a user