modules: fix postinst generation for kernel modules
[openwrt.git] / package / base-files / files / lib / functions.sh
index dc3b805..72d954d 100755 (executable)
@@ -154,10 +154,13 @@ config_list_foreach() {
 }
 
 insert_modules() {
-       [ -d /etc/modules.d ] && {
-               cd /etc/modules.d
-               sed 's/^[^#]/insmod &/' $* | ash 2>&- || :
-       }
+       for m in $*; do
+               if [ -f /etc/modules.d/$m ]; then
+                       sed 's/^[^#]/insmod &/' /etc/modules.d/$m | ash 2>&- || :
+               else
+                       modprobe $m
+               fi
+       done
 }
 
 default_prerm() {