aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-07-17 22:39:27 +0200
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-07-18 17:56:09 +0200
commit4b047ad61e53066e6c5d96f0f79ea3f194938c84 (patch)
treed013d95d52f0aff49897295cbd72d85452c5a6d2
parent258848ace2bcecf1ae6c3b7b433805b18fbd37d0 (diff)
Add a module auto loading service
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
-rw-r--r--.gitignore2
-rw-r--r--Makefile.am1
-rw-r--r--configure.ac2
-rw-r--r--scripts/Makemodule.am2
-rw-r--r--scripts/modules_load.sh.in39
-rw-r--r--services/Makemodule.am2
-rw-r--r--services/modules.in7
7 files changed, 53 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 9bdaf3b..086e96f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,9 +31,11 @@ services/sysfs
services/ifrename
services/ifcfg
services/ifdown
+services/modules
scripts/devfs.sh
scripts/ifrename.sh
scripts/ifcfg.sh
+scripts/modules_load.sh
etc/initd.env
diff --git a/Makefile.am b/Makefile.am
index ba51643..e087a8c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -46,6 +46,7 @@ install-data-local:
$(LN_S) $(TEMPLATEDIR)/sigterm $(DESTDIR)$(SVCDIR)/sigterm@reboot
$(LN_S) $(TEMPLATEDIR)/ifdown $(DESTDIR)$(SVCDIR)/ifdown@reboot
$(LN_S) $(TEMPLATEDIR)/ifcfg $(DESTDIR)$(SVCDIR)/ifcfg
+ $(LN_S) $(TEMPLATEDIR)/modules $(DESTDIR)$(SVCDIR)/modules
if USYSLOGD
$(LN_S) $(TEMPLATEDIR)/usyslogd $(DESTDIR)$(SVCDIR)/usyslogd
endif
diff --git a/configure.ac b/configure.ac
index 77b8abd..63fe498 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,9 +65,11 @@ AC_CONFIG_FILES([services/procfs])
AC_CONFIG_FILES([services/ifrename])
AC_CONFIG_FILES([services/ifcfg])
AC_CONFIG_FILES([services/ifdown])
+AC_CONFIG_FILES([services/modules])
AC_CONFIG_FILES([scripts/devfs.sh])
AC_CONFIG_FILES([scripts/ifrename.sh])
AC_CONFIG_FILES([scripts/ifcfg.sh])
+AC_CONFIG_FILES([scripts/modules_load.sh])
AC_CONFIG_FILES([etc/initd.env])
AC_OUTPUT([Makefile])
diff --git a/scripts/Makemodule.am b/scripts/Makemodule.am
index c0e7a82..6dca6e5 100644
--- a/scripts/Makemodule.am
+++ b/scripts/Makemodule.am
@@ -1,4 +1,4 @@
helper_SCRIPTS += scripts/devfs.sh scripts/trymount.sh scripts/ifrename.sh
-helper_SCRIPTS += scripts/ifcfg.sh scripts/ifdown.sh
+helper_SCRIPTS += scripts/ifcfg.sh scripts/ifdown.sh scripts/modules_load.sh
EXTRA_DIST += scripts/trymount.sh scripts/ifdown.sh
diff --git a/scripts/modules_load.sh.in b/scripts/modules_load.sh.in
new file mode 100644
index 0000000..518228c
--- /dev/null
+++ b/scripts/modules_load.sh.in
@@ -0,0 +1,39 @@
+#!/bin/sh
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# Copyright (C) 2018 - David Oberhollenzer
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+#
+MODLIST="@ETCPATH@/modules"
+
+if [ ! -f "$MODLIST" ]; then
+ exit 0
+fi
+
+while read LINE;
+do
+ trimmed=`echo -- $LINE`
+ [ ! -z "$trimmed" ] || continue
+ set $trimmed
+
+ case "$1" in
+ \#*)
+ ;;
+ *)
+ modprobe "$1"
+ ;;
+ esac
+done < "$MODLIST"
diff --git a/services/Makemodule.am b/services/Makemodule.am
index 75ab76d..4cad483 100644
--- a/services/Makemodule.am
+++ b/services/Makemodule.am
@@ -6,7 +6,7 @@ init_DATA += services/sigterm services/sync services/devfs
init_DATA += services/sysfs services/procfs services/tmpfs
init_DATA += services/vfs services/ifrename services/ifcfg
init_DATA += services/dhcpcd services/dhcpcdmaster services/unbound
-init_DATA += services/dnsmasq services/ifdown
+init_DATA += services/dnsmasq services/ifdown services/modules
if USYSLOGD
init_DATA += services/usyslogd
diff --git a/services/modules.in b/services/modules.in
new file mode 100644
index 0000000..3e0b69c
--- /dev/null
+++ b/services/modules.in
@@ -0,0 +1,7 @@
+description "load kernel modules"
+type wait
+target boot
+after vfs
+before sysinit
+
+exec "@SCRIPTDIR@/modules_load.sh" \ No newline at end of file