├── Alfasetup.sh └── README.md /Alfasetup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # AWUS036ACH Automated Driver Install Script 4 | 5 | # Function to check if running as root 6 | check_root() { 7 | if [[ $EUID -ne 0 ]]; then 8 | echo "This script must be run as root. Use 'sudo' or log in as the root user." 9 | exit 1 10 | fi 11 | } 12 | 13 | # Check for Linux distribution 14 | detect_distribution() { 15 | if [[ -f /etc/debian_version ]]; then 16 | PACKAGE_MANAGER="apt-get" 17 | elif [[ -f /etc/redhat-release ]]; then 18 | PACKAGE_MANAGER="dnf" 19 | else 20 | echo "Unsupported Linux distribution. Exiting." 21 | exit 1 22 | fi 23 | } 24 | 25 | # Install git if not present 26 | install_git() { 27 | if ! command -v git &> /dev/null; then 28 | echo "git is not installed. Installing git..." 29 | sudo "$PACKAGE_MANAGER" install git -y 30 | fi 31 | } 32 | 33 | # Install kernel headers 34 | install_kernel_headers() { 35 | echo "Installing kernel headers..." 36 | if ! sudo "$PACKAGE_MANAGER" install linux-headers-$(uname -r) -y; then 37 | echo "Specific kernel headers not found. Installing generic headers instead..." 38 | sudo "$PACKAGE_MANAGER" install linux-headers-generic -y 39 | if [[ $? -ne 0 ]]; then 40 | echo "Failed to install kernel headers. Exiting." 41 | exit 1 42 | fi 43 | fi 44 | } 45 | 46 | # Update and upgrade system packages 47 | update_system() { 48 | echo "Setting DEBIAN_FRONTEND to noninteractive for updates." 49 | export DEBIAN_FRONTEND=noninteractive 50 | 51 | echo "Installing updates and upgrades. Give it some time." 52 | sudo "$PACKAGE_MANAGER" update -y && \ 53 | sudo "$PACKAGE_MANAGER" upgrade -y && \ 54 | sudo "$PACKAGE_MANAGER" dist-upgrade -y 55 | } 56 | 57 | # Check if the Realtek driver is already installed 58 | check_existing_driver() { 59 | if lsmod | grep -q "88XXau"; then 60 | echo "Driver already installed." 61 | 62 | # Ask the user if they want to remove the existing driver 63 | read -p "Do you want to remove the existing installation? (y/n): " REMOVE_CHOICE 64 | 65 | if [[ "$REMOVE_CHOICE" == "y" || "$REMOVE_CHOICE" == "Y" ]]; then 66 | echo "Removing existing driver installation." 67 | 68 | # Unload the kernel module 69 | sudo rmmod 88XXau 70 | if [[ $? -ne 0 ]]; then 71 | echo "Failed to remove the driver from the kernel. Exiting." 72 | exit 1 73 | fi 74 | 75 | # Check if DKMS is managing the module and remove it 76 | if command -v dkms &> /dev/null; then 77 | # Need to specify the module and version for removal 78 | sudo dkms remove rtl8812au/ --all 79 | if [[ $? -ne 0 ]]; then 80 | echo "Failed to remove the driver using DKMS. Continuing to manual removal..." 81 | fi 82 | fi 83 | 84 | # Manually remove the driver files from /lib/modules 85 | DRIVER_PATH="/lib/modules/$(uname -r)/kernel/drivers/net/wireless/88XXau.ko" 86 | if [[ -f "$DRIVER_PATH" ]]; then 87 | sudo rm -f "$DRIVER_PATH" 88 | echo "Driver files removed from $DRIVER_PATH." 89 | else 90 | echo "Driver files not found in $DRIVER_PATH. They might have already been removed." 91 | fi 92 | 93 | # Update module dependencies 94 | sudo depmod -a 95 | 96 | echo "Driver uninstalled successfully." 97 | else 98 | echo "Skipping driver removal." 99 | exit 0 100 | fi 101 | fi 102 | } 103 | 104 | # Option to install Realtek drivers 105 | install_realtek_drivers() { 106 | read -p "Do you want to install Realtek drivers using the package manager (1) or from the source (2)? Enter 1 or 2: " INSTALL_CHOICE 107 | 108 | if [[ "$INSTALL_CHOICE" == "1" ]]; then 109 | echo "Installing Realtek drivers using the package manager." 110 | sudo "$PACKAGE_MANAGER" install realtek-rtl88xxau-dkms -y 111 | elif [[ "$INSTALL_CHOICE" == "2" ]]; then 112 | echo "Installing Realtek drivers from the source." 113 | 114 | echo "Cloning the rtl8812au repository from aircrack-ng..." 115 | git clone https://github.com/aircrack-ng/rtl8812au 116 | 117 | echo "Building all necessary rtl8812 executable files into binary applications. This will take some time." 118 | cd rtl8812au || { echo "Failed to change directory. Exiting."; exit 1; } 119 | 120 | echo "Cleaning previous builds..." 121 | make clean 122 | 123 | echo "Compiling the driver..." 124 | make 125 | if [[ $? -ne 0 ]]; then 126 | echo "Make command failed. Exiting." 127 | exit 1 128 | fi 129 | 130 | echo "Taking newly created binaries and copying them into the appropriate locations on the file system." 131 | sudo make install 132 | if [[ $? -ne 0 ]]; then 133 | echo "Installation of the driver binaries failed. Exiting." 134 | exit 1 135 | fi 136 | else 137 | echo "Invalid choice. Exiting." 138 | exit 1 139 | fi 140 | } 141 | 142 | # Main script execution 143 | check_root 144 | detect_distribution 145 | update_system 146 | install_git 147 | install_kernel_headers 148 | check_existing_driver 149 | install_realtek_drivers 150 | 151 | echo "Driver installation process completed. Please reboot the system to apply changes." 152 | read -p "Do you want to reboot now? (y/n): " REBOOT_CHOICE 153 | if [[ "$REBOOT_CHOICE" == "y" || "$REBOOT_CHOICE" == "Y" ]]; then 154 | echo "Rebooting now..." 155 | reboot 156 | else 157 | echo "Please remember to reboot your system later to apply changes." 158 | fi 159 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AWUS036ACH Automated Driver Install Script 2 | 3 | ![Hyper-V Not Supported](https://img.shields.io/badge/Hyper--V-not%20supported-red) 4 | ![VMware Supported](https://img.shields.io/badge/VMware-supported-brightgreen) 5 | ![VirtualBox Supported](https://img.shields.io/badge/VirtualBox-supported-brightgreen) 6 | 7 | --- 8 | 9 | **⚠️ This repository is not compatible with Hyper-V!** 10 | Please avoid using Hyper-V — use VirtualBox, VMware, or native hardware instead. 11 | 12 | ## Overview 13 | 14 | This bash script automates the installation of Realtek wireless drivers for the **AWUS036ACH** on Linux systems. It performs the following tasks: 15 | 16 | - Checks for the Linux distribution. 17 | - Installs `git` if not present. 18 | - Updates the system. 19 | - Installs kernel headers necessary for building the driver. 20 | - Installs Realtek drivers. 21 | - Clones the `rtl8812au` repository from Aircrack-ng. 22 | - Compiles the drivers. 23 | - Prompts for a reboot to apply changes. 24 | - Optionally removes any existing driver installations. 25 | 26 | ## Prerequisites 27 | 28 | - The script must be run as root. Use `sudo` or log in as the root user. 29 | - Supported Linux distributions: 30 | - Debian-based (e.g., Debian, Ubuntu) 31 | - Fedora-based (e.g., Fedora, RHEL) 32 | 33 | ## Usage 34 | 35 | 1. Download the script or copy its content into a file. 36 | 2. Clone the repository: 37 | ```bash 38 | git clone https://github.com/Khatcode/AWUS036ACH-Automated-Driver-Install 39 | cd AWUS036ACH-Automated-Driver-Install 40 | ``` 41 | 3. Make the script executable: 42 | ```bash 43 | chmod +x Alfasetup.sh 44 | ``` 45 | 4. Run the script as root: 46 | ```bash 47 | sudo ./Alfasetup.sh 48 | ``` 49 | or combine the commands: 50 | ```bash 51 | git clone https://github.com/Khatcode/AWUS036ACH-Automated-Driver-Install && cd AWUS036ACH-Automated-Driver-Install && chmod +x Alfasetup.sh && sudo ./Alfasetup.sh 52 | ``` 53 | 54 | ## Script Steps 55 | 56 | 1. **Root Check:** 57 | - Verifies if the script is run with root privileges. 58 | 59 | 2. **Distribution Detection:** 60 | - Identifies the Linux distribution to use the appropriate package manager (`apt-get` or `dnf`). 61 | 62 | 3. **Git Installation:** 63 | - Checks for the presence of `git` and installs it if necessary. 64 | 65 | 4. **System Updates:** 66 | - Updates the system, upgrades packages, and performs a distribution upgrade. 67 | - Automatically restarts services during package upgrades without user interaction. 68 | 69 | 5. **Kernel Headers Installation:** 70 | - Installs the necessary kernel headers required for building the driver. 71 | 72 | 6. **Realtek Drivers Installation:** 73 | - Installs Realtek wireless drivers using the detected package manager. 74 | 75 | 7. **Existing Driver Removal:** 76 | - Checks if a version of the driver is already installed. 77 | - Prompts the user to remove the existing installation if found, which helps avoid conflicts. 78 | 79 | 8. **Additional Drivers Installation:** 80 | - Clones the `rtl8812au` repository from Aircrack-ng and compiles the drivers. 81 | 82 | 9. **Executable Building:** 83 | - Compiles the necessary `rtl8812` executable files into binary applications. 84 | 85 | 10. **Installation:** 86 | - Installs the compiled binaries into the appropriate locations on the file system. 87 | 88 | 11. **Reboot Prompt:** 89 | - Notifies the user that a system reboot is necessary to apply changes and initiates a countdown. 90 | 91 | ## Note 92 | 93 | - The script will prompt for a system reboot after completing the installation. 94 | - It is recommended to remove any existing driver installations before proceeding with the new installation to ensure compatibility and avoid potential issues. 95 | --------------------------------------------------------------------------------