2 # Generate kboot.conf by inspecting /boot contents.
3 # Copyright (C) 2011 Antonio Ospite <ospite@studenti.unina.it>
5 # Inspired by kboot-mkconfig
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This progra, is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this software. If not, see <http://www.gnu.org/licenses/>.
22 PACKAGE_NAME=kboot-mkconfig
27 sbindir=${exec_prefix}/sbin
28 bindir=${exec_prefix}/bin
29 libdir=${exec_prefix}/lib
32 datarootdir=${prefix}/share
33 datadir=${datarootdir}
34 pkgdatadir=${datadir}/kboot
44 Generate a kboot config file
46 -o, --output=FILE output generated config to FILE [default=stdout]
47 -h, --help print this message and exit
48 -v, --version print the version information and exit
50 Report bugs to <bug-kboot@gnu.org>.
58 if test $# -eq 0; then
59 echo "$0: option requires an argument -- '$opt'" 1>&2
65 # Check the arguments.
76 echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
79 kboot_conf=`argument $option "$@"`; shift;;
81 kboot_conf=`echo "$option" | sed 's/--output=//'`
84 echo "Unrecognized option \`$option'" 1>&2
88 # Explicitly ignore non-option arguments, for compatibility.
92 . ${libdir}/kboot/kboot-mkconfig_lib
94 if [ "x$EUID" = "x" ] ; then
98 if [ "$EUID" != 0 ] ; then
100 case "`uname 2>/dev/null`" in
102 # Cygwin: Assume root if member of admin group
103 for g in `id -G 2>/dev/null` ; do
109 if [ $root != t ] ; then
110 echo "$self: You must run this as root" >&2
116 if test -f ${sysconfdir}/default/kboot ; then
117 . ${sysconfdir}/default/kboot
121 if [ "x${KBOOT_TIMEOUT}" = "x" ] ; then KBOOT_TIMEOUT=5 ; fi
123 if [ "x${KBOOT_DISTRIBUTOR}" = "x" ] ; then
126 OS="${KBOOT_DISTRIBUTOR} GNU/Linux"
129 # These are optional, user-defined variables.
130 export KBOOT_TIMEOUT \
132 KBOOT_CMDLINE_LINUX \
133 KBOOT_CMDLINE_LINUX_DEFAULT \
134 KBOOT_DISABLE_RECOVERY
136 if test "x${kboot_conf}" != "x"; then
137 rm -f ${kboot_conf}.new
138 exec > ${kboot_conf}.new
140 echo "Generating kboot.conf ..." >&2
144 # DO NOT EDIT THIS FILE
146 # It is automatically generated by $self
147 # with settings from ${sysconfdir}/default/kboot
150 timeout=${KBOOT_TIMEOUT}
154 echo "### BEGIN list of kernels ###"
156 echo "### END list of kernels ###"
158 if test "x${kboot_conf}" != "x" ; then
159 # none of the children aborted with error, install the new kboot.cfg
160 mv -f ${kboot_conf}.new ${kboot_conf}