Identation and end status + 500M step
This commit is contained in:
parent
87be64e61b
commit
8504eafa48
111
mtm-ddwipe
111
mtm-ddwipe
@ -1,77 +1,82 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
declare -r DEV="${1}"
|
declare -r DEV="${1}"
|
||||||
|
declare STARTDATE="$(date)"
|
||||||
|
|
||||||
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}"
|
echo "Begin wiping device ${1}"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Start date :"
|
echo "Start date :"
|
||||||
date
|
echo "${STARTDATE}"
|
||||||
echo ""
|
echo ""
|
||||||
echo "blkdiscard secure"
|
echo "blkdiscard secure"
|
||||||
if ! blkdiscard -f -p 100G -s -v "${1}"; then
|
if ! blkdiscard -f -p 500M -s -v "${1}"; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "blkdiscard zero"
|
echo "blkdiscard zero"
|
||||||
if ! blkdiscard -f -p 100G -z -v "${1}"; then
|
if ! blkdiscard -f -p 500M -z -v "${1}"; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "dd zero"
|
echo "dd zero"
|
||||||
if ! dd if=/dev/zero of="${1}" bs=1M status=progress; then
|
if ! dd if=/dev/zero of="${1}" bs=1M status=progress; then
|
||||||
# Need check if dd has all writed, if yes, return no error
|
# Need check if dd has all writed, if yes, return no error
|
||||||
# echo "Error wiping device ${1}, use phisical destroy !"
|
# echo "Error wiping device ${1}, use phisical destroy !"
|
||||||
echo "Wiped with dd, check if full size is writed."
|
echo "Wiped with dd, check if full size is writed."
|
||||||
echo "Otherwise use a mechanical destruction of the device."
|
echo "Otherwise use a mechanical destruction of the device."
|
||||||
print_time
|
print_time
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
echo "Device ${1} wipped !"
|
echo "Device ${1} wipped !"
|
||||||
}
|
}
|
||||||
|
|
||||||
print_time() {
|
print_time() {
|
||||||
ENDDATE=$(date +%s)
|
echo ""
|
||||||
echo ""
|
echo "Start date :"
|
||||||
echo "End date :"
|
echo "${STARTDATE}"
|
||||||
date
|
|
||||||
|
|
||||||
CALCTIME=$((ENDDATE-STARTDATE))
|
ENDDATE=$(date +%s)
|
||||||
echo ""
|
echo ""
|
||||||
echo "Total time :"
|
echo "End date :"
|
||||||
date -d@${CALCTIME} -u +%H:%M:%S
|
date
|
||||||
|
|
||||||
|
CALCTIME=$((ENDDATE-STARTDATE))
|
||||||
|
echo ""
|
||||||
|
echo "Total time :"
|
||||||
|
date -d@${CALCTIME} -u +%H:%M:%S
|
||||||
}
|
}
|
||||||
|
|
||||||
check_args "${DEV}"
|
check_args "${DEV}"
|
||||||
|
Loading…
Reference in New Issue
Block a user