Compare commits

...

5 Commits
0.0.1 ... dev

Author SHA1 Message Date
80c87e282b Some infos update 2024-05-07 02:23:49 +02:00
4922d1e369 Some infos update 2024-05-07 02:23:06 +02:00
080ac737fe Some infos update 2024-05-07 02:19:19 +02:00
8504eafa48 Identation and end status + 500M step 2024-05-07 02:06:22 +02:00
87be64e61b add wipe status (100Gb step) 2024-05-07 01:53:45 +02:00

View File

@ -1,82 +1,89 @@
#!/bin/bash #!/bin/bash
declare -r DEV="${1}" declare -r DEV="${1}"
declare STARTDATE=""
declare STARTDATESTRING=""
show_help() { show_help() {
echo "ddwipe dev (/dev/sdX)" echo "ddwipe dev (/dev/sdX)"
echo "" echo ""
echo "Version : 0.0.3" echo "Version : 0.0.3"
} }
check_args() { check_args() {
if [ "${1}" == "" ]; then if [ "${1}" == "" ]; then
show_help show_help
exit 1 exit 1
fi fi
} }
check_dev_exist() { check_dev_exist() {
if [ ! -e "${1}" ]; then if [ ! -e "${1}" ]; then
echo "${1} is missing." echo "${1} is missing."
exit 1 exit 1
fi fi
} }
confirm_wipe() { confirm_wipe() {
lsblk "${1}" lsblk "${1}"
echo "" echo ""
read -r -p "Wipe ${1} (y/[n])?" CHOICE read -r -p "Wipe ${1} (y/[n])?" CHOICE
case "${CHOICE}" in case "${CHOICE}" in
y|Y ) echo "";; y|Y ) echo "";;
* ) * )
echo "Canceled" echo "Canceled"
exit 1 exit 1
;; ;;
esac esac
} }
wipe_dev() { wipe_dev() {
echo "Begin wiping device ${1}" STARTDATE=$(date +%s)
echo "" STARTDATESTRING="$(date)"
echo "Start date :" echo "Begin wiping device ${1}"
date echo ""
echo "" echo "Start date :"
echo "blkdiscard secure" echo "${STARTDATESTRING}"
if ! blkdiscard -f -p 1G -s "${1}"; then echo ""
echo "" echo "blkdiscard secure"
echo "blkdiscard zero" if ! blkdiscard -f -p 500M -s -v "${1}"; then
if ! blkdiscard -f -p 1G -z "${1}"; then echo ""
echo "" echo "blkdiscard zero"
echo "dd zero" if ! blkdiscard -f -p 500M -z -v "${1}"; then
if ! dd if=/dev/zero of="${1}" bs=1M status=progress; then echo ""
# Need check if dd has all writed, if yes, return no error echo "dd zero"
# echo "Error wiping device ${1}, use phisical destroy !" if ! dd if=/dev/zero of="${1}" bs=1M status=progress; then
echo "Wiped with dd, check if full size is writed." # Need check if dd has all writed, if yes, return no error
echo "Otherwise use a mechanical destruction of the device." # echo "Error wiping device ${1}, use phisical destroy !"
print_time echo "Wiped with dd, check if full size is writed."
exit 1 echo "Otherwise use a mechanical destruction of the device."
fi print_time
fi exit 1
fi fi
echo "" fi
echo "Device ${1} wipped !" fi
echo ""
echo "Device ${1} wipped !"
} }
print_time() { print_time() {
ENDDATE=$(date +%s) echo ""
echo "" echo "Start date :"
echo "End date :" echo "${STARTDATESTRING}"
date
ENDDATE=$(date +%s)
echo ""
echo "End date :"
date
CALCTIME=$((ENDDATE-STARTDATE)) CALCTIME=$((ENDDATE-STARTDATE))
echo "" echo ""
echo "Total time :" echo "Total time :"
date -d@${CALCTIME} -u +%H:%M:%S date -d@${CALCTIME} -u +%H:%M:%S
} }
check_args "${DEV}" check_args "${DEV}"
check_dev_exist "${DEV}" check_dev_exist "${DEV}"
confirm_wipe "${DEV}" confirm_wipe "${DEV}"
STARTDATE=$(date +%s)
wipe_dev "${DEV}" wipe_dev "${DEV}"
print_time print_time