From bffb00e0a4bd5ff6df331516f2a6114425226888 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 18 Mar 2016 15:08:03 +0100 Subject: [PATCH 11/15] scripts: don't call modprobe if modules are not supported A kernel configured with no modules support would cause some errors to be displayed on the output. bootmodules and firewall are affected. The other ones have explicit modules settings which can thus be disabled in the config files. --- sbin/bootmodules | 2 ++ sbin/init.d/firewall | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/sbin/bootmodules b/sbin/bootmodules index 9b9b9e8..5e69db5 100755 --- a/sbin/bootmodules +++ b/sbin/bootmodules @@ -11,6 +11,8 @@ # It accepts modules lists of the form : # module_name[:arg=value[,value]*]*[;module_name[:....]] +[ -e /proc/modules ] || exit 0 + args=( $(< /proc/cmdline) ) argn=0 diff --git a/sbin/init.d/firewall b/sbin/init.d/firewall index 4b9b947..ad7fff3 100755 --- a/sbin/init.d/firewall +++ b/sbin/init.d/firewall @@ -70,9 +70,11 @@ function load_modules { local sys1=/proc/sys/net/ipv4 local sys2=/proc/sys/net/ipv4/netfilter - /sbin/modprobe ip_tables 2>/dev/null - /sbin/modprobe iptable_filter 2>/dev/null - /sbin/modprobe iptable_mangle 2>/dev/null + if [ -e /proc/modules ]; then + /sbin/modprobe ip_tables 2>/dev/null + /sbin/modprobe iptable_filter 2>/dev/null + /sbin/modprobe iptable_mangle 2>/dev/null + fi if ! grep -q "^filter$" /proc/net/ip_tables_names; then echo "Error: filtering module did not load correctly." @@ -81,7 +83,9 @@ function load_modules { fi if [ -n "$opt_stateful" ]; then - /sbin/modprobe ip_conntrack hashsize=$opt_hashsize + if [ -e /proc/modules ]; then + /sbin/modprobe ip_conntrack hashsize=$opt_hashsize + fi if [ ! -e $sys1/ip_conntrack_max -a \ ! -e $sys2/ip_conntrack_max ]; then echo "Error: conntrack module did not load correctly." @@ -90,7 +94,9 @@ function load_modules { return 1 fi - [ -n "$opt_nat" ] && /sbin/modprobe iptable_nat 2>/dev/null + if [ -e /proc/modules ]; then + [ -n "$opt_nat" ] && /sbin/modprobe iptable_nat 2>/dev/null + fi for arg in "${conntrack_args[@]}"; do var=${arg%%=*} ; val=${arg##*=} -- 1.7.12.1