#!/bin/sh install_awg_packages() { # Получение pkgarch с наибольшим приоритетом PKGARCH=$(opkg print-architecture | awk 'BEGIN {max=0} {if ($3 > max) {max = $3; arch = $2}} END {print arch}') TARGET=$(ubus call system board | jsonfilter -e '@.release.target' | cut -d '/' -f 1) SUBTARGET=$(ubus call system board | jsonfilter -e '@.release.target' | cut -d '/' -f 2) VERSION=$(ubus call system board | jsonfilter -e '@.release.version') PKGPOSTFIX="_v${VERSION}_${PKGARCH}_${TARGET}_${SUBTARGET}.ipk" BASE_URL="https://github.com/Slava-Shchipunov/awg-openwrt/releases/download/" AWG_DIR="/tmp/amneziawg" mkdir -p "$AWG_DIR" if opkg list-installed | grep -q kmod-amneziawg; then echo "kmod-amneziawg already installed" else KMOD_AMNEZIAWG_FILENAME="kmod-amneziawg${PKGPOSTFIX}" DOWNLOAD_URL="${BASE_URL}v${VERSION}/${KMOD_AMNEZIAWG_FILENAME}" wget -O "$AWG_DIR/$KMOD_AMNEZIAWG_FILENAME" "$DOWNLOAD_URL" if [ $? -eq 0 ]; then echo "kmod-amneziawg file downloaded successfully" else echo "Error downloading kmod-amneziawg. Please, install kmod-amneziawg manually and run the script again" exit 1 fi opkg install "$AWG_DIR/$KMOD_AMNEZIAWG_FILENAME" if [ $? -eq 0 ]; then echo "kmod-amneziawg file downloaded successfully" else echo "Error installing kmod-amneziawg. Please, install kmod-amneziawg manually and run the script again" exit 1 fi fi if opkg list-installed | grep -q amneziawg-tools; then echo "amneziawg-tools already installed" else AMNEZIAWG_TOOLS_FILENAME="amneziawg-tools${PKGPOSTFIX}" DOWNLOAD_URL="${BASE_URL}v${VERSION}/${AMNEZIAWG_TOOLS_FILENAME}" wget -O "$AWG_DIR/$AMNEZIAWG_TOOLS_FILENAME" "$DOWNLOAD_URL" if [ $? -eq 0 ]; then echo "amneziawg-tools file downloaded successfully" else echo "Error downloading amneziawg-tools. Please, install amneziawg-tools manually and run the script again" exit 1 fi opkg install "$AWG_DIR/$AMNEZIAWG_TOOLS_FILENAME" if [ $? -eq 0 ]; then echo "amneziawg-tools file downloaded successfully" else echo "Error installing amneziawg-tools. Please, install amneziawg-tools manually and run the script again" exit 1 fi fi if opkg list-installed | grep -q luci-app-amneziawg; then echo "luci-app-amneziawg already installed" else LUCI_APP_AMNEZIAWG_FILENAME="luci-app-amneziawg${PKGPOSTFIX}" DOWNLOAD_URL="${BASE_URL}v${VERSION}/${LUCI_APP_AMNEZIAWG_FILENAME}" wget -O "$AWG_DIR/$LUCI_APP_AMNEZIAWG_FILENAME" "$DOWNLOAD_URL" if [ $? -eq 0 ]; then echo "luci-app-amneziawg file downloaded successfully" else echo "Error downloading luci-app-amneziawg. Please, install luci-app-amneziawg manually and run the script again" exit 1 fi opkg install "$AWG_DIR/$LUCI_APP_AMNEZIAWG_FILENAME" if [ $? -eq 0 ]; then echo "luci-app-amneziawg file downloaded successfully" else echo "Error installing luci-app-amneziawg. Please, install luci-app-amneziawg manually and run the script again" exit 1 fi fi rm -rf "$AWG_DIR" } install_awg_packages