Fix: Erase all forgotten stuff from grml-config-user [Closes: issue1272]
[grml-scripts.git] / usr_sbin / blacklist
index 12c61d8..8446a41 100755 (executable)
@@ -4,34 +4,38 @@
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
-# Latest change: Thu Aug 07 17:16:23 CEST 2008 [mika]
 ################################################################################
 
 PN="$(basename $0)"
-[ -n "$MODPROBEFILE" ] || MODPROBEFILE=/etc/modprobe.d/grml
+[ -n "$MODPROBEFILE" ] || MODPROBEFILE=/etc/modprobe.d/grml.conf
 [ -r /etc/grml/lsb-functions ] && . /etc/grml/lsb-functions
 
-if [ -z "$1" ] ; then
+if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
   echo "Usage: $PN <module>"
   echo "$PN (un)blacklists module via $MODPROBEFILE"
   exit 1
 fi
 
-if [ $UID != 0 ] ; then
-   echo Error: become root before starting $0 >& 2
-   exit 100
+if [ "$(id -ru)" != "0" ] ; then
+  echo Error: become root before starting $0 >& 2
+  exit 100
 fi
 
 [ -f "$MODPROBEFILE" ] || touch "$MODPROBEFILE"
 
 if [ "$PN" = 'blacklist' ] ; then
   if grep -q "^blacklist $1\$" $MODPROBEFILE ; then
-     eerror "Module $1 already on blacklist in $MODPROBEFILE" ; eend 1
+    eerror "Module $1 already on blacklist in $MODPROBEFILE" ; eend 1
   else
     einfo "Adding module $1 to blacklist $MODPROBEFILE"
+
+    if ! modinfo "${1}" >/dev/null 2>&1 ; then
+      ewarn "Notice: module $1 does not seem to exist. Adding anyway."
+      eend 0
+    fi
+
     echo "blacklist $1" >> $MODPROBEFILE
     echo "alias $1 off" >> $MODPROBEFILE ; eend $?
-    modprobe -l | grep -q "${1}.ko" || ( ewarn "Notice: module $1 does not seem to exist. Adding anyway." ; eend 0 )
   fi
 fi