From 830969dc0ce31136f5159ef689d2fc3c33dc3c41 Mon Sep 17 00:00:00 2001 From: ivanovborislav <81085106+ivanovborislav@users.noreply.github.com> Date: Tue, 27 Dec 2022 17:12:07 +0200 Subject: [PATCH] Update install.sh --- install.sh | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index 0df6077..f0a3674 100644 --- a/install.sh +++ b/install.sh @@ -1,10 +1,11 @@ #!/bin/bash -# Simple install script for 8188eu +# Simple install script for 88x2bu # December, 25 2022 v0.0.2 borislavIvanov MODNAME="8188eu" DRVNAME="rtl8188eu" DRVVER="5.13.3" +DRVSTATUS="installed" KVER="$(uname -r)" MODDESTDIR="/lib/modules/${KVER}/kernel/drivers/net/wireless/" @@ -41,7 +42,7 @@ if ! command -v dkms >/dev/null 2>&1;then echo "Module ${DRVNAME} already installed" fi else - if [[ ! "`dkms status`" =~ "${DRVNAME}" ]];then + if [[ ! "$(echo "`dkms status`" | awk '/'${DRVNAME}'/ {print}')" =~ "${DRVSTATUS}" ]];then if [ -e /usr/src/${DRVNAME}-${DRVVER} ];then if [ "$EUID" != "0" ];then echo "You need root permissions:" @@ -67,13 +68,26 @@ else rm -f ${MODDESTDIR}${MODNAME}.ko fi fi - if [ "$EUID" != "0" ];then - echo "You need root permissions:" - sudo dkms add -m ${DRVNAME} -v ${DRVVER}; Error=$? - sudo dkms build -m ${DRVNAME} -v ${DRVVER}; Error=$? + if [[ ! -z "$(echo "`dkms status`" | awk '/'${DRVNAME}'/ {print}')" ]];then + if [ "$EUID" != "0" ];then + echo "You need root permissions:" + sudo dkms remove -m ${DRVNAME} -v ${DRVVER} --all; Error=$? + sudo dkms add -m ${DRVNAME} -v ${DRVVER}; Error=$? + sudo dkms build -m ${DRVNAME} -v ${DRVVER}; Error=$? + else + dkms remove -m ${DRVNAME} -v ${DRVVER} --all; Error=$? + dkms add -m ${DRVNAME} -v ${DRVVER}; Error=$? + dkms build -m ${DRVNAME} -v ${DRVVER}; Error=$? + fi else - dkms add -m ${DRVNAME} -v ${DRVVER}; Error=$? - dkms build -m ${DRVNAME} -v ${DRVVER}; Error=$? + if [ "$EUID" != "0" ];then + echo "You need root permissions:" + sudo dkms add -m ${DRVNAME} -v ${DRVVER}; Error=$? + sudo dkms build -m ${DRVNAME} -v ${DRVVER}; Error=$? + else + dkms add -m ${DRVNAME} -v ${DRVVER}; Error=$? + dkms build -m ${DRVNAME} -v ${DRVVER}; Error=$? + fi fi if [ "$Error" != "0" ];then echo "Install error: $Error" @@ -105,7 +119,7 @@ if ! command -v dkms >/dev/null 2>&1;then echo "Module ${DRVNAME} already uninstalled" fi else - if [[ "`dkms status`" =~ "${DRVNAME}" ]];then + if [[ "$(echo "`dkms status`" | awk '/'${DRVNAME}'/ {print}')" =~ "${DRVSTATUS}" ]] || [[ ! -z "$(echo "`dkms status`" | awk '/'${DRVNAME}'/ {print}')" ]];then if [ "$EUID" != "0" ];then echo "You need root permissions:" sudo dkms remove -m ${DRVNAME} -v ${DRVVER} --all; Error=$?