X-Git-Url: https://git.grml.org/?p=grml-autoconfig.git;a=blobdiff_plain;f=autoconfig.functions;h=a5a550797de75243d280bc2984a6096bf70c909b;hp=081aaca840226324ff70db673767a4bc3aab915f;hb=85222473ccf5fe78cbacdda208c48a07ec735e98;hpb=a18ac56c34c92e182116c7811eb90edce9f3ccc1 diff --git a/autoconfig.functions b/autoconfig.functions index 081aaca..a5a5507 100755 --- a/autoconfig.functions +++ b/autoconfig.functions @@ -7,7 +7,7 @@ ################################################################################ # {{{ path, variables, signals, umask, zsh -export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin" +export PATH="/bin:/sbin:/usr/bin:/usr/sbin" DEBUG="/dev/null" KERNEL="$(uname -r)" ARCH="$(uname -m)" @@ -193,7 +193,7 @@ config_fwtimeout(){ fi if [ -f /sys/class/firmware/timeout ] ; then einfo "Setting timeout for firmware loading to ${TIMEOUT}." - echo 100 > /sys/class/firmware/timeout ; eend $? + echo $TIMEOUT > /sys/class/firmware/timeout ; eend $? fi } # }}} @@ -399,6 +399,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: @@ -613,18 +630,6 @@ fi } # }}} -# {{{ Bring up loopback interface now -config_local_net(){ - if [ -z "$INSTALLED" ] ; then - if grep -q 'iface lo inet loopback' /etc/network/interfaces 2>/dev/null ; then - grep -q lo=lo /etc/network/run/ifstate 2>/dev/null || ifup lo - else - ifconfig lo up - fi - fi -} -# }}} - # {{{ copy passwd-lockfile to ramdisk (fix unionfs-behaviour) # otherwise we will get: passwd: Authentication token lock busy config_fix_passwd(){ @@ -928,12 +933,12 @@ if checkbootparam 'nocpu'; then fi if [[ $(grep -c processor /proc/cpuinfo) -gt 1 ]] ; then - einfo "Detecting CPU:" + einfo "Found CPU:" CPU=$(awk -F: '/^processor/{printf " Processor"$2" is"};/^model name/{printf $2};/^vendor_id/{printf vendor};/^cpu MHz/{printf " %dMHz",int($2)};/^cache size/{printf ","$2" Cache"};/^$/{print ""}' /proc/cpuinfo 2>>$DEBUG) echo $CPU | sed 's/ \{1,\}/ /g' eend 0 else - einfo "Detecting CPU: `awk -F: '/^processor/{printf " Processor"$2" is"};/^model name/{printf $2};/^vendor_id/{printf vendor};/^cpu MHz/{printf " %dMHz",int($2)};/^cache size/{printf ","$2" Cache"};/^$/{print ""}' /proc/cpuinfo 2>>$DEBUG` " ; eend 0 + einfo "Found CPU: `awk -F: '/^processor/{printf " Processor"$2" is"};/^model name/{printf $2};/^vendor_id/{printf vendor};/^cpu MHz/{printf " %dMHz",int($2)};/^cache size/{printf ","$2" Cache"};/^$/{print ""}' /proc/cpuinfo 2>>$DEBUG` " ; eend 0 fi # no cpufreq setup inside VirtualBox @@ -964,6 +969,7 @@ if [ -x /etc/init.d/loadcpufreq ] ; then if [ -n "$MODULE" -a "$MODULE" != none ]; then einfo "Loading cpufreq kernel module $MODULE" ; eend 0 else + SKIP_CPU_GOVERNOR=1 ewarn "Could not find an appropriate kernel module for cpu frequency scaling." ; eend 1 fi fi @@ -971,14 +977,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 @@ -1156,22 +1166,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 @@ -1345,6 +1369,34 @@ config_netscript() { } # }}} +# {{{ stats +config_stats() { + if ! checkbootparam 'nostats' ; then + BASE_URL="http://stats.grml.org/report/" + ACTION_NAME=Boot + + HOST_ID=$(cat /proc/sys/kernel/random/boot_id) + + grep -q " lm " /proc/cpuinfo && HAS_64BIT="1" || HAS_64BIT="0" + DATE_STRING=$(date +'h=%H&m=%M&s=%S') + [ -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/=[^ ]*/=x/g' | tr " " "\n"|sort|tr "\n" " " )" + + 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\¶ms=$PARAMS$ADDITIONAL_PARAMS' + + get_remote_file "$URI" "/dev/null" >/dev/null 2>&1 &! + fi +} +# }}} # {{{ fix/workaround for unionfs fix_unionfs(){ if [ -z "$INSTALLED" ]; then @@ -1362,8 +1414,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 @@ -1371,7 +1422,7 @@ if checkbootparam 'startx' && ! echo "$CMDLINE" | grep -q 'startx.*nostartx' ; t config_userfstab || fstabuser='grml' cat>|/etc/init.d/xstartup< Please use something like xdm, gdm or kdm for starting X on a harddisk system!" ; eend 1 fi else - eerror "/usr/X11R6/bin/X is not present on this grml flavour." + eerror "/usr/bin/X is not present on this grml flavour." eerror " -> Boot parameter startx does not work therefore." ; eend 1 fi fi