feat: add support for Arch Linux

This commit is contained in:
John Bernard 2023-08-30 04:54:33 -05:00
parent 98f45f883c
commit da63c8fe31

View file

@ -34,6 +34,8 @@ elif [[ -e /etc/almalinux-release || -e /etc/rocky-release || -e /etc/centos-rel
elif [[ -e /etc/fedora-release ]]; then elif [[ -e /etc/fedora-release ]]; then
os="fedora" os="fedora"
os_version=$(grep -oE '[0-9]+' /etc/fedora-release | head -1) os_version=$(grep -oE '[0-9]+' /etc/fedora-release | head -1)
elif [[ -e /etc/arch-release ]]; then
os="arch"
else else
echo "This installer seems to be running on an unsupported distribution. echo "This installer seems to be running on an unsupported distribution.
Supported distros are Ubuntu, Debian, AlmaLinux, Rocky Linux, CentOS and Fedora." Supported distros are Ubuntu, Debian, AlmaLinux, Rocky Linux, CentOS and Fedora."
@ -271,7 +273,7 @@ if [[ ! -e /etc/wireguard/wg0.conf ]]; then
echo "WireGuard installation is ready to begin." echo "WireGuard installation is ready to begin."
# Install a firewall if firewalld or iptables are not already available # Install a firewall if firewalld or iptables are not already available
if ! systemctl is-active --quiet firewalld.service && ! hash iptables 2>/dev/null; then if ! systemctl is-active --quiet firewalld.service && ! hash iptables 2>/dev/null; then
if [[ "$os" == "centos" || "$os" == "fedora" ]]; then if [[ "$os" == "centos" || "$os" == "fedora" || "$os" == "arch" ]]; then
firewall="firewalld" firewall="firewalld"
# We don't want to silently enable firewalld, so we give a subtle warning # We don't want to silently enable firewalld, so we give a subtle warning
# If the user continues, firewalld will be installed and enabled during setup # If the user continues, firewalld will be installed and enabled during setup
@ -330,6 +332,11 @@ if [[ ! -e /etc/wireguard/wg0.conf ]]; then
# Fedora # Fedora
dnf install -y wireguard-tools qrencode $firewall dnf install -y wireguard-tools qrencode $firewall
mkdir -p /etc/wireguard/ mkdir -p /etc/wireguard/
elif [[ "$os" == "arch" ]]; then
# Arch
pacman -Sy
pacman -S --needed --noconfirm wireguard-tools qrencode $firewall
mkdir -p /etc/wireguard/
fi fi
# Else, we are inside a container and BoringTun needs to be used # Else, we are inside a container and BoringTun needs to be used
else else
@ -370,6 +377,11 @@ if [[ ! -e /etc/wireguard/wg0.conf ]]; then
# Fedora # Fedora
dnf install -y wireguard-tools qrencode ca-certificates tar $cron $firewall dnf install -y wireguard-tools qrencode ca-certificates tar $cron $firewall
mkdir -p /etc/wireguard/ mkdir -p /etc/wireguard/
elif [[ "$os" == "fedora" ]]; then
# Arch
pacman -Sy
pacman -S --needed --noconfirm wireguard-tools qrencode ca-certificates $cron $firewall
mkdir -p /etc/wireguard/
fi fi
# Grab the BoringTun binary using wget or curl and extract into the right place. # Grab the BoringTun binary using wget or curl and extract into the right place.
# Don't use this service elsewhere without permission! Contact me before you do! # Don't use this service elsewhere without permission! Contact me before you do!
@ -379,7 +391,7 @@ if [[ ! -e /etc/wireguard/wg0.conf ]]; then
echo "[Service] echo "[Service]
Environment=WG_QUICK_USERSPACE_IMPLEMENTATION=boringtun Environment=WG_QUICK_USERSPACE_IMPLEMENTATION=boringtun
Environment=WG_SUDO=1" > /etc/systemd/system/wg-quick@wg0.service.d/boringtun.conf Environment=WG_SUDO=1" > /etc/systemd/system/wg-quick@wg0.service.d/boringtun.conf
if [[ -n "$cron" ]] && [[ "$os" == "centos" || "$os" == "fedora" ]]; then if [[ -n "$cron" ]] && [[ "$os" == "centos" || "$os" == "fedora" || "$os" == "arch" ]]; then
systemctl enable --now crond.service systemctl enable --now crond.service
fi fi
fi fi
@ -659,6 +671,10 @@ else
# Fedora # Fedora
dnf remove -y wireguard-tools dnf remove -y wireguard-tools
rm -rf /etc/wireguard/ rm -rf /etc/wireguard/
elif [[ "$os" == "arch" ]]; then
# Arch
rm -rf /etc/wireguard/
pacman -Rcs --noconfirm wireguard-tools
fi fi
else else
{ crontab -l 2>/dev/null | grep -v '/usr/local/sbin/boringtun-upgrade' ; } | crontab - { crontab -l 2>/dev/null | grep -v '/usr/local/sbin/boringtun-upgrade' ; } | crontab -
@ -690,6 +706,10 @@ else
# Fedora # Fedora
dnf remove -y wireguard-tools dnf remove -y wireguard-tools
rm -rf /etc/wireguard/ rm -rf /etc/wireguard/
elif [[ "$os" == "arch" ]]; then
# Arch
rm -rf /etc/wireguard/
pacman -Rcs --noconfirm wireguard-tools
fi fi
rm -f /usr/local/sbin/boringtun /usr/local/sbin/boringtun-upgrade rm -f /usr/local/sbin/boringtun /usr/local/sbin/boringtun-upgrade
fi fi