tusc / wireguard-kmod

WireGuard for UDM series routers
https://www.wireguard.com/
350 stars 18 forks source link

Feature Request: wireguard-ui option #66

Open CaptInsano opened 2 years ago

CaptInsano commented 2 years ago

I know this is a big ask and possibly against the minimal ideals of this project but would you ever consider adding an option to include wireguard-ui with this project?:

https://github.com/ngoduykhanh/wireguard-ui

They have an ARM64 binary in their releases that runs on the UDM that facilitates a much easier setup for those of us who do not always find it easiest in the commandline or ssh terminal. Also makes it so easy to add new clients and scan qrcodes via other devices.

I am currently running the https://github.com/ngoduykhanh/wireguard-ui/releases/download/v0.3.7/wireguard-ui-v0.3.7-linux-arm64.tar.gz binary in a very hacky way by adding:

nohup ./wireguard-ui &

to my setup_wireguard.sh in the on_boot.d folder.

The current issue is that it requires a manual issuing of the "wg-quick down wg0" and "wg-quick up wg0" commands after any configuration changes but the project repo README.md suggests ways to automate that which is above my very minimal ability!

Again, I appreciate that this may not be in the interests of the dev but I felt it was worth asking!!

Thanks again

TomW1605 commented 2 years ago

hi i would really like this too, im pretty good with command line but if i have to remote in with my phone to setup a new client so i can connect a new laptop having a ui would be much nicer.

in the mean time @CaptInsano could you explain how you installed it on the UDM? is it just a matter of extracting the tar file to /mnt/data?

edit: nvm i got it working. as for running wg-quick down wg0 and wg-quick up wg0 i am not sure the method described in the README will even work on UnifiOS. i dont think it has systemd

CaptInsano commented 2 years ago

My solution (very janky) includes a solution for running wg-quick down wg0 & wg-quick up wg0 is by using a different busybox binary as the included binary is not complied to include inotifyd functionality.

I would really really appreciate any advice on making my solution better and conform to best practice as I am aware how janky it is!!

My steps:

Create working Dir

mkdir /mnt/data/wireguard-ui

cd /mnt/data/wireguard-ui

Gather wireguard-ui binary and make executable

curl -LJo wireguard-ui.tar.gz https://github.com/ngoduykhanh/wireguard-ui/releases/download/v0.3.7/wireguard-ui-v0.3.7-linux-arm64.tar.gz

tar -xf wireguard-ui.tar.gz
rm wireguard-ui.tar.gz

chmod +x wireguard-ui

Gather a busybox binary with notifyd enabled (built-in version does not support inotify) (This is an older version of busybox here but available online, would love if someone could offer better solution)

curl -LJo busybox-arm64 https://github.com/xerta555/Busybox-Binaries/raw/master/busybox-arm64

chmod +x busybox-arm64

Create a script to restart wireguard which will be called on wg0.conf config changes made my wireguard-ui:

vi restart_wg

contents of restart_wg:

#!/bin/sh
wg-quick down wg0
sleep 5
wg-quick up wg0

make executable:

chmod +x restart_wg

Create on.boot.d script to start wireguard-ui and watch for config changes, restarting wireguard as needed

vi /mnt/data/on_boot.d/20-wireguard-ui.sh

contents of wireguard-ui.sh (note I also use this script to start my instance of wireguard on boot and is set to run after 10-setup_wireguard.sh)

#!/bin/sh
#start wireguard
wg-quick down wg0
wg-quick up wg0

#kill any existing busybox-arm64 instances
killall -9 busybox-arm64

#monitor wg0.conf for changes
/mnt/data/wireguard-ui/busybox-arm64 inotifyd /mnt/data/wireguard-ui/restart_wg /etc/wireguard/wg0.conf:w &

#kill any existing wireguard-ui instances
killall -9 wireguard-ui

#start wireguard-ui
cd /mnt/data/wireguard-ui
nohup ./wireguard-ui &

make executable:

chmod +x /etc/data/on.boot.d/20-wireguard-ui.sh

Finally run it and things should be up and running!

/etc/data/on.boot.d/20-wireguard-ui.sh

TomW1605 commented 2 years ago

oh cool thanks

TomW1605 commented 2 years ago

do you have an issue with the ui loosing its db when the UDM reboots?

CaptInsano commented 2 years ago

I do not have this issue but maybe I have a typo in the instructions I provided.

wireguard-ui makes a db folder wherever the wireguard-ui command is made from, this is why my script moves to the /mnt/data/wireguard-ui folder before issuing the wireguard-ui command.

my "mnt/data/wireguard-ui" folder contains the following:

# ls -la
total 21916
drwxr-xr-x    3 root     root          4096 Jun 15 14:54 .
drwxr-xr-x   18 root     root          4096 Jun 13 18:10 ..
-rwxr-xr-x    1 root     root       1478216 Jun 15 14:35 busybox-arm64
drwxr-xr-x    5 root     root          4096 Jun 13 19:39 db
-rw-------    1 root     root         89762 Jun 21 14:15 nohup.out
-rwxr-xr-x    1 root     root            52 Jun 15 14:52 restart_wg
-rwxr-xr-x    1 root     root      20844929 Jun 13 18:11 wireguard-ui

and if I killall wireguard-ui instances (killall -9 wireguard-ui) and then just run the "/etc/data/on.boot.d/20-wireguard-ui.sh" command (simulating a reboot) it comes back up and works for me.

TomW1605 commented 2 years ago

script moves to the /mnt/data/wireguard-ui folder before issuing the wireguard-ui command

oh i compleatly missed the cd command. thanks

mcpat-it commented 1 year ago

I need beta-testers for my repo. Wireguard-ui is included there. Requirements: UDM base or pro, firmware at least on 2.4.x (fully tested on my UDM base 2.5.x). see here.

Start with this commandline (save your wg0.conf if something happens)

cd /tmp && wget https://ui-ware.mcpat.com/repo/ui-ware_1.0.0_all.deb && dpkg -i ui-ware_1.0.0_all.deb &&  rm ui-ware_1.0.0_all.deb

then

apt-get update
apt-install opt-wireguard-ui