1
0
mirror of https://github.com/morrownr/8821cu-20210916.git synced 2024-11-18 19:44:48 +00:00

Addressed whines from "shellcheck -s sh"

This commit is contained in:
Miles Goodhew 2023-01-26 00:09:22 +11:00
parent 5fd204f3df
commit c0281e1d05
2 changed files with 16 additions and 17 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# Purpose: Remove Realtek out-of-kernel USB WiFi adapter drivers.
#
@ -33,11 +33,10 @@ KARCH="$(uname -m)"
MODDESTDIR="/lib/modules/${KVER}/kernel/drivers/net/wireless/"
DRV_NAME="rtl${MODULE_NAME}"
DRV_DIR="$(pwd)"
OPTIONS_FILE="${MODULE_NAME}.conf"
# check to ensure sudo was used
if [[ $EUID -ne 0 ]]; then
if [ "$(id -u)" -ne 0 ]; then
echo "You must run this script with superuser (root) privileges."
echo "Try: \"sudo ./${SCRIPT_NAME}\""
exit 1
@ -66,28 +65,28 @@ echo ": ${SCRIPT_NAME} v${SCRIPT_VERSION}"
# check for and remove non-dkms installations
# standard naming
if [[ -f "${MODDESTDIR}${MODULE_NAME}.ko" ]]; then
if [ -f "${MODDESTDIR}${MODULE_NAME}.ko" ]; then
echo "Removing a non-dkms installation: ${MODDESTDIR}${MODULE_NAME}.ko"
rm -f ${MODDESTDIR}${MODULE_NAME}.ko
/sbin/depmod -a ${KVER}
rm -f "${MODDESTDIR}${MODULE_NAME}.ko"
/sbin/depmod -a "${KVER}"
fi
# check for and remove non-dkms installations
# with rtl added to module name (PClinuxOS)
if [[ -f "${MODDESTDIR}rtl${MODULE_NAME}.ko" ]]; then
if [ -f "${MODDESTDIR}rtl${MODULE_NAME}.ko" ]; then
echo "Removing a non-dkms installation: ${MODDESTDIR}rtl${MODULE_NAME}.ko"
rm -f ${MODDESTDIR}rtl${MODULE_NAME}.ko
/sbin/depmod -a ${KVER}
rm -f "${MODDESTDIR}rtl${MODULE_NAME}.ko"
/sbin/depmod -a "${KVER}"
fi
# check for and remove non-dkms installations
# 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
# Dear Armbiam, this is a really bad idea.
if [[ -f "/usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz" ]]; then
if [ -f "/usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz" ]; then
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
/sbin/depmod -a ${KVER}
rm -f "/usr/lib/modules/${KVER}/kernel/drivers/net/wireless/${DRV_NAME}/${MODULE_NAME}.ko.xz"
/sbin/depmod -a "${KVER}"
fi
# information that helps with bug reports
@ -109,8 +108,8 @@ if command -v dkms >/dev/null 2>&1; then
# 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
# may complain.
if [[ ("$RESULT" = "0")||("$RESULT" = "3") ]]; then
if [[ ("$RESULT" = "0") ]]; then
if [ "$RESULT" = "0" ] || [ "$RESULT" = "3" ]; then
if [ "$RESULT" = "0" ]; then
echo "${DRV_NAME}/${DRV_VERSION} has been removed"
fi
else
@ -130,9 +129,10 @@ echo "You may now delete the driver directory if desired."
# if NoPrompt is not used, ask user some questions
if [ $NO_PROMPT -ne 1 ]; then
read -p "Do you want to reboot now? (recommended) [y/N] " -n 1 -r
echo "Do you want to reboot now? (recommended) [y/N]"
read -r REPLY
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
if [ "$REPLY" = y ] || [ "$REPLY" = Y ]; then
reboot
fi
fi

View File

@ -1,4 +1,3 @@
#!/usr/bin/dash
#!/bin/sh
#
SCRIPT_NAME="save-log.sh"