Merge pull request #53 from M0les/main

Test for ${EDITOR} or fall-back to nano for text file editing
pull/55/head
Nick 2023-01-17 09:51:37 -06:00 committed by GitHub
commit 41b038f40f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 10 deletions

View File

@ -546,7 +546,7 @@ dtoverlay=disable-wifi
#### Step 1: Edit wpa_supplicant.conf #### Step 1: Edit wpa_supplicant.conf
``` ```
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf sudo ${EDITOR} /etc/wpa_supplicant/wpa_supplicant.conf
``` ```
#### Step 2: Delete the relevant WiFi network block (including the 'network=' and opening/closing braces. #### Step 2: Delete the relevant WiFi network block (including the 'network=' and opening/closing braces.

View File

@ -29,7 +29,7 @@ How do I Enable Concurrent Mode?
Edit the `Makefile` with a text editor: Edit the `Makefile` with a text editor:
``` ```
nano Makefile ${EDITOR} Makefile
``` ```
Change the following line: Change the following line:

View File

@ -2,6 +2,7 @@
# #
OPTIONS_FILE="8821cu.conf" OPTIONS_FILE="8821cu.conf"
SCRIPT_NAME="edit-options.sh" SCRIPT_NAME="edit-options.sh"
DEFAULT_EDITOR="nano"
# #
# Purpose: Make it easier to edit the driver options file. # Purpose: Make it easier to edit the driver options file.
# #
@ -20,7 +21,24 @@ then
exit 1 exit 1
fi fi
nano /etc/modprobe.d/${OPTIONS_FILE} # Try to find the user's default text editor through ${VISUAL}, ${EDITOR} or nano
if command -v "${VISUAL}" >/dev/null 2>&1
then
TEXT_EDITOR="${VISUAL}"
elif command -v "${EDITOR}" >/dev/null 2>&1
then
TEXT_EDITOR="${EDITOR}"
elif command -v "${DEFAULT_EDITOR}" >/dev/null 2>&1
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}\""
exit 1
fi
${TEXT_EDITOR} /etc/modprobe.d/${OPTIONS_FILE}
read -p "Do you want to apply the new options by rebooting now? [y/N] " -n 1 -r read -p "Do you want to apply the new options by rebooting now? [y/N] " -n 1 -r
echo # move to a new line echo # move to a new line

View File

@ -19,6 +19,7 @@ SCRIPT_NAME="install-driver.sh"
SCRIPT_VERSION="20230116" SCRIPT_VERSION="20230116"
MODULE_NAME="8821cu" MODULE_NAME="8821cu"
DRV_VERSION="5.12.0.4" DRV_VERSION="5.12.0.4"
DEFAULT_EDITOR="nano"
KVER="$(uname -r)" KVER="$(uname -r)"
KARCH="$(uname -m)" KARCH="$(uname -m)"
@ -88,13 +89,21 @@ then
exit 1 exit 1
fi fi
# check to ensure nano is installed # Try to find the user's default text editor through ${VISUAL}, ${EDITOR} or nano
if ! command -v nano >/dev/null 2>&1 if command -v "${VISUAL}" >/dev/null 2>&1
then then
echo "A required package is not installed." TEXT_EDITOR="${VISUAL}"
echo "Please install the following package: nano" elif command -v "${EDITOR}" >/dev/null 2>&1
echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\"" then
exit 1 TEXT_EDITOR="${EDITOR}"
elif command -v "${DEFAULT_EDITOR}" >/dev/null 2>&1
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}\""
exit 1
fi fi
# support for the NoPrompt option allows non-interactive use of this script # support for the NoPrompt option allows non-interactive use of this script
@ -357,7 +366,7 @@ then
echo echo
if [[ $REPLY =~ ^[Yy]$ ]] if [[ $REPLY =~ ^[Yy]$ ]]
then then
nano /etc/modprobe.d/${OPTIONS_FILE} ${TEXT_EDITOR} /etc/modprobe.d/${OPTIONS_FILE}
fi fi
read -p "Do you want to reboot now? (recommended) [y/N] " -n 1 -r read -p "Do you want to reboot now? (recommended) [y/N] " -n 1 -r