#!/bin/bash
##########################################################
#                       ddCopy                           #
#--------------------------------------------------------#
# Creates a bootable CD/DVD, USB flash drive             #
#--------------------------------------------------------#
#        © 2023 WTFPL lxgator@gmail.com                  #
##########################################################
Title='ddCopy'
Version='0.3.3'
# Create a tmp folder
rm -rf /tmp/ddcopy 2>&1 > /dev/null
if ! test -d /tmp/ddcopy  ; then
mkdir -p /tmp/ddcopy
chmod 0777 /tmp/ddcopy
fi
NVME=$(grep -o nvme /etc/mtab| awk 'NR==1{print $0}')
if [[ $NVME = "" ]]; then
lsblk | grep -o sd[b-z] | tail -n1 | awk 'NR == 1' >> /tmp/ddcopy/usb_key
else
grep -o sd[a-z] /proc/partitions |tail -n1 >> /tmp/ddcopy/usb_key
fi
sleep 1
if ! [ -s "/tmp/ddcopy/usb_key" ]; then
python3 "/usr/lib64/ddcopy/format_notify.py" &
rm -rf /tmp/ddcopy 2>&1 > /dev/null
exit 0
else
DIR=/usr/lib64/ddcopy
python3 $DIR/ddcopy.py -m format "$@"
rm -rf /tmp/ddcopy 2>&1 > /dev/null
exit 0
fi

