mirror of
https://github.com/angristan/wireguard-install.git
synced 2024-11-24 05:56:02 +03:00
style(script) format with shfmt
This commit is contained in:
parent
5b1ec52ac2
commit
efa9e5031a
@ -4,8 +4,7 @@ function addClient () {
|
|||||||
# Load params
|
# Load params
|
||||||
source /etc/wireguard/params
|
source /etc/wireguard/params
|
||||||
|
|
||||||
if [[ $SERVER_PUB_IP =~ .*:.* ]]
|
if [[ $SERVER_PUB_IP =~ .*:.* ]]; then
|
||||||
then
|
|
||||||
echo "IPv6 Detected"
|
echo "IPv6 Detected"
|
||||||
ENDPOINT="[$SERVER_PUB_IP]:$SERVER_PORT"
|
ENDPOINT="[$SERVER_PUB_IP]:$SERVER_PORT"
|
||||||
else
|
else
|
||||||
@ -26,7 +25,10 @@ function addClient () {
|
|||||||
CLIENT_DNS_2="176.103.130.131"
|
CLIENT_DNS_2="176.103.130.131"
|
||||||
read -rp "Second DNS resolver to use for the client: " -e -i "$CLIENT_DNS_2" CLIENT_DNS_2
|
read -rp "Second DNS resolver to use for the client: " -e -i "$CLIENT_DNS_2" CLIENT_DNS_2
|
||||||
|
|
||||||
CLIENT_NAME=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 10 ; echo '')
|
CLIENT_NAME=$(
|
||||||
|
head /dev/urandom | tr -dc A-Za-z0-9 | head -c 10
|
||||||
|
echo ''
|
||||||
|
)
|
||||||
|
|
||||||
# Generate key pair for the client
|
# Generate key pair for the client
|
||||||
CLIENT_PRIV_KEY=$(wg genkey)
|
CLIENT_PRIV_KEY=$(wg genkey)
|
||||||
@ -130,31 +132,31 @@ SERVER_PORT=$(shuf -i49152-65535 -n1)
|
|||||||
read -rp "Server's WireGuard port: " -e -i "$SERVER_PORT" SERVER_PORT
|
read -rp "Server's WireGuard port: " -e -i "$SERVER_PORT" SERVER_PORT
|
||||||
|
|
||||||
# Install WireGuard tools and module
|
# Install WireGuard tools and module
|
||||||
if [[ "$OS" = 'ubuntu' ]]; then
|
if [[ $OS == 'ubuntu' ]]; then
|
||||||
apt-get install -y software-properties-common
|
apt-get install -y software-properties-common
|
||||||
add-apt-repository -y ppa:wireguard/wireguard
|
add-apt-repository -y ppa:wireguard/wireguard
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y "linux-headers-$(uname -r)"
|
apt-get install -y "linux-headers-$(uname -r)"
|
||||||
apt-get install -y wireguard iptables resolvconf qrencode
|
apt-get install -y wireguard iptables resolvconf qrencode
|
||||||
elif [[ "$OS" = 'debian' ]]; then
|
elif [[ $OS == 'debian' ]]; then
|
||||||
echo "deb http://deb.debian.org/debian/ unstable main" >/etc/apt/sources.list.d/unstable.list
|
echo "deb http://deb.debian.org/debian/ unstable main" >/etc/apt/sources.list.d/unstable.list
|
||||||
printf 'Package: *\nPin: release a=unstable\nPin-Priority: 90\n' >/etc/apt/preferences.d/limit-unstable
|
printf 'Package: *\nPin: release a=unstable\nPin-Priority: 90\n' >/etc/apt/preferences.d/limit-unstable
|
||||||
apt update
|
apt update
|
||||||
apt-get install -y "linux-headers-$(uname -r)"
|
apt-get install -y "linux-headers-$(uname -r)"
|
||||||
apt-get install -y wireguard iptables resolvconf qrencode
|
apt-get install -y wireguard iptables resolvconf qrencode
|
||||||
apt-get install -y bc # mitigate https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=956869
|
apt-get install -y bc # mitigate https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=956869
|
||||||
elif [[ "$OS" = 'fedora' ]]; then
|
elif [[ $OS == 'fedora' ]]; then
|
||||||
if [[ "$VERSION_ID" -lt 32 ]]; then
|
if [[ $VERSION_ID -lt 32 ]]; then
|
||||||
dnf install -y dnf-plugins-core
|
dnf install -y dnf-plugins-core
|
||||||
dnf copr enable -y jdoss/wireguard
|
dnf copr enable -y jdoss/wireguard
|
||||||
dnf install -y wireguard-dkms
|
dnf install -y wireguard-dkms
|
||||||
fi
|
fi
|
||||||
dnf install -y wireguard-tools iptables qrencode
|
dnf install -y wireguard-tools iptables qrencode
|
||||||
elif [[ "$OS" = 'centos' ]]; then
|
elif [[ $OS == 'centos' ]]; then
|
||||||
curl -Lo /etc/yum.repos.d/wireguard.repo https://copr.fedorainfracloud.org/coprs/jdoss/wireguard/repo/epel-7/jdoss-wireguard-epel-7.repo
|
curl -Lo /etc/yum.repos.d/wireguard.repo https://copr.fedorainfracloud.org/coprs/jdoss/wireguard/repo/epel-7/jdoss-wireguard-epel-7.repo
|
||||||
yum -y install epel-release
|
yum -y install epel-release
|
||||||
yum -y install wireguard-dkms wireguard-tools iptables qrencode
|
yum -y install wireguard-dkms wireguard-tools iptables qrencode
|
||||||
elif [[ "$OS" = 'arch' ]]; then
|
elif [[ $OS == 'arch' ]]; then
|
||||||
pacman -S --noconfirm linux-headers
|
pacman -S --noconfirm linux-headers
|
||||||
pacman -S --noconfirm wireguard-tools iptables wireguard-arch qrencode
|
pacman -S --noconfirm wireguard-tools iptables wireguard-arch qrencode
|
||||||
fi
|
fi
|
||||||
@ -209,14 +211,14 @@ systemctl is-active --quiet "wg-quick@$SERVER_WG_NIC"
|
|||||||
WG_RUNNING=$?
|
WG_RUNNING=$?
|
||||||
|
|
||||||
# Warn user about kernel version mismatch with headers
|
# Warn user about kernel version mismatch with headers
|
||||||
if [[ "$OS" =~ (fedora|centos) ]] && [[ $WG_RUNNING -ne 0 ]]; then
|
if [[ $OS =~ (fedora|centos) ]] && [[ $WG_RUNNING -ne 0 ]]; then
|
||||||
echo -e "\nWARNING: WireGuard does not seem to be running."
|
echo -e "\nWARNING: WireGuard does not seem to be running."
|
||||||
echo "Due to kernel mismatch issues on $OS, WireGuard might work if your system is out of date."
|
echo "Due to kernel mismatch issues on $OS, WireGuard might work if your system is out of date."
|
||||||
echo "You can check if WireGuard is running with: systemctl status wg-quick@$SERVER_WG_NIC"
|
echo "You can check if WireGuard is running with: systemctl status wg-quick@$SERVER_WG_NIC"
|
||||||
echo "If you get something like \"Cannot find device wg0\", please run:"
|
echo 'If you get something like "Cannot find device wg0", please run:'
|
||||||
if [[ "$OS" = 'fedora' ]]; then
|
if [[ $OS == 'fedora' ]]; then
|
||||||
echo "dnf update -y && reboot"
|
echo "dnf update -y && reboot"
|
||||||
elif [[ "$OS" = 'centos' ]]; then
|
elif [[ $OS == 'centos' ]]; then
|
||||||
echo "yum update -y && reboot"
|
echo "yum update -y && reboot"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user