2020-03-24 13:16:25 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
2025-05-07 19:47:24 +02:00
|
|
|
function main() {
|
|
|
|
local VERSION
|
|
|
|
VERSION="$(get_version)"
|
|
|
|
ensure_no_cli_args "$@"
|
|
|
|
ensure_root_permissions
|
2025-05-09 09:09:26 +02:00
|
|
|
remove_driver
|
2025-05-07 19:47:24 +02:00
|
|
|
put_sources_in_place "$VERSION"
|
|
|
|
deploy_driver "$VERSION"
|
|
|
|
}
|
|
|
|
|
2025-05-09 09:10:26 +02:00
|
|
|
function get_version() {
|
|
|
|
sed -En 's/PACKAGE_VERSION="(.*)"/\1/p' dkms.conf
|
|
|
|
}
|
|
|
|
|
2020-03-24 13:16:25 +01:00
|
|
|
function ensure_no_cli_args() {
|
2025-05-07 19:47:24 +02:00
|
|
|
if [ $# -ne 0 ]; then
|
2020-03-24 13:16:25 +01:00
|
|
|
echo "No command line arguments accepted!" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function ensure_root_permissions() {
|
2025-05-07 19:47:24 +02:00
|
|
|
if ! sudo -v; then
|
2020-03-24 13:16:25 +01:00
|
|
|
echo "Root permissions required to deploy the driver!" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2025-05-09 09:09:26 +02:00
|
|
|
function remove_driver() {
|
|
|
|
sudo dkms remove rtl88x2bu/5.8.7.1 --all &>/dev/null || true
|
2020-03-24 13:16:25 +01:00
|
|
|
}
|
|
|
|
|
2025-05-07 19:47:24 +02:00
|
|
|
function put_sources_in_place() {
|
|
|
|
local VERSION="$1"
|
|
|
|
sudo rsync --delete --exclude=.git -rvhP ./ "/usr/src/rtl88x2bu-${VERSION}"
|
|
|
|
}
|
|
|
|
|
2020-03-24 13:16:25 +01:00
|
|
|
function deploy_driver() {
|
2025-05-07 19:47:24 +02:00
|
|
|
local VERSION="$1"
|
|
|
|
sudo dkms "add" -m rtl88x2bu -v "${VERSION}"
|
|
|
|
find /boot -maxdepth 1 -iname "initrd.img*" |
|
|
|
|
cut -d- -f2- |
|
|
|
|
while read -r kernel; do
|
|
|
|
# xargs -n1 sudo dkms install -m rtl88x2bu -v 5.8.7.1 -k
|
|
|
|
for action in build install; do
|
|
|
|
sudo dkms "${action}" -m rtl88x2bu -v "${VERSION}" -k "${kernel}"
|
|
|
|
done
|
|
|
|
done
|
2020-03-24 13:16:25 +01:00
|
|
|
sudo modprobe 88x2bu
|
|
|
|
}
|
|
|
|
|
2025-05-07 19:47:24 +02:00
|
|
|
main "$@"
|