diff --git a/install.sh b/install.sh index 5550508..1414b55 100644 --- a/install.sh +++ b/install.sh @@ -1,51 +1,63 @@ #!/bin/bash -if [ "$(id -u)" != "0" ]; then - echo "This script must be run as root" 1>&2 - exit 1 -fi +function vefificaRoot(){ + if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 + fi +} -sudo apt install build-essential bc git wget +function installDep(){ + for dep in build-essential bc git wget; do + sudo apt install $dep + done +} -cd /usr/src +function configure(){ -git clone --depth 1 https://github.com/raspberrypi/linux.git + cd /usr/src + git clone --depth 1 https://github.com/raspberrypi/linux.git -ln -s linux $(uname -r) -ln -s /usr/src/linux /lib/modules/$(uname -r)/build -cd linux + ln -s linux $(uname -r) + ln -s /usr/src/linux /lib/modules/$(uname -r)/build + cd linux -wget -O Module.symvers https://raw.githubusercontent.com/raspberrypi/firmware/master/extra/Module7.symvers -KERNEL=kernel7 + wget -O Module.symvers https://raw.githubusercontent.com/raspberrypi/firmware/master/extra/Module7.symvers + KERNEL=kernel7 -make bcm2709_defconfig && make prepare && make modules_prepare + make bcm2709_defconfig && make prepare && make modules_prepare -sudo wget "https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source" -O /usr/bin/rpi-source -sudo chmod 755 /usr/bin/rpi-source -rpi-source --skip-gcc + sudo wget "https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source" -O /usr/bin/rpi-source + sudo chmod 755 /usr/bin/rpi-source + rpi-source --skip-gcc -git clone "https://github.com/gnab/rtl8812au" -cd rtl8812au + git clone "https://github.com/gnab/rtl8812au" + cd rtl8812au -sed -i 's/CONFIG_PLATFORM_I386_PC = y/CONFIG_PLATFORM_I386_PC = n/g' Makefile -sed -i 's/CONFIG_PLATFORM_ARM_RPI = n/CONFIG_PLATFORM_ARM_RPI = y/g' Makefile + sed -i 's/CONFIG_PLATFORM_I386_PC = y/CONFIG_PLATFORM_I386_PC = n/g' Makefile + sed -i 's/CONFIG_PLATFORM_ARM_RPI = n/CONFIG_PLATFORM_ARM_RPI = y/g' Makefile -make + make -sudo cp 8812au.ko /lib/modules/`uname -r`/kernel/drivers/net/wireless -sudo depmod -a -sudo modprobe 8812au + sudo cp 8812au.ko /lib/modules/`uname -r`/kernel/drivers/net/wireless + sudo depmod -a + sudo modprobe 8812au -echo " - ***Success*** -***Module will be activated automatically at next reboot*** -" && + echo " + ***Success*** + ***Module will be activated automatically at next reboot*** + " && -while true; do - read -p "Do you wish to activate the module now? (y/n)" yn - case $yn in - [Yy]* ) insmod 8812au.ko && echo "***Module activated***" && break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done + while true; do + read -p "Do you wish to activate the module now? (y/n)" yn + case $yn in + [Yy]* ) insmod 8812au.ko && echo "***Module activated***" && break;; + [Nn]* ) exit;; + * ) echo "Please answer yes or no.";; + esac + done +} + +verificaRoot +installDep +configure