mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-28 21:44:50 +03:00
f68264965f
x-ui install-awg-kernel stopped at the DKMS build on Ubuntu 26.04 with a 7.0.x kernel: Ubuntu backported the struct sock * form of setup_udp_tunnel_sock(), and the pinned v3.1.20260906 compat header still passed it a struct socket * on every kernel below 7.1.5, so AmneziaWG kernel mode could not be enabled there. v3.1.20261113 skips that shim on Ubuntu 7.0 kernels with ABI 38 or later; the only other change in it is the version string. The tools pin is unchanged. Built with DKMS against linux-headers 7.0.0-44-generic (Ubuntu 26.04): the old pin fails with the reported error and the new one produces amneziawg.ko. Both pins build against Debian 13's 6.12 headers.
85 lines
3.3 KiB
Bash
85 lines
3.3 KiB
Bash
#!/usr/bin/env bash
|
|
#
|
|
# Installs the AmneziaWG kernel module and tools, the prerequisite for an
|
|
# AmneziaWG inbound's "kernel mode" (internal/amneziawgkern). Without it the
|
|
# panel refuses to enable the setting and says why.
|
|
#
|
|
# Verified on Debian 13 (trixie), kernel 7.1.11-x64v3-xanmod1, x86_64.
|
|
set -eu
|
|
|
|
log() { printf '\n==> %s\n' "$*"; }
|
|
die() { printf '\nERROR: %s\n' "$*" >&2; exit 1; }
|
|
|
|
[ "$(id -u)" -eq 0 ] || die "run as root"
|
|
command -v apt-get >/dev/null || die "this installer supports Debian and Ubuntu; elsewhere install amneziawg-linux-kernel-module and amneziawg-tools 3.x by hand"
|
|
|
|
KERNEL="$(uname -r)"
|
|
SRC_DIR="${SRC_DIR:-/usr/local/src}"
|
|
MODULE_REPO="https://github.com/amnezia-vpn/amneziawg-linux-kernel-module.git"
|
|
TOOLS_REPO="https://github.com/amnezia-vpn/amneziawg-tools.git"
|
|
|
|
# Pinned to tested releases and verified by commit, since this runs as root.
|
|
# Module and tools must share the 3.x series: 1.0 tools send u32 H1-H4 and
|
|
# `awg setconf` then fails with "Invalid argument".
|
|
MODULE_TAG="v3.1.20261113"
|
|
MODULE_COMMIT="6879e270797840b148cd71e7fe04d19f9ddbda96"
|
|
TOOLS_TAG="v3.1.20260812"
|
|
TOOLS_COMMIT="ee0f0a9aa34ff0a0da4b3433b9512781cfe02843"
|
|
|
|
log "Kernel: $KERNEL"
|
|
[ -d "/lib/modules/$KERNEL/build" ] || die "kernel headers missing; install linux-headers-$KERNEL"
|
|
|
|
log "Installing build dependencies"
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
apt-get update -qq
|
|
apt-get install -y -qq dkms build-essential git libmnl-dev pkg-config nftables
|
|
|
|
# A clang-built kernel makes DKMS invoke the module build with LLVM=1, which
|
|
# fails outright when only gcc is present. /proc/version names the compiler.
|
|
if grep -qi clang /proc/version; then
|
|
log "Kernel was built with clang; installing the LLVM toolchain to match"
|
|
apt-get install -y -qq clang lld llvm
|
|
fi
|
|
|
|
log "Module $MODULE_TAG, tools $TOOLS_TAG"
|
|
|
|
mkdir -p "$SRC_DIR"
|
|
cd "$SRC_DIR"
|
|
rm -rf amneziawg-linux-kernel-module amneziawg-tools
|
|
git clone -q --depth 1 --branch "$MODULE_TAG" "$MODULE_REPO"
|
|
git clone -q --depth 1 --branch "$TOOLS_TAG" "$TOOLS_REPO"
|
|
[ "$(git -C amneziawg-linux-kernel-module rev-parse HEAD)" = "$MODULE_COMMIT" ] || die "module $MODULE_TAG is not commit $MODULE_COMMIT"
|
|
[ "$(git -C amneziawg-tools rev-parse HEAD)" = "$TOOLS_COMMIT" ] || die "tools $TOOLS_TAG is not commit $TOOLS_COMMIT"
|
|
|
|
MODULE_SRC="$SRC_DIR/amneziawg-linux-kernel-module/src"
|
|
|
|
log "Building the module via DKMS"
|
|
cd "$MODULE_SRC"
|
|
rm -rf /usr/src/amneziawg-1.0.0
|
|
make dkms-install
|
|
dkms status -m amneziawg -v 1.0.0 | grep -q . || dkms add -m amneziawg -v 1.0.0
|
|
dkms build -m amneziawg -v 1.0.0
|
|
dkms install -m amneziawg -v 1.0.0 --force
|
|
|
|
log "Loading the module"
|
|
modprobe amneziawg
|
|
lsmod | grep -q '^amneziawg' || die "module did not load"
|
|
|
|
# The panel is sandboxed with ProtectKernelModules=yes, so the boot-time load
|
|
# has to come from modules-load.d; modprobe alone only lasts until reboot (#7186).
|
|
log "Loading the module at boot"
|
|
mkdir -p /etc/modules-load.d
|
|
printf 'amneziawg\n' > /etc/modules-load.d/amneziawg.conf
|
|
|
|
log "Building amneziawg-tools"
|
|
cd "$SRC_DIR/amneziawg-tools/src"
|
|
make
|
|
make install
|
|
|
|
log "Done"
|
|
printf ' module: %s\n' "$(dkms status -m amneziawg)"
|
|
printf ' tools: %s\n' "$(awg --version)"
|
|
printf ' boot: /etc/modules-load.d/amneziawg.conf\n'
|
|
printf '\nEnable "Kernel mode" on the AmneziaWG inbound in the panel to use it.\n'
|
|
printf 'DKMS rebuilds the module on kernel upgrades; Secure Boot hosts must sign it.\n'
|