2 # Generate kboot.conf by inspecting /boot contents.
3 # Copyright (C) 2011 Antonio Ospite <ospite@studenti.unina.it>
5 # Inspired by grub-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
31 datarootdir=${prefix}/share
32 datadir=${datarootdir}
33 pkgdatadir=${datadir}/kboot
43 Generate a kboot config file
45 -o, --output=FILE output generated config to FILE [default=stdout]
46 -h, --help print this message and exit
47 -v, --version print the version information and exit
49 Report bugs to <bug-kboot@gnu.org>.
57 if test $# -eq 0; then
58 echo "$0: option requires an argument -- '$opt'" 1>&2
64 # Check the arguments.
75 echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
78 kboot_conf=`argument $option "$@"`; shift;;
80 kboot_conf=`echo "$option" | sed 's/--output=//'`
83 echo "Unrecognized option \`$option'" 1>&2
87 # Explicitly ignore non-option arguments, for compatibility.
91 . ${datadir}/kboot/kboot-mkconfig_lib
93 if [ "x$EUID" = "x" ] ; then
97 if [ "$EUID" != 0 ] ; then
99 case "`uname 2>/dev/null`" in
101 # Cygwin: Assume root if member of admin group
102 for g in `id -G 2>/dev/null` ; do
108 if [ $root != t ] ; then
109 echo "$self: You must run this as root" >&2
115 if test -f ${sysconfdir}/default/kboot ; then
116 . ${sysconfdir}/default/kboot
120 if [ "x${KBOOT_TIMEOUT}" = "x" ] ; then KBOOT_TIMEOUT=5 ; fi
122 if [ "x${KBOOT_DISTRIBUTOR}" = "x" ] ; then
125 OS="${KBOOT_DISTRIBUTOR} GNU/Linux"
128 # These are optional, user-defined variables.
129 export KBOOT_TIMEOUT \
131 KBOOT_CMDLINE_LINUX \
132 KBOOT_CMDLINE_LINUX_DEFAULT \
133 KBOOT_DISABLE_RECOVERY
135 if test "x${kboot_conf}" != "x"; then
136 rm -f ${kboot_conf}.new
137 exec > ${kboot_conf}.new
139 echo "Generating kboot.conf ..." >&2
143 # DO NOT EDIT THIS FILE
145 # It is automatically generated by $self
146 # with settings from ${sysconfdir}/default/kboot
149 timeout=${KBOOT_TIMEOUT}
153 echo "### BEGIN list of kernels ###"
155 echo "### END list of kernels ###"
157 if test "x${kboot_conf}" != "x" ; then
158 # none of the children aborted with error, install the new kboot.cfg
159 mv -f ${kboot_conf}.new ${kboot_conf}