n2n/packages/openwrt
Hamish Coleman a1facf0f3f
Update Openwrt process (#900)
* First attempt at a openwrt CI

* Fix action - helps if I dont forget the syntax half way through writing it

* Try building /this/ branch for the openwrt CI

* Try a build with openssl configured

* Dont enable the n2n package until we have built the environment - makes errors easier to see and clearly related to n2n

* Attempt to speed up the openwrt build

* Upload any created ipkg packages

* Dont test with openssl for the moment

* Attempt to speed up openwrt build using a cache of the build dir

* The make defconfig run turns all the built binaries stale, so stop caching them.  Also use a real ref for the cache key

* Minor text name changes

* Address yamllint concerns

* Attempt to simplify and document missing parts of the openwrt makefile

* Attempt to fix mystery openwrt make error

* Rename build job name

* Avoid nested checkouts, use two separate dirs for the two checkouts in this build

* Move the n2n checkout to earler, allowing us to skip one defconfig run

* We are going to need working tags from the n2n repo, so ensure we unbreak the github checkout braindamage

* Calculate and save the n2n version string

* Prepare the way to pass the correct external vars into the openwrt build

* Hook calculated build variables into the openwrt package definition

* Update artifacts source to match moved checkout dir

* Pass env vars in to the make

* Allow version script to be influenced by external vars

* It will help if I use the same variable names everywhere

* Add more version variable calculation overrides

* Configure openwrt to use the external git checkout instead of their create-tar-then-extract dance

* Using the correct syntax for ifdef will help significantly

* Use as many jobs as we have cpus

* As the USE_SOURCE_DIR option allows us to use a full git checkout, we do not need to hack the version.sh to allow overrides

* Ensure scripts/version.sh works from anywhere

* Remove unneeded variables

* Update openwrt build documentation to match the new build process

* Catch failure to cd as per shellcheck suggestion

* Limit lengthy openwrt builds to manual triggers or on a release

* Also run on specially named branches

* Break list into separate lines for easier future editing
2021-11-18 21:28:50 +00:00
..
etc/init.d fix(openwrt): move config to /etc/n2n 2020-09-05 12:00:13 +08:00
Makefile Update Openwrt process (#900) 2021-11-18 21:28:50 +00:00
README.md Update Openwrt process (#900) 2021-11-18 21:28:50 +00:00

Prerequisites

This instructions explain how to build an OpenWRT .ipk package for n2n.

Before going on, it is required to have a working cross-compiling build environment for the OpenWRT version installed into your device. This usually comes down to the following steps:

  1. Download and extract the SDK toolchain for your device. The toolchain must match the exact OpenWRT version installed in your device. Toolchain for official OpenWRT images can be downloaded from https://downloads.openwrt.org

  2. Build the toolchain: run make menuconfig, save the configuration, then run make to build the cross compiling tools

  3. Download the feeds with ./scripts/feeds update -a

Compilation

These instructions are for building the current checked out version of the n2n source (The generally used OpenWRT alternative is to download a tar.gz file of a specific n2n version, but that is not as suitable for development or local builds)

You need both the openwrt repository and the n2n repository checked out for this. In these instructions, we assume that openwrt is the directory where your openwrt checkout is located and n2n is the directory for the n2n repository.

git clone https://github.com/ntop/n2n n2n
N2N_PKG_VERSION=$(n2n/scripts/version.sh)
export N2N_PKG_VERSION

cp -r n2n/packages/openwrt openwrt/package/n2n

cd openwrt
make menuconfig # select Network -> VPN -> n2n-edge and n2n-supernode
make package/n2n/clean V=s
make package/n2n/prepare USE_SOURCE_DIR=../n2n V=s
make package/n2n/compile V=s

If everything went fine, two ipk will be generated, one for the n2n-edge and the other for n2n-supernode. They can be found with find . -name "n2n*.ipk", copied to the target device, and installed with opkg install.

The github action described in .github/workflows/openwrt.yml implements an automated version of the above steps.

Configuration

The edge node can be started with /etc/init.d/edge start. Its configuration file is /etc/n2n/edge.conf.

The supernode can be started with /etc/init.d/supernode start. Its configuration file is /etc/n2n/supernode.conf.