Merge remote-tracking branch 'origin/github/pr/11'
authorMichael Prokop <mika@grml.org>
Fri, 6 May 2022 10:24:08 +0000 (12:24 +0200)
committerMichael Prokop <mika@grml.org>
Fri, 6 May 2022 10:24:08 +0000 (12:24 +0200)
26 files changed:
.github/workflows/tests.yml [new file with mode: 0644]
Makefile [new file with mode: 0644]
manpages/grml-swapon.8
usr_bin/grepedit
usr_bin/grml-exec-wrapper
usr_bin/grml-lang
usr_bin/grml-lock
usr_bin/grml-resolution
usr_bin/iso-term
usr_bin/notifyd.py
usr_bin/random-hostname
usr_bin/soundtest
usr_sbin/blacklist
usr_sbin/dirvish-setup
usr_sbin/grml-chroot
usr_sbin/grml-config-root
usr_sbin/grml-hostname
usr_sbin/grml-iptstate
usr_sbin/grml-setkeyboard
usr_sbin/grml-setlang
usr_sbin/grml-setservices
usr_sbin/grml2ram
usr_sbin/noeject
usr_sbin/noprompt
usr_share/run-screen
usr_share/run-welcome

diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
new file mode 100644 (file)
index 0000000..b06617b
--- /dev/null
@@ -0,0 +1,56 @@
+name: Code Testing
+
+on:
+  push:
+  pull_request:
+  schedule:
+    - cron: '42 1 * * *'
+
+jobs:
+  spellcheck:
+    runs-on: ubuntu-latest
+    name: Run spellcheck
+
+    steps:
+    - name: Checkout source
+      uses: actions/checkout@v2
+
+    - name: Install lintian
+      run: sudo apt-get -y install lintian
+
+    - name: Spellcheck execution
+      run: make spellcheck
+
+  codecheck:
+    runs-on: ubuntu-latest
+    name: Run codecheck
+
+    steps:
+    - name: Checkout source
+      uses: actions/checkout@v2
+
+    - name: Display original shellcheck version
+      run: shellcheck --version
+
+    - name: Update shellcheck to latest stable version
+      run: |
+        wget -qO- https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz | tar -xJv
+        sudo cp shellcheck-stable/shellcheck /usr/bin/
+
+    - name: pip install flake8, isort + black
+      run: pip3 install -U flake8 isort black
+
+    - name: Display current shellcheck version
+      run: shellcheck --version
+
+    - name: Display current flake8 version
+      run: flake8 --version
+
+    - name: Display current isort version
+      run: isort --version
+
+    - name: Display current black version
+      run: black --version
+
+    - name: Codecheck execution
+      run: make --keep-going codecheck
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..bcbfe07
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,68 @@
+.DEFAULT_GOAL:=help
+
+help:  ## Display this help
+       @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n  make \033[36m\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf "  \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
+
+allcheck: codecheck spellcheck ## Run codecheck and spellcheck
+
+codecheck: shellcheck pythoncheck ## Run shellcheck and pythoncheck
+
+.ONESHELL:
+shellcheck: ## Run shellcheck
+       @RETURN=0
+       @for shellfile in $$(ls usr_bin/* usr_sbin/* usr_share/*); do
+       @       [ "$${shellfile}" = "usr_bin/iimage" ] && continue
+       @       [ "$${shellfile}" = "usr_sbin/make_chroot_jail" ] && continue
+       @       file "$${shellfile}" | grep -q shell && (shellcheck -x "$${shellfile}" || RETURN=1)
+       @done
+       @exit $${RETURN}
+
+.ONESHELL:
+pythoncheck: ## Run pythoncheck (flakecheck, isortcheck + blackcheck)
+       @RETURN=0
+       @for pythonfile in usr_bin/* usr_sbin/* usr_share/*; do
+       @       if head -1 "$${pythonfile}" | grep -q "python"; then
+       @               flake8 --max-line-length 88 "$${pythonfile}" || RETURN=1
+       @               isort --check "$${pythonfile}" || RETURN=1
+       @               black --check "$${pythonfile}" || RETURN=1
+       @       fi
+       @done
+       @exit $${RETURN}
+
+.ONESHELL:
+flakecheck: ## Run flake8 only
+       @RETURN=0
+       @for pythonfile in usr_bin/* usr_sbin/* usr_share/*; do
+       @       if head -1 "$${pythonfile}" | grep -q "python"; then
+       @               flake8 --max-line-length 88 "$${pythonfile}" || RETURN=1
+       @       fi
+       @done
+       @exit $${RETURN}
+
+.ONESHELL:
+isortcheck: ## Run isort --check only
+       @RETURN=0
+       @for pythonfile in usr_bin/* usr_sbin/* usr_share/*; do
+       @       if head -1 "$${pythonfile}" | grep -q "python"; then
+       @               isort --check "$${pythonfile}" || RETURN=1
+       @       fi
+       @done
+       @exit $${RETURN}
+
+.ONESHELL:
+blackcheck: ## Run black --check only
+       @RETURN=0
+       @for pythonfile in usr_bin/* usr_sbin/* usr_share/*; do
+       @       if head -1 "$${pythonfile}" | grep -q "python"; then
+       @               black --check "$${pythonfile}" || RETURN=1
+       @       fi
+       @done
+       @exit $${RETURN}
+
+.ONESHELL:
+spellcheck: ## Run spellcheck
+       @OUTPUT="$$(spellintian manpages/*)"
+       @echo $$OUTPUT
+       @if [ -n "$$OUTPUT" ]; then
+       @       false
+       @fi
index 8ede4c1..965be99 100644 (file)
@@ -8,7 +8,7 @@ grml\-swapon \- activate swap partitions with taking care of suspend signatures
 
 grml-swapon is a small script for enabling swap partitions found in /etc/fstab.
 Starting with grml 0.9 booting the live-cd system does not activate swap
-parititions by default anymore. It is possible to force usage of swap partitions
+partitions by default anymore. It is possible to force usage of swap partitions
 via booting with the bootoption "swap". In case you forgot to use this
 bootoption but want to use swap partition(s) anyway you could do that by running
 "swapon \-a". But the command "swapon" does not take of suspend signatures,
index 2d5730b..9908ff2 100755 (executable)
@@ -1,20 +1,20 @@
 #!/usr/bin/python
 
-##  Copyright 2005 Drew Perttula
-  
-##  This program is free software; you can redistribute it and/or modify
-##  it under the terms of the GNU General Public License as published by
-##  the Free Software Foundation; either version 2 of the License, or
-##  (at your option) any later version.
-
-##  This program is distributed in the hope that it will be useful,
-##  but WITHOUT ANY WARRANTY; without even the implied warranty of
-##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-##  GNU General Public License for more details.
-
-##  You should have received a copy of the GNU General Public License
-##  along with this program; if not, write to the Free Software
-##  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#  Copyright 2005 Drew Perttula
+
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 """sometimes we grep for something in a bunch of files, and then we
 want to make edits to the lines that were returned from the grep. It's
@@ -49,9 +49,14 @@ ez_setup.py-179-    for name in filenames:
 
 """
 
-import tempfile, sys, os, re
+import os
+import re
+import sys
+import tempfile
+
 from sets import Set
 
+
 def grep_parse(filename):
     """parse grep output lines in given file into a dict of
     (filename, lineno) : text"""
@@ -59,41 +64,50 @@ def grep_parse(filename):
     for line in open(filename):
         if line == "--\n":
             continue
-        m = re.match(r"(?P<filename>.*?)(?P<sep>[-:])(?P<lineno>\d+)(?P=sep)(?P<line>.*\n)$", line)
+        m = re.match(
+            r"(?P<filename>.*?)(?P<sep>[-:])(?P<lineno>\d+)(?P=sep)(?P<line>.*\n)$",
+            line,
+        )
         if m is None:
-            print "couldn't parse grep result line %r" % line
+            print("couldn't parse grep result line %r" % line)
             continue
-        filename, lineno, text = (m.group('filename'), int(m.group('lineno')),
-                                  m.group('line'))
-        if (filename,lineno) in parse:
-            raise ValueError("multiple results found for %s:%s" %
-                             (filename, lineno))
+        filename, lineno, text = (
+            m.group("filename"),
+            int(m.group("lineno")),
+            m.group("line"),
+        )
+        if (filename, lineno) in parse:
+            raise ValueError("multiple results found for %s:%s" % (filename, lineno))
         parse[(filename, lineno)] = text
     return parse
 
+
 options = {}
 passthru_args = []
 for arg in sys.argv[1:]:
     if arg == "--sort-text":
-        options['sort-text'] = True
+        options["sort-text"] = True
         continue
     passthru_args.append(arg)
 
 tf = tempfile.NamedTemporaryFile(prefix="grepedit_")
 tf.close()
 
-cmd = ("grep --with-filename --line-number --binary-files=without-match %s > %s" %
-       (" ".join(['"%s"' % s.replace("\\","\\\\").replace('"','\\"')
-                  for s in passthru_args]),tf.name))
+cmd = "grep --with-filename --line-number --binary-files=without-match %s > %s" % (
+    " ".join(
+        ['"%s"' % s.replace("\\", "\\\\").replace('"', '\\"') for s in passthru_args]
+    ),
+    tf.name,
+)
 os.system(cmd)
 
 originals = grep_parse(tf.name)
 
-if options.get('sort-text', False):
-    orig = [(v,k) for k,v in originals.items()]
+if options.get("sort-text", False):
+    orig = [(v, k) for k, v in list(originals.items())]
     orig.sort()
     f = open(tf.name, "w")
-    for text, (filename,lineno) in orig:
+    for text, (filename, lineno) in orig:
         f.write("%s:%s:%s" % (filename, lineno, text))
     f.close()
 
@@ -101,25 +115,29 @@ os.system("%s %s" % (os.getenv("EDITOR"), tf.name))
 
 corrections = grep_parse(tf.name)
 
-files = Set([filename for filename,lineno in corrections.keys()])
+files = Set([filename for filename, lineno in list(corrections.keys())])
 for orig_filename in files:
     (copy_fd, copy_filename) = tempfile.mkstemp(
         dir=os.path.dirname(orig_filename),
-        prefix="_%s_tmp_grepedit" % os.path.basename(orig_filename))
+        prefix="_%s_tmp_grepedit" % os.path.basename(orig_filename),
+    )
 
     any_changes = False
-    for lineno,line in enumerate(open(orig_filename)):
-        lineno = lineno + 1 # grep is 1-based
-        key = orig_filename,lineno
+    for lineno, line in enumerate(open(orig_filename)):
+        lineno = lineno + 1  # grep is 1-based
+        key = orig_filename, lineno
         if key in corrections:
             if line != originals[key]:
-                print "%s:%s has changed since the grep command ran- not modifying this line" % key
-                print repr(line)
-                print repr(originals[key])
+                print(
+                    "%s:%s has changed since the grep command ran- "
+                    "not modifying this line" % key
+                )
+                print(repr(line))
+                print(repr(originals[key]))
             elif corrections[key] == line:
                 pass
             else:
-                print "%s:%s substituting new line" % key
+                print("%s:%s substituting new line" % key)
                 line = corrections[key]
                 any_changes = True
         os.write(copy_fd, line)
@@ -128,7 +146,5 @@ for orig_filename in files:
     if any_changes:
         os.rename(copy_filename, orig_filename)
     else:
-        print "no changes made in file %s" % orig_filename
+        print("no changes made in file %s" % orig_filename)
         os.unlink(copy_filename)
-        
-    
index d3ff8ee..4e5a3cc 100755 (executable)
@@ -6,15 +6,16 @@
 # License:       This file is licensed under the GPL v2 or any later version.
 ################################################################################
 
+PN=$(basename "$0")
+
 usage() {
-  printf "Usage: $0 <program> [<arguments>]
+  printf "Usage: %s <program> [<arguments>]
 
 Available options:
 
   -h | --help   display this usage information
   -p <program>  check specified argument instead of default args, like:
-                $(basename $0) -p aumix xterm -T aumix -e aumix
-"
+                %s -p aumix xterm -T aumix -e aumix\n" "${PN}" "${PN}"
 }
 
 is_installed() {
@@ -49,7 +50,7 @@ else
 fi
 }
 
-if [ -z "$1" -o "$1" = '-h' -o "$1" = '--help' ] ; then
+if [ -z "$1" ] || [ "$1" = '-h' ] || [ "$1" = '--help' ] ; then
     usage
     exit 1
 fi
@@ -80,7 +81,7 @@ Looks like the grml flavour you are using does not ship ${PROG}. :(
 
 You can search for ${PROG} executing:
 
-apt-get update && apt-cache search $(basename ${PROG})
+apt-get update && apt-cache search $(basename "${PROG}")
     "
 
 exit 1
index 0e774ae..52b81a0 100755 (executable)
@@ -7,10 +7,10 @@
 ################################################################################
 
 CONFFILE=/etc/default/keyboard
-PN="$(basename $0)"
+PN="$(basename "$0")"
 
 usage(){
-    echo "Usage: $0 <language>"
+    echo "Usage: ${PN} <language>"
     echo "supported values: at, ch, de, dvorak, es, fr, it, jp, us"
 }
 
@@ -26,6 +26,7 @@ fi
 
 LANGUAGE="$1"
 
+# shellcheck disable=SC1091
 . /etc/grml/language-functions
 
 if [ -n "$XKEYBOARD" ] ; then
index 27ba082..46e0ab5 100755 (executable)
@@ -21,6 +21,7 @@ Usage: just execute $PN without any further options."
 fi
 
 if [ -r /etc/grml/script-functions ] ; then
+   # shellcheck disable=SC1091
    . /etc/grml/script-functions
    check4progs physlock sudo chpasswd dialog || { echo "Sorry, necessary tools missing - can not continue. Exiting.">&2 ; exit 1 ; }
 fi
index c30111e..5b334d7 100755 (executable)
@@ -6,13 +6,13 @@
 # License:       This file is licensed under the GPL v2.
 ################################################################################
 
-PN=$(basename $0)
+PN="$(basename "$0")"
 RESOLUTION=$(mktemp)
 ERROR=$(mktemp)
 
 bailout(){
-  rm -f $RESOLUTION $ERROR
-  exit $1
+  rm -f "$RESOLUTION" "$ERROR"
+  exit "$1"
 }
 
 trap bailout 1 2 3 15
@@ -27,27 +27,29 @@ CURRENT_NUM=$(xrandr | awk '/\*/ {print $1}' | tr -d '*')
 CURRENT_RESOLUTION=$(xrandr | awk '/\*/ {print $2 $3 $4}')
 
 # menu
-for i in $(xrandr | awk {'print $2$3$4'} | grep "^[0-9]") ; do
+for i in $(xrandr | awk '{print $2$3$4}' | grep "^[0-9]") ; do
   STRING="$STRING $COUNTER $i"
   ((COUNTER++))
 done
 
 # Menu Tool
-dialog --title "$PN" --menu "Change X resolution via xrandr (current resolution: $CURRENT_RESOLUTION):" 0 0 0 $STRING 2>$RESOLUTION
+# shellcheck disable=SC2086
+dialog --title "$PN" --menu "Change X resolution via xrandr (current resolution: $CURRENT_RESOLUTION):" 0 0 0 $STRING 2>"$RESOLUTION"
 retval=$?
 case $retval in
       (1)   echo "Cancel pressed." ; exit 1 ;;
       (255) echo "ESC pressed."    ; exit 1 ;;
 esac
 
-CHOSE=$(cat $RESOLUTION)
+CHOSE=$(cat "$RESOLUTION")
 
 if [ "$CHOSE" = "$CURRENT_NUM" ] ; then
    dialog --title "$PN" --msgbox "Chosen resolution corresponds to current resolution. No changes needed." 0 0
 elif [ -n "$CHOSE" ] ; then
-  xrandr -s $CHOSE 2>$ERROR && \
+# shellcheck disable=SC2015
+  xrandr -s "$CHOSE" 2>"$ERROR" && \
   dialog --title "$PN" --msgbox "Running xrandr with resolution was succesful." 0 0 || \
-  dialog --title "$PN" --msgbox "Error when running xrandr with resolution $CHOSE: `cat $ERROR`" 0 0
+  dialog --title "$PN" --msgbox "Error when running xrandr with resolution $CHOSE: $(cat "$ERROR")" 0 0
 fi
 }
 
@@ -55,6 +57,6 @@ while true ; do
   main
 done
 
-bailout
+bailout 0
 
 # EOF #
index 0362eb2..440233b 100755 (executable)
@@ -15,12 +15,10 @@ esac
 }
 
 if isutfenv ; then
