0e50f1f
#! /bin/sh -e
0e50f1f
0e50f1f
# update-grub helper script.
0e50f1f
# Copyright (C) 2008  Free Software Foundation, Inc.
0e50f1f
#
0e50f1f
# GRUB is free software: you can redistribute it and/or modify
0e50f1f
# it under the terms of the GNU General Public License as published by
0e50f1f
# the Free Software Foundation, either version 3 of the License, or
0e50f1f
# (at your option) any later version.
0e50f1f
#
0e50f1f
# GRUB is distributed in the hope that it will be useful,
0e50f1f
# but WITHOUT ANY WARRANTY; without even the implied warranty of
0e50f1f
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0e50f1f
# GNU General Public License for more details.
0e50f1f
#
0e50f1f
# You should have received a copy of the GNU General Public License
0e50f1f
# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
0e50f1f
0e50f1f
# The output of this script is copied from part of grub.cfg
0e50f1f
# that correspond to itself. The achievement is that user can
0e50f1f
# modify that part of grub.cfg directly, and it will be persistent
0e50f1f
# across update-grub runs.
0e50f1f
0e50f1f
transform="s&^&&;s,grub,grub2,"
0e50f1f
ME=$(echo $0 |sed 's,/,\\/,g')
0e50f1f
GRUBCFG=/boot/`echo grub | sed ${transform}`/grub.cfg
0e50f1f
0e50f1f
# Exit gracefully if there's no configuration file yet
0e50f1f
[ -f ${GRUBCFG} ] || exit 0
0e50f1f
0e50f1f
awk "
0e50f1f
	BEGIN {echo = 0}
0e50f1f
	/### BEGIN $ME ###/ {echo = 1; next}
0e50f1f
	/### END $ME ###/ {echo = 0; next}
0e50f1f
	{if (echo) print}
0e50f1f
" ${GRUBCFG}