Skip to content

Instantly share code, notes, and snippets.

@srgrn
srgrn / autopart.sh
Last active November 3, 2017 07:22 — forked from trentmswanson/autopart.sh
#!/bin/bash
# An set of disks to ignore from partitioning and formatting
BLACKLIST="/dev/sda|/dev/sdb"
# Base directory to hold the data* files
DATA_BASE="/media"
usage() {
echo "Usage: $(basename $0) <new disk>"
}
# bourne shell functions below take 1 argument, the file_to_hash.
# prints hex digest on stdout
md5() {
perl -MDigest::MD5=md5_hex -le'print md5_hex(<> or die)' "$1"
# ruby -rdigest/md5 -e"puts Digest::MD5.file'/dev/null'"
# python -sBc "import hashlib;print hashlib.md5(open('$1','rb').read()).hexdigest()"
# md5 "$1"|cut -d' ' -f4 # mac/bsd
# md5sum "$1"|cut -d' ' -f1 # linux
}