mirror of
https://github.com/morrownr/8821cu-20210916.git
synced 2024-12-21 22:06:32 +00:00
commit
169993a75a
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
# SMEM needs to be set here if dkms build is not initiated by install-driver.sh
|
# SMEM needs to be set here if dkms build is not initiated by install-driver.sh
|
||||||
SMEM=$(LANG=C free | awk '/Mem:/ { print $2 }')
|
SMEM=$(LANG=C free | awk '/Mem:/ { print $2 }')
|
||||||
@ -7,10 +7,8 @@ SMEM=$(LANG=C free | awk '/Mem:/ { print $2 }')
|
|||||||
sproc=$(nproc)
|
sproc=$(nproc)
|
||||||
|
|
||||||
# Avoid Out of Memory condition in low-RAM systems by limiting core usage.
|
# Avoid Out of Memory condition in low-RAM systems by limiting core usage.
|
||||||
if [ "$sproc" -gt 1 ]
|
if [ "$sproc" -gt 1 ]; then
|
||||||
then
|
if [ "$SMEM" -lt 1400000 ]; then
|
||||||
if [ "$SMEM" -lt 1400000 ]
|
|
||||||
then
|
|
||||||
sproc=2
|
sproc=2
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
# Purpose: Make it easier to edit the driver options file.
|
# Purpose: Make it easier to edit the driver options file.
|
||||||
#
|
#
|
||||||
@ -26,42 +26,37 @@
|
|||||||
SCRIPT_NAME="edit-options.sh"
|
SCRIPT_NAME="edit-options.sh"
|
||||||
SCRIPT_VERSION="20230120"
|
SCRIPT_VERSION="20230120"
|
||||||
OPTIONS_FILE="8821cu.conf"
|
OPTIONS_FILE="8821cu.conf"
|
||||||
DEFAULT_EDITOR="$(<default-editor.txt)"
|
DEFAULT_EDITOR="$(cat default-editor.txt)"
|
||||||
EDITORS_SEARCH=("${VISUAL}" "${EDITOR}" "${DEFAULT_EDITOR}" "vi")
|
|
||||||
|
|
||||||
if [[ $EUID -ne 0 ]]
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
then
|
|
||||||
echo "You must run this script with superuser (root) privileges."
|
echo "You must run this script with superuser (root) privileges."
|
||||||
echo "Try: \"sudo ./${SCRIPT_NAME}\""
|
echo "Try: \"sudo ./${SCRIPT_NAME}\""
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Try to find the user's default text editor through the EDITORS_SEARCH array
|
# Try to find the user's default text editor through the EDITORS_SEARCH array
|
||||||
for editor in ${EDITORS_SEARCH[@]}
|
for TEXT_EDITOR in "${VISUAL}" "${EDITOR}" "${DEFAULT_EDITOR}" vi; do
|
||||||
do
|
command -v "${TEXT_EDITOR}" >/dev/null 2>&1 && break
|
||||||
if command -v "${editor}" >/dev/null 2>&1
|
|
||||||
then
|
|
||||||
TEXT_EDITOR="${editor}"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Fail if no editor was found
|
# Fail if no editor was found
|
||||||
if ! command -v "${TEXT_EDITOR}" >/dev/null 2>&1
|
if ! command -v "${TEXT_EDITOR}" >/dev/null 2>&1; then
|
||||||
then
|
|
||||||
echo "No text editor found (default: ${DEFAULT_EDITOR})."
|
echo "No text editor found (default: ${DEFAULT_EDITOR})."
|
||||||
echo "Please install ${DEFAULT_EDITOR} or edit the file 'default-editor.txt' to specify your editor."
|
echo "Please install ${DEFAULT_EDITOR} or edit the file 'default-editor.txt' to specify your editor."
|
||||||
echo "Once complete, please run \"sudo ./${SCRIPT_NAME}\""
|
echo "Once complete, please run \"sudo ./${SCRIPT_NAME}\""
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# displays script name and version
|
||||||
|
echo ": ${SCRIPT_NAME} v${SCRIPT_VERSION}"
|
||||||
|
|
||||||
${TEXT_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
|
printf "Do you want to apply the new options by rebooting now? [y/N] "
|
||||||
|
read -r REPLY
|
||||||
echo # move to a new line
|
echo # move to a new line
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
case "$REPLY" in
|
||||||
then
|
[yY]*) reboot ;;
|
||||||
reboot
|
esac
|
||||||
fi
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
# Purpose: Install Realtek out-of-kernel USB WiFi adapter drivers.
|
# Purpose: Install Realtek out-of-kernel USB WiFi adapter drivers.
|
||||||
#
|
#
|
||||||
@ -38,12 +38,10 @@ OPTIONS_FILE="${MODULE_NAME}.conf"
|
|||||||
|
|
||||||
SMEM=$(LANG=C free | awk '/Mem:/ { print $2 }')
|
SMEM=$(LANG=C free | awk '/Mem:/ { print $2 }')
|
||||||
sproc=$(nproc)
|
sproc=$(nproc)
|
||||||
DEFAULT_EDITOR="$(<default-editor.txt)"
|
DEFAULT_EDITOR="$(cat default-editor.txt)"
|
||||||
EDITORS_SEARCH=("${VISUAL}" "${EDITOR}" "${DEFAULT_EDITOR}" "vi")
|
|
||||||
|
|
||||||
# check to ensure sudo was used
|
# check to ensure sudo was used
|
||||||
if [[ $EUID -ne 0 ]]
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
then
|
|
||||||
echo "You must run this script with superuser (root) privileges."
|
echo "You must run this script with superuser (root) privileges."
|
||||||
echo "Try: \"sudo ./${SCRIPT_NAME}\""
|
echo "Try: \"sudo ./${SCRIPT_NAME}\""
|
||||||
exit 1
|
exit 1
|
||||||
@ -55,8 +53,7 @@ if ! echo "$PATH" | grep -qw sbin; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# check to ensure gcc is installed
|
# check to ensure gcc is installed
|
||||||
if ! command -v gcc >/dev/null 2>&1
|
if ! command -v gcc >/dev/null 2>&1; then
|
||||||
then
|
|
||||||
echo "A required package is not installed."
|
echo "A required package is not installed."
|
||||||
echo "Please install the following package: gcc"
|
echo "Please install the following package: gcc"
|
||||||
echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\""
|
echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\""
|
||||||
@ -64,8 +61,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# check to ensure make is installed
|
# check to ensure make is installed
|
||||||
if ! command -v make >/dev/null 2>&1
|
if ! command -v make >/dev/null 2>&1; then
|
||||||
then
|
|
||||||
echo "A required package is not installed."
|
echo "A required package is not installed."
|
||||||
echo "Please install the following package: make"
|
echo "Please install the following package: make"
|
||||||
echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\""
|
echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\""
|
||||||
@ -81,8 +77,7 @@ if [ ! -d "/lib/modules/$(uname -r)/build" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# check to ensure iw is installed
|
# check to ensure iw is installed
|
||||||
if ! command -v iw >/dev/null 2>&1
|
if ! command -v iw >/dev/null 2>&1; then
|
||||||
then
|
|
||||||
echo "A required package is not installed."
|
echo "A required package is not installed."
|
||||||
echo "Please install the following package: iw"
|
echo "Please install the following package: iw"
|
||||||
echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\""
|
echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\""
|
||||||
@ -90,8 +85,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# check to ensure rfkill is installed
|
# check to ensure rfkill is installed
|
||||||
if ! command -v rfkill >/dev/null 2>&1
|
if ! command -v rfkill >/dev/null 2>&1; then
|
||||||
then
|
|
||||||
echo "A required package is not installed."
|
echo "A required package is not installed."
|
||||||
echo "Please install the following package: rfkill"
|
echo "Please install the following package: rfkill"
|
||||||
echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\""
|
echo "Once the package is installed, please run \"sudo ./${SCRIPT_NAME}\""
|
||||||
@ -99,18 +93,12 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Try to find the user's default text editor through the EDITORS_SEARCH array
|
# Try to find the user's default text editor through the EDITORS_SEARCH array
|
||||||
for editor in ${EDITORS_SEARCH[@]}
|
for TEXT_EDITOR in "${VISUAL}" "${EDITOR}" "${DEFAULT_EDITOR}" vi; do
|
||||||
do
|
command -v "${TEXT_EDITOR}" >/dev/null 2>&1 && break
|
||||||
if command -v "${editor}" >/dev/null 2>&1
|
|
||||||
then
|
|
||||||
TEXT_EDITOR="${editor}"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Fail if no editor was found
|
# Fail if no editor was found
|
||||||
if ! command -v "${TEXT_EDITOR}" >/dev/null 2>&1
|
if ! command -v "${TEXT_EDITOR}" >/dev/null 2>&1; then
|
||||||
then
|
|
||||||
echo "No text editor found (default: ${DEFAULT_EDITOR})."
|
echo "No text editor found (default: ${DEFAULT_EDITOR})."
|
||||||
echo "Please install ${DEFAULT_EDITOR} or edit the file 'default-editor.txt' to specify your editor."
|
echo "Please install ${DEFAULT_EDITOR} or edit the file 'default-editor.txt' to specify your editor."
|
||||||
echo "Once complete, please run \"sudo ./${SCRIPT_NAME}\""
|
echo "Once complete, please run \"sudo ./${SCRIPT_NAME}\""
|
||||||
@ -121,8 +109,7 @@ fi
|
|||||||
NO_PROMPT=0
|
NO_PROMPT=0
|
||||||
|
|
||||||
# get the script options
|
# get the script options
|
||||||
while [ $# -gt 0 ]
|
while [ $# -gt 0 ]; do
|
||||||
do
|
|
||||||
case $1 in
|
case $1 in
|
||||||
NoPrompt)
|
NoPrompt)
|
||||||
NO_PROMPT=1 ;;
|
NO_PROMPT=1 ;;
|
||||||
@ -150,8 +137,7 @@ echo ": ${KARCH} (ARCH)"
|
|||||||
echo ": ${SMEM} (SMEM)"
|
echo ": ${SMEM} (SMEM)"
|
||||||
|
|
||||||
# Avoid Out of Memory condition in low-RAM systems by limiting core usage.
|
# Avoid Out of Memory condition in low-RAM systems by limiting core usage.
|
||||||
if [ "$sproc" -gt 1 ]
|
if [ "$sproc" -gt 1 ]; then
|
||||||
then
|
|
||||||
if [ "$SMEM" -lt 1400000 ]
|
if [ "$SMEM" -lt 1400000 ]
|
||||||
then
|
then
|
||||||
sproc=2
|
sproc=2
|
||||||
@ -165,20 +151,18 @@ echo ": ${KVER} (KVER)"
|
|||||||
|
|
||||||
# display gcc version
|
# display gcc version
|
||||||
gcc_ver=$(gcc --version | grep -i gcc)
|
gcc_ver=$(gcc --version | grep -i gcc)
|
||||||
echo ": "${gcc_ver}
|
echo ": ${gcc_ver}"
|
||||||
|
|
||||||
# display dkms version if installed
|
# display dkms version if installed
|
||||||
if command -v dkms >/dev/null 2>&1
|
if command -v dkms >/dev/null 2>&1; then
|
||||||
then
|
|
||||||
dkms_ver=$(dkms --version)
|
dkms_ver=$(dkms --version)
|
||||||
echo ": "${dkms_ver}
|
echo ": ${dkms_ver}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# display secure mode status if mokutil is installed
|
# display secure mode status if mokutil is installed
|
||||||
if command -v mokutil >/dev/null 2>&1
|
if command -v mokutil >/dev/null 2>&1; then
|
||||||
then
|
|
||||||
sb_state=$(mokutil --sb-state)
|
sb_state=$(mokutil --sb-state)
|
||||||
echo ": "${sb_state}
|
echo ": ${sb_state}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ": ---------------------------"
|
echo ": ---------------------------"
|
||||||
@ -195,11 +179,10 @@ echo ": ---------------------------"
|
|||||||
|
|
||||||
# check for and remove non-dkms installations
|
# check for and remove non-dkms installations
|
||||||
# standard naming
|
# standard naming
|
||||||
if [[ -f "${MODDESTDIR}${MODULE_NAME}.ko" ]]
|
if [ -f "${MODDESTDIR}${MODULE_NAME}.ko" ]; then
|
||||||
then
|
|
||||||
echo "Removing a non-dkms installation: ${MODDESTDIR}${MODULE_NAME}.ko"
|
echo "Removing a non-dkms installation: ${MODDESTDIR}${MODULE_NAME}.ko"
|
||||||
rm -f ${MODDESTDIR}${MODULE_NAME}.ko
|
rm -f "${MODDESTDIR}${MODULE_NAME}.ko"
|
||||||
/sbin/depmod -a ${KVER}
|
/sbin/depmod -a "${KVER}"
|
||||||
echo "Removing ${OPTIONS_FILE} from /etc/modprobe.d"
|
echo "Removing ${OPTIONS_FILE} from /etc/modprobe.d"
|
||||||
rm -f /etc/modprobe.d/${OPTIONS_FILE}
|
rm -f /etc/modprobe.d/${OPTIONS_FILE}
|
||||||
echo "Removing source files from /usr/src/${DRV_NAME}-${DRV_VERSION}"
|
echo "Removing source files from /usr/src/${DRV_NAME}-${DRV_VERSION}"
|
||||||
@ -209,11 +192,10 @@ fi
|
|||||||
|
|
||||||
# check for and remove non-dkms installations
|
# check for and remove non-dkms installations
|
||||||
# with rtl added to module name (PClinuxOS)
|
# with rtl added to module name (PClinuxOS)
|
||||||
if [[ -f "${MODDESTDIR}rtl${MODULE_NAME}.ko" ]]
|
if [ -f "${MODDESTDIR}rtl${MODULE_NAME}.ko" ]; then
|
||||||
then
|
|
||||||
echo "Removing a non-dkms installation: ${MODDESTDIR}rtl${MODULE_NAME}.ko"
|
echo "Removing a non-dkms installation: ${MODDESTDIR}rtl${MODULE_NAME}.ko"
|
||||||
rm -f ${MODDESTDIR}rtl${MODULE_NAME}.ko
|
rm -f "${MODDESTDIR}rtl${MODULE_NAME}.ko"
|
||||||
/sbin/depmod -a ${KVER}
|
/sbin/depmod -a "${KVER}"
|
||||||
echo "Removing ${OPTIONS_FILE} from /etc/modprobe.d"
|
echo "Removing ${OPTIONS_FILE} from /etc/modprobe.d"
|
||||||
rm -f /etc/modprobe.d/${OPTIONS_FILE}
|
rm -f /etc/modprobe.d/${OPTIONS_FILE}
|
||||||
echo "Removing source files from /usr/src/${DRV_NAME}-${DRV_VERSION}"
|
echo "Removing source files from /usr/src/${DRV_NAME}-${DRV_VERSION}"
|
||||||
@ -225,11 +207,10 @@ fi
|
|||||||
# with compressed module in a unique non-standard location (Armbian)
|
# with compressed module in a unique non-standard location (Armbian)
|
||||||
# Example: /usr/lib/modules/5.15.80-rockchip64/kernel/drivers/net/wireless/rtl8821cu/8821cu.ko.xz
|
# Example: /usr/lib/modules/5.15.80-rockchip64/kernel/drivers/net/wireless/rtl8821cu/8821cu.ko.xz
|
||||||
# Dear Armbiam, this is a really bad idea.
|
# Dear Armbiam, this is a really bad idea.
|
||||||
if [[ -f "/usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz" ]]
|
if [ -f "/usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz" ]; then
|
||||||
then
|
|
||||||
echo "Removing a non-dkms installation: /usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz"
|
echo "Removing a non-dkms installation: /usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz"
|
||||||
rm -f /usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz
|
rm -f "/usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz"
|
||||||
/sbin/depmod -a ${KVER}
|
/sbin/depmod -a "${KVER}"
|
||||||
echo "Removing ${OPTIONS_FILE} from /etc/modprobe.d"
|
echo "Removing ${OPTIONS_FILE} from /etc/modprobe.d"
|
||||||
rm -f /etc/modprobe.d/${OPTIONS_FILE}
|
rm -f /etc/modprobe.d/${OPTIONS_FILE}
|
||||||
echo "Removing source files from /usr/src/${DRV_NAME}-${DRV_VERSION}"
|
echo "Removing source files from /usr/src/${DRV_NAME}-${DRV_VERSION}"
|
||||||
@ -238,10 +219,8 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# check for and remove dkms installations
|
# check for and remove dkms installations
|
||||||
if command -v dkms >/dev/null 2>&1
|
if command -v dkms >/dev/null 2>&1; then
|
||||||
then
|
if dkms status | grep -i ${DRV_NAME}; then
|
||||||
if dkms status | grep -i ${DRV_NAME}
|
|
||||||
then
|
|
||||||
echo "Removing a dkms installation: ${DRV_NAME}"
|
echo "Removing a dkms installation: ${DRV_NAME}"
|
||||||
dkms remove -m ${DRV_NAME} -v ${DRV_VERSION} --all
|
dkms remove -m ${DRV_NAME} -v ${DRV_VERSION} --all
|
||||||
echo "Removing ${OPTIONS_FILE} from /etc/modprobe.d"
|
echo "Removing ${OPTIONS_FILE} from /etc/modprobe.d"
|
||||||
@ -256,17 +235,15 @@ echo "Installing ${OPTIONS_FILE} to /etc/modprobe.d"
|
|||||||
cp -f ${OPTIONS_FILE} /etc/modprobe.d
|
cp -f ${OPTIONS_FILE} /etc/modprobe.d
|
||||||
|
|
||||||
# determine if dkms is installed and run the appropriate routines
|
# determine if dkms is installed and run the appropriate routines
|
||||||
if ! command -v dkms >/dev/null 2>&1
|
if ! command -v dkms >/dev/null 2>&1; then
|
||||||
then
|
|
||||||
echo "The non-dkms installation routines are in use."
|
echo "The non-dkms installation routines are in use."
|
||||||
|
|
||||||
make clean >/dev/null 2>&1
|
make clean >/dev/null 2>&1
|
||||||
|
|
||||||
make -j$(nproc)
|
make "-j$(nproc)"
|
||||||
RESULT=$?
|
RESULT=$?
|
||||||
|
|
||||||
if [[ "$RESULT" != "0" ]]
|
if [ "$RESULT" != "0" ]; then
|
||||||
then
|
|
||||||
echo "An error occurred: ${RESULT}"
|
echo "An error occurred: ${RESULT}"
|
||||||
echo "Please report this error."
|
echo "Please report this error."
|
||||||
echo "Please copy all screen output and paste it into the problem report."
|
echo "Please copy all screen output and paste it into the problem report."
|
||||||
@ -282,8 +259,7 @@ then
|
|||||||
make install
|
make install
|
||||||
RESULT=$?
|
RESULT=$?
|
||||||
|
|
||||||
if [[ "$RESULT" = "0" ]]
|
if [ "$RESULT" = "0" ]; then
|
||||||
then
|
|
||||||
make clean >/dev/null 2>&1
|
make clean >/dev/null 2>&1
|
||||||
echo "The driver was installed successfully."
|
echo "The driver was installed successfully."
|
||||||
else
|
else
|
||||||
@ -306,10 +282,8 @@ else
|
|||||||
|
|
||||||
# RESULT will be 3 if the DKMS tree already contains the same module/version
|
# RESULT will be 3 if the DKMS tree already contains the same module/version
|
||||||
# combo. You cannot add the same module/version combo more than once.
|
# combo. You cannot add the same module/version combo more than once.
|
||||||
if [[ "$RESULT" != "0" ]]
|
if [ "$RESULT" != "0" ]; then
|
||||||
then
|
if [ "$RESULT" = "3" ]; then
|
||||||
if [[ "$RESULT" = "3" ]]
|
|
||||||
then
|
|
||||||
echo "This driver may already be installed."
|
echo "This driver may already be installed."
|
||||||
echo "Run the following and then reattempt installation."
|
echo "Run the following and then reattempt installation."
|
||||||
echo "$ sudo ./remove-driver.sh"
|
echo "$ sudo ./remove-driver.sh"
|
||||||
@ -326,16 +300,14 @@ else
|
|||||||
echo "The driver was added to dkms successfully."
|
echo "The driver was added to dkms successfully."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if command -v /usr/bin/time >/dev/null 2>&1
|
if command -v /usr/bin/time >/dev/null 2>&1; then
|
||||||
then
|
|
||||||
/usr/bin/time -f "Compile time: %U seconds" dkms build -m ${DRV_NAME} -v ${DRV_VERSION}
|
/usr/bin/time -f "Compile time: %U seconds" dkms build -m ${DRV_NAME} -v ${DRV_VERSION}
|
||||||
else
|
else
|
||||||
dkms build -m ${DRV_NAME} -v ${DRV_VERSION}
|
dkms build -m ${DRV_NAME} -v ${DRV_VERSION}
|
||||||
fi
|
fi
|
||||||
RESULT=$?
|
RESULT=$?
|
||||||
|
|
||||||
if [[ "$RESULT" != "0" ]]
|
if [ "$RESULT" != "0" ]; then
|
||||||
then
|
|
||||||
echo "An error occurred. dkms build error: ${RESULT}"
|
echo "An error occurred. dkms build error: ${RESULT}"
|
||||||
echo "Please report this error."
|
echo "Please report this error."
|
||||||
echo "Please copy all screen output and paste it into the problem report."
|
echo "Please copy all screen output and paste it into the problem report."
|
||||||
@ -349,8 +321,7 @@ else
|
|||||||
dkms install -m ${DRV_NAME} -v ${DRV_VERSION}
|
dkms install -m ${DRV_NAME} -v ${DRV_VERSION}
|
||||||
RESULT=$?
|
RESULT=$?
|
||||||
|
|
||||||
if [[ "$RESULT" != "0" ]]
|
if [ "$RESULT" != "0" ]; then
|
||||||
then
|
|
||||||
echo "An error occurred. dkms install error: ${RESULT}"
|
echo "An error occurred. dkms install error: ${RESULT}"
|
||||||
echo "Please report this error."
|
echo "Please report this error."
|
||||||
echo "Please copy all screen output and paste it into the problem report."
|
echo "Please copy all screen output and paste it into the problem report."
|
||||||
@ -363,29 +334,27 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# unblock wifi
|
# unblock wifi
|
||||||
if command -v rfkill >/dev/null 2>&1
|
if command -v rfkill >/dev/null 2>&1; then
|
||||||
then
|
|
||||||
rfkill unblock wlan
|
rfkill unblock wlan
|
||||||
else
|
else
|
||||||
echo "Unable to run $ rfkill unblock wlan"
|
echo "Unable to run $ rfkill unblock wlan"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if NoPrompt is not used, ask user some questions
|
# if NoPrompt is not used, ask user some questions
|
||||||
if [ $NO_PROMPT -ne 1 ]
|
if [ $NO_PROMPT -ne 1 ]; then
|
||||||
then
|
printf "Do you want to edit the driver options file now? [y/N] "
|
||||||
read -p "Do you want to edit the driver options file now? [y/N] " -n 1 -r
|
read -r REPLY
|
||||||
echo
|
echo
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
case "$REPLY" in
|
||||||
then
|
[yY]*) ${TEXT_EDITOR} /etc/modprobe.d/${OPTIONS_FILE} ;;
|
||||||
${TEXT_EDITOR} /etc/modprobe.d/${OPTIONS_FILE}
|
esac
|
||||||
fi
|
|
||||||
|
|
||||||
read -p "Do you want to reboot now? (recommended) [y/N] " -n 1 -r
|
printf "Do you want to reboot now? (recommended) [y/N] "
|
||||||
|
read -r REPLY
|
||||||
echo
|
echo
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
case "$REPLY" in
|
||||||
then
|
[yY]*) reboot ;;
|
||||||
reboot
|
esac
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
# Purpose: Remove Realtek out-of-kernel USB WiFi adapter drivers.
|
# Purpose: Remove Realtek out-of-kernel USB WiFi adapter drivers.
|
||||||
#
|
#
|
||||||
@ -33,12 +33,10 @@ KARCH="$(uname -m)"
|
|||||||
MODDESTDIR="/lib/modules/${KVER}/kernel/drivers/net/wireless/"
|
MODDESTDIR="/lib/modules/${KVER}/kernel/drivers/net/wireless/"
|
||||||
|
|
||||||
DRV_NAME="rtl${MODULE_NAME}"
|
DRV_NAME="rtl${MODULE_NAME}"
|
||||||
DRV_DIR="$(pwd)"
|
|
||||||
OPTIONS_FILE="${MODULE_NAME}.conf"
|
OPTIONS_FILE="${MODULE_NAME}.conf"
|
||||||
|
|
||||||
# check to ensure sudo was used
|
# check to ensure sudo was used
|
||||||
if [[ $EUID -ne 0 ]]
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
then
|
|
||||||
echo "You must run this script with superuser (root) privileges."
|
echo "You must run this script with superuser (root) privileges."
|
||||||
echo "Try: \"sudo ./${SCRIPT_NAME}\""
|
echo "Try: \"sudo ./${SCRIPT_NAME}\""
|
||||||
exit 1
|
exit 1
|
||||||
@ -48,8 +46,7 @@ fi
|
|||||||
NO_PROMPT=0
|
NO_PROMPT=0
|
||||||
|
|
||||||
# get the script options
|
# get the script options
|
||||||
while [ $# -gt 0 ]
|
while [ $# -gt 0 ]; do
|
||||||
do
|
|
||||||
case $1 in
|
case $1 in
|
||||||
NoPrompt)
|
NoPrompt)
|
||||||
NO_PROMPT=1 ;;
|
NO_PROMPT=1 ;;
|
||||||
@ -68,31 +65,28 @@ echo ": ${SCRIPT_NAME} v${SCRIPT_VERSION}"
|
|||||||
|
|
||||||
# check for and remove non-dkms installations
|
# check for and remove non-dkms installations
|
||||||
# standard naming
|
# standard naming
|
||||||
if [[ -f "${MODDESTDIR}${MODULE_NAME}.ko" ]]
|
if [ -f "${MODDESTDIR}${MODULE_NAME}.ko" ]; then
|
||||||
then
|
|
||||||
echo "Removing a non-dkms installation: ${MODDESTDIR}${MODULE_NAME}.ko"
|
echo "Removing a non-dkms installation: ${MODDESTDIR}${MODULE_NAME}.ko"
|
||||||
rm -f ${MODDESTDIR}${MODULE_NAME}.ko
|
rm -f "${MODDESTDIR}${MODULE_NAME}.ko"
|
||||||
/sbin/depmod -a ${KVER}
|
/sbin/depmod -a "${KVER}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check for and remove non-dkms installations
|
# check for and remove non-dkms installations
|
||||||
# with rtl added to module name (PClinuxOS)
|
# with rtl added to module name (PClinuxOS)
|
||||||
if [[ -f "${MODDESTDIR}rtl${MODULE_NAME}.ko" ]]
|
if [ -f "${MODDESTDIR}rtl${MODULE_NAME}.ko" ]; then
|
||||||
then
|
|
||||||
echo "Removing a non-dkms installation: ${MODDESTDIR}rtl${MODULE_NAME}.ko"
|
echo "Removing a non-dkms installation: ${MODDESTDIR}rtl${MODULE_NAME}.ko"
|
||||||
rm -f ${MODDESTDIR}rtl${MODULE_NAME}.ko
|
rm -f "${MODDESTDIR}rtl${MODULE_NAME}.ko"
|
||||||
/sbin/depmod -a ${KVER}
|
/sbin/depmod -a "${KVER}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check for and remove non-dkms installations
|
# check for and remove non-dkms installations
|
||||||
# with compressed module in a unique non-standard location (Armbian)
|
# with compressed module in a unique non-standard location (Armbian)
|
||||||
# Example: /usr/lib/modules/5.15.80-rockchip64/kernel/drivers/net/wireless/rtl8821cu/8821cu.ko.xz
|
# Example: /usr/lib/modules/5.15.80-rockchip64/kernel/drivers/net/wireless/rtl8821cu/8821cu.ko.xz
|
||||||
# Dear Armbiam, this is a really bad idea.
|
# Dear Armbiam, this is a really bad idea.
|
||||||
if [[ -f "/usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz" ]]
|
if [ -f "/usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz" ]; then
|
||||||
then
|
|
||||||
echo "Removing a non-dkms installation: /usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz"
|
echo "Removing a non-dkms installation: /usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz"
|
||||||
rm -f /usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz
|
rm -f "/usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz"
|
||||||
/sbin/depmod -a ${KVER}
|
/sbin/depmod -a "${KVER}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# information that helps with bug reports
|
# information that helps with bug reports
|
||||||
@ -104,8 +98,7 @@ echo ": ${KVER}"
|
|||||||
echo ": ${KARCH}"
|
echo ": ${KARCH}"
|
||||||
|
|
||||||
# determine if dkms is installed and run the appropriate routines
|
# determine if dkms is installed and run the appropriate routines
|
||||||
if command -v dkms >/dev/null 2>&1
|
if command -v dkms >/dev/null 2>&1; then
|
||||||
then
|
|
||||||
echo "Removing a dkms installation."
|
echo "Removing a dkms installation."
|
||||||
# 2>/dev/null suppresses the output of dkms
|
# 2>/dev/null suppresses the output of dkms
|
||||||
dkms remove -m ${DRV_NAME} -v ${DRV_VERSION} --all 2>/dev/null
|
dkms remove -m ${DRV_NAME} -v ${DRV_VERSION} --all 2>/dev/null
|
||||||
@ -115,10 +108,8 @@ then
|
|||||||
# RESULT will be 3 if there are no instances of module to remove
|
# RESULT will be 3 if there are no instances of module to remove
|
||||||
# however we still need to remove various files or the install script
|
# however we still need to remove various files or the install script
|
||||||
# may complain.
|
# may complain.
|
||||||
if [[ ("$RESULT" = "0")||("$RESULT" = "3") ]]
|
if [ "$RESULT" = "0" ] || [ "$RESULT" = "3" ]; then
|
||||||
then
|
if [ "$RESULT" = "0" ]; then
|
||||||
if [[ ("$RESULT" = "0") ]]
|
|
||||||
then
|
|
||||||
echo "${DRV_NAME}/${DRV_VERSION} has been removed"
|
echo "${DRV_NAME}/${DRV_VERSION} has been removed"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -137,14 +128,13 @@ echo "The driver was removed successfully."
|
|||||||
echo "You may now delete the driver directory if desired."
|
echo "You may now delete the driver directory if desired."
|
||||||
|
|
||||||
# if NoPrompt is not used, ask user some questions
|
# if NoPrompt is not used, ask user some questions
|
||||||
if [ $NO_PROMPT -ne 1 ]
|
if [ $NO_PROMPT -ne 1 ]; then
|
||||||
then
|
printf "Do you want to reboot now? (recommended) [y/N] "
|
||||||
read -p "Do you want to reboot now? (recommended) [y/N] " -n 1 -r
|
read -r REPLY
|
||||||
echo
|
echo
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
case "$REPLY" in
|
||||||
then
|
[yY]*) reboot ;;
|
||||||
reboot
|
esac
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
SCRIPT_NAME="save-log.sh"
|
SCRIPT_NAME="save-log.sh"
|
||||||
#
|
#
|
||||||
@ -12,7 +12,7 @@ SCRIPT_NAME="save-log.sh"
|
|||||||
#
|
#
|
||||||
# $ sudo ./edit-options.sh
|
# $ sudo ./edit-options.sh
|
||||||
#
|
#
|
||||||
if [[ $EUID -ne 0 ]]; then
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
echo "You must run this script with superuser (root) privileges."
|
echo "You must run this script with superuser (root) privileges."
|
||||||
echo "Try: \"sudo ./${SCRIPT_NAME}\""
|
echo "Try: \"sudo ./${SCRIPT_NAME}\""
|
||||||
exit 1
|
exit 1
|
||||||
@ -24,7 +24,7 @@ rm -f -- rtw.log
|
|||||||
dmesg | cut -d"]" -f2- | grep "RTW" >> rtw.log
|
dmesg | cut -d"]" -f2- | grep "RTW" >> rtw.log
|
||||||
RESULT=$?
|
RESULT=$?
|
||||||
|
|
||||||
if [[ "$RESULT" != "0" ]]; then
|
if [ "$RESULT" != "0" ]; then
|
||||||
echo "An error occurred while running: ${SCRIPT_NAME}"
|
echo "An error occurred while running: ${SCRIPT_NAME}"
|
||||||
echo "Did you set a log level > 0 ?"
|
echo "Did you set a log level > 0 ?"
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
Reference in New Issue
Block a user