#! /bin/sh

set -e

if [ -n "$DEB_MAINT_PARAMS" ]; then
    eval set -- "$DEB_MAINT_PARAMS"
    if [ -z "$1" ] || [ "$1" != "configure" ]; then
        exit 0;
    fi
fi

# copy sun20i_d1_nezha.dtb to /media/boot/ in case it exists
if [ -f /boot/sun20i_d1_nezha.dtb ]; then
        if [ -d /media/boot ]; then
                cp /boot/sun20i_d1_nezha.dtb /media/boot/
        fi
fi

# copy sun20i-d1-nezha.dtb to /media/boot/ in case it exists
if [ -f /boot/sun20i-d1-nezha.dtb ]; then
        if [ -d /media/boot ]; then
                cp /boot/sun20i-d1-nezha.dtb /boot/sun20i-d1-licheerv-86panel.dtb /boot/sun20i-d1-licheerv-dock.dtb /media/boot/
        fi
fi

if [ -f /media/boot/sun20i-d1-nezha.dtb ]; then
	cp /media/boot/sun20i-d1-nezha.dtb /media/boot/dtb
fi

# copy sun20i-d1-nezha-linux.dtb to /media/boot/ in case it exists
if [ -f /boot/sun20i-d1-nezha-linux.dtb ]; then
        if [ -d /media/boot ]; then
                cp /boot/sun20i-d1-nezha-linux.dtb /media/boot/
        fi
fi

if [ -f /media/boot/sun20i-d1-nezha-linux.dtb ]; then
	cp /media/boot/sun20i-d1-nezha-linux.dtb /media/boot/dtb
fi

