Run wrap-and-sort -a on debian directory
[grml-autoconfig.git] / autoconfig.functions
index 22abae3..577e3b0 100755 (executable)
@@ -1317,6 +1317,9 @@ config_mixer () {
             IFS='
 '
             for CONTROL in ${=CONTROLS} ; do
+               # such devices can not be controlled with amixer ... unmute
+               [[ "$CONTROL" == *Console* ]] && continue
+
                if ! echo "${CONTROL}" | grep -q -i "mic" ; then
                    if amixer -c $card sget "${CONTROL}" | grep -q 'Capabilities:.*pswitch' ; then
                       amixer -c $card -q set "${CONTROL}" unmute
@@ -1718,7 +1721,7 @@ if checkbootparam 'debs' ; then
      # backwards compatibility: if no path is given get debs from debs/
      DEBS="debs/$DEBS"
    fi
-   einfo "Tring to install debian package(s) ${DEBS}"
+   einfo "Trying to install Debian package(s) ${DEBS}"
    DEBS="$(eval echo ${DCSDIR}/$DEBS)"
    dpkg -i $DEBS ; eend $?
 fi
@@ -1734,22 +1737,20 @@ 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
        einfo "Trying to execute ${SCRIPTS}"
        sh -c $SCRIPTS
+       eend $?
      elif [ -d "$SCRIPTS" ]; then
        einfo "Bootparameter scripts found. Trying to execute from directory ${SCRIPTS}:"
        run-parts --regex '.*' $SCRIPTS
+       eend $?
      else
        einfo "Bootparameter scripts found. Trying to execute ${SCRIPTS}:"
        sh -c $SCRIPTS
+       eend $?
      fi
    fi
 fi
@@ -2259,9 +2260,63 @@ if $VIRTUALBOX ; then
       eend $?
 
       einfo "Starting VBoxService."
-      VBoxService >/dev/null &
+      VBoxService >/dev/null
       eend $?
 
+      local vbautomation='automation'
+      if checkbootparam 'vbautomation'; then
+        vbautomation="$(getbootparam 'vbautomation' 2>>$DEBUG)"
+      fi
+
+      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
+        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
+          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
+            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
+      fi
+
     eoutdent
   fi
 fi