[Lunar-commits] CVS: theedge/var/lib/lunar/plugins bootloader-lilo.plugin, NONE, 1.1 bootloader-grub.plugin, NONE, 1.1

Auke Kok sofar at lunar-linux.org
Sun Mar 27 22:02:33 UTC 2005


Update of /var/cvs/lunar/theedge/var/lib/lunar/plugins
In directory espresso.foo-projects.org:/tmp/cvs-serv14505/var/lib/lunar/plugins

Added Files:
	bootloader-lilo.plugin bootloader-grub.plugin 
Log Message:
Moving bootloader code to plugins: we need to move the plugins out to the moonbase-modules later on.


--- NEW FILE: bootloader-lilo.plugin ---
#!/bin/bash
#############################################################
#                                                           #
# bootloader-lilo.plugin - plugin that performs lilo.conf   #
#                          maintenance                      #
#                                                           #
#############################################################
#                                                           #
# Copyright 2005 by Auke Kok under GPLv2                    #
#                                                           #
#############################################################


plugin_kernel_updatebootloader_lilo() {
	# preferred? - master switch for experienced users
	if [ -n "$BOOTLOADER" -a "$BOOTLOADER" != "lilo" ]; then
		return 2
	fi
	debug_msg "plugin_kernel_updatebootloader_lilo ($@)"

	if ! ( grep -q "$1" /etc/lilo.conf && grep -q "$1.old" /etc/lilo.conf ) ; then
		IFS_OLD=$IFS
		export IFS="
"
		rm -rf /etc/lilo.conf.new
		cp /etc/lilo.conf /etc/lilo.conf.old

		(( IMAGE_COUNT=0 ))
		for LINE in $(cat /etc/lilo.conf) ; do
			if echo $LINE | grep -q "image" || echo $LINE | grep -q "other" ; then
				echo >> /etc/lilo.conf.new
				if (( IMAGE_COUNT == 0 )) ; then
					if ! grep -q "$1" /etc/lilo.conf ; then
						printf "\nimage = %s\n    label = %s\n    read-only\n\n" "/boot/$1" "$2" >> /etc/lilo.conf.new
				fi
					if [ -f "/boot/$1.old" ] && ! grep -q "$1.old" /etc/lilo.conf ; then
						printf "\nimage = %s\n    label = %s\n    read-only\n\n"  "/boot/$1.old" "$2.old" >> /etc/lilo.conf.new
					fi
				fi
				(( IMAGE_COUNT++ ))
			fi
			if (( IMAGE_COUNT == 14 )) ; then
				break
			fi
			echo $LINE >> /etc/lilo.conf.new
		done

		if (( IMAGE_COUNT == 0 )) ; then
			echo >> /etc/lilo.conf.new
			if ! grep -q "$1" /etc/lilo.conf ; then
				printf "\nimage = %s\n    label = %s\n    read-only\n\n" "/boot/$1" "$2" >> /etc/lilo.conf.new
			fi
			if [ -f /boot/"$1.old" ] && ! grep -q "$1.old" /etc/lilo.conf ; then
				printf "\nimage = %s\n    label = %s\n    read-only\n\n"  "/boot/$1.old" "$2.old" >> /etc/lilo.conf.new
			fi
		fi

		cp /etc/lilo.conf.new /etc/lilo.conf
		export IFS=$IFS_OLD
	fi

    if query "Edit lilo configuration manually ?" n ; then
		edit_file /etc/lilo.conf
	fi

	/sbin/lilo
	sleep 4

	# right now we want to have it run all bootloaders?
	return 2
}


plugin_register KERNEL_UPDATEBOOTLOADER plugin_kernel_updatebootloader_lilo



--- NEW FILE: bootloader-grub.plugin ---
#!/bin/bash
#############################################################
#                                                           #
# bootloader-grub.plugin - plugin that performs grub        #
#                          maintenance                      #
#                                                           #
#############################################################
#                                                           #
# Copyright 2005 by Auke Kok under GPLv2                    #
#                                                           #
#############################################################


plugin_kernel_updatebootloader_grub() {
	# preferred? - master switch for experienced users
	if [ -n "$BOOTLOADER" -a "$BOOTLOADER" != "grub" ]; then
		return 2
	fi
	debug_msg "plugin_kernel_updatebootloader_grub ($@)"

	if ! ( grep -q "$1" /boot/grub/menu.lst && grep -q "$1.old" /boot/grub/menu.lst ) ; then
		IFS_OLD=$IFS
		export IFS="
"

		rm -rf /boot/grub/menu.lst.new
		cp /boot/grub/menu.lst /boot/grub/menu.lst.old

		(( IMAGE_COUNT=0 ))
		for LINE in $(cat /boot/grub/menu.lst) ; do
			if echo $LINE | grep -q "title" ; then
				# To create a separating line between entries
				echo "" >> /boot/grub/menu.lst.new

				if (( IMAGE_COUNT == 0 )) ; then
					if ! grep -q "$1" /boot/grub/menu.lst ; then
						printf "title   %s\nkernel  %s\nroot    %s\n\n" $2 $GRUB_BOOT/$1 $GRUB_ROOT "$GRUB_IMAGE_ENTRY" >> /boot/grub/menu.lst.new
					fi
				 if [ -f /boot/"$1.old" ] && ! grep -q "$1.old" /boot/grub/menu.lst ; then
						printf "title   %s\nkernel  %s\nroot    %s\n\n" $2.old $GRUB_BOOT/$1.old $GRUB_ROOT "$GRUB_IMAGE_ENTRY" >> /boot/grub/menu.lst.new
					fi
				fi
				(( IMAGE_COUNT++ ))
			fi
			if (( IMAGE_COUNT == 14 )) ; then
				break
			fi
			echo $LINE >> /boot/grub/menu.lst.new
		done

		if (( IMAGE_COUNT == 0 )) ; then
			if ! grep -q "$1" /boot/grub/menu.lst ; then
				printf "title   %s\nkernel  %s\nroot    %s\n\n" $2 $GRUB_BOOT/$1 $GRUB_ROOT "$GRUB_IMAGE_ENTRY" >> /boot/grub/menu.lst.new
			fi
			if [ -f /boot/"$1.old" ] && ! grep -q "$1.old" /boot/grub/menu.lst ; then
				printf "title   %s\nkernel  %s\nroot    %s\n\n" $2.old $GRUB_BOOT/$1.old $GRUB_ROOT "$GRUB_IMAGE_ENTRY" >> /boot/grub/menu.lst.new
			fi
		fi

		cp /boot/grub/menu.lst.new /boot/grub/menu.lst
		export IFS=$IFS_OLD
	fi

	if query "Edit grub configuration manually ?" n ; then
		edit_file /boot/grub/menu.lst
	fi

cat << EOF
* * * * * * * * * * * * * * * * * * * * * * * *
*                                             *
*              W A R N I N G                  *
*                                             *
*  Do not forget to install grub to your MBR  *
*  if you haven't done so before rebooting    *
*                                             *
* * * * * * * * * * * * * * * * * * * * * * * *
EOF

	# right now we want to have it run all bootloaders?
	return 2
}


plugin_register KERNEL_UPDATEBOOTLOADER plugin_kernel_updatebootloader_grub





More information about the Lunar-commits mailing list