Commits

TZ86 committed 1f36803

return support of modules-load.d

Comments (0)

Files changed (4)

 	install -m755 -t $(DESTDIR)/usr/sbin rc.d
 	install -m644 -t $(DESTDIR)/usr/share/man/man5 rc.conf.5
 	install -m644 -t $(DESTDIR)/usr/share/man/man8 rc.d.8 arch-daemons.8
-	install -m755 -t $(DESTDIR)/usr/lib/initscripts arch-tmpfiles arch-sysctl arch-binfmt
+	install -m755 -t $(DESTDIR)/usr/lib/initscripts arch-tmpfiles arch-sysctl arch-binfmt arch-modules
 	install -m755 -t $(DESTDIR)/usr/lib/systemd/system-generators arch-daemons
 	install -m644 -t $(DESTDIR)/usr/lib/systemd/system rc-local.service rc-local-shutdown.service arch-daemons.target
 	install -m644 tmpfiles.conf $(DESTDIR)/usr/lib/tmpfiles.d/initscripts.conf
+#!/bin/bash
+#
+# /usr/lib/initscripts/arch-modules
+#
+# Configure kernel modules to load at boot following
+# http://0pointer.de/public/systemd-man/modules-load.d.html
+#
+
+shopt -s nullglob
+
+declare -a modules_d
+# files given has argv supersede config files
+if (( $# > 0 )); then
+	for arg; do [[ -r "$arg" ]] && modules_d+=("$arg"); done
+else
+	modules_d=(
+		/usr/lib/modules-load.d/*.conf
+		/etc/modules-load.d/*.conf
+		/run/modules-load.d/*.conf
+	)
+fi
+
+# check there is file to load
+(( ${#modules_d[@]} > 0 )) || exit 1
+
+# files declared later in the modules_d array will override earlier
+# Example: `/etc/modules-load.d/foo.conf' supersedes `/usr/lib/modules-load.d/foo.conf'.
+declare -A fragments
+for path in "${modules_d[@]}"; do
+	[[ -f $path ]] && fragments[${path##*/}]=$path
+done
+
+for path in "${fragments[@]}"; do
+	while read -r line; do
+		[[ ${line:0:1} == [\#\;] ]] && continue
+		modprobe -ab "$line"
+	done < "$path"
+done
+
+:
+
+# vim: set ts=2 sw=2 noet:
 		udevadm trigger --action=add --type=devices
 	stat_done
 
-	# Load modules from the MODULES array and modules-load.d
+	# Load modules from the MODULES array or modules-load.d
 	#status "Loading user-specified modules" load_modules
-	(( ${#MODULES[*]} )) &&
+	if (( ${#MODULES[*]} )); then
                 status "Loading User-specified Modules" modprobe -ab "${MODULES[@]}"
+	else
+		/usr/lib/initscripts/arch-modules
+	fi
 
 	status "Waiting for udev uevents to be processed" \
 		udevadm settle
 
 Modules to load at boot-up.  To blacklist modules, see man modprobe.d(5).
 
+If leave commented, contents of modules-load.d will be used.
+
 *USEDMRAID=*
 
 Scan for FakeRAID (dmraid) volumes at start-up.