Support getfile.retries=... boot option
[grml-autoconfig.git] / autoconfig.functions
index 5580812..3ab2c02 100755 (executable)
@@ -821,26 +821,6 @@ fi
 }
 # }}}
 
-# {{{ Collect partitions from /proc/partitions first for enabling DMA
-check_partitions(){
-partitions=""
-IDEDISKS=""
-while read major minor blocks partition relax; do
-  partition="${partition##*/}"
-  [ -z "$partition" -o ! -e "/dev/$partition" ] && continue
-  case "$partition" in
-    hd?) IDEDISKS="$IDEDISKS $partition";;                # IDE  Harddisk, entire disk
-    sd?) ;;                                               # SCSI Harddisk, entire disk
-#    [hs]d*) partitions="$partitions /dev/$partition";;    # IDE or SCSI disk partition
-    [hs]d*|ub*) partitions="$partitions /dev/$partition";;    # IDE, USB or SCSI disk partition
-  esac
-done <<EOT
-$(awk 'BEGIN{old="__start"}{if($0==old){exit}else{old=$0;if($4&&$4!="name"){print $0}}}' /proc/partitions)
-EOT
-}
-check_partitions >/dev/null 2>&1 # avoid output "check_partitions:3: read-only file system"
-# }}}
-
 # {{{ Start brltty
 config_brltty() {
   if checkbootparam 'brltty' ; then
@@ -849,27 +829,6 @@ config_brltty() {
 }
 # }}}
 
-# {{{ Enable DMA for all IDE drives now if not disabled
-# Notice: Already done by linuxrc, but make sure it's done also on harddisk-installed systems
-config_dma(){
-if checkbootparam 'nodma'; then
-  ewarn "Skipping DMA accelleration as requested on boot commandline." ; eend 0
-else
-  for d in $(cd /proc/ide 2>>$DEBUG && echo hd[a-z]); do
-    if test -d /proc/ide/$d; then
-      if egrep -q 'using_dma[ \t]+0' /proc/ide/$d/settings 2>>$DEBUG; then
-        MODEL="$(cat /proc/ide/$d/model 2>>$DEBUG)"
-        test -z "$MODEL" && MODEL="[GENERIC IDE DEVICE]"
-        einfo "Enabling DMA acceleration for: ${WHITE}$d        ${YELLOW}[${MODEL}]${NORMAL}"
-        echo "using_dma:1" >/proc/ide/$d/settings
-        eend 0
-      fi
-    fi
-  done
-fi
-}
-# }}}
-
 # {{{ Start creating /etc/fstab with HD partitions and USB SCSI devices now
 config_fstab(){
 
@@ -1466,7 +1425,13 @@ get_remote_file() {
        --read-timeout=10 ${SOURCE} -O ${TARGET} && return 0 || return 1
   }
   einfo "Trying to get ${WHITE}${TARGET}${NORMAL}"
-  counter=10
+
+  if checkbootparam 'getfile.retries' ; then
+    local counter="$(getbootparam 'getfile.retries' 2>>$DEBUG)"
+  else
+    local counter=10
+  fi
+
   while ! getconfig && [[ "$counter" != 0 ]] ; do
     echo -n "Sleeping for 1 second and trying to get config again... "
     counter=$(( counter-1 ))
@@ -1621,7 +1586,7 @@ DCSMP="/mnt/grml"
 # autoconfig, see issue673
 GRMLCFG="$(getbootparam 'autoconfig' 2>>$DEBUG)"
 [ -n "$GRMLCFG" ] || GRMLCFG="GRMLCFG"
-if checkbootparam 'noautoconfig' || checkbootparam 'forensic' ; then
+if checkbootparam 'noautoconfig' ; then
   DCSDIR="${LIVECD_PATH}" # 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
@@ -1737,11 +1702,6 @@ if checkbootparam 'scripts' || [ "$DCSMP" = "/mnt/grmlcfg" ]; then
      # backwards compatibility: if no path is given get scripts from scripts/
      SCRIPTS="scripts/$SCRIPTS"
    fi
-   if [ "$DCSMP" = "/mnt/grmlcfg" ]; then
-     # we are executing from a GRMLCFG labeled fs
-     # kick everything we have done before and start over
-     SCRIPTS="$(cd ${DCSDIR}; /bin/ls -1d [Gg][Rr][Mm][Ll].[Ss][Hh] 2>>$DEBUG)"
-   fi
    if [ -n "$SCRIPTS" ]; then
      SCRIPTS="${DCSDIR}/$SCRIPTS"
      if [ "$DCSMP" = "/mnt/grmlcfg" ]; then
@@ -1923,9 +1883,8 @@ fi
 config_swraid(){
   [ -n "$INSTALLED" ] && return 0
 
-  # notice: checkbootparam "forensic" is just for users who don't know how to really use the bootoption
   if checkbootparam 'noraid'   || checkbootparam 'noswraid' || \
-     checkbootparam 'forensic' || checkbootparam 'raid=noautodetect' ; then
+     checkbootparam 'raid=noautodetect' ; then
      ewarn "Skipping SW-RAID code as requested on boot commandline." ; eend 0
   else
     [ -e /proc/mdstat ] || modprobe md_mod
@@ -2237,6 +2196,7 @@ fi # checkbootparam "BOOT_IMAGE=debian2hd
 }
 # }}}
 
+# {{{ virtualbox shared folders
 config_virtualbox_shared_folders() {
 if $VIRTUALBOX ; then
   einfo "VirtualBox detected, trying to set up Shared Folders."
@@ -2268,39 +2228,65 @@ if $VIRTUALBOX ; then
       VBoxService >/dev/null
       eend $?
 
-      local vbox_automation='/media/sf_automation'
+      local vbautomation='automation'
       if checkbootparam 'vbautomation'; then
-        vbox_automation="$(getbootparam 'vbautomation' 2>>$DEBUG)"
+        vbautomation="$(getbootparam 'vbautomation' 2>>$DEBUG)"
       fi
 
-      local distri="$(getbootparam 'distri' 2>>$DEBUG)"
-      [ -n "$distri" ] || distri='grml'
-
-      if [ -d "${vbox_automation}" ] ; then
-        einfo "Found shared folders automation directory $vbox_automation"
+      if ! VBoxControl sharedfolder list | egrep -q "^[0-9]+ - ${vbautomation}$" ; then
+        ewarn "No automount shared folder '$vbautomation' available"
+        eend 0
+      else
+        einfo "Found automount shared folder '$vbautomation'"
         eend 0
 
+        local distri="$(getbootparam 'distri' 2>>$DEBUG)"
+        [ -n "$distri" ] || distri='grml'
+
+        local vbox_auto_sf="/media/sf_${vbautomation}"
+
+        sleep 1 # ugly but necessary
+
+        counter=10
         eindent
-        if checkbootparam 'novbautomation' ; then
-          einfo "Bootoption novbautomation found. Disabling automation script execution."
+        while ! [ -d "${vbox_auto_sf}" ] && [[ "$counter" != 0 ]]; do
+          einfo "Waiting another second to retry access to ${vbox_auto_sf}"
+          sleep 1
+          counter=$(( counter-1 ))
           eend 0
+        done
+        eoutdent
+
+        if ! [ -d "${vbox_auto_sf}" ] ; then
+          eerror "Giving up trying to access folder ${vbox_auto_sf} which doesn't seem to exist"
+          eend 1
         else
-          if ! [ -x "${vbox_automation}/${distri}" ] ; then
-            ewarn "Couldn't find an automation script named ${vbox_automation}/${distri}"
-            eend 1
+          einfo "Found shared folders automation directory $vbox_auto_sf"
+          eend 0
+
+          eindent
+          if checkbootparam 'novbautomation' ; then
+            einfo "Bootoption novbautomation found. Disabling automation script execution."
+            eend 0
           else
-            einfo "Executing '${vbox_automation}/${distri}' now:"
-            "${vbox_automation}/${distri}"
-            eend $?
+            if ! [ -x "${vbox_auto_sf}/${distri}" ] ; then
+              ewarn "Couldn't find an automation script named ${vbox_auto_sf}/${distri}"
+              eend 1
+            else
+              einfo "Executing '${vbox_auto_sf}/${distri}' now:"
+              "${vbox_auto_sf}/${distri}"
+              eend $?
+            fi
           fi
+          eoutdent
         fi
-        eoutdent
       fi
 
     eoutdent
   fi
 fi
 }
+# }}}
 
 # {{{ Support customization
 config_distri(){