Last active
June 8, 2021 14:01
-
-
Save nikolareljin/78175e2d9574028b29e7192adc67dbf1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------------------------ | |
# Clone the drives with GUI dialog. | |
# Uses `dialog` which needs to be installed first.. | |
# | |
# Use: | |
# gui_dd <input drive> <output drive> | |
# ------------------------------------------------ | |
function gui_dd() { | |
in_d=$1 | |
out_d=$2 | |
if [[ -z $in_d ]] || [[ -z $out_d ]]; then | |
echo "Input and output drives not specified!" | |
exit 1 | |
} | |
if [[ -z $(which pv) ]]; then | |
echo "Please install pv cli tool" | |
exit 1 | |
fi | |
if [[ -z $(which dialog) ]]; then | |
echo "Dialog not installed. fallback to non-gui" | |
dd if=${in_d} of=${out_d} bs=128M | |
else | |
(pv -n ${in_d} | dd of=${out_d} bs=128M conv=notrunc,noerror) 2>&1 | \ | |
dialog --gauge "Clonning drive ${in_d} -> ${out_d}, please wait..." 10 70 0 | |
clear | |
fi | |
echo "Clonning completed" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment