diff options
author | Nebulosa2007 | 2023-10-15 21:26:23 +0300 |
---|---|---|
committer | Nebulosa2007 | 2023-10-15 21:26:23 +0300 |
commit | f2de24686ce70a398352fae9b5c2b2aa2e6b2c09 (patch) | |
tree | 2202b5e37f94e0128d354693521bc8fe83cd3d22 | |
download | aur-f2de24686ce70a398352fae9b5c2b2aa2e6b2c09.tar.gz |
Initial commit
-rw-r--r-- | .SRCINFO | 25 | ||||
-rw-r--r-- | 99-wg.conf | 2 | ||||
-rw-r--r-- | PKGBUILD | 35 | ||||
-rw-r--r-- | wg-reload.path | 8 | ||||
-rw-r--r-- | wg-reload.service | 10 | ||||
-rw-r--r-- | wgiptables.sh | 25 | ||||
-rw-r--r-- | wireguard-ui.install | 47 | ||||
-rw-r--r-- | wireguard-ui.service | 12 |
8 files changed, 164 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..9af2bc6fbfa8 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,25 @@ +pkgbase = wireguard-ui-bin + pkgdesc = A web user interface to manage your WireGuard setup. + pkgver = 0.5.2 + pkgrel = 1 + url = https://github.com/ngoduykhanh/wireguard-ui + install = wireguard-ui.install + arch = x86_64 + license = MIT + depends = wireguard-tools + provides = wireguard-ui + conflicts = wireguard-ui + source = https://github.com/ngoduykhanh/wireguard-ui/releases/download/v0.5.2/wireguard-ui-v0.5.2-linux-amd64.tar.gz + source = wireguard-ui.service + source = 99-wg.conf + source = wgiptables.sh + source = wg-reload.path + source = wg-reload.service + md5sums = aa38b4b0950e9df0dcf3ddba87516f0a + md5sums = 9632dcff1438fdd29befaf0f4db1873c + md5sums = 70c4fc283f2195096c491f7be65d6342 + md5sums = 1fe01c771e1faabcaca6a24c09f299ae + md5sums = 9efcd8b52477051ac3297b295e3a777e + md5sums = 66b402a7b0ac73787f744931302f3dac + +pkgname = wireguard-ui-bin diff --git a/99-wg.conf b/99-wg.conf new file mode 100644 index 000000000000..f501eb913c7a --- /dev/null +++ b/99-wg.conf @@ -0,0 +1,2 @@ +net.ipv4.ip_forward = 1 +net.ipv6.conf.all.forwarding = 1 diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..012bfb7e128d --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,35 @@ +# Maintainer: Nebulosa <nebulosa2007-at-yandex-dot-ru> +pkgname=wireguard-ui-bin +_pkgname=wireguard-ui +pkgver=0.5.2 +pkgrel=1 +pkgdesc="A web user interface to manage your WireGuard setup." +arch=('x86_64') +url="https://github.com/ngoduykhanh/wireguard-ui" +license=('MIT') +provides=('wireguard-ui') +conflicts=('wireguard-ui') +depends=('wireguard-tools') +install=$_pkgname.install + +source=(https://github.com/ngoduykhanh/$_pkgname/releases/download/v$pkgver/$_pkgname-v$pkgver-linux-amd64.tar.gz + $_pkgname.service + 99-wg.conf + wgiptables.sh + wg-reload.path + wg-reload.service) +md5sums=('aa38b4b0950e9df0dcf3ddba87516f0a' + '9632dcff1438fdd29befaf0f4db1873c' + '70c4fc283f2195096c491f7be65d6342' + '1fe01c771e1faabcaca6a24c09f299ae' + '9efcd8b52477051ac3297b295e3a777e' + '66b402a7b0ac73787f744931302f3dac') +package() { + install -d $pkgdir/{opt/$_pkgname,usr/lib/systemd/system,etc/sysctl.d} + install -Dm755 $_pkgname $pkgdir/opt/$_pkgname/$_pkgname + install -Dm644 $srcdir/$_pkgname.service ${pkgdir}/usr/lib/systemd/system/$_pkgname.service + install -Dm644 $srcdir/99-wg.conf ${pkgdir}/etc/sysctl.d/99-wg.conf + install -Dm755 $srcdir/wgiptables.sh ${pkgdir}/opt/$_pkgname/wgiptables + install -Dm644 $srcdir/wg-reload.path ${pkgdir}/usr/lib/systemd/system/wg-reload.path + install -Dm644 $srcdir/wg-reload.service ${pkgdir}/usr/lib/systemd/system/wg-reload.service +} diff --git a/wg-reload.path b/wg-reload.path new file mode 100644 index 000000000000..93f1f2ad6b21 --- /dev/null +++ b/wg-reload.path @@ -0,0 +1,8 @@ +[Unit] +Description=Watch /etc/wireguard/wg0.conf for changes + +[Path] +PathModified=/etc/wireguard/wg0.conf + +[Install] +WantedBy=multi-user.target diff --git a/wg-reload.service b/wg-reload.service new file mode 100644 index 000000000000..d3810204db35 --- /dev/null +++ b/wg-reload.service @@ -0,0 +1,10 @@ +[Unit] +Description=Restart WireGuard +After=network.target + +[Service] +Type=oneshot +ExecStart=/usr/bin/systemctl restart wg-quick@wg0.service + +[Install] +RequiredBy=wg-reload.path diff --git a/wgiptables.sh b/wgiptables.sh new file mode 100644 index 000000000000..55f0f12c4582 --- /dev/null +++ b/wgiptables.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# From: https://github.com/angristan/wireguard-install + +SERVER_WG_NIC="wg0" #Default interface +SERVER_PUB_NIC=$(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)' | head -1) +SERVER_PORT=$(grep -Po '(?<=ListenPort = )(\S+)' "/etc/wireguard/"$SERVER_WG_NIC".conf") + +if [ "$1" == "up" ]; then + iptables -I INPUT -p udp --dport $SERVER_PORT -j ACCEPT + iptables -I FORWARD -i $SERVER_PUB_NIC -o $SERVER_WG_NIC -j ACCEPT + iptables -I FORWARD -i $SERVER_WG_NIC -j ACCEPT + iptables -t nat -A POSTROUTING -o $SERVER_PUB_NIC -j MASQUERADE + ip6tables -I FORWARD -i $SERVER_WG_NIC -j ACCEPT + ip6tables -t nat -A POSTROUTING -o $SERVER_PUB_NIC -j MASQUERADE +fi + +if [ "$1" == "down" ]; then + iptables -D INPUT -p udp --dport $SERVER_PORT -j ACCEPT + iptables -D FORWARD -i $SERVER_PUB_NIC -o $SERVER_WG_NIC -j ACCEPT + iptables -D FORWARD -i $SERVER_WG_NIC -j ACCEPT + iptables -t nat -D POSTROUTING -o $SERVER_PUB_NIC -j MASQUERADE + ip6tables -D FORWARD -i $SERVER_WG_NIC -j ACCEPT + ip6tables -t nat -D POSTROUTING -o $SERVER_PUB_NIC -j MASQUERADE +fi diff --git a/wireguard-ui.install b/wireguard-ui.install new file mode 100644 index 000000000000..14debb3271d6 --- /dev/null +++ b/wireguard-ui.install @@ -0,0 +1,47 @@ +all_off="$(tput sgr0)" +bold="${all_off}$(tput bold)" +blue="${bold}$(tput setaf 4)" +yellow="${bold}$(tput setaf 3)" + +noteb() { + printf "${blue} ->${yellow} ${bold}$1${all_off}\n" +} + +note() { + printf "${blue} ->${yellow} $1${all_off}\n" +} + +post_install() { + sysctl -q --system + systemctl --quiet daemon-reload + echo + noteb "Please start and enable service:" + echo "sudo systemctl enable --now wireguard-ui" + echo + note "Then open in browser http://<ip_server>:5000" + noteb "The default username and password are 'admin'. Please change it to secure your setup!" + echo + noteb "REQUIRED: Also specify in server settings PostUp and PostDown scripts:" + echo "PostUp: '/opt/wireguard-ui/wgiptables up'" + echo "PostDown: '/opt/wireguard-ui/wgiptables down'" + echo + noteb "Then save server settings and finally start wg server:" + echo "sudo systemctl enable --now wg-reload.{service,path}" + echo +} + +post_upgrade() { + post_install +} + +pre_remove() { + systemctl --quiet --no-reload disable --now wireguard-ui.service + systemctl --quiet --no-reload disable --now wg-reload.path + systemctl --quiet --no-reload disable --now wg-reload.service +} + +post_remove() { + rm -fr /opt/wireguard-ui + systemctl --quiet daemon-reload + sysctl -q --system +} diff --git a/wireguard-ui.service b/wireguard-ui.service new file mode 100644 index 000000000000..5657e773842a --- /dev/null +++ b/wireguard-ui.service @@ -0,0 +1,12 @@ +[Unit] +Description=Wireguard web interface +Documentation=https://github.com/ngoduykhanh/wireguard-ui +Wants=network-online.target +After=network-online.target nss-lookup.target + +[Service] +WorkingDirectory=/opt/wireguard-ui +ExecStart=/opt/wireguard-ui/wireguard-ui + +[Install] +WantedBy=multi-user.target |