rtl8188eu/install.sh

186 lines
4.7 KiB
Bash
Raw Normal View History

2022-12-25 20:09:27 +01:00
#!/bin/bash
2022-12-27 16:13:52 +01:00
# Simple install script for 8188eu
2023-01-14 10:52:28 +01:00
# December, 25 2022 v0.0.4 borislavIvanov
2022-12-26 13:58:40 +01:00
MODNAME="8188eu"
DRVNAME="rtl8188eu"
DRVVER="5.13.3"
2022-12-27 16:17:58 +01:00
DRVSTATUS="installed"
2022-12-26 13:58:40 +01:00
KVER="$(uname -r)"
MODDESTDIR="/lib/modules/${KVER}/kernel/drivers/net/wireless/"
2023-01-14 10:43:03 +01:00
BLFILE="/etc/modprobe.d/realtek.conf"
BLDRV="r8188eu"
2022-12-25 20:09:27 +01:00
help () {
echo ""
echo "usage: ./install.sh [options]"
echo ""
echo "options:"
echo ""
2022-12-26 13:58:40 +01:00
echo " -i : Install Realtek ${DRVNAME} Wireless Lan Driver"
echo " -u : Uninstall Realtek ${DRVNAME} Wireless Lan Driver"
2022-12-25 20:09:27 +01:00
echo " -h, --help : Displays this usage screen"
echo ""
exit
}
inst_drv () {
if ! command -v dkms >/dev/null 2>&1;then
2022-12-26 13:58:40 +01:00
if [ ! -f "${MODDESTDIR}${MODNAME}.ko" ];then
2022-12-25 20:09:27 +01:00
make clean; Error=$?
make; Error=$?
if [ "$Error" != "0" ];then
echo "Install error: $Error"
exit
else
if [ "$EUID" != "0" ];then
echo "You need root permissions:"
sudo make install; Error=$?
else
make install; Error=$?
fi
fi
else
2022-12-26 13:58:40 +01:00
echo "Module ${DRVNAME} already installed"
2022-12-25 20:09:27 +01:00
fi
else
2022-12-27 16:17:58 +01:00
if [[ ! "$(echo "`dkms status`" | awk '/'${DRVNAME}'/ {print}')" =~ "${DRVSTATUS}" ]];then
2023-01-07 09:12:48 +01:00
make clean; Error=$?
2022-12-26 13:58:40 +01:00
if [ -e /usr/src/${DRVNAME}-${DRVVER} ];then
if [ "$EUID" != "0" ];then
echo "You need root permissions:"
sudo rm -r /usr/src/${DRVNAME}-${DRVVER}
sudo cp -r "$(pwd)" /usr/src/${DRVNAME}-${DRVVER}
else
rm -r /usr/src/${DRVNAME}-${DRVVER}
cp -r "$(pwd)" /usr/src/${DRVNAME}-${DRVVER}
fi
else
if [ "$EUID" != "0" ];then
echo "You need root permissions:"
sudo cp -r "$(pwd)" /usr/src/${DRVNAME}-${DRVVER}
else
cp -r "$(pwd)" /usr/src/${DRVNAME}-${DRVVER}
fi
fi
if [ -f "${MODDESTDIR}${MODNAME}.ko" ];then
2022-12-25 20:09:27 +01:00
if [ "$EUID" != "0" ];then
echo "You need root permissions:"
2022-12-26 13:58:40 +01:00
sudo rm -f ${MODDESTDIR}${MODNAME}.ko
2022-12-25 20:09:27 +01:00
else
2022-12-26 13:58:40 +01:00
rm -f ${MODDESTDIR}${MODNAME}.ko
fi
fi
2022-12-27 16:17:58 +01:00
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
2022-12-26 13:58:40 +01:00
else
2022-12-27 16:17:58 +01:00
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
2022-12-26 13:58:40 +01:00
fi
if [ "$Error" != "0" ];then
echo "Install error: $Error"
exit
else
if [ "$EUID" != "0" ];then
echo "You need root permissions:"
sudo dkms install -m ${DRVNAME} -v ${DRVVER}; Error=$?
else
dkms install -m ${DRVNAME} -v ${DRVVER}; Error=$?
fi
fi
else
echo "Module ${DRVNAME} already installed"
fi
fi
}
uinst_drv () {
if ! command -v dkms >/dev/null 2>&1;then
if [ -f "${MODDESTDIR}${MODNAME}.ko" ];then
if [ "$EUID" != "0" ];then
echo "You need root permissions:"
sudo make uninstall; Error=$?
else
make uninstall; Error=$?
fi
else
echo "Module ${DRVNAME} already uninstalled"
fi
else
2023-01-07 09:12:48 +01:00
if [[ ! -z "$(echo "`dkms status`" | awk '/'${DRVNAME}'/ {print}')" ]];then
2022-12-26 13:58:40 +01:00
if [ "$EUID" != "0" ];then
echo "You need root permissions:"
sudo dkms remove -m ${DRVNAME} -v ${DRVVER} --all; Error=$?
else
dkms remove -m ${DRVNAME} -v ${DRVVER} --all; Error=$?
fi
else
echo "Module ${DRVNAME} already uninstalled"
fi
fi
}
2023-01-14 10:43:03 +01:00
bl_drv () {
if [ "$1" = "-i" ]; then
if [ ! -z "${BLDRV}" ] && [ "$Error" = "0" ]; then
if [ ! -e ${BLFILE} ]; then
sudo sh -c "echo 'blacklist ${BLDRV}' > ${BLFILE}"
else
if [[ ! "$(cat ${BLFILE} | awk '/'${BLDRV}'/ {print}')" =~ "${BLDRV}" ]]; then
sudo sh -c "echo 'blacklist ${BLDRV}' >> ${BLFILE}"
else
echo "Module ${BLDRV} already blacklisted"
fi
fi
fi
elif [ "$1" = "-u" ]; then
if [ ! -z "${BLDRV}" ] && [ "$Error" = "0" ]; then
if [ -e ${BLFILE} ]; then
if [[ "$(cat ${BLFILE} | awk '/'${BLDRV}'/ {print}')" =~ "${BLDRV}" ]]; then
sudo sed -i '/'${BLDRV}'/d' ${BLFILE}
if [ ! -s "${BLFILE}" ];then
sudo rm -r ${BLFILE}
fi
else
echo "Module ${BLDRV} already unblacklisted"
fi
else
echo "Module ${BLDRV} already unblacklisted"
fi
fi
fi
}
2022-12-26 13:58:40 +01:00
if [ -z "$1" ];then
echo "[options] is not defined"
help
elif [ "$1" = "-h" ] || [ "$1" = "--help" ];then
help
elif [ "$1" = "-i" ];then
echo "Install Realtek ${DRVNAME} Wireless Lan Driver..."
inst_drv
2023-01-14 10:43:03 +01:00
bl_drv "$1"
2022-12-26 13:58:40 +01:00
elif [ "$1" = "-u" ];then
echo "Uninstall Realtek ${DRVNAME} Wireless Lan Driver..."
uinst_drv
2023-01-14 10:43:03 +01:00
bl_drv "$1"
2022-12-26 13:58:40 +01:00
else
echo "Incorrect [options] "$1""
help
2022-12-25 20:09:27 +01:00
fi