add check on blockdevice

This commit is contained in:
Tobias Powalowski 2024-08-13 23:25:12 +02:00
parent 0e47c265fc
commit 8798835dd1
2 changed files with 29 additions and 21 deletions

View file

@ -22,9 +22,13 @@ echo -e "\e[91mWARNING: 10 seconds for hitting CTRL+C to stop the process on $*
sleep 10
#shellcheck disable=SC2068
for i in $@; do
if [[ -b "${i}" ]]; then
echo -e "\e[1mSTEP 1/2:\e[m Cleaning ${i} filesystem signatures..."
wipefs -f -a "${i}"
echo -e "\e[1mSTEP 2/2:\e[m Cleaning ${i} partition table..."
dd if=/dev/zero of="${i}" bs=1M count=10
echo -e "\e[1mFinished ${i}.\e[m"
else
echo -e "\e[1m\e[91mError: ${i} not a valid blockdevice! \e[m"
fi
done

View file

@ -16,6 +16,7 @@ _usage()
##################################################
[[ -z "${1}" ]] && _usage
_root_check
if [[ -b "${1}" ]]; then
echo -e "\e[91mWARNING: 10 seconds for hitting CTRL+C to stop the process on ${1} now! \e[m"
sleep 10
# clean partitiontable
@ -41,3 +42,6 @@ sleep 5
echo -e "\e[1mSTEP 3/3:\e[m Create FAT32 filesystem..."
mkfs.vfat -F32 "${1}"1
echo -e "\e[1mFinished.\e[m"
else
echo -e "\e[1m\e[91mError: ${1} not a valid blockdevice! \e[m"
fi