Added a position shift for script arguments, simplified conditional case
This commit is contained in:
9
zfs/zfs-media-drive.help
Normal file
9
zfs/zfs-media-drive.help
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
This script allows the creation of ZFS pool specifically for the purpose of media.
|
||||||
|
This pool is divided into datasets that allow useful storage management of that media.
|
||||||
|
|
||||||
|
-k Option to provide a custom path to the key for the encrypted filesystem. Equivalent to 'keylocation' option in ZFS pool creation.
|
||||||
|
-f Opton to provide a custom format for the aforementioned key. Equivalnt to 'keyformat' option in ZFS pool creation.
|
||||||
|
-c Option to specify custom ZFS compression algorithm for ZFS pool. Equivalent to 'compression' option in ZFS pool creation.
|
||||||
|
-v Option to specify custom ZFS version for compatibility purposes. Equivalent to 'compatibility' option in ZFS pool creation.
|
||||||
|
-p Option to provide a custom name for the created ZFS pool.
|
||||||
|
-d Specify the storage device, volume or partition to be given a pool.
|
@@ -1,6 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
SCRIPT_ROOT=$(dirname "$0")
|
||||||
# @TODO: Implement more soft-coding and interactivity to this script
|
# @TODO: Implement more soft-coding and interactivity to this script
|
||||||
ZFS_POOL_NAME="media"
|
ZFS_POOL_NAME="media"
|
||||||
ZFS_COMPAT="openzfs-2.1-linux"
|
ZFS_COMPAT="openzfs-2.1-linux"
|
||||||
@@ -61,14 +62,16 @@ create_datasets () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
print_menu () {
|
print_menu () {
|
||||||
echo "Placeholder content"
|
echo "$(<"${SCRIPT_ROOT}"/zfs-media-drive.help)"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! [ -z "$1" ] && [ "$1" == "init" ]; then
|
if [ -n "$1" ] && [ "$1" == "init" ]; then
|
||||||
|
shift
|
||||||
|
|
||||||
while getopts "d:p:k:f:c:v:" opt; do
|
while getopts "d:p:k:f:c:v:" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
k) ZFS_KEY_LOC="${OPTARG}";;
|
k) ZFS_KEY_LOC="${OPTARG}";;
|
||||||
@@ -82,7 +85,7 @@ if ! [ -z "$1" ] && [ "$1" == "init" ]; then
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "$ZFS_TARGET_DRIVE" ]; then
|
if [ -z "$ZFS_TARGET_DRIVE" ]; then
|
||||||
echo "It is necessary to argue a -d option."
|
echo "Error: It is necessary to argue a -d option."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user