Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- function execute_with_sudo() {
- if [ "$EUID" -ne 0 ]; then
- sudo "$@"
- else
- "$@"
- fi
- }
- function check_online_git() {
- if ! command -v git &>/dev/null; then
- echo "Git is not installed. Please install Git before proceeding."
- return 1
- fi
- if ! curl --head --silent https://github.com/lwfinger/rtw88.git &>/dev/null; then
- echo "Git repository is not available online. Please check your internet connection or the repository URL."
- return 1
- fi
- return 0
- }
- function check_device() {
- if ! lsusb | grep -q "0bda:885c"; then
- echo "Realtek device 0bda:885c not found. Make sure the device is connected."
- return 1
- fi
- return 0
- }
- function check_existing_folder() {
- if [ -d "rtw88" ]; then
- echo "'rtw88' folder already exists. No need to clone again."
- return 1
- fi
- return 0
- }
- function install_dependencies() {
- echo "Installing dependencies..."
- execute_with_sudo apt update
- execute_with_sudo apt install -y git build-essential dkms
- }
- function download_driver() {
- check_device || return
- check_online_git || return
- check_existing_folder || return
- echo "Downloading the driver..."
- git clone https://github.com/lwfinger/rtw88.git
- }
- function install_driver() {
- echo "Installing the driver..."
- cd rtw88
- make
- execute_with_sudo make install
- }
- function load_kernel_module() {
- echo "Loading the kernel module..."
- execute_with_sudo modprobe rtw_8822b
- }
- function update_udev_rules() {
- echo "Updating udev rules..."
- execute_with_sudo update-initramfs -u
- }
- function main() {
- clear
- echo "Starting the installation of the Realtek 0bda:885c driver..."
- check_device || return
- install_dependencies
- download_driver
- install_driver
- load_kernel_module
- update_udev_rules
- echo "Driver installed successfully."
- }
- main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement