Last active
May 4, 2022 13:10
-
-
Save pstadler/2eb645ae829941850db2e09628fe0d85 to your computer and use it in GitHub Desktop.
Revisions
-
pstadler revised this gist
May 4, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,12 +29,12 @@ get_local_version () { } get_latest_version () { echo $releases | jq -r --arg version "$BOARD-v2" \ '[.[] | select(.assets | .[].browser_download_url | contains($version))][0] | .tag_name' } get_latest_download_url () { echo $releases | jq -r --arg version "$BOARD-v2" \ '[.[].assets | .[] | select(.browser_download_url | contains($version))][0] | .browser_download_url' } -
pstadler revised this gist
May 4, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,7 @@ BOARD=e300 # ER4 CMD_WRAPPER=/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper echo "Fetching WireGuard releases..." releases=$(curl -sSL https://api.github.com/repos/WireGuard/wireguard-vyatta-ubnt/releases) is_installed () { dpkg -S wireguard >/dev/null 2>&1 -
pstadler revised this gist
May 4, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ echo "Fetching WireGuard releases..." releases=$(curl -sSL https://api.github.com/repos/Lochnair/vyatta-wireguard/releases) is_installed () { dpkg -S wireguard >/dev/null 2>&1 } get_local_version () { -
pstadler revised this gist
Mar 4, 2019 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,9 +39,9 @@ get_latest_download_url () { } install_latest_version () { curl -L -o "/tmp/wireguard-$BOARD.deb" $(get_latest_download_url) dpkg -i "/tmp/wireguard-$BOARD.deb" rm "/tmp/wireguard-$BOARD.deb" } uninstall () { -
pstadler revised this gist
Mar 4, 2019 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -38,7 +38,6 @@ get_latest_download_url () { '[.[].assets | .[] | select(.browser_download_url | contains($version))][0] | .browser_download_url' } install_latest_version () { curl -L -o "/tmp/wireguard-$BOARD-$version.deb" $(get_latest_download_url) dpkg -i "/tmp/wireguard-$BOARD-$version.deb" -
pstadler revised this gist
Mar 4, 2019 . No changes.There are no files selected for viewing
-
pstadler revised this gist
Mar 4, 2019 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,13 @@ #!/bin/bash -e # vyatta-wireguard # # Usage: `./wireguard.sh [upgrade|uninstall]`. # # When called without arguments, the latest version will be fetched and installed. # # To automatically install the latest version of WireGuard after Firmware upgrades, # this script should be placed in `/config/scripts/post-config.d/wireguard.sh`. # # Change `BOARD` to match your hardware. See: https://github.com/Lochnair/vyatta-wireguard/releases BOARD=e300 # ER4 -
pstadler created this gist
Mar 4, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,106 @@ #!/bin/bash -e # WireGuard on EdgeRouter # # On EdgeRouter, this script should be in `/config/scripts/post-config.d/wireguard.sh` # to automatically install the latest version after firmware upgrades. # # Usage: `./wireguard.sh [upgrade|uninstall]`. # # If this script is called without arguments, the latest version will be fetched and installed. # # Change `BOARD` to match your hardware. See: https://github.com/Lochnair/vyatta-wireguard/releases BOARD=e300 # ER4 # Don't touch the lines below CMD_WRAPPER=/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper echo "Fetching WireGuard releases..." releases=$(curl -sSL https://api.github.com/repos/Lochnair/vyatta-wireguard/releases) is_installed () { dpkg -s wireguard >/dev/null 2>&1 } get_local_version () { ! is_installed && return dpkg-query --showformat='${Version}' --show wireguard } get_latest_version () { echo $releases | jq -r --arg version "wireguard-$BOARD" \ '[.[] | select(.assets | .[].browser_download_url | contains($version))][0] | .tag_name' } get_latest_download_url () { echo $releases | jq -r --arg version "wireguard-$BOARD" \ '[.[].assets | .[] | select(.browser_download_url | contains($version))][0] | .browser_download_url' } install_latest_version () { curl -L -o "/tmp/wireguard-$BOARD-$version.deb" $(get_latest_download_url) dpkg -i "/tmp/wireguard-$BOARD-$version.deb" rm "/tmp/wireguard-$BOARD-$version.deb" } uninstall () { $CMD_WRAPPER begin $CMD_WRAPPER set interfaces wireguard wg0 route-allowed-ips false $CMD_WRAPPER commit $CMD_WRAPPER delete interfaces wireguard $CMD_WRAPPER commit sudo rmmod wireguard sudo dpkg --purge wireguard } # uninstall if [ "$1" = "uninstall" ]; then ! is_installed && (echo "WireGuard is not installed."; exit 1) echo "Uninstalling WireGuard..." uninstall exit 0 fi # upgrade if [ "$1" = "upgrade" ]; then latest_version=$(get_latest_version) local_version=$(get_local_version) if [[ "$latest_version" = "$local_version" || "${latest_version}-1" = "$local_version" ]]; then echo "WireGuard is up-to-date. (local: $(get_local_version); remote: $latest_version)" exit 0 fi if ! is_installed; then echo "WireGuard is not installed yet. Run script without arguments to install." exit 1 fi echo "Upgrading WireGuard from $local_version to $latest_version..." uninstall install_latest_version sudo modprobe wireguard $CMD_WRAPPER load $CMD_WRAPPER commit echo "Upgrade done." exit 0 fi # install if is_installed; then echo "WireGuard $(get_local_version) is already installed." exit 1 fi echo "Installing latest WireGuard version..." install_latest_version $CMD_WRAPPER begin $CMD_WRAPPER load $CMD_WRAPPER commit $CMD_WRAPPER end echo "Installation done." exit 0