amnezia-vpn / amneziawg-linux-kernel-module

AmneziaWG Linux kernel module
https://www.wireguard.com
GNU General Public License v2.0
85 stars 19 forks source link

sh script to universal installation to Ubuntu >= 22 and Debian >= 11 #32

Open GubernievS opened 1 month ago

GubernievS commented 1 month ago
set -e
OS=$(lsb_release -si | tr '[:upper:]' '[:lower:]')

apt update
apt install -y curl gnupg2

gpg --keyserver keyserver.ubuntu.com --recv-keys 75c9dd72c799870e310542e24166f2c257290828
gpg --export 75c9dd72c799870e310542e24166f2c257290828 | tee /usr/share/keyrings/amnezia.gpg > /dev/null

rm -f /etc/apt/sources.list.d/amnezia.list || true
rm -f /etc/apt/sources.list.d/amneziawg.sources || true
rm -f /etc/apt/sources.list.d/amneziawg.sources.list || true

if [[ $OS == "ubuntu" ]]; then
    echo "deb [signed-by=/usr/share/keyrings/amnezia.gpg] https://ppa.launchpadcontent.net/amnezia/ppa/ubuntu $(lsb_release -cs) main" | tee -a /etc/apt/sources.list.d/amnezia.list
    echo "deb-src [signed-by=/usr/share/keyrings/amnezia.gpg] https://ppa.launchpadcontent.net/amnezia/ppa/ubuntu $(lsb_release -cs) main" | tee -a /etc/apt/sources.list.d/amnezia.list
elif [[ $OS == "debian" ]]; then
    echo "deb [signed-by=/usr/share/keyrings/amnezia.gpg] https://ppa.launchpadcontent.net/amnezia/ppa/ubuntu focal main" | tee -a /etc/apt/sources.list.d/amnezia.list
    echo "deb-src [signed-by=/usr/share/keyrings/amnezia.gpg] https://ppa.launchpadcontent.net/amnezia/ppa/ubuntu focal main" | tee -a /etc/apt/sources.list.d/amnezia.list
fi

if [[ -e /etc/apt/sources.list.d/ubuntu.sources ]]; then
    if ! grep -qE '^[^#]*deb-src' /etc/apt/sources.list.d/ubuntu.sources; then
        cp /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/amneziawg.sources
        sed -i '/^$/d; /^#/d; s/deb/deb-src/' /etc/apt/sources.list.d/amneziawg.sources
    fi
elif [[ -e /etc/apt/sources.list ]]; then
    if ! grep -q "^deb-src" /etc/apt/sources.list; then
        cp /etc/apt/sources.list /etc/apt/sources.list.d/amneziawg.sources.list
        sed -i '/^$/d; /^#/d; s/^deb/deb-src/' /etc/apt/sources.list.d/amneziawg.sources.list
    fi
fi

apt update
apt install -y amneziawg