mirror of
https://github.com/morrownr/8821cu-20210916.git
synced 2024-12-21 22:06:32 +00:00
Changed to search through VISUAL -> EDITOR -> nano -> -FAIL- for a text editor
This commit is contained in:
parent
e5c1d42247
commit
016389da56
@ -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,20 +21,24 @@ then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if ${EDITOR} is an executable or try to default to nano or finally complain if it's not installed.
|
# Try to find the user's default text editor through ${VISUAL}, ${EDITOR} or nano
|
||||||
if ! [ -x "${EDITOR}" ]
|
if command -v "${VISUAL}" >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
EDITOR="$(which nano 2>/dev/null)"
|
TEXT_EDITOR="${VISUAL}"
|
||||||
if ! [ -x "${EDITOR}" ]
|
elif command -v "${EDITOR}" >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
echo "No text editor found (default: nano)."
|
TEXT_EDITOR="${EDITOR}"
|
||||||
echo "Please install one and set the EDITOR variable to point to it."
|
elif command -v "${DEFAULT_EDITOR}" >/dev/null 2>&1
|
||||||
echo "When you have an editor, please run \"sudo ./${SCRIPT_NAME}\""
|
then
|
||||||
exit 1
|
TEXT_EDITOR="${DEFAULT_EDITOR}"
|
||||||
fi
|
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
|
||||||
|
|
||||||
${EDITOR} /etc/modprobe.d/${OPTIONS_FILE}
|
${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
|
||||||
|
@ -19,6 +19,7 @@ SCRIPT_NAME="install-driver.sh"
|
|||||||
SCRIPT_VERSION="20230111"
|
SCRIPT_VERSION="20230111"
|
||||||
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)"
|
||||||
@ -87,17 +88,21 @@ then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if ${EDITOR} is an executable or try to default to nano or finally complain if it's not installed.
|
# Try to find the user's default text editor through ${VISUAL}, ${EDITOR} or nano
|
||||||
if ! [ -x "${EDITOR}" ]
|
if command -v "${VISUAL}" >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
EDITOR="$(which nano 2>/dev/null)"
|
TEXT_EDITOR="${VISUAL}"
|
||||||
if ! [ -x "${EDITOR}" ]
|
elif command -v "${EDITOR}" >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
echo "No text editor found (default: nano)."
|
TEXT_EDITOR="${EDITOR}"
|
||||||
echo "Please install one and set the EDITOR variable to point to it."
|
elif command -v "${DEFAULT_EDITOR}" >/dev/null 2>&1
|
||||||
echo "When you have an editor, please run \"sudo ./${SCRIPT_NAME}\""
|
then
|
||||||
exit 1
|
TEXT_EDITOR="${DEFAULT_EDITOR}"
|
||||||
fi
|
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 +362,7 @@ then
|
|||||||
echo
|
echo
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
||||||
then
|
then
|
||||||
${EDITOR} /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
|
||||||
|
Loading…
Reference in New Issue
Block a user