#!/bin/sh

# Initramfs hook script
# Script name: live-rw
# Script location: /usr/share/initramfs-tools/hooks/

# Support RW mount of the live-media partition.
# Replace /lib/live/boot/9990-misc-helpers.sh with a modified version.
# The modified version resides at /usr/lib/live-boot-rw/
# New, optional cmdline parameter "mountmode=rw".is introduced.

# Must be run after "/usr/share/initramfs-tools/hooks/live":
PREREQ="live"

prereqs()
{
	echo "$PREREQ"
}
case $1 in
prereqs)
	prereqs
	exit 0
	;;
esac

. /usr/share/initramfs-tools/hook-functions

# Begin real processing below this line

if [ -x "/usr/lib/live-boot-rw/9990-misc-helpers.sh" ]; then
	echo "Running live-boot-rw initramfs hook script..."
	rm -f "${DESTDIR}/lib/live/boot/9990-misc-helpers.sh"
	cp -v "/usr/lib/live-boot-rw/9990-misc-helpers.sh" "${DESTDIR}/lib/live/boot/"
fi

exit 0
