2 # Filename: autoconfig.functions
3 # Purpose: basic system configuration and hardware setup for grml system
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 ################################################################################
9 # {{{ path, variables, signals, umask, zsh
10 export PATH="/bin:/sbin:/usr/bin:/usr/sbin"
16 # old linuxrc version:
17 [ -d /cdrom ] && export LIVECD_PATH=/cdrom
18 # initramfs layout until around December 2012:
19 [ -d /live/image ] && export LIVECD_PATH=/live/image
20 # initramfs layout since around December 2012:
21 [ -d /lib/live/mount/medium ] && export LIVECD_PATH=/lib/live/mount/medium
23 # Ignore these signals in non-interactive mode: INT, TERM, SEGV
24 [ -z "$PS1" ] && trap "" 2 3 11
28 if [ -n "$ZSH_VERSION" ] ; then
34 # avoid 'no matches found: ...'
35 iszsh && setopt no_nomatch # || echo "Warning: not running under zsh!"
38 # {{{ Read in boot parameters
39 if [ -z "$CMDLINE" ]; then
40 # if CMDLINE was set from the outside, we're debugging.
41 # otherwise, take CMDLINE from Kernel and config files.
42 CMDLINE="$(cat /proc/cmdline)"
43 [ -d ${LIVECD_PATH}/bootparams/ ] && CMDLINE="$CMDLINE $(cat ${LIVECD_PATH}/bootparams/* | tr '\n' ' ')"
44 modprobe 9p 2>/dev/null || true
45 if grep -q 9p /proc/filesystems ; then
47 if grep -q "$TAG" /sys/bus/virtio/devices/*/mount_tag 2>/dev/null ; then
48 MOUNTDIR="$(mktemp -d)"
49 mount -t 9p -o trans=virtio,ro "$TAG" "$MOUNTDIR"
50 CMDLINE="$CMDLINE $(cat "$MOUNTDIR"/* 2>/dev/null | tr '\n' ' ')"
58 ### {{{ Utility Functions
60 # Get a bootoption's parameter: read boot command line and either
61 # echo last parameter's argument or return false.
69 result="${line##*[$ws]$1=}"
70 result="${result%%[$ws]*}"
78 # Check boot commandline for specified option
80 [ -n "$1" ] || ( echo "Error: missing argument to checkbootparam()" ; return 1 )
86 *[${ws}]"$1"=*|*[${ws}]"$1"[${ws}]*)
93 # Check if currently using a framebuffer
95 [ -e /dev/fb0 ] && return 0 || return 1
98 # Check wheter a configuration variable (like $CONFIG_TOHD) is
102 [yY][eE][sS]) return 0 ;; # it's set to 'yes'
103 [tT][rR][uU][eE]) return 0 ;; # it's set to 'true'
104 *) return 1 ;; # default
108 # Are we using grml-small?
110 grep -q small /etc/grml_version 2>>$DEBUG && return 0 || return 1
115 # {{{ filesystems (proc, pts, sys) and fixes
117 [ -f /proc/version ] || mount -t proc /proc /proc 2>/dev/null
121 grep -q "/dev/pts" /proc/mounts || mount -t devpts /dev/pts /dev/pts 2>/dev/null
125 [ -d /sys/devices ] || mount -t sysfs /sys /sys 2>/dev/null
129 # {{{ Check if we are running in live mode or from HD
131 [ -e /etc/grml_cd ] || INSTALLED="yes"
134 # {{{ provide information about virtual environments
135 VIRTUAL=false # assume physical system by default
140 if vmware-detect &>/dev/null; then
141 VIRTUAL=true; VMWARE=true; VIRTUAL_ENV='VMware'
142 elif [ "$(virt-what 2>/dev/null)" = "kvm" ] || \
143 [ "$(imvirt 2>/dev/null)" = "KVM" ] ; then
144 VIRTUAL=true; KVM=true; VIRTUAL_ENV='KVM'
145 elif [ "$(virt-what 2>/dev/null)" = "virtualbox" ] || \
146 [ "$(imvirt 2>/dev/null)" = "VirtualBox" ] ; then
147 VIRTUAL=true; VIRTUALBOX=true; VIRTUAL_ENV='VirtualBox'
151 # {{{ source lsb-functions , color handling
152 if checkbootparam 'nocolor'; then
154 . /etc/grml/lsb-functions
155 einfo "Disabling colors in bootsequence as requested on commandline." ; eend 0
157 . /etc/grml/lsb-functions
164 checkbootparam 'debug' && BOOTDEBUG="yes"
165 checkbootparam "BOOT_IMAGE=debug" && BOOTDEBUG="yes"
168 if [ -n "$BOOTDEBUG" ]; then
169 einfo "Starting intermediate shell stage $stage as requested by \"debug\" option."
170 if [ grep -q "debug=noscreen" "$CMDLINE" ] ; then
171 einfo "Notice that the shell does not provide job handling: ctrl-z, bg and fg won't work!"
172 einfo "Just exit the shell to continue boot process..."
176 if [ -r /etc/grml/screenrc ] ; then
177 einfo "Starting GNU screen to be able to use a full featured shell environment."
178 einfo "Just exit the shells (and therefore screen) to continue boot process..."
179 /bin/zsh -c "screen -c /etc/grml/screenrc"
181 einfo "Notice that the shell does not provide job handling: ctrl-z, bg and fg won't work!"
182 einfo "Just exit the shell to continue boot process..."
194 if checkbootparam 'log' || checkbootparam 'debug' ; then
195 export DEBUG="/tmp/grml.log.`date +%Y%m%d`"
197 einfo "Bootparameter log found. Log files: ${DEBUG} and /var/log/boot"
199 einfo "Starting bootlogd." # known to be *very* unreliable :(
200 bootlogd -r -c >>$DEBUG 2>&1 ; eend $?
208 # {{{ set firmware timeout via bootparam
210 if checkbootparam 'fwtimeout' ; then
211 TIMEOUT="$(getbootparam 'fwtimeout' 2>>$DEBUG)"
212 einfo "Bootoption fwtimeout found. (Re)Loading firmware_class module."
213 rmmod firmware_class >>$DEBUG 2>&1
214 modprobe firmware_class ; eend $?
216 if [ -z "$TIMEOUT" ] ; then
217 TIMEOUT="100" # linux kernel default: 10
219 if [ -f /sys/class/firmware/timeout ] ; then
220 einfo "Setting timeout for firmware loading to ${TIMEOUT}."
221 echo $TIMEOUT > /sys/class/firmware/timeout ; eend $?
226 ### {{{ language configuration / localization
229 einfo "Activating language settings:"
232 # people can specify $LANGUAGE and $CONSOLEFONT in a config file
233 [ -r /etc/grml/autoconfig ] && . /etc/grml/autoconfig
235 # check for bootoption which overrides config from /etc/grml/autoconfig
236 BOOT_LANGUAGE="$(getbootparam 'lang' 2>>$DEBUG)"
237 [ -n "$BOOT_LANGUAGE" ] && LANGUAGE="$BOOT_LANGUAGE"
239 # set default to 'en' in live-cd mode iff $LANGUAGE is not set yet
240 if [ -z "$INSTALLED" ] ; then
241 [ -n "$LANGUAGE" ] || LANGUAGE='en'
244 if [ -x /usr/sbin/grml-setlang ] ; then
245 # if bootoption lang is used update /etc/default/locale accordingly
246 if [ -n "$BOOT_LANGUAGE" ] ; then
247 /usr/sbin/grml-setlang "$LANGUAGE"
248 # otherwise default to lang=en
250 /usr/sbin/grml-setlang "en"
255 if [ -z "$CONSOLEFONT" ] ; then
256 if ! checkbootparam 'nodefaultfont' >>$DEBUG 2>&1 ; then
257 if [ -r /usr/share/consolefonts/Uni3-Terminus16.psf.gz ] ; then
258 CONSOLEFONT='Uni3-Terminus16'
260 ewarn "/usr/share/consolefonts/Uni3-Terminus16.psf.gz not available. Please upgrade package console-terminus." ; eend 1
263 CONSOLEFONT='Lat15-Terminus16'
268 # export it now, so error messages get translated, too
269 [ -r /etc/default/locale ] && . /etc/default/locale
272 # configure keyboard layout, read in already set values first:
273 [ -r /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard
275 # now allow keyboard override by boot commandline for later use:
276 KKEYBOARD="$(getbootparam 'keyboard' 2>>$DEBUG)"
277 [ -n "$KKEYBOARD" ] && KEYTABLE="$KKEYBOARD"
278 # notce: de/at is a bad choice, so take de-latin1-nodeadkeys instead:
279 [[ "$KKEYBOARD" == 'de' ]] && KEYTABLE=de-latin1-nodeadkeys
280 [[ "$KKEYBOARD" == 'at' ]] && KEYTABLE=de-latin1-nodeadkeys
282 # modify /etc/sysconfig/keyboard only in live-cd mode:
283 if [ -z "$INSTALLED" ] ; then
285 local LANGUAGE="$BOOT_LANGUAGE"
286 . /etc/grml/language-functions
287 # allow setting xkeyboard explicitly different than console keyboard
288 KXKEYBOARD="$(getbootparam 'xkeyboard' 2>>$DEBUG)"
289 if [ -n "$KXKEYBOARD" ]; then
290 XKEYBOARD="$KXKEYBOARD"
291 KDEKEYBOARD="$KXKEYBOARD"
292 elif [ -n "$KKEYBOARD" ]; then
293 XKEYBOARD="$KKEYBOARD"
294 KDEKEYBOARD="$KKEYBOARD"
297 # duplicate of previous code to make sure /etc/grml/language-functions
298 # does not overwrite our values....
299 # now allow keyboard override by boot commandline for later use:
300 KKEYBOARD="$(getbootparam 'keyboard' 2>>$DEBUG)"
301 [ -n "$KKEYBOARD" ] && KEYTABLE="$KKEYBOARD"
302 # notce: de/at is a bad choice, so take de-latin1-nodeadkeys instead:
303 [[ "$KKEYBOARD" == 'de' ]] && KEYTABLE=de-latin1-nodeadkeys
304 [[ "$KKEYBOARD" == 'at' ]] && KEYTABLE=de-latin1-nodeadkeys
306 # write keyboard related variables to file for later use
307 [ -d /etc/sysconfig ] || mkdir /etc/sysconfig
308 if ! [ -e /etc/sysconfig/keyboard ] ; then
309 echo "KEYTABLE=\"$KEYTABLE\"" > /etc/sysconfig/keyboard
310 echo "XKEYBOARD=\"$XKEYBOARD\"" >> /etc/sysconfig/keyboard
311 echo "KDEKEYBOARD=\"$KDEKEYBOARD\"" >> /etc/sysconfig/keyboard
312 echo "KDEKEYBOARDS=\"$KDEKEYBOARDS\"" >> /etc/sysconfig/keyboard
316 [ -r /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard
318 # activate unicode console if running within utf8 environment
319 if [ -r /etc/default/locale ] ; then
320 if grep -q "LANG=.*UTF" /etc/default/locale ; then
321 einfo "Setting up unicode environment."
322 unicode_start >>$DEBUG 2>&1 ; eend $?
326 # Set default keyboard before interactive setup
327 if [ -n "$KEYTABLE" ] ; then
328 einfo "Running loadkeys for ${WHITE}${KEYTABLE}${NORMAL} in background"
329 loadkeys -q $KEYTABLE &
333 # we have to set up all consoles, therefore loop it over all ttys:
334 NUM_CONSOLES=$(fgconsole --next-available 2>/dev/null)
335 if [ -n "$NUM_CONSOLES" ] ; then
336 NUM_CONSOLES=$(expr ${NUM_CONSOLES} - 1)
337 [ ${NUM_CONSOLES} -eq 1 ] && NUM_CONSOLES=6
339 CUR_CONSOLE=$(fgconsole 2>/dev/null)
341 if [ -x "$(which setfont)" ] ; then
343 elif [ -x "$(which consolechars)" ] ; then
344 use_consolechars=true
346 eerror "Neither setfont nor consolechars tool present, can not set font."
351 if [ -n "$CHARMAP" ] ; then
352 einfo "Setting font to ${CHARMAP}"
354 for vc in $(seq 0 ${NUM_CONSOLES}) ; do
355 if $use_setfont ; then
356 setfont -C /dev/tty${vc} $CHARMAP ; RC=$?
357 elif $use_consolechars ; then
358 consolechars --tty=/dev/tty${vc} -m ${CHARMAP} ; RC=$?
361 if [ -n "$CUR_CONSOLE" ] ; then
362 [ "$CUR_CONSOLE" != "serial" ] && chvt $CUR_CONSOLE
367 if checkbootparam 'noconsolefont' ; then
368 ewarn "Skipping setting console font as requested on boot commandline." ; eend 0
370 if [ -n "$CONSOLEFONT" ] ; then
371 einfo "Setting font to ${CONSOLEFONT}"
373 for vc in $(seq 0 ${NUM_CONSOLES}) ; do
374 if $use_setfont ; then
375 setfont -C /dev/tty${vc} ${CONSOLEFONT} ; RC=$?
376 elif $use_consolechars ; then
377 consolechars --tty=/dev/tty${vc} -f ${CONSOLEFONT} ; RC=$?
380 if [ -n "$CUR_CONSOLE" ] ; then
381 [ "$CUR_CONSOLE" != "serial" ] && chvt $CUR_CONSOLE
393 if ! checkbootparam 'hostname' ; then
397 HOSTNAME="$(getbootparam 'hostname' 2>>$DEBUG)"
398 if [ -z "$HOSTNAME" ] && [ -x /usr/bin/random-hostname ] ; then
399 einfo "Generating random hostname as no hostname was specified."
400 HOSTNAME="$(/usr/bin/random-hostname)"
404 einfo "Setting hostname to $HOSTNAME as requested."
405 grml-hostname $HOSTNAME >>$DEBUG
410 # fstabuser (needed when running from harddisk with username != grml {{{
412 # force load of build-in and local config
413 [ -r /etc/grml/autoconfig ] && . /etc/grml/autoconfig
414 [ -r /etc/grml/autoconfig ] && . /etc/grml/autoconfig.local
416 # 1st. try configured fstab user
417 if [ -n "$CONFIG_FSTAB_USER" ] ; then
418 fstabuser=$(getent passwd $CONFIG_FSTAB_USER | cut -d: -f1)
421 # 2nd. use standard user id
422 [ -n "$fstabuser" ] || fstabuser=$(getent passwd 1000 | cut -d: -f1)
424 # 3rd. use standard user name
425 [ -n "$fstabuser" ] || fstabuser=$(getent passwd grml | cut -d: -f1)
427 # if not yet set fall back to 'root' user, avoid bad /etc/fstab
428 [ -n "$fstabuser" ] || fstabuser='root'
432 # local_user (needed when running with username != grml {{{
435 # force load of build-in and local config
436 [ -r /etc/grml/autoconfig ] && . /etc/grml/autoconfig
437 [ -r /etc/grml/autoconfig ] && . /etc/grml/autoconfig.local
439 # 1st. try id of primary user
440 localuser=$(getent passwd 1000 | cut -d: -f1)
442 # 2nd. use name standard user
443 [ -n "$localuser" ] || localuser=$(getent passwd grml | cut -d: -f1)
449 einfo "Mounting configfs"
450 CONFIGFS_DIR=/sys/kernel/config/
451 modprobe configfs 2>/dev/null 1>&2
452 if ! [ -d "$CONFIGFS_DIR" ] ; then
454 einfo "$CONFIGFS_DIR does not exist, can't mount directory"
458 mount -t configfs configfs "$CONFIGFS_DIR" 2>/dev/null 1>&2
464 # {{{ Set clock (Local time is more often used than GMT, so it is default)
466 # don't touch the files if running from harddisk:
467 if [ -z "$INSTALLED" ]; then
468 # The default hardware clock timezone is stated as representing local time.
470 grep -q "^UTC=" /etc/default/rcS || echo "UTC=no" >> /etc/default/rcS
471 checkbootparam 'utc' >>$DEBUG 2>&1 && sed -i "s|^UTC=.*$|UTC=yes|" /etc/default/rcS
472 checkbootparam 'gmt' >>$DEBUG 2>&1 && sed -i "s|^UTC=.*$|UTC=yes|" /etc/default/rcS
473 checkbootparam 'localtime' >>$DEBUG 2>&1 && sed -i "s|^UTC=.*$|UTC=no|" /etc/default/rcS
474 grep -q -i "^UTC=yes" /etc/default/rcS && UTC="-u"
475 # hwclock uses the TZ variable
476 KTZ="$(getbootparam 'tz' 2>>$DEBUG)"
477 [ -z "$KTZ" ] && [ -r /etc/timezone ] && KTZ=$(cat /etc/timezone)
478 if [ ! -f "/usr/share/zoneinfo/$KTZ" ] ; then
479 ewarn "Warning: unknown timezone $KTZ" ; eend 1
481 ewarn "Falling back to timezone $KTZ" ; eend 0
484 if ! [ -r /dev/rtc ] ; then
485 ewarn "Warning: realtime clock not available, trying to execute hwclock anyway." ; eend 0
488 ERROR=$(TZ="$KTZ" hwclock $UTC -s 2>&1 | head -1) ; RC=$?
489 if [ -n "$ERROR" ] ; then
491 ERROR=$(TZ="$KTZ" hwclock $UTC -s --directisa 2>&1 | head -1)
492 if [ -n "$ERROR" ] ; then
493 eerror "Problem running hwclock: $ERROR" ; eend 1
502 # {{{ print kernel info
504 if $VIRTUAL && [ -n "$VIRTUAL_ENV" ] ; then
505 einfo "Running Linux Kernel $KERNEL inside $VIRTUAL_ENV" ; eend 0
507 einfo "Running Linux Kernel $KERNEL" ; eend 0
510 if [ -r /proc/cpuinfo ] ; then
511 if egrep -q '^flags.*(vmx|svm)' /proc/cpuinfo ; then
513 einfo 'CPU(s) featuring virtualization technology detected' ; eend 0
518 if [ -d /proc/xen ] ; then
520 einfo 'Running kernel featuring support for Xen detected' ; eend 0
526 # {{{ ld.so.cache + depmod
528 if [ -n "$INSTALLED" ]; then
529 if ! [ -r /etc/grml.first.boot ] ; then
530 einfo "Running from HD for the first time, regenerate ld.so.cache and modules.dep:"
532 # Regenerate ld.so.cache and module dependencies on HD
533 einfo "Running ldconfig" ; ldconfig ; eend $?
534 einfo "Running depmod" ; depmod -a ; eend $?
535 touch /etc/grml.first.boot
545 # don't touch the files if running from harddisk:
546 if [ -z "$INSTALLED" ]; then
547 KTZ="$(getbootparam 'tz' 2>>$DEBUG)"
548 if [ -n "$KTZ" ] ; then
549 if [ ! -f "/usr/share/zoneinfo/$KTZ" ]
551 ewarn "Warning: unknown timezone $KTZ"; eend 0
553 einfo "Setting timezone."
555 area=$(echo $KTZ | cut -d '/' -f1)
556 zone=$(echo $KTZ | cut -d '/' -f2)
557 echo "tzdata tzdata/Areas select $area" | debconf-set-selections
558 echo "tzdata tzdata/Zones/$area select $zone" | debconf-set-selections
560 echo $KTZ > /etc/timezone
562 cp "/usr/share/zoneinfo/$KTZ" /etc/localtime ; eend $?
569 # small computer / nearly no ram {{{
572 RAM=$(/usr/bin/gawk '/MemTotal/{print $2}' /proc/meminfo)
573 # MEM=$(/usr/bin/gawk 'BEGIN{m=0};/MemFree|Cached|SwapFree/{m+=$2};END{print m}' /proc/meminfo)
576 if checkbootparam 'small'; then
577 einfo "Information: ${RAM} kB of RAM available." ; eend 0
578 einfo "Bootoption small detected. Activating small system."
579 if [ -r /etc/inittab.small ] ; then
580 mv /etc/inittab /etc/inittab.normal
581 mv /etc/inittab.small /etc/inittab
583 sed -i 's/^9/#&/' /etc/inittab
584 sed -i 's/^10/#&/' /etc/inittab
585 sed -i 's/^11/#&/' /etc/inittab
586 sed -i 's/^12/#&/' /etc/inittab
588 /sbin/telinit q ; eend $?
590 if checkgrmlsmall ; then
591 if [[ $RAM -lt 25000 ]] ; then
592 ewarn "Information: ${RAM} kB of RAM available." ; eend 1
593 ewarn "At least 32MB of RAM should be available for grml-small." ; eend 1
594 ewarn "Use the bootoption small to save some more MB of memory usage." ; eend 0
595 ewarn "Dropping you into a rescue shell. To continue booting exit the shell." ; eend 0
598 einfo "Information: ${RAM} kB of RAM available." ; eend 0
601 if [[ $RAM -lt 58000 ]] ; then
602 ewarn "Information: ${RAM} kB of RAM available." ; eend 1
603 ewarn "At least 64MB of RAM should be available for grml." ; eend 1
604 ewarn "Use the bootoption small to save some more MB of memory usage." ; eend 0
605 ewarn "Dropping you into a rescue shell. To continue booting exit the shell." ; eend 0
608 einfo "Information: ${RAM} kB of RAM available." ; eend 0
616 # skip startup of w3m {{{
618 if checkbootparam 'fast'; then
619 ewarn "Bootoption fast detected. Skipping startup of grml-quickconfig."
620 sed -i '/1:/s#/usr/share/grml-scripts/run-welcome#/bin/zsh#' /etc/inittab
621 /sbin/telinit q ; eend $?
626 # activate serial console {{{
628 if checkbootparam 'console'; then
633 einfo "Bootoption for serial console detected:"
637 line="${line#*[$ws]}"
639 while [ -n "$line" ]; do
643 local device="${this%%,*}"
644 local device="${device##*=}"
645 if echo $serial | grep -q ttyS ; then
646 local option="${serial##*,}"
647 # default (works for kvm & CO):
648 local speed="115200,57600,38400,19200,9600,4800,2400,1200";
649 # ... unless overriden by command line:
651 115200*) speed=115200 ;;
652 57600*) speed=57600 ;;
653 38400*) speed=38400 ;;
654 19200*) speed=19200 ;;
661 einfo "Activating console login on device ${device} with speed ${speed}."
662 local number="${device#ttyS}"
663 sed -i "/^T$number:/d;/^#grmlserial#/iT$number:23:respawn:/bin/bash -c \"/sbin/getty -L $device -l /usr/share/grml-scripts/run-welcome $speed vt100 || sleep 30\"" /etc/inittab
670 this="${line%%[$ws]*}"
671 line="${line#*[$ws]}"
674 if [ -n "$telinitq" ]; then
682 # {{{ copy passwd-lockfile to ramdisk (fix unionfs-behaviour)
683 # otherwise we will get: passwd: Authentication token lock busy
685 if [ -z "$INSTALLED" ] ; then
693 if checkbootparam 'testcd' ; then
694 einfo "Checking CD data integrity as requested by '${WHITE}testcd${NORMAL}' boot option."
698 local FOUND_FILE=false
699 local logfile='/tmp/md5sum.log'
703 for md5 in $(find "${LIVECD_PATH}" -name md5sums) ; do
704 einfo "Checking files against $md5, this may take a while..."
709 md5sum -c $(basename "$md5") |& tee -a "${logfile}"
710 if [ $pipestatus[1] -eq 0 ] ; then
716 if ! $FOUND_FILE ; then
717 eerror 'Error: Could not find md5sum file' ; eend 1
722 einfo "Everything looks OK" ; eend 0
724 eerror 'Checksum failed for theses files:' ; eend 1
725 egrep -v '(^md5sum:|OK$)' "${logfile}"
726 eerror 'Data on the medium is possibly incomplete/damaged or RAM of your system is broken.' ; eend 1
727 einfon "Hit return to continue, or press the power button to shut down system."
736 # {{{ blacklist specific module [ used in /etc/init.d/udev ]
738 if checkbootparam 'blacklist' ; then
739 if [ -z "$INSTALLED" ]; then
740 einfo "Bootoption blacklist found."
741 BLACK="$(getbootparam 'blacklist' 2>>$DEBUG)"
742 BLACKLIST_FILE='/etc/modprobe.d/grml.conf'
743 if [ -n "$BLACK" ] ; then
744 for module in $(echo ${BLACK//,/ }) ; do
745 einfo "Blacklisting module ${module} via ${BLACKLIST_FILE}."
746 echo "# begin entry generated by config_blacklist of grml-autoconfig" >> "$BLACKLIST_FILE"
747 echo "blacklist $module" >> "$BLACKLIST_FILE"
748 echo "alias $module off" >> "$BLACKLIST_FILE"
749 echo "# end entry generated by config_blacklist of grml-autoconfig" >> "$BLACKLIST_FILE" ; eend $?
752 eerror "No given module for blacklist found. Blacklisting will not work therefore."
755 ewarn "Backlisting via bootoption is not intended for use on harddisk installations." ; eend 1
757 einfo "Please blacklist the module(s) manually using the 'blacklist' script."
766 if checkbootparam 'noacpi'; then
767 ewarn "ACPI: Not loading modules as requested by boot option \"noacpi\"." ; eend 0
768 elif checkbootparam 'nogrmlacpi' ; then
769 ewarn "ACPI: Not loading modules as requested by boot option \"nogrmlacpi\"." ; eend 0
770 elif [ ! -d /proc/acpi ] ; then
771 ewarn "ACPI: Kernel support not present." ; eend 0
773 einfo "ACPI: Loading modules (disable with boot option noacpi / nogrmlacpi): "
776 for a in /lib/modules/$KERNEL/kernel/drivers/acpi/*; do
778 basename="${basename%%.*}"
779 case "$basename" in *_acpi)
780 egrep -qi "${basename%%_acpi}" /proc/acpi/dsdt 2>>$DEBUG || continue ;;
782 modprobe $basename >>$DEBUG 2>&1 && found="yes"
783 local BASE="$BASE $basename"
785 if [ -n "$found" ] ; then
786 einfo "$BASE" ; eend 0
788 ewarn "(none)" ; eend 1
790 if ! pgrep acpid >/dev/null ; then
791 einfo "Starting acpi daemon."
792 /etc/init.d/acpid start >>$DEBUG 2>&1 ; eend $?
794 ewarn "acpi daemon already running."
802 # {{{ Collect partitions from /proc/partitions first for enabling DMA
806 while read major minor blocks partition relax; do
807 partition="${partition##*/}"
808 [ -z "$partition" -o ! -e "/dev/$partition" ] && continue
810 hd?) IDEDISKS="$IDEDISKS $partition";; # IDE Harddisk, entire disk
811 sd?) ;; # SCSI Harddisk, entire disk
812 # [hs]d*) partitions="$partitions /dev/$partition";; # IDE or SCSI disk partition
813 [hs]d*|ub*) partitions="$partitions /dev/$partition";; # IDE, USB or SCSI disk partition
816 $(awk 'BEGIN{old="__start"}{if($0==old){exit}else{old=$0;if($4&&$4!="name"){print $0}}}' /proc/partitions)
819 check_partitions >/dev/null 2>&1 # avoid output "check_partitions:3: read-only file system"
824 if checkbootparam 'brltty' ; then
825 [ -x /lib/brltty/brltty.sh ] && /lib/brltty/brltty.sh
830 # {{{ Enable DMA for all IDE drives now if not disabled
831 # Notice: Already done by linuxrc, but make sure it's done also on harddisk-installed systems
833 if checkbootparam 'nodma'; then
834 ewarn "Skipping DMA accelleration as requested on boot commandline." ; eend 0
836 for d in $(cd /proc/ide 2>>$DEBUG && echo hd[a-z]); do
837 if test -d /proc/ide/$d; then
838 if egrep -q 'using_dma[ \t]+0' /proc/ide/$d/settings 2>>$DEBUG; then
839 MODEL="$(cat /proc/ide/$d/model 2>>$DEBUG)"
840 test -z "$MODEL" && MODEL="[GENERIC IDE DEVICE]"
841 einfo "Enabling DMA acceleration for: ${WHITE}$d ${YELLOW}[${MODEL}]${NORMAL}"
842 echo "using_dma:1" >/proc/ide/$d/settings
851 # {{{ Start creating /etc/fstab with HD partitions and USB SCSI devices now
854 NOSWAP="yes" # we do not use swap by default!
855 if checkbootparam 'swap' || checkbootparam 'anyswap' ; then
857 checkbootparam 'anyswap' && export ANYSWAP='yes' || export ANYSWAP=""
860 # Scan for swap, config, homedir - but only in live-mode
861 if [ -z "$INSTALLED" ] ; then
862 [ -z "$NOSWAP" ] && einfo "Searching for swap partition(s) as requested."
865 HOMEDIR="$(getbootparam 'home')"
866 if [ -n "$partitions" ]; then
867 while read p m f relax; do
868 case "$p" in *fd0*|*proc*|*sys*|*\#*) continue;; esac
869 partoptions="users,exec"
871 # it's a swap partition?
874 if [ -n "$NOSWAP" ]; then
875 ewarn "Ignoring swap partition ${WHITE}$p${NORMAL}. (Force usage via boot option 'swap', or execute grml-swapon)"
878 case "$(dd if=$p bs=1 count=6 skip=4086 2>/dev/null)" in
879 S1SUSP|S2SUSP|pmdisk|[zZ]*)
880 if [ -n "$ANYSWAP" ] ; then
881 einfo "Using swap partition ${WHITE}${p}${NORMAL} [bootoption anyswap found]."
882 swapon $p 2>>$DEBUG ; eend $?
884 ewarn "Suspend signature on ${WHITE}${p}${NORMAL} found, not using as swap. (Force usage via boot option: anyswap)"
888 if [[ "$p" == LABEL* ]] ; then
889 p=$(blkid -t $p | awk -F: '{print $1}')
891 if grep -q $p /proc/swaps ; then
892 ewarn "Not using swap partition ${WHITE}${p}${NORMAL} as it is already in use." ; eend 0
894 if [ -b "$p" ] ; then
895 einfo "Using swap partition ${WHITE}${p}${NORMAL}."
896 swapon $p 2>>$DEBUG ; eend $?
898 ewarn "$p is not a valid block device - not using it therefore." ; eend 0
907 esac # it's a swap partition?
912 vfat|msdos|ntfs) MOUNTOPTS="$MOUNTOPTS,uid=${fstabuser},gid=${fstabuser}" ;;
913 ext2|ext3|reiserfs|jfs|reiser4|xfs) MOUNTOPTS="$MOUNTOPTS,noatime" ;;
915 # *) NONEFOUND='1'; continue ;;
919 if [ -z "$NOSWAP" ] ; then
920 mount -o "$MOUNTOPTS" -t $f $p $m 2>>$DEBUG && MOUNTED=1 || continue
921 # Activate swapfile, if exists
922 SWAPFILE="$(/bin/ls -1d $m/[Gg][Rr][Mm][Ll].[Ss][Ww][Pp] 2>/dev/null)"
924 if [ -z "$NOSWAP" -a -n "$SWAPFILE" -a -f "$SWAPFILE" ]; then
925 mount -o remount,rw $m && MOUNTED=1
926 if swapon "$SWAPFILE" 2>>$DEBUG ; then
928 einfo "Using GRML swapfile ${WHITE}${SWAPFILE}${NORMAL}."
930 fnew="$SWAPFILE swap swap defaults 0 0"
931 grep -q "$fnew" "/etc/fstab" || echo "$fnew" >> /etc/fstab
932 GRML_SWP="$GRML_SWP $SWAPFILE"
935 mount -o remount,ro $m 2>>$DEBUG && MOUNTED=1
938 # use a image as home
939 IMAGE="$(/bin/ls -1d $m/[Gg][Rr][Mm][Ll].[Ii][Mm][Gg] 2>/dev/null)"
940 if [ -z "$GRML_IMG" -a -n "$IMAGE" -a -f "$IMAGE" ]; then
941 if [ -n "$HOMEDIR" ]; then
942 if [ "$HOMEDIR" != "scan" -a "$HOMEDIR" != "$IMAGE" -a "$HOMEDIR" != "${IMAGE%/*.*}" ]; then
946 if type -a grml-image >/dev/null 2>&1 && grml-image "$IMAGE" </dev/console >/dev/console 2>&1; then
948 mount -o remount,ro $m 2>>$DEBUG && MOUNTED=1
953 # Umount, if not in use
954 [ -n "$MOUNTED" ] && umount -r $m 2>/dev/null
966 if [ -n "$MOUSE_DEVICE" ] ; then
967 einfo "Detecting mouse: ${MOUSE_FULLNAME} at ${MOUSE_DEVICE}" ; eend $?
972 # {{{ IPv6 configuration
973 # Load IPv6 kernel module and print IP adresses
975 if checkbootparam 'ipv6'; then
976 einfo "Enabling IPv6 as requested on boot commandline (sleeping for 2 seconds)"
978 # we probably need some time until stateless autoconfiguration has happened
980 NETDEVICES="$(awk -F: '/eth.:|tr.:|wlan.:/{print $1}' /proc/net/dev 2>>$DEBUG)"
981 for DEVICE in `echo "$NETDEVICES"`; do
984 ADDRESSES="$(ifconfig $DEVICE | awk '/.*inet6 addr:.*/{print $3}')"
985 COUNT="$(ifconfig $DEVICE | awk '/.*inet6 addr:.*/{ sum += 1};END {print sum }')"
987 for ADDR in `echo "$ADDRESSES"` ; do
990 if [ "$COUNT" -eq "0" ] ; then
991 einfo "(none)" ; eend 1
1003 if checkbootparam 'nocpu'; then
1004 ewarn "Skipping CPU detection as requested on boot commandline." ; eend 0
1008 if [[ $(grep -c processor /proc/cpuinfo) -gt 1 ]] ; then
1010 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)
1011 echo $CPU | sed 's/ \{1,\}/ /g'
1014 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
1017 # no cpufreq setup inside VirtualBox
1018 if $VIRTUALBOX ; then
1019 einfo 'Virtual Box detected, skipping cpufreq setup.' ; eend 0
1023 if [ -x /etc/init.d/loadcpufreq ] ; then
1024 einfo "Trying to set up cpu frequency scaling:"
1026 SKIP_CPU_GOVERNOR=''
1027 LOADCPUFREQ=$(mktemp)
1028 /etc/init.d/loadcpufreq start >"$LOADCPUFREQ" 2>&1 ; RC=$?
1029 if grep -q FATAL "$LOADCPUFREQ" ; then
1035 for line in $(grep FATAL "$LOADCPUFREQ" | sed 's/.*FATAL: //; s/ (.*)//') ; do
1036 eerror "$line" ; eend $RC
1040 elif grep -q done "$LOADCPUFREQ" ; then
1041 MODULE=$(grep done "$LOADCPUFREQ" | sed 's/.*done (\(.*\))./\1/')
1042 if [ -n "$MODULE" -a "$MODULE" != none ]; then
1043 einfo "Loading cpufreq kernel module $MODULE" ; eend 0
1046 ewarn "Could not find an appropriate kernel module for cpu frequency scaling." ; eend 1
1052 if [ -z "$SKIP_CPU_GOVERNOR" ] ; then
1053 if grep -vq ondemand /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors; then
1054 einfo "Loading cpufreq_ondemand"
1055 modprobe cpufreq_ondemand
1059 einfo "Setting ondemand governor"
1061 for file in $(find /sys/devices/system/cpu/ -name scaling_governor 2>/dev/null) ; do
1062 echo ondemand > $file || RC=1
1072 # {{{ autostart of ssh
1074 if checkbootparam 'ssh' ; then
1076 SSH_PASSWD="$(getbootparam 'ssh' 2>>$DEBUG)"
1078 einfo "Bootoption ssh found, trying to set password for root and user $localuser"
1079 [ -z "$localuser" ] && eend 1
1081 if [ -z "$SSH_PASSWD" ] ; then
1082 if [ -x /usr/bin/apg ] ; then
1083 SSH_PASSWD="$(apg -M NL -a 0 -m 8 -x 12 -n 1)"
1084 elif [ -x /usr/bin/gpw ] ; then
1085 SSH_PASSWD="$(gpw 1)"
1086 elif [ -x /usr/bin/pwgen ] ; then
1087 SSH_PASSWD="$(pwgen -1 8)"
1088 elif [ -x /usr/bin/hexdump ] ; then
1089 SSH_PASSWD="$(dd if=/dev/urandom bs=14 count=1 2>/dev/null | hexdump | awk '{print $3 $4}')"
1090 elif [ -n "$RANDOM" ] ; then
1091 SSH_PASSWD="grml${RANDOM}"
1094 eerror "Empty passphrase and neither pwgen nor hexdump nor \$RANDOM found. Skipping."
1098 if [ -n "$SSH_PASSWD" ] ; then
1099 ewarn "No given password for ssh found. Using random password: $SSH_PASSWD" ; eend 0
1104 # finally check if we have a password we can use:
1105 if [ -n "$SSH_PASSWD" ] ; then
1106 # chpasswd sucks, seriously.
1108 if chpasswd --help 2>&1 | grep -q -- '-m,' ; then
1111 echo "$localuser:$SSH_PASSWD" | chpasswd $chpass_options
1112 echo "root:$SSH_PASSWD" | chpasswd $chpass_options
1115 einfo "Starting secure shell server in background for root and user $localuser"
1116 /etc/init.d/rmnologin start >>$DEBUG 2>>$DEBUG
1117 /etc/init.d/ssh start >>$DEBUG 2>>$DEBUG &
1121 ewarn "Warning: please change the password for root and user $localuser as soon as possible!"
1128 # {{{ display hostkeys of SSH server
1129 config_display_ssh_fingerprints() {
1130 if ! ls /etc/ssh/ssh_host_\*_key >/dev/null 2>&1 ; then
1131 return 0 # no SSH host keys present
1134 einfo "SSH key fingerprints:"
1135 for file in /etc/ssh/ssh_host_*_key ; do
1137 ssh-keygen -l -f $file
1143 # {{{ autostart of x11vnc
1145 if checkbootparam 'vnc' ; then
1148 VNC_PASSWD="$(getbootparam 'vnc' 2>>$DEBUG)"
1149 einfo "Bootoption vnc found, trying to set password for user $localuser."
1151 if [ -z "$VNC_PASSWD" ] ; then
1152 if [ -x /usr/bin/apg ] ; then
1153 VNC_PASSWD="$(apg -M NL -a 0 -m 8 -x 12 -n 1)"
1154 elif [ -x /usr/bin/gpw ] ; then
1155 VNC_PASSWD="$(gpw 1)"
1156 elif [ -x /usr/bin/pwgen ] ; then
1157 VNC_PASSWD="$(pwgen -1 8)"
1158 elif [ -x /usr/bin/hexdump ] ; then
1159 VNC_PASSWD="$(dd if=/dev/urandom bs=14 count=1 2>/dev/null | hexdump | awk '{print $3 $4}')"
1160 elif [ -n "$RANDOM" ] ; then
1161 VNC_PASSWD="${localuser}${RANDOM}"
1164 eerror "Empty passphrase and neither pwgen nor hexdump nor \$RANDOM found. Skipping."
1168 if [ -n "$VNC_PASSWD" ] ; then
1169 ewarn "No given password for vnc found. Using random password: $VNC_PASSWD" ; eend 0
1174 # finally check if we have a password we can use:
1175 if [ -n "$VNC_PASSWD" ] ; then
1177 VNCDIR="/home/${localuser}/.vnc"
1178 [ -d "$VNCDIR" ] || mkdir "$VNCDIR"
1180 if [ ! -x /usr/bin/x11vnc ] ; then
1181 eerror "Error: x11vnc not found - can not set up vnc. Please make sure to install the x11vnc package."
1184 /usr/bin/x11vnc -storepasswd "$VNC_PASSWD" "$VNCDIR"/passwd ; eend $?
1185 /bin/chown -R "$localuser": "$VNCDIR"
1188 if checkbootparam 'vnc_connect' ; then
1190 VNC_CONNECT="$(getbootparam 'vnc_connect' 2>>$DEBUG)"
1191 einfo "Bootoption vnc_connect found, will start vnc with connect to $VNC_CONNECT."
1192 #store the options in a file
1193 VNCDIR="/home/${localuser}/.vnc"
1194 [ -d "$VNCDIR" ] || mkdir "$VNCDIR"
1195 echo " --connect $VNC_CONNECT " >> $VNCDIR/options
1201 # {{{ set password for default user
1203 if checkbootparam 'passwd' >>$DEBUG 2>&1; then
1204 PASSWD="$(getbootparam 'passwd' 2>>$DEBUG)"
1206 einfo "Bootoption passwd found, change password for user '$localuser'."
1207 [ -z "$localuser" ] && eend 1
1208 if [ -n "$PASSWD" ] ; then
1209 echo "$localuser:$PASSWD" | chpasswd -m ; eend $?
1211 eerror "No given password for ssh found. Autostart of SSH will not work." ; eend 1
1214 ewarn "Warning: please change the password for user grml set via bootparameter as soon as possible!"
1222 if ! [ -x /usr/bin/amixer ] ; then
1223 eerror "amixer binary not available. Can not set sound volumes therefore."
1226 if ! [ -r /proc/asound/cards ] ; then
1227 ewarn "No soundcard present, skipping mixer settings therefore."
1232 for card in $(cat /proc/asound/cards| grep -e '^\s*[0-9]' | awk '{print $1}') ; do
1233 einfo "Configuring soundcard \"$(awk -F\[ '/^ *'$card' \[/{ FS=" "; $0=$2; print $1}' < /proc/asound/cards)\""
1236 if checkbootparam 'vol' ; then
1237 VOL="$(getbootparam 'vol' 2>>$DEBUG)"
1238 if [ -z "$VOL" ] ; then
1239 eerror "Bootoption vol found but no volume level/parameter given. Using defaults (75%)."
1247 if checkbootparam 'nosound' ; then
1248 einfo "Muting sound devices on request."
1249 ERROR=$(amixer -q set Master mute)
1251 if [ -n "$ERROR" ] ; then
1253 eerror "Problem muting sound devices: $ERROR"
1257 elif [ -z "$INSTALLED" ] ; then
1258 einfo "Setting mixer volumes to level ${WHITE}${VOL}${NORMAL}."
1260 if checkbootparam 'micvol' ; then
1261 MICVOL="$(getbootparam 'micvol' 2>>$DEBUG)"
1262 einfo "Setting microphone to ${WHITE}${MICVOL}${NORMAL}."
1267 CONTROLS=$(amixer -c $card scontrols | awk -F"Simple mixer control " '{print $2}')
1271 for CONTROL in ${=CONTROLS} ; do
1272 if ! echo "${CONTROL}" | grep -q -i "mic" ; then
1273 if amixer -c $card sget "${CONTROL}" | grep -q 'Capabilities:.*pswitch' ; then
1274 amixer -c $card -q set "${CONTROL}" unmute
1276 if amixer -c $card sget "${CONTROL}" | grep -q -P 'Capabilities:.*(pvolume| volume)' ; then
1277 amixer -c $card -q set "${CONTROL}" "${VOL}"%
1281 if [ ${MICVOL} -ne 0 ] ; then
1282 if amixer -c $card sget "${CONTROL}" | grep -q 'Capabilities:.*cswitch' ; then
1283 amixer -c $card -q set "${CONTROL}" unmute
1285 if amixer -c $card sget "${CONTROL}" | grep -q 'Capabilities:.*cvolume' ; then
1286 amixer -c $card -q set "${CONTROL}" $MICVOL%
1292 fi # checkbootparam 'nosound'
1299 # {{{ modem detection
1301 if checkbootparam 'nomodem'; then
1302 ewarn "Skipping check for AC97 modem controller as requested on boot commandline." ; eend 0
1304 if [ -x /etc/init.d/sl-modem-daemon ] ; then
1305 if lspci | grep Intel | grep -q "AC'97 Modem Controller" ; then
1306 einfo "AC97 modem controller detected. Start it running 'Start sl-modem-daemon'."
1315 config_wondershaper(){
1316 if checkbootparam 'wondershaper' ; then
1317 WONDER="$(getbootparam 'wondershaper' 2>>$DEBUG)"
1322 if [ -n "$WONDER" ]; then
1324 DEVICE="${WONDER%%,*}"
1326 if [ -n "$R" -a "$R" != "$WONDER" ]; then
1328 DOWNSTREAM="${WONDER%%,*}"
1330 if [ -n "$R" -a "$R" != "$WONDER" ]; then
1332 UPSTREAM="${WONDER%%,*}"
1337 [ -n "$DEVICE" ] && CMD="$CMD $DEVICE"
1338 [ -n "$DOWNSTREAM" ] && CMD="$CMD $DOWNSTREAM"
1339 [ -n "$UPSTREAM" ] && CMD="$CMD $UPSTREAM"
1340 einfo "Starting wondershaper (${CMD}) in background."
1341 ( sh -c $CMD & ) && eend 0
1348 if checkbootparam 'nosyslog'; then
1349 ewarn "Not starting syslog daemon as requested on boot commandline." ; eend 0
1352 [ -x /etc/init.d/syslog-ng ] && SYSLOGD='syslog-ng'
1353 [ -x /etc/init.d/rsyslog ] && SYSLOGD='rsyslog'
1354 [ -x /etc/init.d/dsyslog ] && SYSLOGD='dsyslog'
1355 [ -x /etc/init.d/sysklogd ] && SYSLOGD='sysklogd'
1356 [ -x /etc/init.d/inetutils-syslogd ] && SYSLOGD='inetutils-syslogd'
1358 if [ -z "$SYSLOGD" ] ; then
1359 eerror "No syslog daemon found." ; eend 1
1361 einfo "Starting $SYSLOGD in background."
1362 /etc/init.d/$SYSLOGD start >>$DEBUG &
1371 if checkbootparam 'nogpm'; then
1372 ewarn "Not starting GPM as requested on boot commandline." ; eend 0
1374 if ! [ -r /dev/input/mice ] ; then
1375 eerror "No mouse found - not starting GPM." ; eend 1
1377 einfo "Starting gpm in background."
1378 /etc/init.d/gpm start >>$DEBUG &
1379 # ( while [ ! -e /dev/psaux ]; do sleep 5; done; /etc/init.d/gpm start >>$DEBUG ) &
1388 if checkbootparam 'services' ; then
1389 SERVICE="$(getbootparam 'services' 2>>$DEBUG)"
1390 SERVICELIST=$(echo "$SERVICE" | sed 's/,/\\n/g')
1391 SERVICENL=$(echo "$SERVICE" | sed 's/,/ /g')
1392 for service in $(echo -e $SERVICELIST) ; do
1393 # support running (custom) init scripts in non-blocking mode
1394 # if they contain the keyword "DO_NO_RUN_IN_BACKGROUND".
1395 if grep -q 'DO_NO_RUN_IN_BACKGROUND' "/etc/init.d/${service}" 2>>$DEBUG ; then
1396 einfo "Starting service ${service}."
1397 /etc/init.d/${service} start >>$DEBUG
1399 einfo "Starting service ${service} in background."
1400 /etc/init.d/${service} start >>$DEBUG &
1410 [ "$#" -eq 2 ] || ( echo "Error: wrong parameter for get_remote_file()" ; return 1 )
1411 SOURCE=$(eval echo "$1")
1414 wget --timeout=10 --dns-timeout=10 --connect-timeout=10 --tries=1 \
1415 --read-timeout=10 ${SOURCE} -O ${TARGET} && return 0 || return 1
1417 einfo "Trying to get ${WHITE}${TARGET}${NORMAL}"
1419 while ! getconfig && [[ "$counter" != 0 ]] ; do
1420 echo -n "Sleeping for 1 second and trying to get config again... "
1421 counter=$(( counter-1 ))
1422 echo "$counter tries left" ; sleep 1
1424 if [ -s "$TARGET" ] ; then
1425 einfo "Downloading was successfull." ; eend 0
1426 einfo "md5sum of ${WHITE}${TARGET}${NORMAL}: "
1427 md5sum ${TARGET} ; eend 0
1430 einfo "Sorry, could not fetch ${SOURCE}" ; eend 1
1438 if checkbootparam 'netconfig' ; then
1439 CONFIG="$(getbootparam 'netconfig' 2>>$DEBUG)"
1440 CONFIGFILE='/tmp/netconfig.grml'
1442 if get_remote_file ${CONFIG} ${CONFIGFILE} ; then
1443 cd / && einfo "Unpacking ${WHITE}${CONFIGFILE}${NORMAL}:" && /usr/bin/unp $CONFIGFILE $EXTRACTOPTIONS ; eend $?
1450 # {{{ remote scripts
1451 config_netscript() {
1452 if checkbootparam 'netscript' ; then
1453 CONFIG="$(getbootparam 'netscript' 2>>$DEBUG)"
1454 SCRIPTFILE='/tmp/netscript.grml'
1456 if get_remote_file ${CONFIG} ${SCRIPTFILE} ; then
1457 chmod +x ${SCRIPTFILE}
1458 einfo "Running ${WHITE}${SCRIPTFILE}${NORMAL}:" && NETSCRIPT=${CONFIG} ${SCRIPTFILE} ; eend $?
1467 if ! checkbootparam 'nostats' ; then
1468 BASE_URL="http://stats.grml.org/report/"
1471 HOST_ID=$(cat /proc/sys/kernel/random/boot_id)
1473 grep -q " lm " /proc/cpuinfo && HAS_64BIT="1" || HAS_64BIT="0"
1474 DATE_STRING=$(date +'h=%H&m=%M&s=%S')
1475 [ -e /etc/grml_version ] && VERSION=$(cat /etc/grml_version) || \
1476 VERSION=$(lsb_release -d | awk -F: '{gsub(/^[ \t]+/, "", $2); print $2}')
1478 PARAMS="$( echo "$CMDLINE" | sed -e 's/=[^ ]*/=x/g' | tr " " "\n"|sort|tr "\n" " " )"
1480 echo "$CMDLINE" | grep -q -e "fetch" -e "nfsroot" && BOOT="remote"
1481 [ -z "$BOOT" ] && BOOT="local"
1483 ADDITIONAL_PARAMS=""
1484 ( [ -n "$COLUMNS" ] && [ -n "$LINES" ] ) && \
1485 ADDITIONAL_PARAMS="$ADDITIONAL_PARAMS&res=$((COLUMNS * 8))x$((LINES * 16))"
1487 URI='$BASE_URL?action=${ACTION_NAME}\&$DATE_STRING\&unique_id=${HOST_ID}\&support_64bit=$HAS_64BIT\&version=$VERSION\&bootup=$BOOT\¶ms=$PARAMS$ADDITIONAL_PARAMS'
1489 get_remote_file "$URI" "/dev/null" >/dev/null 2>&1 &!
1494 # {{{ fix/workaround for unionfs
1496 if [ -z "$INSTALLED" ]; then
1497 touch /var/cache/apt/*cache.bin
1502 # {{{ start X window system via grml-x
1504 # make sure we start X only if startx is used *before* a nostartx option
1505 # so it's possible to disable automatic X startup using nostart
1506 if checkbootparam 'startx' && ! echo "$CMDLINE" | grep -q 'startx.*nostartx' ; then
1507 if [ -x "$(which X)" ] ; then
1508 if [ -z "$INSTALLED" ] ; then
1509 WINDOWMANAGER="$(getbootparam 'startx' 2>>$DEBUG)"
1510 if [ -z "$WINDOWMANAGER" ] ; then
1511 einfo "No window manager specified. Using default one." && eend 0
1513 einfo "Window manager ${WHITE}${WINDOWMANAGER}${NORMAL} found as bootoption." && eend 0
1515 einfo "Setting up and invoking grml-x ${WINDOWMANAGER}. Just exit X windows system to get full featured consoles."
1517 cat>|/etc/init.d/xstartup<<EOF
1519 su $localuser -c "/usr/bin/grml-x ${WINDOWMANAGER}"
1521 chmod 755 /etc/init.d/xstartup
1523 # adjust inittab for xstartup
1524 if grep -q '^6:' /etc/inittab ; then
1525 sed -i 's|^6:.*|6:2345:respawn:/bin/zsh --login -c "/etc/init.d/xstartup ; /usr/share/grml-scripts/run-welcome" >/dev/tty6 2>\&1 </dev/tty6|' /etc/inittab
1526 else # just append tty6 to inittab if no definition is present:
1527 echo '6:2345:respawn:/bin/zsh --login -c "/etc/init.d/xstartup ; /usr/share/grml-scripts/run-welcome" >/dev/tty6 2>&1 < /dev/tty6' >> /etc/inittab
1530 /sbin/telinit q ; eend $?
1532 if grep -q '^allowed_users=' /etc/X11/Xwrapper.config ; then
1533 sed -i 's/^allowed_users=.*/allowed_users=anybody/' /etc/X11/Xwrapper.config
1535 echo 'allowed_users=anybody' >> /etc/X11/Xwrapper.config
1539 eerror "We are not running in live mode - startx will not work, skipping it."
1540 eerror " -> Please use something like xdm, gdm or kdm for starting X on a harddisk system!" ; eend 1
1543 eerror "/usr/bin/X is not present on this grml flavour."
1544 eerror " -> Boot parameter startx does not work therefore." ; eend 1
1550 # {{{ configuration framework
1552 if checkbootparam 'extract' ; then
1553 EXTRACT="$(getbootparam 'extract' 2>>$DEBUG)"
1554 EXTRACTOPTIONS="-- -x $EXTRACT"
1558 config_finddcsdir() {
1559 # - If no GRMLCFG partition is found and noautoconfig is _not_ given
1560 # on the command line, nothing is changed and the dcs files are
1561 # searched within the .iso, $dcs-dir is set to the root directory
1563 # - If a GRMLCFG partition is found, $dcs-dir is set to the root of
1564 # the GRMLCFG partition unless noautoconfig is set. If noautoconfig is
1565 # set, $dcs-dir is set to the root directory within the .iso.
1566 # - If myconfig=foo is set on the command line, $dcs-dir is set to
1567 # foo, even if a GRMLCFG partition is present.
1570 # autoconfig, see issue673
1571 GRMLCFG="$(getbootparam 'autoconfig' 2>>$DEBUG)"
1572 [ -n "$GRMLCFG" ] || GRMLCFG="GRMLCFG"
1573 if checkbootparam 'noautoconfig' || checkbootparam 'forensic' ; then
1574 DCSDIR="${LIVECD_PATH}" # set default so it works for "scripts" boot option as expected
1575 ewarn "Skipping running automount of device(s) labeled $GRMLCFG as requested." ; eend 0
1577 if [ -z "$INSTALLED" ] ; then
1578 if checkbootparam 'myconfig' ; then
1579 DCSDEVICE="$(getbootparam 'myconfig' 2>>$DEBUG)"
1580 if [ -z "$DCSDEVICE" ]; then
1581 eerror "Error: No device for bootoption myconfig provided." ; eend 1
1582 fi # [ -z "$DCSDEVICE" ]
1583 elif checkvalue $CONFIG_MYCONFIG; then # checkbootparam myconfig
1584 einfo "Searching for device(s) labeled with $GRMLCFG. (Disable this via boot option: noautoconfig)" ; eend 0
1586 # We do need the following fix so floppy disk is available to blkid in any case :-/
1587 if [ -r /dev/fd0 ] ; then
1588 einfo "Floppy device detected. Trying to access floppy disk (this might take a few seconds)."
1589 if timeout 4 dd if=/dev/fd0 of=/dev/null bs=512 count=1 >>$DEBUG 2>&1 ; then
1590 timeout 4 blkid /dev/fd0 >>$DEBUG 2>&1
1593 DCSDEVICE=$(blkid -t LABEL=$GRMLCFG | head -1 | awk -F: '{print $1}')
1595 modprobe 9p 2>/dev/null || true
1596 if [ -z "$DCSDEVICE" ] && grep -q 9p /proc/filesystems ; then
1597 if grep -q "$GRMLCFG" /sys/bus/virtio/devices/*/mount_tag 2>/dev/null ; then
1598 einfo "Found 9p-virtio fs with mount_tag $GRMLCFG"
1599 DCSDEVICE="$GRMLCFG"
1600 MOUNTOPTIONS="ro,trans=virtio"
1605 if [ -n "$DCSDEVICE" ]; then
1606 DCSMP="/mnt/grmlcfg"
1611 # if not specified/present then assume default:
1612 if [ -z "$DCSDEVICE" ]; then
1613 DCSDIR="${LIVECD_PATH}"
1616 einfo "debs, config, scripts are read from $DCSDEVICE." ; eend 0
1617 DCSDIR="$(< /proc/mounts awk -v DCSDEV=$DCSDEVICE '{if ($1 == DCSDEV) { print $2 }}')"
1618 if [ -n "$DCSDIR" ]; then
1619 ewarn "$DCSDEVICE already mounted on $DCSDIR"; eend 0
1621 [ -d $DCSMP ] || mkdir $DCSMP
1622 umount $DCSMP >>$DEBUG 2>&1 # make sure it is not mounted
1623 mount -o ${MOUNTOPTIONS:-ro} -t ${DCSFS:-auto} $DCSDEVICE $DCSMP ; RC="$?"
1624 if [[ $RC == 0 ]]; then
1625 einfo "Successfully mounted $DCSDEVICE to $DCSMP (readonly)." ; eend 0
1627 eerror "Error: mounting $DCSDEVICE to $DCSMP (readonly) failed." ; eend 1
1636 if [ -n "$DCSDIR" -a "$DCSDIR" != "${LIVECD_PATH}" ] ; then
1637 einfo "Debs, config, scripts (if present) will be read from $DCSDIR." ; eend 0
1638 elif checkbootparam 'debs' || checkbootparam 'config' || checkbootparam 'scripts'; then
1639 einfo "Debs, config, scripts will be read from the live image directly." ; eend 0
1645 if checkbootparam 'partconf' ; then
1646 MOUNTDEVICE="$(getbootparam 'partconf' 2>>$DEBUG)"
1647 if [ -n "$MOUNTDEVICE" ]; then
1648 [ -d /mnt/grml ] || mkdir /mnt/grml
1649 mount -o ro -t auto $MOUNTDEVICE /mnt/grml ; RC="$?"
1650 if [[ $RC == 0 ]]; then
1651 einfo "Successfully mounted $MOUNTDEVICE to /mnt/grml (readonly)." ; eend 0
1652 einfo "Copying files from $MOUNTDEVICE over grml system."
1653 for file in `cat /etc/grml/partconf` ; do
1654 [ -d /mnt/grml/$file ] && cp -a /mnt/grml/${file}* ${file} && echo "copied: $file"
1655 [ -f /mnt/grml/$file ] && cp -a /mnt/grml/${file} ${file} && echo "copied: $file"
1658 einfo "Could not mount $MOUNTDEVICE to /mnt/grml - sorry." ; eend 1
1659 fi # mount $MOUNTDEVICE
1660 grep -q '/mnt/grml' /proc/mounts && umount /mnt/grml
1662 einfo "Sorry, no device for bootoption partconf provided. Skipping." ; eend 1
1663 fi # [ -n "$MOUNTDEVICE" ]
1668 # {{{ /cdrom/.*-options
1670 if checkbootparam 'debs' ; then
1671 iszsh && setopt localoptions shwordsplit
1672 DEBS="$(getbootparam 'debs' 2>>$DEBUG)"
1673 if [ -z "$DEBS" ] ; then
1676 if ! echo $DEBS | grep -q '/'; then
1677 # backwards compatibility: if no path is given get debs from debs/
1680 einfo "Tring to install debian package(s) ${DEBS}"
1681 DEBS="$(eval echo ${DCSDIR}/$DEBS)"
1682 dpkg -i $DEBS ; eend $?
1687 if checkbootparam 'scripts' || [ "$DCSMP" = "/mnt/grmlcfg" ]; then
1688 SCRIPTS="$(getbootparam 'scripts' 2>>$DEBUG)"
1689 if [ -d ${DCSDIR}/scripts ] && [ -z "$SCRIPTS" ]; then
1690 SCRIPTS="$(cd ${DCSDIR}/scripts; /bin/ls -1d [Gg][Rr][Mm][Ll].[Ss][Hh] 2>>$DEBUG)"
1692 if ! echo $SCRIPTS | grep -q '/'; then
1693 # backwards compatibility: if no path is given get scripts from scripts/
1694 SCRIPTS="scripts/$SCRIPTS"
1696 if [ "$DCSMP" = "/mnt/grmlcfg" ]; then
1697 # we are executing from a GRMLCFG labeled fs
1698 # kick everything we have done before and start over
1699 SCRIPTS="$(cd ${DCSDIR}; /bin/ls -1d [Gg][Rr][Mm][Ll].[Ss][Hh] 2>>$DEBUG)"
1701 if [ -n "$SCRIPTS" ]; then
1702 SCRIPTS="${DCSDIR}/$SCRIPTS"
1703 if [ "$DCSMP" = "/mnt/grmlcfg" ]; then
1704 einfo "Trying to execute ${SCRIPTS}"
1706 elif [ -d "$SCRIPTS" ]; then
1707 einfo "Bootparameter scripts found. Trying to execute from directory ${SCRIPTS}:"
1708 run-parts --regex '.*' $SCRIPTS
1710 einfo "Bootparameter scripts found. Trying to execute ${SCRIPTS}:"
1718 if checkbootparam 'config' || [ "$DCSMP" = "/mnt/grmlcfg" ]; then
1719 CONFIG="$(getbootparam 'config' 2>>$DEBUG)"
1720 if [ -z "$CONFIG" ]; then
1721 CONFIG="$(cd ${DCSDIR}; ls -1d [Cc][Oo][Nn][Ff][Ii][Gg].[Tt][Bb][Zz] 2>>$DEBUG)"
1723 if [ -n "$CONFIG" ]; then
1724 if [ -d "${DCSDIR}/${CONFIG}" ] ; then
1725 einfo "Taking configuration from directory ${DCSDIR}/${CONFIG}"
1727 cp -a ${DCSDIR}/${CONFIG}/* /
1728 elif [ -f "${DCSDIR}/${CONFIG}" ]; then
1729 einfo "Extracting configuration from file ${DCSDIR}/${CONFIG}"
1732 unp ${DCSDIR}/${CONFIG} $EXTRACTOPTIONS ; eend $?
1734 ewarn "Sorry, could not find configuration file or directory ${DCSDIR}/${FILENAME}." ; eend 1
1741 # {{{ confing_umount_dcsdir
1742 config_umount_dcsdir(){
1743 # umount $DCSMP if it was mounted by finddcsdir
1744 grep -q "$DCSMP" /proc/mounts && umount "$DCSMP"
1750 if checkbootparam 'mypath' ; then
1751 MY_PATH="$(getbootparam 'mypath' 2>>$DEBUG)"
1752 einfo "Bootparameter mypath found, adding ${MY_PATH} to /etc/grml/my_path"
1753 touch /etc/grml/my_path
1754 chmod 644 /etc/grml/my_path
1755 # make sure the directories exist:
1757 for i in $(echo $MY_PATH | sed 's/:/\n/g') ; do
1758 if ! [ -d "$i" ] ; then
1759 einfo "Creating directory $i"
1760 mkdir -p "$i" ; eend $?
1763 grep -q "${MY_PATH}" /etc/grml/my_path || echo "${MY_PATH}" >> /etc/grml/my_path ; eend $?
1771 if checkbootparam 'distcc' ; then
1772 OPTIONS="$(getbootparam 'distcc' 2>>$DEBUG)"
1773 if [ -n "$OPTIONS" ]; then
1776 if [ -n "$OPTIONS" ]; then
1777 NET="${OPTIONS%%,*}"
1779 if [ -n "$R" -a "$R" != "$OPTIONS" ]; then
1781 INTERFACE="${OPTIONS%%,*}"
1786 CONFIG=/etc/default/distcc
1787 sed -i "s#^STARTDISTCC=.*#STARTDISTCC=YES#" $CONFIG
1788 sed -i "s#^ALLOWEDNETS=.*#ALLOWEDNETS=$NET#" $CONFIG
1790 if [ -n "$INTERFACE" ] ; then
1791 IP=$(LANG=C ifconfig $INTERFACE | gawk -F: /"inet addr"/'{print $2}' | gawk '{print $1}')
1794 while [ -z "$IP" ] && [[ "$counter" != 0 ]] ; do
1795 counter=$(( counter-1 ))
1796 ewarn "No ip address for $INTERFACE found. Sleeping for 3 seconds. $counter tries left."
1798 IP=$(LANG=C ifconfig $INTERFACE | gawk -F: /"inet addr"/'{print $2}' | gawk '{print $1}')
1802 if [ -n "$IP" ] ; then
1803 sed -i "s#^LISTENER=.*#LISTENER=$IP#" $CONFIG
1805 einfo "Bootoption distcc found. Preparing setup for distcc daemon."
1807 id distccd >/dev/null 2>&1 || \
1809 einfo "Creating distcc user" ; \
1810 adduser --quiet --system --ingroup nogroup --home / --no-create-home distccd ; eend $?
1813 einfo "Starting distcc for network ${NET}, listening on ${IP}."
1814 /etc/init.d/distcc start >/dev/null ; eend $?
1817 eerror "No ip address for $INTERFACE found. distcc can not be used without it." ; eend 1
1821 if checkbootparam 'gcc'; then
1822 GCC="$(getbootparam 'gcc' 2>>$DEBUG)"
1824 einfo "Pointing /usr/bin/gcc to /usr/bin/gcc-${GCC}."
1827 ln -s /usr/bin/gcc-${GCC} /usr/bin/gcc ; eend $?
1830 if checkbootparam 'gpp'; then
1831 GPP="$(getbootparam 'gpp' 2>>$DEBUG)"
1833 einfo "Pointing /usr/bin/g++ to /usr/bin/g++-${GPP}."
1834 if [ -x /usr/bin/g++-${GPP} ] ; then
1836 ln -s /usr/bin/g++-${GPP} /usr/bin/g++ ; eend $?
1838 einfo "Pointing /usr/bin/cpp to /usr/bin/cpp-${GPP}."
1839 if [ -x /usr/bin/cpp-${GPP} ] ; then
1841 ln -s /usr/bin/cpp-${GPP} /usr/bin/cpp ; eend $?
1850 # Notice: use it only on live-cd system, if running from harddisk please
1851 # add modules to /etc/modules and activate /etc/init.d/module-init-tools
1852 # in /etc/runlevel.conf
1854 MODULES_FILE=/etc/grml/modules
1855 if checkbootparam 'nomodules' ; then
1856 ewarn "Skipping loading of modules defined in ${MODULES_FILE} as requested." ; eend 0
1857 elif [ -z "$INSTALLED" ]; then
1858 if [ -r $MODULES_FILE ] ; then
1859 einfo "Loading modules specified in ${MODULES_FILE}:"
1861 grep '^[^#]' $MODULES_FILE | \
1862 while read module args; do
1863 [ "$module" ] || continue
1865 modprobe $module $args ; eend $?
1869 ewarn "File $MODULES_FILE does not exist. Skipping loading of specific modules." ; eend 1
1877 [ -n "$INSTALLED" ] && return 0
1879 # notice: checkbootparam "forensic" is just for users who don't know how to really use the bootoption
1880 if checkbootparam 'noraid' || checkbootparam 'noswraid' || \
1881 checkbootparam 'forensic' || checkbootparam 'raid=noautodetect' ; then
1882 ewarn "Skipping SW-RAID code as requested on boot commandline." ; eend 0
1884 [ -e /proc/mdstat ] || modprobe md_mod
1885 if ! [ -x /sbin/mdadm ] ; then
1886 eerror "mdadm not available, can not execute it." ; eend 1
1889 # if ! egrep -qv '^(MAILADDR.*|#.*|)$' /etc/mdadm/mdadm.conf 2>>$DEBUG ; then
1890 # find out whether we have a valid configuration file already
1891 if ! grep -q ARRAY /etc/mdadm/mdadm.conf 2>>$DEBUG ; then
1892 einfo "Creating /etc/mdadm/mdadm.conf for use with mdadm."
1893 [ -r /etc/mdadm/mdadm.conf ] && mv /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf.old
1894 MDADM_MAILADDR__='root' /usr/share/mdadm/mkconf > /etc/mdadm/mdadm.conf ; eend $?
1896 ewarn "/etc/mdadm/mdadm.conf looks like a configured mdadm setup, will not touch it." ; eend 0
1899 if ! checkbootparam 'swraid' ; then
1901 einfo "Just run 'Start mdadm-raid' to assemble md arrays or boot using 'swraid' as bootoption for autostart."
1904 einfo "Bootoption swraid found. Searching for software RAID arrays:"
1909 for line in $(mdadm --assemble --scan --auto=yes --symlink=no 2>&1) ; do
1911 *'No arrays found'*)
1912 ewarn "$line" ; eend 0
1915 einfo "$line" ; eend 0
1922 if [ -r /proc/mdstat ] ; then
1924 MDSTAT=$(grep '^md[0-9]' /proc/mdstat)
1925 if [ -z "$MDSTAT" ] ; then
1926 ewarn "No active arrays found" ; eend 0
1931 for line in $(grep '^md[0-9]' /proc/mdstat) ; do
1932 einfo "active arrays: $line" ; eend 0
1938 fi # bootoption swraid
1940 fi # is /sbin/mdadm executable?
1941 fi # check for bootoptions
1947 [ -n "$INSTALLED" ] && return 0
1949 if checkbootparam 'nodmraid' ; then
1950 ewarn "Skipping dmraid code as requested on boot commandline." ; eend 0
1954 if ! [ -x /sbin/dmraid ] ; then
1955 eerror "dmraid not available, can not execute it." ; eend 1
1960 # usage: dmraid_wrapper <dmraid_option>
1961 [ -n "$1" ] || return 1
1968 for line in $(dmraid $1 ; echo errcode:$?); do
1970 *'no block devices found'*)
1971 einfo "No block devices found" ; eend 0
1975 einfo "No active dmraid devices found" ; eend 0
1994 if checkbootparam 'dmraid' ; then
1995 local ACTION="$(getbootparam 'dmraid' 2>>$DEBUG)"
1996 if [ "$ACTION" = "off" ] ; then
1997 # Deactivates all active software RAID sets:
1998 einfo "Deactivating present dmraid sets (as requested via dmraid=off):"
2001 # Activate all software RAID sets discovered:
2002 einfo "Activating present dmraid sets (as requested via dmraid):"
2009 # by default (no special bootoptions) discover all software RAID devices:
2010 einfo "Searching for any present dmraid sets:"
2015 # {{{ LVM (Logical Volumes)
2017 [ -n "$INSTALLED" ] && return 0
2019 if checkbootparam 'nolvm' ; then
2020 ewarn "Skipping LVM code as requested on boot commandline." ; eend 0
2022 # Debian etch provides /etc/init.d/lvm only, newer suites provide /etc/init.d/lvm2
2023 if ! [ -x /sbin/lvm -a -x /sbin/lvdisplay ] || ! [ -x /etc/init.d/lvm2 -o -x /etc/init.d/lvm ] ; then
2024 eerror "LVM not available, can not execute it." ; eend 1
2026 if lvdisplay 2>&1 | grep -v 'No volume groups found' >/dev/null 2>&1 ; then
2027 einfo "You seem to have logical volumes (LVM) on your system."
2029 einfo "Just run 'Start lvm2' to activate them or boot using 'lvm' as bootoption for autostart."
2031 if checkbootparam 'lvm' ; then
2032 einfo "Bootoption LVM found. Searching for logical volumes:"
2033 /etc/init.d/lvm2 start ; eend $?
2037 fi # check for lvm binary
2038 fi # check for bootoption nolvm
2042 # {{{ debnet: setup network based on an existing one found on a partition
2044 if checkbootparam 'debnet' ; then
2045 einfo "Bootoption 'debnet' found. Searching for Debian network configuration: "
2051 # {{{ disable console blanking
2053 if checkbootparam 'noblank' ; then
2054 einfo "Bootoption noblank found. Disabling monitor blanking."
2055 setterm -blank 0 ; eend $?
2060 # {{{ tohd= bootoption
2063 if checkbootparam 'tohd' ; then
2064 local TARGET="$(getbootparam 'tohd' 2>>$DEBUG)"
2065 if [ -z "$TARGET" ] ; then
2066 eerror "Error: tohd specified without any partition, can not continue." ; eend 1
2067 eerror "Please use something like tohd=/dev/sda9." ; eend 1
2071 if ! [ -b "$TARGET" ] ; then
2072 eerror "Error: $TARGET is not a valid block device, sorry." ; eend 1
2076 if grep -q $TARGET /proc/mounts ; then
2077 eerror "$TARGET already mounted, skipping execution of tohd therefore."
2082 local MOUNTDIR=$(mktemp -d)
2084 if mount -o rw "$TARGET" "$MOUNTDIR" ; then
2085 einfo "Copyring live system to $TARGET - this might take a while"
2086 rsync -a --progress ${LIVECD_PATH}/live $MOUNTDIR
2090 einfo "Booting with \"grml bootfrom=$TARGET\" should work now." ; eend 0
2092 eerror "Error when trying to mount $TARGET, sorry."; eend 1
2101 # {{{ debootstrap: automatic installation
2102 config_debootstrap(){
2104 if checkbootparam "BOOT_IMAGE=debian2hd" || checkbootparam "debian2hd" ; then
2106 einfo "Bootoption debian2hd found. Setting up environment for automatic installation via grml-debootstrap." ; eend 0
2108 if ! [ -x /usr/sbin/grml-debootstrap ] ; then
2110 eerror "Bootoption debian2hd found, but grml-debootstrap is not available." ; eend 1
2115 if checkbootparam 'target' ; then
2117 TARGET="$(getbootparam 'target' 2>>$DEBUG)"
2118 # notice: the following checks whether the given partition is available, if not the skip
2119 # execution of grml-debootstrap as it might result in data loss...
2120 if ! [ -r "$TARGET" ] ; then
2121 eerror "Target $TARGET does not exist. Skipping execution of grml-debootstrap therefore." ; eend 1
2125 eerror "No bootoption named target found, can not continue execution of grml-debootstrap." ; eend 1
2130 if checkbootparam 'grub' ; then
2132 GRUB="$(getbootparam 'grub' 2>>$DEBUG)"
2135 if checkbootparam 'groot' ; then
2137 GROOT="$(getbootparam 'groot' 2>>$DEBUG)"
2140 if checkbootparam 'release' ; then
2142 RELEASE="$(getbootparam 'release' 2>>$DEBUG)"
2145 if checkbootparam 'mirror' ; then
2147 MIRROR="$(getbootparam 'mirror' 2>>$DEBUG)"
2150 if checkbootparam 'boot_append' ; then
2152 BOOT_APPEND="$(getbootparam 'boot_append' 2>>$DEBUG)"
2155 if checkbootparam 'password' ; then
2157 PASSWORD="$(getbootparam 'password' 2>>$DEBUG)"
2160 # now check which options are available
2161 if [ -n "TARGET" ] ; then
2162 TARGETCMD="--target $TARGET"
2166 eerror "Target not set via bootoption. Skipping execution of grml-debootstrap therefore."; eend 1
2170 [ -n "$GRUB" ] && GRUBCMD="--grub $GRUB" || GRUBCMD=''
2171 [ -n "$GROOT" ] && GROOTCMD="--groot $GROOT" || GROOTCMD=''
2172 [ -n "$RELEASE" ] && RELEASECMD="--release $RELEASE" || RELEASECMD=''
2173 [ -n "$MIRROR" ] && MIRRORCMD="--mirror $MIRROR" || MIRRORCMD=''
2174 [ -n "$PASSWORD" ] && PASSWORDCMD="--password $PASSWORD" || PASSWORDCMD=''
2175 [ -n "$BOOT_APPEND" ] && BOOT_APPEND="--boot_append $BOOT_APPEND" || BOOT_APPEND=''
2177 # and finally write script and execute it
2178 cat>|/usr/bin/grml-debootstrap_noninteractive<<EOF
2180 AUTOINSTALL='yes' grml-debootstrap $TARGETCMD $GRUBCMD $GROOTCMD $RELEASECMD $MIRRORCMD $PASSWORDCMD $BOOT_APPEND
2183 chmod 750 /usr/bin/grml-debootstrap_noninteractive
2185 screen /usr/bin/grml-debootstrap_noninteractive
2186 einfo "Invoking a shell, just exit to continue booting..."
2189 fi # checkbootparam "BOOT_IMAGE=debian2hd
2193 config_virtualbox_shared_folders() {
2194 if $VIRTUALBOX ; then
2195 einfo "VirtualBox detected, trying to set up Shared Folders."
2196 if ! modinfo vboxsf &>/dev/null ; then
2197 ewarn "vboxsf driver not present, not setting up VirtualBox Shared Folders."
2199 elif ! [ -x /usr/sbin/VBoxService ] ; then
2200 ewarn "virtualbox-guest-utils not installed, not setting up VirtualBox Shared Folders."
2205 einfo "Loading vboxsf driver."
2206 lsmod | grep -q vboxsf || modprobe vboxsf
2209 einfo "Adjusting /dev/vboxguest."
2210 chown root:vboxsf /dev/vboxguest
2211 chmod 660 /dev/vboxguest
2216 einfo "Adding $fstabuser to group vboxsf."
2217 adduser grml vboxsf &>/dev/null
2220 einfo "Starting VBoxService."
2221 VBoxService >/dev/null &
2229 # {{{ Support customization
2231 if checkbootparam 'distri'; then
2232 DISTRI="$(getbootparam 'distri' 2>>$DEBUG)"
2233 if [ -r "${LIVECD_PATH}"/desktop/"$DISTRI".jpg ] ; then
2234 [ -n "$BOOTDEBUG" ] && einfo "Debug: bootoption distri found and file ${LIVECD_PATH}/desktop/${DISTRI} present" && eend 0
2235 # make sure the desktop.jpg file is not a symlink, so copying does not file then
2236 [ -L /usr/share/grml/desktop.jpg ] && rm /usr/share/grml/desktop.jpg
2237 cp "${LIVECD_PATH}"/desktop/"$DISTRI".jpg /usr/share/grml/desktop.jpg
2243 ## END OF FILE #################################################################
2244 # vim:foldmethod=marker expandtab ai ft=zsh shiftwidth=2