Skip to content

Commit 5d7b6b1

Browse files
committed
Added examples to Usage, added version output, added set log at cli
1 parent 2011e01 commit 5d7b6b1

File tree

1 file changed

+33
-18
lines changed

1 file changed

+33
-18
lines changed

src/create-encrypted-data-at-rest-drive.sh

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# create-encrypted-at-rest-drive.sh
55
################################################################################
66
# Author: Aaron `Tripp` N. Josserand Austin
7-
# Version: v0.1.7-alpha - Initial Public Alpha Release
8-
# Date: 14-JAN-2024 T 16:24 Mountain US
7+
# Version: v0.1.8-alpha - Initial Public Alpha Release
8+
# Date: 14-JAN-2024 T 21:23 Mountain US
99
################################################################################
1010
# MIT License
1111
################################################################################
@@ -76,7 +76,9 @@
7676
# the GitHub repository: https://github.com/anjaustin/encrypted-data-at-rest
7777
################################################################################
7878

79-
### SCRIPT-LEVEL VARIABLES ###
79+
### VARIABLES ###
80+
readonly VERSION="v0.1.8-alpha"
81+
8082
# Enable DEBUG mode (set to 1 to enable)
8183
DEBUG=0
8284

@@ -360,42 +362,55 @@ update_user_bash() {
360362
fi
361363
}
362364

363-
# Usage information
364-
usage() {
365-
cat <<EOF
366-
Usage: $0 [-h|--help]
365+
# Parse command-line options
366+
while [[ $# -gt 0 ]]; do
367+
case "$1" in
368+
-h|--help)
369+
# Display usage information
370+
cat <<EOF
371+
Usage: [sudo] $0 [-h|--help] [-l|--log-dir LOG_DIR]
367372
368373
Create encrypted storage drives at rest using LUKS encryption.
369374
370375
Options:
371-
-h, --help Display this help message and exit.
376+
-h, --help Display this help message and exit.
377+
-l, --log-dir LOG_DIR Set the log directory. Default is "/var/log/edar_drive_setup".
378+
379+
Examples:
380+
./create-encrypted-at-rest-drive.sh
381+
sudo ./create-encrypted-at-rest-drive.sh
382+
sudo ./create-encrypted-at-rest-drive.sh --log-dir /path/to/custom/logs
372383
373384
Requirements:
374-
- This script requires elevated privileges. You may need to run it with 'sudo'.
385+
- This script selectively requires elevated privileges. You can run it with 'sudo' for your convenience.
375386
- Dependencies: cryptsetup, lsblk, numfmt.
376387
377388
How to Run:
378389
1. Make the script executable: chmod u+x $0
379-
2. Run the script with elevated privileges: sudo $0
390+
2. Run the script: [sudo] $0
391+
3. Run the script with debugging: DEBUG=1 [sudo] $0
380392
381393
Feedback:
382394
Your feedback is valuable. Please report any issues or suggest improvements on
383395
the GitHub repository: https://github.com/anjaustin/encrypted-data-at-rest
384396
EOF
385-
}
386-
387-
# Parse command-line options
388-
while [[ $# -gt 0 ]]; do
389-
case "$1" in
390-
-h|--help)
391-
usage
392397
exit 0
393398
;;
399+
-l|--log-dir)
400+
# Set custom log directory
401+
shift
402+
LOG_DIR="$1"
403+
;;
404+
-v|--version)
405+
# Display version
406+
echo "$VERSION"
407+
;;
394408
*)
395409
echo "Error: Invalid option. Use -h or --help for usage information."
396410
exit 1
397411
;;
398412
esac
413+
shift
399414
done
400415

401416
### START ###
@@ -423,4 +438,4 @@ update_user_bash
423438
log_message "INFO" "User .bashrc and .bash_logout update function completed."
424439

425440
log_message "INFO" "Script ended without errors."
426-
# EOF >>>
441+
# EOF >>>

0 commit comments

Comments
 (0)