Added a position shift for script arguments, simplified conditional case

This commit is contained in:
Alex Tavarez
2025-09-17 12:03:40 -04:00
parent 61051d7a3e
commit fb906b659c
2 changed files with 15 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
#!/bin/bash
set -euo pipefail
SCRIPT_ROOT=$(dirname "$0")
# @TODO: Implement more soft-coding and interactivity to this script
ZFS_POOL_NAME="media"
ZFS_COMPAT="openzfs-2.1-linux"
@@ -61,14 +62,16 @@ create_datasets () {
}
print_menu () {
echo "Placeholder content"
echo "$(<"${SCRIPT_ROOT}"/zfs-media-drive.help)"
}
if [ -z "$1" ]; then
exit 1
fi
if ! [ -z "$1" ] && [ "$1" == "init" ]; then
if [ -n "$1" ] && [ "$1" == "init" ]; then
shift
while getopts "d:p:k:f:c:v:" opt; do
case $opt in
k) ZFS_KEY_LOC="${OPTARG}";;
@@ -82,7 +85,7 @@ if ! [ -z "$1" ] && [ "$1" == "init" ]; then
done
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
fi