2022-11-17 14:26:57 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
OPTIONS_FILE="8821cu.conf"
|
|
|
|
SCRIPT_NAME="edit-options.sh"
|
2023-01-17 11:51:13 +00:00
|
|
|
DEFAULT_EDITOR="nano"
|
2022-11-17 14:26:57 +00:00
|
|
|
#
|
|
|
|
# Purpose: Make it easier to edit the driver options file.
|
|
|
|
#
|
|
|
|
# To make this file executable:
|
|
|
|
#
|
|
|
|
# $ chmod +x edit-options.sh
|
|
|
|
#
|
|
|
|
# To execute this file:
|
|
|
|
#
|
|
|
|
# $ sudo ./edit-options.sh
|
|
|
|
#
|
|
|
|
if [[ $EUID -ne 0 ]]
|
|
|
|
then
|
|
|
|
echo "You must run this script with superuser (root) privileges."
|
|
|
|
echo "Try: \"sudo ./${SCRIPT_NAME}\""
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-01-17 11:51:13 +00:00
|
|
|
# Try to find the user's default text editor through ${VISUAL}, ${EDITOR} or nano
|
|
|
|
if command -v "${VISUAL}" >/dev/null 2>&1
|
2023-01-15 02:15:28 +00:00
|
|
|
then
|
2023-01-17 11:51:13 +00:00
|
|
|
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
|
2023-01-15 02:15:28 +00:00
|
|
|
fi
|
|
|
|
|
2023-01-17 11:51:13 +00:00
|
|
|
${TEXT_EDITOR} /etc/modprobe.d/${OPTIONS_FILE}
|
2022-11-17 14:26:57 +00:00
|
|
|
|
|
|
|
read -p "Do you want to apply the new options by rebooting now? [y/N] " -n 1 -r
|
|
|
|
echo # move to a new line
|
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
|
|
|
then
|
|
|
|
reboot
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|