Browse Source

Use modules-load from s6

Also add manpage for modules-load
2.3.1
Nathan Owens 1 year ago
parent
commit
2171fdaef5
  1. 10
      Makefile
  2. 52
      doc/man/man8/modules-load.8
  3. 101
      module/boot@/configure/modules.sh

10
Makefile

@ -30,8 +30,9 @@ install-service-instance-module: $(MODULE_INSTANCE_TARGET:module/boot@/service@/
install-configure: $(MODULE_CONFIGURE_TARGET:module/boot@/configure/configure=$(DESTDIR)$(module_directory)/boot@/configure/configure)
install-rc-local: $(SKEL_SCRIPT_TARGET:module/boot@/configure/rc.local=$(DESTDIR)$(skel_directory)/rc.local)
install-html: $(INSTALL_HTML:doc/html/%.html=$(DESTDIR)$(datarootdir)/doc/$(package)/%.html)
install-man: install-man1
install-man: install-man1 install-man8
install-man1: $(INSTALL_MAN:doc/man/man1/%.1=$(DESTDIR)$(mandir)/man1/%.1)
install-man8: $(INSTALL_MAN:doc/man/man8/%.8=$(DESTDIR)$(mandir)/man8/%.8)
$(DESTDIR)$(script_directory)/%: module/boot@/configure/%
exec $(INSTALL) -D -m 755 $< $@
@ -49,7 +50,9 @@ $(DESTDIR)$(module_directory)/boot@/service/%: module/boot@/service/%
$(DESTDIR)$(module_directory)/boot@/service@/%: module/boot@/service@/%
exec $(INSTALL) -D -m 644 $< $@
sed -i -e "s,@scripts@,$(script_directory)," $(DESTDIR)$(module_directory)/boot@/service/system/devices/devices-crypttab
sed -e "s,@scripts@,$(script_directory)," \
-i $(DESTDIR)$(module_directory)/boot@/service/system/devices/devices-crypttab \
-i $(DESTDIR)$(module_directory)/boot@/service/system/modules/modules-system
$(DESTDIR)$(service_directory)/%: service/%
exec $(INSTALL) -D -m 644 $< $@
@ -108,6 +111,9 @@ $(DESTDIR)$(mandir)/man1/%.1: doc/man/man1/%.1
$(INSTALL) -D -m 644 $< $@ && \
sed -e 's,%%skel_directory%%,$(skel_directory),g' $< > $@
$(DESTDIR)$(mandir)/man8/%.8: doc/man/man8/%.8
$(INSTALL) -D -m 644 $< $@ && \
sed -e 's,%%skel_directory%%,$(skel_directory),g' $< > $@
version:
@echo $(version)

52
doc/man/man8/modules-load.8

@ -0,0 +1,52 @@
.Dd June 1, 2016
.Dt MODULES-LOAD 8
.Os Linux
.Sh NAME
.Nm modules-load
.Nd Configure kernel modules to load at boot
.Sh SYNOPSIS
.Nm modules-load
.Op Fl nv
.Sh DESCRIPTION
.Nm
reads files which contain kernel modules to load during boot from the list of
locations below.
.Bl -tag -width indent
.It Fl n
dry-run mode.
This option does everything but actually insert or delete the modules.
.It Fl v
verbose mode.
Print messages about what the program is doing.
.El
.Sh FILES
Configuration files are read from the following locations:
.Bl -tag -width indent
.It /etc/modules-load.d/*.conf
.It /run/modules-load.d/*.conf
.It /usr/lib/modules-load.d/*.conf
.El
.Pp
The configuration files should simply contain a list of kernel module names
to load, separated by newlines.
Empty lines and lines whose first non-whitespace character is # or ; are
ignored.
.Sh EXAMPLES
.Pa /etc/modules-load.d/virtio-net.conf :
.Bd -literal -offset indent
# Load virtio-net.ko at boot
virtio-net
.Ed
.Sh SEE ALSO
.Xr modprobe 8
.Sh HISTORY
This program is a replacement for the
.Nm modules-load
utility provided by
.Nm systemd .
.Sh AUTHOR
.An Leah Neukirchen ,
.Mt leah@vuxu.org .
.Sh LICENSE
.Nm
is in the public domain.

101
module/boot@/configure/modules.sh

@ -1,82 +1,19 @@
#!@BINDIR@/sh
#
# This scripts is a pure-POSIX sh version
#
# Copyright (c) 2015-2021 Eric Vidal <eric@obarun.org>
# All rights reserved.
#
# This file is part of Obarun. It is subject to the license terms in
# the LICENSE file found in the top-level directory of this
# distribution.
# This file may not be copied, modified, propagated, or distributed
# except according to the terms contained in the LICENSE file.
# Configuration files are read from directories in
# /etc/modules-load.d, /run/modules-load.d, and /usr/lib/modules-load.d,
# in order of precedence
MODULES_PATH='/etc/modules-load.d /run/modules-load.d /usr/lib/modules-load.d'
MODULES_NAME=""
MODULES_RESULT=""
check_elements(){
for e in $2; do [ "$e" = "$1" ] && return 0; done; return 1;
}
build_array() {
printf "%s %s" "$1" "$2"
}
check_file(){
tidy_loop="" conf=""
for tidy_loop in $MODULES_PATH; do
if [ -d "${tidy_loop}" ]; then
for conf in "${tidy_loop}"/*.conf ; do
if [ -f "${conf}" ]; then
if ! check_elements "${conf##*/}" "${MODULES_NAME}"; then
MODULES_NAME=$(build_array "${MODULES_NAME}" "${conf##*/}")
fi
fi
done
fi
done
unset tidy_loop conf
}
check_path(){
path="" tidy_loop=""
for path in ${MODULES_PATH}; do
for tidy_loop in ${MODULES_NAME}; do
if [ -f "${path}/${tidy_loop}" ]; then
if ! check_elements "${tidy_loop}" "${MODULES_RESULT##*/}";then
MODULES_RESULT=$(build_array "${MODULES_RESULT}" "${path}/${tidy_loop}")
fi
fi
done
done
unset path tidy_loop
}
check_file
if [ -n "${MODULES_NAME}" ]; then
check_path
else
printf "$0: %s\n" "No modules found -- nothing to do"
exit 0
fi
for mod in ${MODULES_RESULT}; do
while read -r line; do
comment=$(printf "%s" "$line" | awk '{ string=substr($0, 0, 1); print string; }' )
if [ "${comment}" = "#" ] || [ -z "${line}" ];then
continue
fi
for check in ${line};do
modprobe -b "${check}" -v | sed 's:insmod [^ ]*/:Load modules :g; s:\.ko\(\.gz\)\? ::g'
done
done < "${mod}"
done
exit 0
#!/bin/sh
# modules-load [-n] [-v] - modules-load.d(8) compatible kernel module loader
export PATH=/bin:/sbin
{
# Parameters passed as modules-load= or rd.modules-load= in kernel command line.
sed -nr 's/,/\n/;s/(.* |^)(rd\.)?modules-load=([^ ]*).*/\3/p' /proc/cmdline
# Find files /{etc,run,usr/lib}/modules-load.d/*.conf in that order.
find -L /etc/modules-load.d /run/modules-load.d /usr/lib/modules-load.d \
-maxdepth 1 -name '*.conf' -printf '%p %P\n' 2>/dev/null |
# Load each basename only once.
sort -k2 -s | uniq -f1 | cut -d' ' -f1 |
# Read the files, output all non-empty, non-comment lines.
tr '\012' '\0' | xargs -0 -r grep -h -v -e '^[#;]' -e '^$'
} |
# Call modprobe on the list of modules
tr '\012' '\0' | xargs -0 -r modprobe -ab "$@"

Loading…
Cancel
Save