#! /bin/sh set -e # Generate VasEBoot.cfg by inspecting /boot contents. # Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc. # # VasEBoot is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # VasEBoot is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with VasEBoot. If not, see . prefix="@prefix@" exec_prefix="@exec_prefix@" datarootdir="@datarootdir@" prefix="@prefix@" exec_prefix="@exec_prefix@" sbindir="@sbindir@" bindir="@bindir@" sysconfdir="@sysconfdir@" PACKAGE_NAME=@PACKAGE_NAME@ PACKAGE_VERSION=@PACKAGE_VERSION@ host_os=@host_os@ datadir="@datadir@" if [ "x$pkgdatadir" = x ]; then pkgdatadir="${datadir}/@PACKAGE@" fi # export it for scripts export pkgdatadir VasEBoot_cfg="" VasEBoot_mkconfig_dir="${sysconfdir}"/VasEBoot.d self=`basename $0` VasEBoot_probe="${sbindir}/@VasEBoot_probe@" VasEBoot_file="${bindir}/@VasEBoot_file@" VasEBoot_editenv="${bindir}/@VasEBoot_editenv@" VasEBoot_script_check="${bindir}/@VasEBoot_script_check@" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" . "${pkgdatadir}/VasEBoot-mkconfig_lib" # Usage: usage # Print the usage. usage () { gettext_printf "Usage: %s [OPTION]\n" "$self" gettext "Generate a VasEBoot config file"; echo echo print_option_help "-o, --output=$(gettext FILE)" "$(gettext "output generated config to FILE [default=stdout]")" print_option_help "-h, --help" "$(gettext "print this message and exit")" print_option_help "-v, --version" "$(gettext "print the version information and exit")" echo gettext "Report bugs to ."; echo } argument () { opt=$1 shift if test $# -eq 0; then gettext_printf "%s: option requires an argument -- \`%s'\n" "$self" "$opt" 1>&2 exit 1 fi echo $1 } # Check the arguments. while test $# -gt 0 do option=$1 shift case "$option" in -h | --help) usage exit 0 ;; -V | --version) echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" exit 0 ;; -o | --output) VasEBoot_cfg=`argument $option "$@"`; shift;; --output=*) VasEBoot_cfg=`echo "$option" | sed 's/--output=//'` ;; -*) gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2 usage exit 1 ;; # Explicitly ignore non-option arguments, for compatibility. esac done if [ "x$EUID" = "x" ] ; then EUID=`id -u` fi if [ "$EUID" != 0 ] ; then root=f case "`uname 2>/dev/null`" in CYGWIN*) # Cygwin: Assume root if member of admin group for g in `id -G 2>/dev/null` ; do case $g in 0|544) root=t ;; esac done ;; esac if [ $root != t ] ; then gettext_printf "%s: You must run this as root\n" "$self" >&2 exit 1 fi fi set $VasEBoot_probe dummy if test -f "$1"; then : else gettext_printf "%s: Not found.\n" "$1" 1>&2 exit 1 fi # Device containing our userland. Typically used for root= parameter. VasEBoot_DEVICE="`${VasEBoot_probe} --target=device /`" VasEBoot_DEVICE_UUID="`${VasEBoot_probe} --device ${VasEBoot_DEVICE} --target=fs_uuid 2> /dev/null`" || true # Device containing our /boot partition. Usually the same as VasEBoot_DEVICE. VasEBoot_DEVICE_BOOT="`${VasEBoot_probe} --target=device /boot`" VasEBoot_DEVICE_BOOT_UUID="`${VasEBoot_probe} --device ${VasEBoot_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true # Filesystem for the device containing our userland. Used for stuff like # choosing Hurd filesystem module. VasEBoot_FS="`${VasEBoot_probe} --device ${VasEBoot_DEVICE} --target=fs 2> /dev/null || echo unknown`" if [ x"$VasEBoot_FS" = xunknown ]; then VasEBoot_FS="$(stat -f --printf=%T / || echo unknown)" fi if test -f ${sysconfdir}/default/VasEBoot ; then . ${sysconfdir}/default/VasEBoot fi # XXX: should this be deprecated at some point? if [ "x${VasEBoot_TERMINAL}" != "x" ] ; then VasEBoot_TERMINAL_INPUT="${VasEBoot_TERMINAL}" VasEBoot_TERMINAL_OUTPUT="${VasEBoot_TERMINAL}" fi termoutdefault=0 if [ "x${VasEBoot_TERMINAL_OUTPUT}" = "x" ]; then VasEBoot_TERMINAL_OUTPUT=gfxterm; termoutdefault=1; fi for x in ${VasEBoot_TERMINAL_OUTPUT}; do case "x${x}" in xgfxterm) ;; xconsole | xserial | xofconsole | xvga_text) # make sure all our children behave in conformance with ascii.. export LANG=C;; *) echo "Invalid output terminal \"${VasEBoot_TERMINAL_OUTPUT}\"" >&2 ; exit 1 ;; esac done VasEBoot_ACTUAL_DEFAULT="$VasEBoot_DEFAULT" if [ "x${VasEBoot_ACTUAL_DEFAULT}" = "xsaved" ] ; then VasEBoot_ACTUAL_DEFAULT="`"${VasEBoot_editenv}" - list | sed -n '/^saved_entry=/ s,^saved_entry=,,p'`" ; fi # These are defined in this script, export them here so that user can # override them. export VasEBoot_DEVICE \ VasEBoot_DEVICE_UUID \ VasEBoot_DEVICE_BOOT \ VasEBoot_DEVICE_BOOT_UUID \ VasEBoot_FS \ VasEBoot_FONT \ VasEBoot_PRELOAD_MODULES \ VasEBoot_ACTUAL_DEFAULT # These are optional, user-defined variables. export VasEBoot_DEFAULT \ VasEBoot_HIDDEN_TIMEOUT \ VasEBoot_HIDDEN_TIMEOUT_QUIET \ VasEBoot_TIMEOUT \ VasEBoot_TIMEOUT_STYLE \ VasEBoot_DEFAULT_BUTTON \ VasEBoot_HIDDEN_TIMEOUT_BUTTON \ VasEBoot_TIMEOUT_BUTTON \ VasEBoot_TIMEOUT_STYLE_BUTTON \ VasEBoot_BUTTON_CMOS_ADDRESS \ VasEBoot_BUTTON_CMOS_CLEAN \ VasEBoot_DISTRIBUTOR \ VasEBoot_CMDLINE_LINUX \ VasEBoot_CMDLINE_LINUX_DEFAULT \ VasEBoot_CMDLINE_XEN \ VasEBoot_CMDLINE_XEN_DEFAULT \ VasEBoot_CMDLINE_LINUX_XEN_REPLACE \ VasEBoot_CMDLINE_LINUX_XEN_REPLACE_DEFAULT \ VasEBoot_CMDLINE_NETBSD \ VasEBoot_CMDLINE_NETBSD_DEFAULT \ VasEBoot_CMDLINE_GNUMACH \ VasEBoot_TERMINAL_INPUT \ VasEBoot_TERMINAL_OUTPUT \ VasEBoot_SERIAL_COMMAND \ VasEBoot_DISABLE_LINUX_UUID \ VasEBoot_DISABLE_RECOVERY \ VasEBoot_VIDEO_BACKEND \ VasEBoot_GFXMODE \ VasEBoot_BACKGROUND \ VasEBoot_THEME \ VasEBoot_GFXPAYLOAD_LINUX \ VasEBoot_DISABLE_OS_PROBER \ VasEBoot_INIT_TUNE \ VasEBoot_SAVEDEFAULT \ VasEBoot_ENABLE_CRYPTODISK \ VasEBoot_BADRAM \ VasEBoot_OS_PROBER_SKIP_LIST \ VasEBoot_DISABLE_SUBMENU if test "x${VasEBoot_cfg}" != "x"; then rm -f "${VasEBoot_cfg}.new" oldumask=$(umask); umask 077 exec > "${VasEBoot_cfg}.new" umask $oldumask fi gettext "Generating VasEBoot configuration file ..." >&2 echo >&2 cat << EOF # # DO NOT EDIT THIS FILE # # It is automatically generated by $self using templates # from ${VasEBoot_mkconfig_dir} and settings from ${sysconfdir}/default/VasEBoot # EOF for i in "${VasEBoot_mkconfig_dir}"/* ; do case "$i" in # emacsen backup files. FIXME: support other editors *~) ;; # emacsen autosave files. FIXME: support other editors */\#*\#) ;; *) if VasEBoot_file_is_not_garbage "$i" && test -x "$i" ; then echo echo "### BEGIN $i ###" "$i" echo "### END $i ###" fi ;; esac done if test "x${VasEBoot_cfg}" != "x" ; then if ! ${VasEBoot_script_check} ${VasEBoot_cfg}.new; then # TRANSLATORS: %s is replaced by filename gettext_printf "Syntax errors are detected in generated VasEBoot config file. Ensure that there are no errors in /etc/default/VasEBoot and /etc/VasEBoot.d/* files or please file a bug report with %s file attached." "${VasEBoot_cfg}.new" >&2 echo >&2 exit 1 else # none of the children aborted with error, install the new VasEBoot.cfg mv -f ${VasEBoot_cfg}.new ${VasEBoot_cfg} fi fi gettext "done" >&2 echo >&2