#!/bin/bash # errors ERR_FOLDER_NOT_EXISTS=1 ERR_COPY_FAIL=2 # variables SOURCES="$HOME/leahi-distro/tmp/deploy/images/ccimx8mm-dvk" DEST_WINDW="/mnt/c/Users/Administrator/ely/images/" DEST_EXTRA="$HOME/leahi-distro-image" #Functions usage() { echo " --- usage ---" echo "./copy_wsl.sh [-W] [-I] [-h,--help]" echo " -W" echo " When present will copy the images into the following folder maped from windows to the wsl:" echo " $DEST_WINDW" echo " -I" echo " Extra location to copy the images into." echo " -h,--help or empty call" echo " Current help" } folder_exists() { if [ ! -d "$1" ];then echo "Folder does not exist." echo "<$1>" exit $ERR_FOLDER_NOT_EXISTS fi } copy_file() { echo "copy $1" cp "$1" . local res=$? if [[ ! $res -eq 0 ]];then echo "FAILED <$res>" exit $ERR_COPY_FAIL fi } copy_to_folder() { # DEBUG: exit 0 folder_exists "$1" # if not will exit. cd "$1" copy_file ${SOURCES}/dey-image-qt-fb-ccimx8mm-dvk.boot.vfat copy_file ${SOURCES}/dey-image-qt-fb-ccimx8mm-dvk.ext4.gz copy_file ${SOURCES}/dey-image-qt-fb-ccimx8mm-dvk.recovery.vfat copy_file ${SOURCES}/imx-boot-ccimx8mm-dvk.bin copy_file ${SOURCES}/install_linux_fw_uuu.sh copy_file ${HOME}/leahi-distro/sources/meta-leahi/sdk/uuu copy_file ${HOME}/leahi-distro/sources/meta-leahi/sdk/uuu.exe echo "Successful!" } has_arg() { local needle=$1 shift for arg in "$@"; do [[ "$arg" == "$needle" ]] && return 0 done return 1 } if [[ "$#" -eq 0 ]] || has_arg "-h" "$@" || has_arg "--help" "$@" ; then usage exit 0 fi if has_arg "-W" "$@"; then echo "Copy to the $DEST_WINDW" copy_to_folder "$DEST_WINDW" fi if has_arg "-I" "$@"; then echo "Copy to the $DEST_EXTRA" copy_to_folder "$DEST_EXTRA" fi exit 0