-   for ENV in `env | grep UTF` ; do
-       eval export "$(echo $ENV | sed 's/UTF-8/iso885915/')"
+   for ENV in $(env | grep UTF) ; do
+       eval export "$(echo "$ENV" | sed 's/UTF-8/iso885915/')"
    done
-   ZSH_NO_DEFAULT_LOCALE=1 x-terminal-emulator $*
-else
-   ZSH_NO_DEFAULT_LOCALE=1 x-terminal-emulator $*
 fi
+ZSH_NO_DEFAULT_LOCALE=1 x-terminal-emulator "$@"
 
 ## END OF FILE #################################################################
index 312c9b0..ec50fce 100755 (executable)
@@ -29,7 +29,7 @@ host = "127.0.0.1"
 port = 8901
 logfile = os.path.expanduser("~/.event.log")
 osdparams = "-p bottom  --color=red --delay=4 --age=4 " \
- "--font=\-\*\-helvetica\-medium\-r\-\*\-\*\-34\-\*\-\*\-\*\-\*\-\*\-\*\-15 " \
+ "--font=\-\*\-helvetica\-medium\-r\-\*\-\*\-34\-\*\-\*\-\*\-\*\-\*\-\*\-15 " \  # noqa: W605,E501
      "--offset=100 --shadow=0 --lines=5 --align=right --indent=100"
 actions = (
     (".*", [log], True),
@@ -40,78 +40,101 @@ actions = (
 
 """
 
+import getopt
+import logging
 import os
-import sys
 import re
-import string
 import socket
-import logging
-import getopt
+import string
 import subprocess
+import sys
 
-default_hostname = 'localhost'
+default_hostname = "localhost"
 default_port = 1234
-default_osd_params = osdparams = "-p bottom  --color=red --delay=4 --age=4 " \
-           "--font=\-\*\-helvetica\-medium\-r\-\*\-\*\-34\-\*\-\*\-\*\-\*\-\*\-\*\-15 " \
-            "--offset=100 --shadow=0 --lines=5 --align=right --indent=100"
+default_osd_params = osdparams = (
+    "-p bottom  --color=red --delay=4 --age=4 "
+    "--font=\-\*\-helvetica\-medium\-r\-\*\-\*\-34\-\*\-\*\-\*\-\*\-\*\-\*\-15 "  # noqa: W605,E501
+    "--offset=100 --shadow=0 --lines=5 --align=right --indent=100"
+)
 default_logfile = None
 
 
 def play(sound_file):
     def play_wrapper(msg):
-        with open(os.devnull, 'w') as devnull:
-            subprocess.Popen(['/usr/bin/aplay', sound_file], stderr=devnull)
+        with open(os.devnull, "w") as devnull:
+            subprocess.Popen(["/usr/bin/aplay", sound_file], stderr=devnull)
+
     return play_wrapper
 
+
 def execute(command):
     def command_wrapper(msg):
-        subprocess.call(command % dict(msg = msg))
+        subprocess.call(command % dict(msg=msg))
+
     return command_wrapper
 
+
 def osd(msg):
     osdcmd = "/usr/bin/osd_cat"
-    osdpipe = os.popen("%s %s" % (osdcmd, osdparams), 'w')
+    osdpipe = os.popen("%s %s" % (osdcmd, osdparams), "w")
     osdpipe.write(msg)
     osdpipe.close()
 
+
 def libnotify(msg):
     try:
         import dbus
     except ImportError:
-        sys.stderr.write('Please install python-dbus\n')
+        sys.stderr.write("Please install python-dbus\n")
         raise SystemExit(1)
 
     bus = dbus.SessionBus()
-    notifyService = bus.get_object("org.freedesktop.Notifications", '/org/freedesktop/Notifications')
-    interface = dbus.Interface(notifyService, 'org.freedesktop.Notifications')
+    notifyService = bus.get_object(
+        "org.freedesktop.Notifications", "/org/freedesktop/Notifications"
+    )
+    interface = dbus.Interface(notifyService, "org.freedesktop.Notifications")
 
-    message, title = (':' + msg).split(':')[::-1][0:2]
+    message, title = (":" + msg).split(":")[::-1][0:2]
     if not title:
         title, message = message, title
-    interface.Notify('notify-server', 0, 'notification-message-im', title, message, [], {'x-canonical-append':'allowed'}, -1)
+    interface.Notify(
+        "notify-server",
+        0,
+        "notification-message-im",
+        title,
+        message,
+        [],
+        {"x-canonical-append": "allowed"},
+        -1,
+    )
+
 
 def log(msg):
     if logger:
         logger.info(msg)
 
+
 def syntax():
-    print "osd_server.py [options]"
-    print "   options:"
-    print "     -h --help       print this message"
-    print "     -H --host       host of the osd server (def: " + default_hostname + ")"
-    print "     -P --port       port of the osd server (def: " + str(default_port) + ")"
-    print "     -l --log        log file ('-' logs to stdout)"
-
-
-env = { 'play' : play,
-        'execute' : execute,
-        'osd' : osd,
-        'libnotify' : libnotify,
-        'log' : log,
-        'host' : default_hostname,
-        'port' : default_port,
-        'logfile' : default_logfile,
-        }
+    print("osd_server.py [options]")
+    print("   options:")
+    print("     -h --help       print this message")
+    print("     -H --host       host of the osd server (def: " + default_hostname + ")")
+    print(
+        "     -P --port       port of the osd server (def: " + str(default_port) + ")"
+    )
+    print("     -l --log        log file ('-' logs to stdout)")
+
+
+env = {
+    "play": play,
+    "execute": execute,
+    "osd": osd,
+    "libnotify": libnotify,
+    "log": log,
+    "host": default_hostname,
+    "port": default_port,
+    "logfile": default_logfile,
+}
 
 default_actions = (
     (".*", [log], True),
@@ -122,12 +145,22 @@ default_actions = (
 default_bind = (default_hostname, default_port)
 
 try:
-    execfile(os.path.expanduser('~/.notifyd.conf'), {}, env)
+    exec(
+        compile(
+            open(os.path.expanduser("~/.notifyd.conf"), "rb").read(),
+            os.path.expanduser("~/.notifyd.conf"),
+            "exec",
+        ),
+        {},
+        env,
+    )
 except IOError:
     pass
 
 try:
-    opts, args = getopt.getopt(sys.argv[1:], "hH:P:l:", ["help", "host=", "port=", "log="])
+    opts, args = getopt.getopt(
+        sys.argv[1:], "hH:P:l:", ["help", "host=", "port=", "log="]
+    )
 except getopt.GetoptError:
     syntax()
     sys.exit(2)
@@ -137,23 +170,23 @@ for opt, arg in opts:
         syntax()
         sys.exit(3)
     elif opt in ("-H", "--host"):
-        env['host'] = arg
+        env["host"] = arg
     elif opt in ("-P", "--port"):
-        env['port'] = int(arg)
+        env["port"] = int(arg)
     elif opt in ("-l", "--log"):
-        env['logfile'] = arg
+        env["logfile"] = arg
 
 
-actions = env.get('actions', default_actions)
-logfile_name = env.get('logfile')
-logfile_format = env.get('logformat', '%(asctime)s %(message)s')
-bind_address = (env['host'], env['port'])
-osd_params = env.get('osdparams', default_osd_params)
+actions = env.get("actions", default_actions)
+logfile_name = env.get("logfile")
+logfile_format = env.get("logformat", "%(asctime)s %(message)s")
+bind_address = (env["host"], env["port"])
+osd_params = env.get("osdparams", default_osd_params)
 
 if logfile_name:
-    logger = logging.getLogger('notify_server')
+    logger = logging.getLogger("notify_server")
     lformatter = logging.Formatter(logfile_format)
-    if logfile_name not in ('', '-'):
+    if logfile_name not in ("", "-"):
         lfh = logging.FileHandler(logfile_name)
         lfh.setFormatter(lformatter)
         logger.addHandler(lfh)
@@ -165,23 +198,25 @@ if logfile_name:
 else:
     logger = None
 
-l = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-l.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
-l.bind(bind_address)
-l.listen(5)
+listen = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+listen.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+listen.bind(bind_address)
+listen.listen(5)
+
 
 def filter_char(c):
-    return c in string.printable + "äöüßÄÖÜ" and c or '_'
+    return c in string.printable + "äöüßÄÖÜ" and c or "_"
+
 
 while 1:
     try:
-        (con, addr) = l.accept()
-    except:
+        (con, addr) = listen.accept()
+    except OSError:
         continue
     data = con.recv(50).strip()
     con.close()
 
-    log = ''.join(filter_char(c) for c in data)
+    log = "".join(filter_char(c) for c in data)
 
     for pattern, handlers, cont in actions:
         if re.match(pattern, log):
index b523523..7386abb 100755 (executable)
@@ -5,13 +5,13 @@
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
 ################################################################################
-num=$(wc -l $0)
-num=${num%% $0}
-num=$(( $num - 16 ))
-randline=$(($(date +%Y%M%S) * $$ % $num))
-hostname=$(tail -n $randline "$0" | head -1 | grep -v "'" | grep -v '^#' | grep -v '^$')
+hostname_start=$(grep -n "^# EOF" "$0")
+hostname_start=${hostname_start%%:#*}
+hostname_start=$(( hostname_start + 3 ))
+hostname=$(tail -n +$hostname_start "$0" | grep -v "'" | grep -v '^#' | grep -v '^$' | sort -R | tail -1)
 [ -n "$hostname" ] && echo "$hostname" || echo "grml"
-# EOF - line 15; now the hostnames:
+# EOF - now the hostnames:
+# shellcheck disable=SC2034
 hostnames='
 23
 42
index 6146df7..dc57bf3 100755 (executable)
@@ -6,7 +6,7 @@
 # License:       This file is licensed under the GPL v2.
 ################################################################################
 
-if ! [ $(which speaker-test) ] ; then
+if ! [ "$(command -v speaker-test)" ] ; then
   echo "Sorry, speaker-test (from alsa-utils) not available.">&2
   exit 1
 fi
index 8446a41..396dc08 100755 (executable)
@@ -6,8 +6,9 @@
 # License:       This file is licensed under the GPL v2.
 ################################################################################
 
-PN="$(basename $0)"
+PN="$(basename "$0")"
 [ -n "$MODPROBEFILE" ] || MODPROBEFILE=/etc/modprobe.d/grml.conf
+# shellcheck disable=SC1091
 [ -r /etc/grml/lsb-functions ] && . /etc/grml/lsb-functions
 
 if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
@@ -17,7 +18,7 @@ if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
 fi
 
 if [ "$(id -ru)" != "0" ] ; then
-  echo Error: become root before starting $0 >& 2
+  echo "Error: become root before starting $0" >& 2
   exit 100
 fi
 
index bef4524..8a2497c 100755 (executable)
@@ -13,7 +13,9 @@
 
 set -e
 
+# shellcheck disable=SC1091
 . /etc/grml/script-functions
+# shellcheck disable=SC1091
 . /etc/grml/lsb-functions
 
 check4root
@@ -71,7 +73,8 @@ EOF
 
 # TODO / integrate?
 cronsetup() {
-  test -f ~/.keychain/`uname -n`-sh && . ~/.keychain/`uname -n`-sh
+# shellcheck disable=SC1090
+  test -f "${HOME}/.keychain/$(uname -n)-sh" && . "${HOME}/.keychain/$(uname -n)-sh"
 }
 
 get_backup_dir() {
@@ -80,8 +83,9 @@ get_backup_dir() {
 
   if ! [ -d "$BACKUP_DIR" ] ; then
     dialog --stdout --title "${PN}" --yesno "The directory $BACKUP_DIR does not yet exist. Do you want me to create it for you? " 0 0
+    RC=$?
 
-    if [ $? -eq 0 ]; then
+    if [ ${RC} -eq 0 ]; then
        echo "mkdir $BACKUP_DIR"
        echo "chmod 700 $BACKUP_DIR"
     else
@@ -121,23 +125,25 @@ EOF
 }
 
 sshkey_setup() {
-  CLIENTNAME="$(dialog --stdout --inputbox 'Please choose user login and hostname for the client you want to backup. Syntax: user@host' 0 0 root@$(hostname))"
+  CLIENTNAME="$(dialog --stdout --inputbox 'Please choose user login and hostname for the client you want to backup. Syntax: user@host' 0 0 root@"$(hostname)")"
 
   dialog --stdout --title "${PN}" --yesno "Do you want me to create ssh setup for client ${CLIENTNAME} using ssh-keygen and ssh-copy-id?" 0 0
+  RC=$?
 
-  if [ $? -eq 0 ]; then
+  if [ ${RC} -eq 0 ]; then
      [ -d "$HOME/.ssh" ] || mkdir "$HOME/.ssh"
      einfo "Creating $HOME/.ssh/id_rsa_dirvish_${CLIENT} using ssh-keygen:"
      ssh-keygen -t rsa -f "$HOME/.ssh/id_rsa_dirvish_${CLIENT}" ; eend $?
      einfo "Running ssh-copy-id to copy ssh key to $CLIENTNAME:"
-     ssh-copy-id -i "$HOME/.ssh/id_rsa_dirvish_${CLIENT}.pub" $CLIENTNAME ; eend $?
+     ssh-copy-id -i "$HOME/.ssh/id_rsa_dirvish_${CLIENT}.pub" "$CLIENTNAME" ; eend $?
   fi
 }
 
 client_setup() {
   dialog --stdout --title "${PN}" --yesno "Do you want to backup $CLIENT via network? Answering with no will use localhost [$(hostname)] as client." 0 0
+  RC=$?
 
-  if [ $? -eq 0 ]; then
+  if [ ${RC} -eq 0 ]; then
      sshkey_setup
   else
      CLIENTNAME=$(hostname) # use localhost only
@@ -148,7 +154,7 @@ display_info() {
   einfo "Running $PN was successful. Enjoy using dirvish!" ; eend 0
   echo
   einfo "Please adjust ${BACKUP_DIR}/${CLIENT}/dirvish/default.conf according to your needs.
-$MASTERINFO  
+$MASTERINFO
 Then run the following command to create an initial backup:
 
   dirvish --summary long --vault $CLIENT --init
index e8ed430..8fcdabf 100755 (executable)
@@ -6,14 +6,14 @@
 # License:       This file is licensed under the GPL v2.
 ################################################################################
 
-PROG_NAME_=$(basename $0)
+PROG_NAME_=$(basename "$0")
 DEST_=""
 MOUNTED_=""     # all mounted destinations
 
 
 function die
 {
-    echo "Error: $@" >&2
+    echo "Error: $*" >&2
     exit 1
 }
 
@@ -50,12 +50,13 @@ function mountit
     else
         all_options_="-t $type_ none"
     fi
-    mount $all_options_ "${DEST_}/$dest_" && storeMounts "$dest_"
+    mount "$all_options_" "${DEST_}/$dest_" && storeMounts "$dest_"
 }
 
 function umount_all
 {
-    local reverse=$(echo $MOUNTED_ | awk '{ for (i=NF; i>1; i--) printf("%s ",$i); print $1; }')
+    local reverse
+    reverse=$(echo "$MOUNTED_" | awk '{ for (i=NF; i>1; i--) printf("%s ",$i); print $1; }')
     for i in $reverse; do
         umount "${DEST_}/$i"
     done
@@ -72,14 +73,14 @@ while getopts "h" opt; do
         ?) printUsage; exit 64 ;;
     esac
 done
-shift $(($OPTIND - 1))
+shift $((OPTIND - 1))
 
 if (( $# < 1 )); then
     printUsage
     die "Wrong number of arguments."
 fi
 
-if ! which awk >/dev/null 2>&1 ; then
+if ! command -v awk >/dev/null 2>&1 ; then
   die "No awk binary found, required for execution."
 fi
 
@@ -122,7 +123,7 @@ else
 fi
 umount_all
 
-if [ ! -z "$WROTE_DEBIAN_CHROOT" ]; then
+if [ -n "$WROTE_DEBIAN_CHROOT" ]; then
     rm "$DEST_"/etc/debian_chroot
 fi
 
index e1e1158..db6a2a5 100755 (executable)
@@ -9,8 +9,8 @@
 PATH=${PATH:-'/bin/:/sbin/:/usr/bin:/usr/sbin'}
 
 # set up some variables
-DIALOG=`which dialog`
-PN=$(basename $0)
+DIALOG=$(command -v dialog)
+PN=$(basename "$0")
 
 if [ "$(id -ru)" != "0" ] ; then
         $DIALOG --msgbox "Error: $0 requires root permissions. Exiting." 0 0
index ade8631..400aeef 100755 (executable)
@@ -6,6 +6,7 @@
 # License:       This file is licensed under the GPL v2.
 ################################################################################
 
+# shellcheck disable=SC1091
 . /etc/grml/script-functions
 
 check4root || exit 1
@@ -31,7 +32,7 @@ fi
 if [ -z "$NONINTERACTIVE" ] ; then
    NEW_HOSTNAME="$(dialog --stdout --title "${PN}" --extra-button --extra-label "Propose hostname" \
    --inputbox "Set hostname (/etc/hostname, /etc/hosts and /etc/postfix/main.cf will be adjusted)\
-\n\nTip: press 'Propose hostname' for another proposal" 14 70 $NEW_HOSTNAME)"
+\\n\\nTip: press 'Propose hostname' for another proposal" 14 70 "$NEW_HOSTNAME")"
   retval=$?
 else
   retval=0
@@ -55,7 +56,9 @@ case $retval in
   0)
      echo "$NEW_HOSTNAME" > /etc/hostname
      echo "$NEW_HOSTNAME" > /etc/mailname
+     # shellcheck disable=SC1117
      sed -ir "s/^\(127.0.0.1\s*\).*localhost.*/\1$NEW_HOSTNAME localhost/" /etc/hosts
+     # shellcheck disable=SC1117
      sed -ir "s/^\(::1\s*\).*ip6-localhost.*/\1ip6-localhost ip6-loopback $NEW_HOSTNAME/" /etc/hosts
 
      POSTFIX=''
@@ -66,7 +69,7 @@ Configuration of myhostname in /etc/postfix/main.cf has been adjusted as well. D
      fi
 
      if [ -n "$DISPLAY" ] ; then
-       if sudo -u $RUNASUSER xauth add $(xauth -n list | grep "${OLDHOSTNAME}/unix:0" | sed "s|${OLDHOSTNAME}/unix:0|${NEW_HOSTNAME}/unix:0|") ; then
+       if sudo -u $RUNASUSER xauth add "$(xauth -n list | grep "${OLDHOSTNAME}/unix:0" | sed "s|${OLDHOSTNAME}/unix:0|${NEW_HOSTNAME}/unix:0|")" ; then
          sudo -u $RUNASUSER xauth remove "${OLDHOSTNAME}/unix:0"
        fi
      fi
index b9e9a2f..6dad6c2 100755 (executable)
@@ -6,7 +6,9 @@
 # License:       This file is licensed under the GPL v2.
 ################################################################################
 
+# shellcheck disable=SC1091
 . /etc/grml/script-functions
+# shellcheck disable=SC1091
 . /etc/grml/lsb-functions
 check4progs iptstate || exit 1
 
@@ -18,8 +20,9 @@ else
    ewarn "Module ip_conntrack is not present. Can not start iptstate therefore."
    eindent
      einfon "Do you want to load it and invoke iptstate afterwards? [YES|no] "
-     read a
-     if [ "$a" = YES -o "$a" = yes -o "$a" = '' -o "$a" = y -o "$a" = Y ] ; then
+     read -r a
+     a=$(echo "$a" | tr '[:upper:]' '[:lower:]')
+     if [ "$a" = "yes" ] || [ "$a" = "y" ] || [ "$a" = "" ] ; then
         modprobe ip_conntrack ; RC=$?
        eend $RC
        [ "$RC" = 0 ] && exec iptstate
index 0ee4eab..ad2366c 100755 (executable)
@@ -6,10 +6,11 @@
 # License:       This file is licensed under the GPL v2.
 ################################################################################
 
-PN="$(basename $0)"
+PN="$(basename "$0")"
 DIALOG=dialog
 CMDLINE=/proc/cmdline
 
+# shellcheck disable=SC1091
 . /etc/grml/script-functions
 
 check4root || exit 1
@@ -17,10 +18,10 @@ check4root || exit 1
 setvalue(){
   [ -n "$2" ] || return 1
   # already present in conffile?
-  if grep -q ${1} $CONFFILE ; then
-     sed -i "s#^${1}.*#${1}=${2}#"   $CONFFILE
+  if grep -q "${1}" "$CONFFILE" ; then
+     sed -i "s#^${1}.*#${1}=${2}#" "$CONFFILE"
   else
-     echo "$1=${2}" >> $CONFFILE
+     echo "$1=${2}" >> "$CONFFILE"
   fi
 }
 
@@ -39,6 +40,7 @@ getbootparam(){
   return 0
 }
 
+# shellcheck disable=SC1091
 [ -r /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard
 
 [ -n "$KEYTABLE" ] && DEFAULT_KEYBOARD="$KEYTABLE"
@@ -49,6 +51,8 @@ if [ -z "$DEFAULT_KEYBOARD" ] ; then
   fi
 fi
 
+# shellcheck disable=SC1010
+{
 LANGUAGE=$(LANG=C $DIALOG --stdout --title "$PN" --default-item $DEFAULT_KEYBOARD --radiolist \
 "Which keyboard layout do you want to use?
 
@@ -85,6 +89,7 @@ Configuration will be written to /etc/sysconfig/keyboard" 0 0 0 \
  tw  "chinese (traditional)" off \
  uk  british off \
 )
+}
 
 retval=$?
 case $retval in
@@ -96,7 +101,8 @@ case $retval in
 esac
 
 # read in the file where all the $LANGUAGE stuff is defined
-  . /etc/grml/language-functions
+# shellcheck disable=SC1091
+. /etc/grml/language-functions
 
 cat > /etc/sysconfig/keyboard <<EOF
 # File generated by $PN on $(date)
index ae6a096..4a15d5c 100755 (executable)
@@ -6,9 +6,8 @@
 # License:       This file is licensed under the GPL v2.
 ################################################################################
 
-PN="$(basename $0)"
+PN="$(basename "$0")"
 DIALOG=dialog
-CMDLINE=/proc/cmdline
 LANGFUNC=/etc/grml/language-functions
 
 # notice: Debian's locales.postinst has been modified to write
@@ -17,8 +16,11 @@ LANGFUNC=/etc/grml/language-functions
 # so modifying it was a policy violation.
 CONFFILE=/etc/default/locale
 
+# shellcheck disable=SC1091
+{
 . /etc/grml/script-functions
 . /etc/grml/lsb-functions
+}
 
 check4root || exit 100
 
@@ -43,6 +45,7 @@ setvalue(){
      sed -i "s#^${1}.*#${1}${2}#"  $CONFFILE
   # is the new Debian style /etc/default/locale present?
   elif grep -q "^# ${1}$" "$CONFFILE" ; then
+     # shellcheck disable=SC1117
      sed -i "s#^\# ${1}#${1}${2}#" $CONFFILE
   else
      echo "$1${2}" >> $CONFFILE
@@ -61,8 +64,11 @@ You have to make sure the appropriate packages are installed." 0 0
    fi
 fi
 
+# shellcheck disable=SC1091
+{
 [ -r /etc/environment ]    && . /etc/environment
 [ -r /etc/default/locale ] && . /etc/default/locale
+}
 [ -n "$LANGUAGE" ] && DEFAULT_LANGUAGE="$LANGUAGE"
 
 if [ -z "$DEFAULT_LANGUAGE" ] ; then
@@ -70,6 +76,8 @@ if [ -z "$DEFAULT_LANGUAGE" ] ; then
 fi
 
 if [ -z "$NONINTERACTIVE" ] ; then
+# shellcheck disable=SC1010
+{
    LANGUAGE=$(LANG=C $DIALOG --stdout --title "$PN" --default-item $DEFAULT_LANGUAGE --radiolist \
 "Which language do you want to use?
 
@@ -148,6 +156,7 @@ Configuration will be written to $CONFFILE" 0 0 0 \
  us 'american (unicode version)' off \
  us-iso 'american (iso version)' off \
 )
+}
 
   retval=$?
   case $retval in
@@ -168,12 +177,13 @@ fi
 # fallback to C if using an ISO system (which is latin1 for LC_CTYPE);
 # this should prevent users from broken ctype settings if the set
 # locale isn't available on a remote system
-if echo $LANGUAGE | grep -q -- '-iso' ; then
+if echo "$LANGUAGE" | grep -q -- '-iso' ; then
    LC_CTYPE=C
 fi
 
 # read in the file where all the $LANGUAGE stuff is defined
-  . $LANGFUNC
+# shellcheck disable=SC1090
+. $LANGFUNC
 
 # make sure the file exists
 if ! [ -r $CONFFILE ] ; then
@@ -194,7 +204,7 @@ LANG=$LANG
 EOF
 fi
 
-setvalue 'LANG='     $LANG
+setvalue 'LANG='     "$LANG"
 
 retval=$?
 case $retval in
index 1d8e146..0ef7af4 100755 (executable)
@@ -6,13 +6,16 @@
 # License:       This file is licensed under the GPL v2.
 ################################################################################
 
-PN="$(basename $0)"
+PN="$(basename "$0")"
 TMP=$(mktemp)
 DIALOG=dialog
 CONFFILE='/etc/runlevel.conf'
 
+# shellcheck disable=SC1091
+{
 . /etc/grml/script-functions
 . /etc/grml/lsb-functions
+}
 
 check4root || exit 100
 
@@ -26,7 +29,7 @@ trap bailout HUP INT QUIT TERM
 is_value_set(){
  [ -n "$1" ] || return 2
  [ -r "$TMP" ] || return 3
- grep -q "$1" $TMP && return 0 || return 1
+ grep -q "$1" "$TMP" && return 0 || return 1
 }
 
 INFO="Which services would you like to have enabled on your system?
@@ -43,7 +46,7 @@ or choose cancel.
 [ -r /etc/init.d/lvm2 ]   && LVM='lvm!logical volume management!on'
 [ -r /etc/init.d/mdadm ]  && SRAID='mdadm!software-raid via mdadm!on'
 [ -r /etc/init.d/dmraid ] && MRAID='dmraid!software-raid via dmraid!off'
-[ -r /etc/init.d/dbus -o -r /etc/init.d/dbus-1 ] && DBUS='dbus!hal/dbus (important for KDE e.g.)!off'
+[ -r /etc/init.d/dbus ] || [ -r /etc/init.d/dbus-1 ] && DBUS='dbus!hal/dbus (important for KDE e.g.)!off'
 [ -r /etc/init.d/hal ]    && HAL='hal!Hardware Abstraction Layer daemon (important for KDE e.g.)!off'
 [ -r /etc/init.d/nfs-common ] && NFS='nfs!Network File System (client setup)!off'
 
@@ -123,7 +126,7 @@ set_values(){
 # the interface itself
 oifs="$IFS"
 IFS='!'
-$DIALOG --title "$PN" --checklist "$INFO" 30 65 8 $LVM $SRAID $MRAID $DBUS $HAL $NFS 2>$TMP
+$DIALOG --title "$PN" --checklist "$INFO" 30 65 8 "$LVM" "$SRAID" "$MRAID" "$DBUS" "$HAL" "$NFS" 2>"$TMP"
 
 retval="$?"
 case $retval in
@@ -144,7 +147,7 @@ case $retval in
           ;;
 esac
 
-rm -f $TMP
+rm -f "$TMP"
 IFS="$oifs"
 
 ## END OF FILE #################################################################
index 3482bdb..a4e119e 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Filename:      grml2ram
 # Purpose:       copy compressed GRML image to RAM
 # Authors:       (c) Michael Schierl <schierlm-public@gmx.de>, (c) Michael Prokop <mika@grml.org>
@@ -8,7 +8,9 @@
 
 set -e
 
+# shellcheck disable=SC1091
 . /etc/grml/lsb-functions
+# shellcheck disable=SC1091
 . /etc/grml/script-functions
 
 check4root || exit 1
@@ -50,7 +52,7 @@ getbootparam(){
 MEDIA_PATH="$(getbootparam live-media-path)"
 MEDIA_PATH="${MEDIA_PATH:-.}"
 
-IMAGE=$(find ${LIVECD_PATH}/${MEDIA_PATH}/ -name *.squashfs 2>/dev/null | head -1)
+IMAGE=$(find "${LIVECD_PATH}/${MEDIA_PATH}/" -name "*.squashfs" 2>/dev/null | head -1)
 if ! [ -r "$IMAGE" ] ; then
    if [ -r /cdrom/GRML/GRML ] ; then
       IMAGE='/cdrom/GRML/GRML'
@@ -68,7 +70,7 @@ case "$*" in -f|--force)
   ewarn "Forcing copy process for grml-image (${GRMLSIZE}kB) as requested via force option." ; eend 0
    ;;
   *)
-   if test $RAM -lt $GRMLSIZE ; then
+   if test "$RAM" -lt "$GRMLSIZE" ; then
       eerror "Sorry, not enough free RAM (${RAM}kB) available for grml-image (${GRMLSIZE}kB)." ; eend 1
       exit 1
    fi
@@ -96,7 +98,12 @@ fi
 [ -n "$GRMLDEV" ] || GRMLDEV='/dev/cdrom'
 
 einfo "Unmounting cdrom"
-[ -d $LIVECD_PATH ] && umount $LIVECD_PATH || umount /cdrom
+if [ -d $LIVECD_PATH ] ;
+then
+  umount $LIVECD_PATH
+else
+  umount /cdrom
+fi
 eend $?
 einfo "Now you can eject your grml-cd (e.g. run 'eject $GRMLDEV')." ; eend 0
 
index 972e331..e45e4be 100755 (executable)
@@ -7,6 +7,6 @@
 ################################################################################
 
 touch /etc/noeject
-exec $*
+exec "$@"
 
 ## END OF FILE #################################################################
index d73786e..ff8b573 100755 (executable)
@@ -7,6 +7,6 @@
 ################################################################################
 
 touch /etc/noprompt
-exec $*
+exec "$@"
 
 ## END OF FILE #################################################################
index cd55f65..4832feb 100755 (executable)
@@ -12,7 +12,7 @@ mkdir -m 700 "${SCREENDIR_}/S-$USER" >/dev/null 2>&1
 
 # now run screen with config
 
-  if [ `id -u` = 0 ] ; then
+  if [ "$(id -u)" = 0 ] ; then
     exec screen -U -c /etc/grml/screenrc
   elif [ -r "$HOME/.screenrc" ] ; then
     exec screen -U -c "$HOME/.screenrc"
index de46a1f..265301e 100755 (executable)
@@ -6,6 +6,7 @@
 # License:       This file is licensed under the GPL v2.
 ################################################################################
 
+# shellcheck disable=SC1091
 . /etc/grml/sh-lib
 
 [ -r /etc/grml_version ] && GRMLVERSION=$(cat /etc/grml_version) || GRMLVERSION='(no version information available)'
@@ -26,7 +27,7 @@ case "$CMDLINE" in
    # allow customized startup via bootoption startup:
    *startup=*)
        script="$(getBootParam startup)"
-       if [ -x $(which $script) ] ; then
+       if [ -x "$(command -v "$script")" ] ; then
           $script
        fi
        ;;
@@ -36,7 +37,7 @@ case "$CMDLINE" in
       ;;
    *) # by default run grml-quickconfig, but only if running as root
       if [ "$(id -u)" = "0" ] ; then
-         which grml-quickconfig &>/dev/null && grml-quickconfig
+         command -v grml-quickconfig &>/dev/null && grml-quickconfig
       fi
 esac