[Updated] idd.sh: Added confirmation prompt before writing to device
This commit is contained in:
parent
1df031fe3f
commit
522522bf90
24
idd.sh
24
idd.sh
@ -44,6 +44,24 @@ CheckDev(){
|
||||
fi
|
||||
}
|
||||
|
||||
ConfirmWrite(){
|
||||
echo
|
||||
printf "${YELLOW}Are you sure you want to write changes to${NC} ${LRED}${2}${NC}${YELLOW}?${NC}\n"
|
||||
printf "${YELLOW}This will overwrite existing data${NC}\n"
|
||||
printf "${YELLOW}[y/n]: ${NC}"
|
||||
read choice
|
||||
|
||||
if [ "${choice}" = "n" ];then
|
||||
echo
|
||||
printf "${LRED}Aborted!${NC}\n"
|
||||
exit 0;
|
||||
else
|
||||
echo
|
||||
printf "${YELLOW}Writing data:${NC}\n"
|
||||
printf "${LGREEN}${1}${NC} --> ${LPURPLE}${2}${NC}\n"
|
||||
echo
|
||||
fi
|
||||
}
|
||||
Quit(){
|
||||
if [ "${1}" = "q" ];then
|
||||
echo
|
||||
@ -92,11 +110,10 @@ case "$1" in
|
||||
Quit ${devname}
|
||||
DEVPATH="${DEVICEDIR}/${devname}"
|
||||
CheckDev ${DEVPATH}
|
||||
ConfirmWrite ${filepath} ${DEVPATH}
|
||||
|
||||
|
||||
echo
|
||||
|
||||
printf "${YELLOW}Writing${NC} ${LGREEN}${filepath}${NC} to ${LGREEN}/dev/${devname}${NC}\n"
|
||||
printf "${LCYAN}Please wait ...${NC}\n"
|
||||
echo
|
||||
pv -tpreb ${filepath} | dd of=${DEVICEDIR}/${devname};sync
|
||||
@ -144,10 +161,9 @@ case "$1" in
|
||||
Quit ${devname}
|
||||
DEVPATH="${DEVICEDIR}/${devname}"
|
||||
CheckDev ${DEVPATH}
|
||||
ConfirmWrite ${filepath} ${DEVPATH}
|
||||
|
||||
echo
|
||||
|
||||
printf "${YELLOW}Writing${NC} ${LGREEN}${filepath}${NC} to ${LGREEN}/dev/${devname}${NC}\n"
|
||||
printf "${LCYAN}Please wait ...${NC}\n"
|
||||
echo
|
||||
pv -tpreb ${filepath} | dd of=${DEVICEDIR}/${devname};sync
|
||||
|
Loading…
x
Reference in New Issue
Block a user