[Updated] idd.sh: Added checks for file and block devices
This commit is contained in:
parent
fb08632381
commit
0cff8f4962
21
idd.sh
21
idd.sh
@ -30,6 +30,20 @@ Options(){
|
|||||||
printf "${BWHITE}[Q]${NC} - Quit\n"
|
printf "${BWHITE}[Q]${NC} - Quit\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckFile(){
|
||||||
|
if [ ! -f "${1}" ];then
|
||||||
|
printf "${LRED}${1} is not a valid file path${NC}\n"
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckDev(){
|
||||||
|
if [ ! -b "${1}" ];then
|
||||||
|
printf "${LRED}${1} is not a valid block device${NC}\n"
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
Quit(){
|
Quit(){
|
||||||
if [ "${1}" = "q" ];then
|
if [ "${1}" = "q" ];then
|
||||||
echo
|
echo
|
||||||
@ -63,6 +77,7 @@ case "$1" in
|
|||||||
|
|
||||||
printf "${YELLOW}Copy & paste full file path here: ${NC}"
|
printf "${YELLOW}Copy & paste full file path here: ${NC}"
|
||||||
read filepath
|
read filepath
|
||||||
|
CheckFile ${filepath}
|
||||||
Quit ${filepath}
|
Quit ${filepath}
|
||||||
clear
|
clear
|
||||||
Options
|
Options
|
||||||
@ -74,6 +89,8 @@ case "$1" in
|
|||||||
echo
|
echo
|
||||||
printf "${YELLOW}Enter name of device${NC} (${LCYAN}example${NC}, ${LBLUE}sdb${NC}): "
|
printf "${YELLOW}Enter name of device${NC} (${LCYAN}example${NC}, ${LBLUE}sdb${NC}): "
|
||||||
read devname
|
read devname
|
||||||
|
DEVPATH="${DEVICEDIR}/${devname}"
|
||||||
|
CheckDev ${DEVPATH}
|
||||||
Quit ${devname}
|
Quit ${devname}
|
||||||
|
|
||||||
echo
|
echo
|
||||||
@ -109,6 +126,7 @@ case "$1" in
|
|||||||
|
|
||||||
printf "${YELLOW}Copy & paste full file path here: ${NC}"
|
printf "${YELLOW}Copy & paste full file path here: ${NC}"
|
||||||
read filepath
|
read filepath
|
||||||
|
CheckFile ${filepath}
|
||||||
|
|
||||||
Quit ${filepath}
|
Quit ${filepath}
|
||||||
|
|
||||||
@ -122,6 +140,9 @@ case "$1" in
|
|||||||
echo
|
echo
|
||||||
printf "${YELLOW}Enter name of device${NC} (${LCYAN}example${NC}, ${LBLUE}sdb${NC}): "
|
printf "${YELLOW}Enter name of device${NC} (${LCYAN}example${NC}, ${LBLUE}sdb${NC}): "
|
||||||
read devname
|
read devname
|
||||||
|
|
||||||
|
DEVPATH="${DEVICEDIR}/${devname}"
|
||||||
|
CheckDev ${DEVPATH}
|
||||||
Quit ${devname}
|
Quit ${devname}
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user