#!/bin/bash

BASE_DIR="$(cd "$(dirname "$0")" && pwd)"

# 删除旧8821驱动（手动安装的）
cd "$BASE_DIR/script"
chmod +x ./*
./uninstall_old8211_driver.sh

# 安装新的内核6.8
cd "$BASE_DIR/script"
./install_kernel.sh ../kernel6.8

# 更新脚本
cd "$BASE_DIR/script"

cp grub /etc/default/grub
update-grub

cp comfast-usb-switch.sh /usr/local/sbin/
chmod +x /usr/local/sbin/comfast-usb-switch.sh

# rules
cp *.rules /etc/udev/rules.d/

udevadm control --reload
udevadm trigger --subsystem-match=usb --action=add

# 示例：将 usb-storage 加入黑名单
echo "blacklist usb-storage" | tee /etc/modprobe.d/blacklist-usb-storage.conf
update-initramfs -u

# 清理
cd "$BASE_DIR"
rm -rf kernel6.8
rm -rf script

cp 2rd_reboot.rar /root/bin-AOI/newupdate.rar

reboot
