# Authors: grml-team (grml.org), (c) Klaus Knopper <knopper@knopper.net>, (c) Michael Prokop <mika@grml.org>
# Bug-Reports: see http://grml.org/bugs/
# License: This file is licensed under the GPL v2.
-# Latest change: Fre Aug 15 23:06:21 CEST 2008 [mika]
################################################################################
# {{{ path, variables, signals, umask, zsh
checkgrmlusb(){
grep -q usb /etc/grml_version 2>>$DEBUG && return 0 || return 1
}
+
+# execute flite only if it's present
+flitewrapper() {
+ [ -x /usr/bin/flite ] && flite -o play -t "$*"
+}
### }}}
# {{{ filesystems (proc, pts, sys) and fixes
# set default to 'en' in live-cd mode if $LANGUAGE is not yet set:
if [ -z "$INSTALLED" ] ; then
- [ -n "$LANGUAGE" ] || LANGUAGE='en-utf8'
+ [ -n "$LANGUAGE" ] || LANGUAGE='us'
fi
# if bootoption lang is used update /etc/default/locale, otherwise *not*!
- if [ -n "$BOOT_LANGUAGE" ] ; then
- [ -x /usr/sbin/grml-setlang ] && /usr/sbin/grml-setlang "$LANGUAGE"
+ if [ -n "$BOOT_LANGUAGE" -a -x /usr/sbin/grml-setlang ] ; then
+ if checkgrmlsmall ; then
+ /usr/sbin/grml-setlang "POSIX"
+ else
+ /usr/sbin/grml-setlang "$LANGUAGE"
+ fi
fi
# set console font
config_time(){
# don't touch the files if running from harddisk:
if [ -z "$INSTALLED" ]; then
- UTC=""
+ # The default hardware clock timezone is stated as representing local time.
+ UTC="--localtime"
checkbootparam utc >>$DEBUG 2>&1 && UTC="-u"
checkbootparam gmt >>$DEBUG 2>&1 && UTC="-u"
# hwclock uses the TZ variable
- [ -r /etc/timezone ] && TZ=$(cat /etc/timezone)
- [ -n "$TZ" ] || TZ=Europe/Vienna
+ KTZ="$(getbootparam tz 2>>$DEBUG)"
+ [ -z "$KTZ" ] && [ -r /etc/timezone ] && KTZ=$(cat /etc/timezone)
+ [ -z "$KTZ" ] && KTZ=Europe/Vienna
if ! [ -r /dev/rtc ] ; then
- ewarn "Realtime clock not available, skipping execution of hwclock therefore." ; eend 0
- else
- ERROR=$(TZ="$TZ" hwclock $UTC -s 2>&1 | head -1) ; RC=$?
- if [ -n "$ERROR" ] ; then
- eindent
- ERROR=$(TZ="$TZ" hwclock $UTC -s --directisa 2>&1 | head -1)
- if [ -n "$ERROR" ] ; then
- eerror "Problem running hwclock: $ERROR" ; eend 1
- fi
- eoutdent
- fi
+ ewarn "Warning: realtime clock not available, trying to execute hwclock anyway." ; eend 0
+ fi
+
+ ERROR=$(TZ="$TZ" hwclock $UTC -s 2>&1 | head -1) ; RC=$?
+ if [ -n "$ERROR" ] ; then
+ eindent
+ ERROR=$(TZ="$TZ" hwclock $UTC -s --directisa 2>&1 | head -1)
+ if [ -n "$ERROR" ] ; then
+ eerror "Problem running hwclock: $ERROR" ; eend 1
+ fi
+ eoutdent
fi
+
fi
}
# }}}
# {{{ run software synthesizer via speakup
config_swspeak(){
-if checkbootparam swspeak ; then
- if [ -d /proc/speakup/ ] ; then
- einfo "Bootoption swspeak found. Kernel supports speakup." ; eend 0
- eindent
- if [ -x /etc/init.d/speech-dispatcher ] ; then
- einfo "Starting speech-dispatcher."
- /etc/init.d/speech-dispatcher start 1>>DEBUG ; eend $?
- einfo "Activating sftsyn in Kernel."
- echo sftsyn >/proc/speakup/synth_name ; eend $?
- einfo "Just run swspeak if you want to use software synthesizer via speakup."
- flite -o play -t "Finished activating software speakup. Just run swspeak when booting finished."
- else
- eerror "speech-dispatcher not available. swspeak will not work without it." ; eend 1
- flite -o play -t "speech-dispatcher not available. speakup will not work without it."
+ if checkbootparam swspeak ; then
+ einfo "Bootoption swspeak found."
+
+ if [ ! -d /proc/speakup/ ] && ! grep -q speakup_soft /proc/modules ; then
+ ewarn "Kernel does not support software speakup - trying to load kernel module:" ; eend 0
+ eindent
+ einfo "Loading speakup_soft"
+ if modprobe speakup_soft ; then
+ eend 0
+ else
+ flitewrapper "Fatal error setting up software speakup"
+ eend 1
+ return 1
+ fi
+ eoutdent
+ fi
+
+ if [ -d /proc/speakup/ ] || grep -q speakup_soft /proc/modules ; then
+ einfo "Kernel supports speakup." ; eend 0
+ eindent
+ einfo "Just run swspeak if you want to use software synthesizer via speakup."
+ flitewrapper "Finished activating software speakup. Just run swspeak when booting finished."
+ eoutdent
+ else
+ eerror "Kernel does not seem to support speakup. Skipping swspeak." ; eend 1
+ flitewrapper "Kernel does not seem to support speakup. Sorry."
+ fi
+ fi
+}
+# }}}
+
+# {{{ support hardware synthesizer via speakup
+config_hwspeak(){
+ if checkbootparam hwspeak ; then
+ einfo "Bootoption hwspeak found."
+
+ if [ ! -d /proc/speakup/ ] && ! grep -q speakup /proc/modules ; then
+ ewarn" Kernel does not support hardware speakup - trying to load kernel modules:" ; eend 0
+ eindent
+ for module in $(find "/lib/modules/${KERNEL}/extra/speakup/" -name \*.ko | \
+ sed 's#.*speakup/##g ; s#.ko$##g' | \
+ grep -ve speakup_soft -ve speakup_dummy | sort -u) ; do
+ einfo "Trying to load $module"
+ modprobe $module
+ eend $?
+ done
+ eoutdent
+ fi
+
+ if [ -d /proc/speakup/ ] || grep -q speakup /proc/modules ; then
+ einfo "Kernel should support speakup now." ; eend 0
+ flitewrapper "Kernel should support speakup now."
+ else
+ eerror "Kernel or hardware do not seem to support speakup. Skipping hwspeak." ; eend 1
+ flitewrapper "Kernel or hardware do not seem to support speakup. Sorry."
+ fi
fi
- eoutdent
- else
- eerror "Kernel does not seem to support speakup. Skipping swspeak." ; eend 1
- flite -o play -t "Kernel does not seem to support speakup. Sorry."
- fi
-fi
}
# }}}
einfo "Bootoption ssh found, trying to set password for user grml."
eindent
if [ -z "$SSH_PASSWD" ] ; then
- if [ -x /usr/bin/pwgen ] ; then
+ if [ -x /usr/bin/apg ] ; then
+ SSH_PASSWD="$(apg -M NL -a 0 -m 8 -x 12 -n 1)"
+ elif [ -x /usr/bin/gpw ] ; then
+ SSH_PASSWD="$(gpw 1)"
+ elif [ -x /usr/bin/pwgen ] ; then
SSH_PASSWD="$(pwgen -1 8)"
elif [ -x /usr/bin/hexdump ] ; then
SSH_PASSWD="$(dd if=/dev/urandom bs=14 count=1 2>/dev/null | hexdump | awk '{print $3 $4}')"
config_blindsound(){
if checkbootparam "blind" ; then
beep
- flite -o play -t "welcome to the gremel system"
+ flitewrapper "welcome to the gremel system"
fi
}
# }}}
# {{{ welcome sound
config_welcome(){
if checkbootparam welcome ; then
- flite -o play -t "welcome to the gremel system"
+ flitewrapper "welcome to the gremel system"
fi
}
# }}}
}
# }}}
+# {{{ tohd= bootoption
+config_tohd()
+{
+ if checkbootparam "tohd" ; then
+ local TARGET="$(getbootparam 'tohd' 2>>$DEBUG)"
+ if [ -z "$TARGET" ] ; then
+ eerror "Error: tohd specified without any partition, can not continue." ; eend 1
+ eerror "Please use something like tohd=/dev/sda9." ; eend 1
+ return 1
+ fi
+
+ if ! [ -b "$TARGET" ] ; then
+ eerror "Error: $TARGET is not a valid block device, sorry." ; eend 1
+ return 1
+ fi
+
+ if grep -q $TARGET /proc/mounts ; then
+ eerror "$TARGET already mounted, skipping execution of tohd therefore."
+ eend 1
+ return 1
+ fi
+
+ local MOUNTDIR=$(mktemp -d)
+
+ if mount -o rw "$TARGET" "$MOUNTDIR" ; then
+ einfo "Copyring live system to $TARGET - this might take a while"
+ rsync -a --progress /live/image/live $MOUNTDIR
+ sync
+ umount "$MOUNTDIR"
+ eend $?
+ einfo "Booting with \"grml bootfrom=$TARGET\" should work now." ; eend 0
+ else
+ eerror "Error when trying to mount $TARGET, sorry."; eend 1
+ return 1
+ fi
+
+ rmdir "$MOUNTDIR"
+ fi
+}
+# }}}
+
# {{{ grml2hd: automatic installation
config_grml2hd(){