Script to install WireGuard on Ubiquiti

Because i had some issues with configuration lost on Edgerouter ER-4 after power loss i’ve search how to upgrade wireguard without losing configuration (like pubkey and privkey).
I found this. Works pretty good. Installed. Saved. Reboot.

ubnt@ubnt-oradea:~$ sudo -i
root@ubnt-oradea:~# cd /config/scripts
root@ubnt-oradea:/config/scripts# curl -LO --silent https://github.com/whiskerz007/ubnt_get_wireguard/raw/master/get_wireguard.sh
root@ubnt-oradea:/config/scripts# chmod +x get_wireguard.sh
root@ubnt-oradea:/config/scripts# ./get_wireguard.sh
[INFO] Board model: EdgeRouter 4
[INFO] Board type: e300
[INFO] Board repo mapping: e300
[INFO] Firmware version: v2.0.4.5199165.190605.1549
[INFO] Installed WireGuard version: 0.0.20190601-1
[INFO] Release version: 0.0.20191219-2
[INFO] Debian package URL: https://github.com/Lochnair/vyatta-wireguard/releases/download/0.0.20191219-2/wireguard-v2.0-e300-0.0.20191219-2.deb
Downloading WireGuard package…
Checking WireGuard package integrity…
Backing up running configuration…
Removing running WireGuard configuration…
Removing WireGuard module…
Installing WireGuard…
Restoring previous running configuration…
Enabling WireGuard installation after firmware update…
WireGuard has been successfully installed.
root@ubnt-oradea:/config/scripts# exit

Added cron for future updates:

ubnt@ubnt-oradea:~$ configure
[edit]
ubnt@ubnt-oradea# set system task-scheduler task get_wireguard executable path /config/scripts/get_wireguard.sh
[edit]
ubnt@ubnt-oradea# set system task-scheduler task get_wireguard interval 7d
[edit]
ubnt@ubnt-oradea# commit
[ system task-scheduler ]
Restarting cron (via systemctl): cron.service.
[edit]
ubnt@ubnt-oradea# save
Saving configuration to '/config/config.boot'…
Done
[edit]
ubnt@ubnt-oradea# exit
exit

Leave a reply:

Your email address will not be published.

Site Footer