From ece6b5f4838f5ad1d64bd2f794832ae0fcdd63fd Mon Sep 17 00:00:00 2001 From: morrownr Date: Sun, 22 Jan 2023 01:52:24 -0600 Subject: [PATCH] misc cleanup --- default-editor | 1 + edit-options.sh | 28 +++++++++++++++++++++------- install-driver.sh | 24 ++++++++++++++++-------- remove-driver.sh | 11 +++++++++-- 4 files changed, 47 insertions(+), 17 deletions(-) create mode 100644 default-editor diff --git a/default-editor b/default-editor new file mode 100644 index 0000000..8c0e1f8 --- /dev/null +++ b/default-editor @@ -0,0 +1 @@ +nano diff --git a/edit-options.sh b/edit-options.sh index 02a0b2d..05c5bb2 100755 --- a/edit-options.sh +++ b/edit-options.sh @@ -1,11 +1,9 @@ #!/bin/bash -# -OPTIONS_FILE="8821cu.conf" -SCRIPT_NAME="edit-options.sh" -DEFAULT_EDITOR="nano" -# + # Purpose: Make it easier to edit the driver options file. # +# Flexible editor support. +# # To make this file executable: # # $ chmod +x edit-options.sh @@ -14,6 +12,22 @@ DEFAULT_EDITOR="nano" # # $ sudo ./edit-options.sh # +# Copyright(c) 2023 Nick Morrow +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +SCRIPT_NAME="edit-options.sh" +SCRIPT_VERSION="20230120" +OPTIONS_FILE="8821cu.conf" +DEFAULT_EDITOR=`cat default-editor` + if [[ $EUID -ne 0 ]] then echo "You must run this script with superuser (root) privileges." @@ -33,8 +47,8 @@ then TEXT_EDITOR="${DEFAULT_EDITOR}" else echo "No text editor found (default: ${DEFAULT_EDITOR})." - echo "Please install one and set the VISUAL or EDITOR variables to point to it." - echo "When you have an editor, please run \"sudo ./${SCRIPT_NAME}\"" + echo "Please install ${DEFAULT_EDITOR} or edit the file 'default-editor' to specify your editor." + echo "Once complete, please run \"sudo ./${SCRIPT_NAME}\"" exit 1 fi diff --git a/install-driver.sh b/install-driver.sh index bb18a63..ae7278a 100755 --- a/install-driver.sh +++ b/install-driver.sh @@ -3,7 +3,15 @@ # Purpose: Install Realtek out-of-kernel USB WiFi adapter drivers. # # Supports dkms and non-dkms installations. - +# +# To make this file executable: +# +# $ chmod +x edit-options.sh +# +# To execute this file: +# +# $ sudo ./edit-options.sh +# # Copyright(c) 2023 Nick Morrow # # This program is free software; you can redistribute it and/or modify @@ -16,10 +24,9 @@ # GNU General Public License for more details. SCRIPT_NAME="install-driver.sh" -SCRIPT_VERSION="20230116" +SCRIPT_VERSION="20230121" MODULE_NAME="8821cu" DRV_VERSION="5.12.0.4" -DEFAULT_EDITOR="nano" KVER="$(uname -r)" KARCH="$(uname -m)" @@ -31,6 +38,7 @@ OPTIONS_FILE="${MODULE_NAME}.conf" SMEM=$(LANG=C free | awk '/Mem:/ { print $2 }') sproc=$(nproc) +DEFAULT_EDITOR=`cat default-editor` # check to ensure sudo was used if [[ $EUID -ne 0 ]] @@ -66,8 +74,8 @@ fi # check to see if header files are installed if [ ! -d "/lib/modules/$(uname -r)/build" ]; then echo "Your kernel header files aren't properly installed." - echo "Please consult your distro documentation." - echo "Once the header files are installed, please run \"sudo ./${SCRIPT_NAME}\"" + echo "Please consult your distro documentation or user support forums." + echo "Once the header files are properly installed, please run \"sudo ./${SCRIPT_NAME}\"" exit 1 fi @@ -101,8 +109,8 @@ then TEXT_EDITOR="${DEFAULT_EDITOR}" else echo "No text editor found (default: ${DEFAULT_EDITOR})." - echo "Please install one and set the VISUAL or EDITOR variables to point to it." - echo "When you have an editor, please run \"sudo ./${SCRIPT_NAME}\"" + echo "Please install ${DEFAULT_EDITOR} or edit the file 'default-editor' to specify your editor." + echo "Once complete, please run \"sudo ./${SCRIPT_NAME}\"" exit 1 fi @@ -146,7 +154,7 @@ then sproc=2 fi fi -# display total number of cpu cores / in use +# display total number of in-use cpu processes / total cpu processes echo ": ${sproc}/$(nproc) (sproc/nproc)" # display kernel version diff --git a/remove-driver.sh b/remove-driver.sh index aa72c6b..d9a3699 100755 --- a/remove-driver.sh +++ b/remove-driver.sh @@ -3,7 +3,15 @@ # Purpose: Remove Realtek out-of-kernel USB WiFi adapter drivers. # # Supports dkms and non-dkms removals. - +# +# To make this file executable: +# +# $ chmod +x edit-options.sh +# +# To execute this file: +# +# $ sudo ./edit-options.sh +# # Copyright(c) 2023 Nick Morrow # # This program is free software; you can redistribute it and/or modify @@ -22,7 +30,6 @@ DRV_VERSION="5.12.0.4" KVER="$(uname -r)" KARCH="$(uname -m)" -#KSRC="/lib/modules/${KVER}/build" MODDESTDIR="/lib/modules/${KVER}/kernel/drivers/net/wireless/" DRV_NAME="rtl${MODULE_NAME}"