From dd13d3cad0e55a3d5d1e385bd4488c800174d2a6 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 18 Mar 2016 15:02:56 +0100 Subject: [PATCH 10/15] functions: only run modprobe if /proc/modules exists We should avoid running modprobe or rmmod when we know the system doesn't support modules, it only causes errors during various services startup or stop. --- sbin/init.d/functions | 4 ++++ 1 file changed, 4 insertions(+) mode change 100755 => 100644 sbin/init.d/functions diff --git a/sbin/init.d/functions b/sbin/init.d/functions old mode 100755 new mode 100644 index dadd42e..924c863 --- a/sbin/init.d/functions +++ b/sbin/init.d/functions @@ -332,6 +332,8 @@ recursive_rmmod() { local -a args local mod + [ -e /proc/modules ] || return 0 + while : ; do args=( $(/sbin/lsmod|tail -n +2|sed "s/([^)]*)//g"|grep "^$1 "|tr -d '\[\]') ) [ ${#args[@]} -gt 0 ] || return 0 @@ -365,6 +367,8 @@ best_effort_rmmod() { local -a list local -a modules + [ -e /proc/modules ] || return 0 + while read mod dummy used args trash ; do eval usedby_${mod//-/_}=\${args//,/ } done < /proc/modules -- 1.7.12.1