2
0
mirror of https://github.com/cilynx/rtl88x2bu synced 2025-08-22 18:19:43 +00:00

feat: Add verbosity flag to CLI

This commit is contained in:
Max Görner 2025-05-09 11:29:30 +02:00
parent 8f1741badf
commit cbd155ead2

View File

@ -3,6 +3,7 @@
set -euo pipefail set -euo pipefail
TARGET_KERNEL= TARGET_KERNEL=
VERBOSE=false
function main() { function main() {
local VERSION local VERSION
@ -19,13 +20,21 @@ function get_version() {
} }
function parse-cli-args() { function parse-cli-args() {
while $#; do while [[ $# -gt 0 ]]; do
case "$1" in case "$1" in
-v | --verbose)
VERBOSE=true
shift
;;
-h | --help) -h | --help)
print-usage >&2 print-usage
exit 1 exit 0
;; ;;
*) *)
if [[ -n "${TARGET_KERNEL}" ]]; then
echo "Only one target kernel can be specified!" >&2
exit 1
fi
TARGET_KERNEL="$1" TARGET_KERNEL="$1"
shift shift
;; ;;
@ -35,13 +44,14 @@ function parse-cli-args() {
function print-usage() { function print-usage() {
cat <<EOF cat <<EOF
Usage: $0 [TARGET_KERNEL] Usage: $0 [-v|--verbose|TARGET_KERNEL]..
Deploy the rtl88x2bu driver to the system. If TARGET_KERNEL is not specified, Deploy the rtl88x2bu driver to the system. If TARGET_KERNEL is not specified,
the driver will be deployed to all available kernels. the driver will be deployed to all available kernels.
Options: Options:
-h, --help Show this help message and exit -h, --help Show this help message and exit
-v, --verbose Enable verbose output
TARGET_KERNEL Specify the target kernel version to deploy the driver to. TARGET_KERNEL Specify the target kernel version to deploy the driver to.
If not specified, the script will deploy to all available If not specified, the script will deploy to all available
kernels. kernels.
@ -61,10 +71,10 @@ function ensure_root_permissions() {
function remove_driver() { function remove_driver() {
sudo dkms remove rtl88x2bu/5.8.7.1 --all &>/dev/null || true sudo dkms remove rtl88x2bu/5.8.7.1 --all &>/dev/null || true
} }
function put_sources_in_place() { function put_sources_in_place() {
local VERSION="$1" local VERSION="$1"
sudo rsync --delete --exclude=.git -rvhP ./ "/usr/src/rtl88x2bu-${VERSION}" sudo rsync --delete --exclude=.git -rvhP ./ "/usr/src/rtl88x2bu-${VERSION}" >/dev/null
log "Sources copied to /usr/src/rtl88x2bu-${VERSION}"
} }
function deploy_driver() { function deploy_driver() {
@ -89,4 +99,10 @@ function list-kernels() {
fi fi
} }
function log() {
if [[ "$VERBOSE" = "true" ]]; then
echo "$1"
fi
}
main "$@" main "$@"