33 lines
643 B
Bash
33 lines
643 B
Bash
#!/bin/bash
|
|
set -o
|
|
|
|
DISK=$1
|
|
|
|
# Confirm DISK choice
|
|
if [ -n "$DISK" ]; then
|
|
read -rp "You selected to OVERWRITE '${DISK}', are you sure? [y/N] " yn
|
|
else
|
|
echo "ERROR: No disk selected. Pass through a disk path, e.g., ./zfslive.sh /dev/sdX"
|
|
exit 1;
|
|
fi
|
|
|
|
case $yn in
|
|
[yY] ) ;;
|
|
* ) echo "ERROR: User aborted"
|
|
exit 1;;
|
|
esac
|
|
|
|
# Is the DISK path a block device?
|
|
DISK_TYPE=$(file "${DISK}" | awk '{ print $2$3 }')
|
|
if [ "$DISK_TYPE" != "blockspecial" ]; then
|
|
echo "ERROR: Disk '${DISK}' is not a block device"
|
|
exit 1;
|
|
fi
|
|
|
|
# Check
|
|
unset CDPATH
|
|
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
df "$SCRIPT_DIR"
|
|
#echo "$SCRIPT_DIR"
|
|
exit 0
|