Skip to content

Commit

Permalink
Added examples to Usage, added version output, added set log at cli
Browse files Browse the repository at this point in the history
  • Loading branch information
anjaustin committed Jan 15, 2024
1 parent 2011e01 commit 5d7b6b1
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions src/create-encrypted-data-at-rest-drive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# create-encrypted-at-rest-drive.sh
################################################################################
# Author: Aaron `Tripp` N. Josserand Austin
# Version: v0.1.7-alpha - Initial Public Alpha Release
# Date: 14-JAN-2024 T 16:24 Mountain US
# Version: v0.1.8-alpha - Initial Public Alpha Release
# Date: 14-JAN-2024 T 21:23 Mountain US
################################################################################
# MIT License
################################################################################
Expand Down Expand Up @@ -76,7 +76,9 @@
# the GitHub repository: https://github.com/anjaustin/encrypted-data-at-rest
################################################################################

### SCRIPT-LEVEL VARIABLES ###
### VARIABLES ###
readonly VERSION="v0.1.8-alpha"

# Enable DEBUG mode (set to 1 to enable)
DEBUG=0

Expand Down Expand Up @@ -360,42 +362,55 @@ update_user_bash() {
fi
}

# Usage information
usage() {
cat <<EOF
Usage: $0 [-h|--help]
# Parse command-line options
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help)
# Display usage information
cat <<EOF
Usage: [sudo] $0 [-h|--help] [-l|--log-dir LOG_DIR]
Create encrypted storage drives at rest using LUKS encryption.
Options:
-h, --help Display this help message and exit.
-h, --help Display this help message and exit.
-l, --log-dir LOG_DIR Set the log directory. Default is "/var/log/edar_drive_setup".
Examples:
./create-encrypted-at-rest-drive.sh
sudo ./create-encrypted-at-rest-drive.sh
sudo ./create-encrypted-at-rest-drive.sh --log-dir /path/to/custom/logs
Requirements:
- This script requires elevated privileges. You may need to run it with 'sudo'.
- This script selectively requires elevated privileges. You can run it with 'sudo' for your convenience.
- Dependencies: cryptsetup, lsblk, numfmt.
How to Run:
1. Make the script executable: chmod u+x $0
2. Run the script with elevated privileges: sudo $0
2. Run the script: [sudo] $0
3. Run the script with debugging: DEBUG=1 [sudo] $0
Feedback:
Your feedback is valuable. Please report any issues or suggest improvements on
the GitHub repository: https://github.com/anjaustin/encrypted-data-at-rest
EOF
}

# Parse command-line options
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help)
usage
exit 0
;;
-l|--log-dir)
# Set custom log directory
shift
LOG_DIR="$1"
;;
-v|--version)
# Display version
echo "$VERSION"
;;
*)
echo "Error: Invalid option. Use -h or --help for usage information."
exit 1
;;
esac
shift
done

### START ###
Expand Down Expand Up @@ -423,4 +438,4 @@ update_user_bash
log_message "INFO" "User .bashrc and .bash_logout update function completed."

log_message "INFO" "Script ended without errors."
# EOF >>>
# EOF >>>

0 comments on commit 5d7b6b1

Please sign in to comment.