#!/bin/sh

set -e

if [ $(multipath -l | grep '^mpath[a-z]\+' | wc -l) -eq 0 ]; then
	exit 0
fi

apt-install multipath-tools-boot || true

if [ -r /etc/multipath.conf ]; then
	cp /etc/multipath.conf /target/etc/multipath.conf
fi

# copy over wwids 
if [ -r /etc/multipath/wwids ]; then
	mkdir -p /target/etc/multipath
	cp /etc/multipath/wwids /target/etc/multipath/
fi

# copy over the persistent binding (in /etc)
if [ -r /etc/multipath/bindings ]; then
	mkdir -p /target/etc/multipath
	cp /etc/multipath/bindings /target/etc/multipath/
fi

# copy over the persistent binding
if [ -r /var/lib/multipath/bindings ]; then
	mkdir -p /target/var/lib/multipath
	cp /var/lib/multipath/bindings /target/var/lib/multipath/
fi

# the initramfs will be updated by the kernel installation
