#!/bin/bash

#INPUT:
#		$1, the source directory of the new image files 
#DESC:
#		copy the boot image files to the system boot directory
#CALLER:
#		xorpsh.sh
#RETURN:

. /etc/functions
 
if [ -d "$1" ]; then
    echo 
    echo "Warning: existing boot images will be overridden..."
    echo 

    for file in LB9A.dtb uImage; do
        # TODO: verify checksum
        #if [ x"${1%/}" = x"/mnt/boot1/" ]; then
        #    echo 
        #    echo "Error: The path you just provided is the same to the default one"
        #    echo "    for boot image, please try another path."
        #    echo 
        #    exit 0
        #fi

        if [ -e "$1"/$file ]; then
            cp -f "$1"/$file ${BOOT_DIR}
        else
            echo 
            echo "Cannot boot from iamges under $1: file $file doesn't exist there."
            echo 
            # Break? or exit 0?
            exit 0
        fi
    done
else
    echo "Path $1 doesn't exist, please try again."
fi

exit 0
