#!/bin/sh

# This script renames multipath partitions using in-target names that
# use -part separator, and mirrors the partman/init.d script. The
# partitions should be named as for in-target from now such that
# lvm2's backup can record in-target like names, and cruitially such
# that cryptsetup can generate valid crypttab in the initrd.
#
# And at the end remove the stamp file, such that init.d script is
# rerun, if partman is restarted.
#
if [ -f /var/lib/partman/multipath ] \
&& [ "$(udpkg --print-os)" = linux ] ; then

	for mpath in $(multipath -l -v1); do
		kpartx -avp -part /dev/mapper/$mpath
	done

	update-dev --settle >/dev/null 2>&1

	rm /var/lib/partman/multipath
fi

exit 0

