Remove mkdir /mnt/{floppy,cdrom,test} from grml-autoconfig
[grml-autoconfig.git] / autoconfig.functions
index 2f7e313..42c03bd 100755 (executable)
@@ -117,10 +117,6 @@ mount_sys(){
 # {{{ Check if we are running in live mode or from HD
 INSTALLED=""
 [ -e /etc/grml_cd ] || INSTALLED="yes"
-
-# testcd
-TESTCD=""
-checkbootparam 'testcd' >>$DEBUG 2>&1 && TESTCD="yes"
 # }}}
 
 # {{{ source lsb-functions , color handling
@@ -399,6 +395,23 @@ config_userfstab(){
 }
 # }}}
 
+# {{{ mount configfs
+config_configfs() {
+  einfo "Mounting configfs"
+  CONFIGFS_DIR=/sys/kernel/config/
+  modprobe configfs 2>/dev/null 1>&2
+  if ! [  -d "$CONFIGFS_DIR" ] ; then
+    eindent
+    einfo "$CONFIGFS_DIR does not exist, can't mount directory"
+    eend 1
+    eoutdent
+  else
+    mount -t configfs configfs "$CONFIGFS_DIR" 2>/dev/null 1>&2
+    eend $?
+  fi
+}
+# }}}
+
 # {{{ Set clock (Local time is more often used than GMT, so it is default)
 config_time(){
  # don't touch the files if running from harddisk:
@@ -624,18 +637,30 @@ config_fix_passwd(){
 
 # {{{ CD Checker
 config_testcd(){
-if [ -n "$TESTCD" ]; then
+if checkbootparam 'testcd' ; then
    einfo "Checking CD data integrity as requested by '${WHITE}testcd${NORMAL}' boot option."
-   einfo "Reading files and checking against GRML/md5sums, this may take a while..."
-   echo -n "${RED}"
 
-   if [ -n "${LIVECD_PATH}"/GRML ] ; then
-      ( cd "${LIVECD_PATH}"/GRML ; rm -f /tmp/md5sum.log ; md5sum -c md5sums 2>&1 | tee /tmp/md5sum.log ; RC=$? )
-   else
+   ERROR=0
+   FOUND_FILE=0
+
+   rm -f /tmp/md5sum.log
+   for md5 in $(find "${LIVECD_PATH}" -name md5sums) ; do
+      einfo "Checking files against $md5, this may take a while..."
+
+      FOUND_FILE=1
+      ( cd $(dirname "$md5") && md5sum -c $(basename "$md5") ; RC=$?)  |& tee -a /tmp/md5sum.log
+
+      if [ $RC -ne 0 ] ; then
+         ERROR=1
+      fi
+   done
+
+   if [ $FOUND_FILE -eq 0 ] ; then
       echo "${RED} *** Error: Could not find md5sum file.                           ***"
+      return
    fi
 
-   if [ "$RC" = "0" ]; then
+   if [ "$ERROR" -eq 0 ]; then
       einfo "Everything looks OK" ; eend 0
    else
       eerror 'Checksum failed for theses files:' ; eend 1
@@ -737,6 +762,14 @@ EOT
 check_partitions >/dev/null 2>&1 # avoid output "check_partitions:3: read-only file system"
 # }}}
 
+# {{{ Start brltty
+config_brltty() {
+  if checkbootparam 'brltty' ; then
+    [ -x /lib/brltty/brltty.sh ] && /lib/brltty/brltty.sh
+  fi
+}
+# }}}
+
 # {{{ 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(){
@@ -960,14 +993,18 @@ if [ -x /etc/init.d/loadcpufreq ] ; then
    rm -f $LOADCPUFREQ
 
    if [ -z "$SKIP_CPU_GOVERNOR" ] ; then
-      einfo "Loading cpufreq_ondemand, setting ondemand governor"
-      RC=0
-      if modprobe cpufreq_ondemand ; RC=$? ; then
-         for file in $(find /sys/devices/system/cpu/ -name scaling_governor 2>/dev/null) ; do
-            echo ondemand > $file
-         done
-      fi
-      eend $RC
+     if grep -vq ondemand /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors; then
+       einfo "Loading cpufreq_ondemand"
+       modprobe cpufreq_ondemand
+       eend $?
+     fi
+
+     einfo "Setting ondemand governor"
+     RC=0
+     for file in $(find /sys/devices/system/cpu/ -name scaling_governor 2>/dev/null) ; do
+       echo ondemand > $file || RC=1
+     done
+     eend $RC
    fi # cpu-governor
 
    eoutdent
@@ -1145,22 +1182,36 @@ config_mixer () {
 
             if checkbootparam 'micvol' ; then
                MICVOL="$(getbootparam 'micvol' 2>>$DEBUG)"
+               einfo "Setting microphone to ${WHITE}${MICVOL}${NORMAL}."
             else
                MICVOL=0
             fi
 
-            for CONTROL in Master PCM ; do
-               if amixer -q | grep -q "Simple mixer control '$CONTROL'" ; then
-                  amixer -q set "${CONTROL}" "${VOL}"%
+            CONTROLS=$(amixer -c $card scontrols | awk -F"Simple mixer control " '{print $2}')
+            IFSOLD=${IFS:-}
+            IFS='
+'
+            for CONTROL in ${=CONTROLS} ; do
+               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
+                   fi
+                   if amixer -c $card sget "${CONTROL}" | grep -q -P 'Capabilities:.*(pvolume| volume)' ; then
+                      amixer -c $card -q set "${CONTROL}" "${VOL}"%
+                   fi
+               fi
+
+               if [ ${MICVOL} -ne 0 ] ; then
+                  if amixer -c $card sget "${CONTROL}" | grep -q 'Capabilities:.*cswitch' ; then
+                     amixer -c $card -q set "${CONTROL}" unmute
+                  fi
+                  if amixer -c $card sget "${CONTROL}" | grep -q 'Capabilities:.*cvolume' ; then
+                     amixer -c $card -q set "${CONTROL}" $MICVOL%
+                  fi
                   eend $?
                fi
             done
-
-            if [ ${MICVOL} -ne 0 ] ; then
-               einfo "Setting microphone to ${WHITE}${MICVOL}${NORMAL}."
-               amixer -q set "Mic" $MICVOL &> /dev/null
-               eend $?
-            fi
+            IFS=$IFSOLD
          fi # checkbootparam 'nosound'
          eoutdent
       done
@@ -1347,16 +1398,16 @@ config_stats() {
    [ -e /etc/grml_version ] && VERSION=$(cat /etc/grml_version) || \
      VERSION=$(lsb_release -d | awk -F: '{gsub(/^[ \t]+/, "", $2); print $2}')
 
-   PARAMS="$( echo "$CMDLINE" | sed -e 's/=[^ ]*/=VALUE/g' | tr " " "\n"|sort|tr "\n" " " )"
+   PARAMS="$( echo "$CMDLINE" | sed -e 's/=[^ ]*/=x/g' | tr " " "\n"|sort|tr "\n" " " )"
 
-   echo "$CMDLINE" | grep -q -e "fetch|nfsroot" && BOOT="remote"
+   echo "$CMDLINE" | grep -q -e "fetch" -e "nfsroot" && BOOT="remote"
    [ -z "$BOOT" ] && BOOT="local"
 
    ADDITIONAL_PARAMS=""
    ( [ -n "$COLUMNS" ] && [ -n "$LINES" ] ) && \
      ADDITIONAL_PARAMS="$ADDITIONAL_PARAMS&res=$((COLUMNS * 8))x$((LINES * 16))"
 
-   URI='$BASE_URL?action=${ACTION_NAME}\&$DATE_STRING\&unique_id=${HOST_ID}\&support_64bit=$HAS_64BIT\&version=$version\&bootup=$BOOT\&params=$PARAMS$ADDITIONAL_PARAMS'
+   URI='$BASE_URL?action=${ACTION_NAME}\&$DATE_STRING\&unique_id=${HOST_ID}\&support_64bit=$HAS_64BIT\&version=$VERSION\&bootup=$BOOT\&params=$PARAMS$ADDITIONAL_PARAMS'
 
    get_remote_file "$URI" "/dev/null"  >/dev/null 2>&1 &!
  fi
@@ -1379,8 +1430,7 @@ if checkbootparam 'startx' && ! echo "$CMDLINE" | grep -q 'startx.*nostartx' ; t
   if [ -z "$INSTALLED" ] ; then
    WINDOWMANAGER="$(getbootparam 'startx' 2>>$DEBUG)"
    if [ -z "$WINDOWMANAGER" ] ; then
-     einfo "No window manager specified. Taking ${WHITE}wm-ng${NORMAL} as default." && eend 0
-     WINDOWMANAGER="wm-ng"
+     einfo "No window manager specified. Using default one." && eend 0
    else
      einfo "Window manager ${WHITE}${WINDOWMANAGER}${NORMAL} found as bootoption." && eend 0
    fi
@@ -1388,7 +1438,7 @@ if checkbootparam 'startx' && ! echo "$CMDLINE" | grep -q 'startx.*nostartx' ; t
    config_userfstab || fstabuser='grml'
  cat>|/etc/init.d/xstartup<<EOF
 #!/bin/sh
-su $fstabuser -c "/usr/bin/grml-x $WINDOWMANAGER"
+su $fstabuser -c "/usr/bin/grml-x"
 EOF
    chmod 755 /etc/init.d/xstartup