Default DCSDIR to /live/image also in noautoconfig/forensic mode
[grml-autoconfig.git] / autoconfig.functions
index 2a3dd66..19e7459 100755 (executable)
@@ -690,40 +690,44 @@ config_fix_passwd(){
 # {{{ CD Checker
 config_testcd(){
 if checkbootparam 'testcd' ; then
-   einfo "Checking CD data integrity as requested by '${WHITE}testcd${NORMAL}' boot option."
+  einfo "Checking CD data integrity as requested by '${WHITE}testcd${NORMAL}' boot option."
+  eindent
 
-   ERROR=0
-   FOUND_FILE=0
+  local ERROR=true
+  local FOUND_FILE=false
+  local logfile='/tmp/md5sum.log'
 
-   rm -f /tmp/md5sum.log
-   for md5 in $(find "${LIVECD_PATH}" -name md5sums) ; do
-      einfo "Checking files against $md5, this may take a while..."
+  rm -f "$logfile"
 
-      FOUND_FILE=1
-      ( cd $(dirname "$md5") && md5sum -c $(basename "$md5") ; RC=$?)  |& tee -a /tmp/md5sum.log
+  for md5 in $(find "${LIVECD_PATH}" -name md5sums) ; do
+    einfo "Checking files against $md5, this may take a while..."
 
-      if [ $RC -ne 0 ] ; then
-         ERROR=1
-      fi
-   done
+    FOUND_FILE=true
+    OLD_PWD=$(pwd)
+    cd $(dirname "$md5")
+    md5sum -c $(basename "$md5") |& tee -a "${logfile}"
+    if [ $pipestatus[1] -eq 0 ] ; then
+      ERROR=false
+    fi
+    cd "${OLD_PWD}"
+  done
 
-   if [ $FOUND_FILE -eq 0 ] ; then
-      echo "${RED} *** Error: Could not find md5sum file.                           ***"
-      return
-   fi
+  if ! $FOUND_FILE ; then
+    eerror 'Error: Could not find md5sum file' ; eend 1
+    return
+  fi
 
-   if [ "$ERROR" -eq 0 ]; then
-      einfo "Everything looks OK" ; eend 0
-   else
-      eerror 'Checksum failed for theses files:' ; eend 1
-      egrep -v '(^md5sum:|OK$)' /tmp/md5sum.log
-      eerror 'Data on the grml medium is possibly incomplete/damaged or...'
-      eerror '... RAM of your computer is broken.' ; eend 1
-      einfon "Hit return to continue, or press the reset button to quit."
-     read a
-   fi
+  if ! $ERROR ; then
+    einfo "Everything looks OK" ; eend 0
+  else
+    eerror 'Checksum failed for theses files:' ; eend 1
+    egrep -v '(^md5sum:|OK$)' "${logfile}"
+    eerror 'Data on the medium is possibly incomplete/damaged or RAM of your system is broken.' ; eend 1
+    einfon "Hit return to continue, or press the power button to shut down system."
+    read a
+  fi
 
-   eend 0
+  eoutdent
 fi
 }
 # }}}
@@ -1117,6 +1121,22 @@ if checkbootparam 'ssh' ; then
    eoutdent
 fi
 }
+
+# }}}
+
+# {{{ display hostkeys of SSH server
+config_display_ssh_fingerprints() {
+  if ! find /etc/ssh/ -name ssh_host_\*_key >/dev/null 2>&1 ; then
+    return 0 # no SSH host keys present
+  fi
+
+  einfo "SSH key fingerprints:"
+  for file in /etc/ssh/ssh_host_*_key ; do
+    einfon
+    ssh-keygen -l -f $file
+  done | column -t
+  eend $?
+}
 # }}}
 
 # {{{ autostart of x11vnc
@@ -1469,6 +1489,7 @@ config_stats() {
  fi
 }
 # }}}
+
 # {{{ fix/workaround for unionfs
 fix_unionfs(){
   if [ -z "$INSTALLED" ]; then
@@ -1549,6 +1570,7 @@ DCSMP="/mnt/grml"
 GRMLCFG="$(getbootparam 'autoconfig' 2>>$DEBUG)"
 [ -n "$GRMLCFG" ] || GRMLCFG="GRMLCFG"
 if checkbootparam 'noautoconfig' || checkbootparam 'forensic' ; then
+  DCSDIR="/live/image" # set default so it works for "scripts" boot option as expected
   ewarn "Skipping running automount of device(s) labeled $GRMLCFG as requested." ; eend 0
 else
   if [ -z "$INSTALLED" ] ; then
@@ -1682,7 +1704,7 @@ if checkbootparam 'scripts' || [ "$DCSMP" = "/mnt/grmlcfg" ]; then
        sh -c $SCRIPTS
      elif [ -d "$SCRIPTS" ]; then
        einfo "Bootparameter scripts found. Trying to execute from directory ${SCRIPTS}:"
-       run-parts $SCRIPTS
+       run-parts --regex '.*' $SCRIPTS
      else
        einfo "Bootparameter scripts found. Trying to execute ${SCRIPTS}:"
        sh -c $SCRIPTS