Rename scripts for better consistancy (#866)

* Address shellcheck concerns with n2n_gateway.sh script

* Rename n2n_gateway.sh to live with all the other scripts (and update docs)

* Rename hack_fakeautoconf to make it clearly a shell script

* Address shellcheck concerns with hack_fakeautoconf.sh

* Rename python scripts to match other n2n tools

* Fix windows compile - when streamlining the use of hack_fakeautoconf.sh, I forgot to update all uses of this script
This commit is contained in:
Hamish Coleman 2021-10-23 23:13:01 +01:00 committed by GitHub
parent 80b33cd1a9
commit 7eb3f2cd7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 28 additions and 30 deletions

View File

@ -186,23 +186,16 @@ jobs:
steps:
- uses: actions/checkout@v2
# This is a pretty big hammer, but gets the windows compile moving
- name: Hack up a fake autoconf
run: |
echo true >autogen.sh
cp scripts/hack_fakeautoconf configure
shell: bash
- name: generate a makefile and use it to install more packages
run: |
./autogen.sh
./configure
# This is a pretty big hammer, but gets the windows compile moving
./scripts/hack_fakeautoconf.sh
make build-dep
shell: bash
- name: Run the real configure step
- name: Run a configure step
run: |
CFLAGS="-fprofile-arcs -ftest-coverage" LDFLAGS="--coverage" ./configure --with-zstd
CFLAGS="-fprofile-arcs -ftest-coverage" LDFLAGS="--coverage" ./scripts/hack_fakeautoconf.sh
shell: bash
- name: Run embedded tests
@ -325,7 +318,7 @@ jobs:
- name: Configure and Build
shell: bash
run: |
./scripts/hack_fakeautoconf
./scripts/hack_fakeautoconf.sh
make
- name: Create binary dir

View File

@ -187,7 +187,7 @@ test: tools
lint: lint.python lint.ccode lint.shell
lint.python:
flake8 scripts/n2nctl scripts/n2nhttpd
flake8 scripts/n2n-ctl scripts/n2n-httpd
lint.ccode:
scripts/indent.sh $(LINT_CCODE)

View File

@ -109,7 +109,7 @@ applied as of 2021-09-29.
- All the remaining commands must be run from inside a bash shell ("C:\Program Files\Git\usr\bin\bash.exe")
- git clone $THIS_REPO
- cd n2n
- ./scripts/hack_fakeautoconf
- ./scripts/hack_fakeautoconf.sh
- make
- make test

View File

@ -19,7 +19,7 @@ On the client side, the easiest way to configure routing is via the `-n` option.
10.0.0.1 is the IP address of the gateway to use to route the specified network. It should correspond to the IP address of the `server` within n2n. Multiple `-n` options can be specified.
As an alternative to the `-n` option, the `ip route` linux command can be manually used. See the [n2n_gateway.sh](doc/n2n_gateway.sh) script for an example. See also the following description of other use cases and in depth explanation.
As an alternative to the `-n` option, the `ip route` linux command can be manually used. See the [n2n-gateway.sh](scripts/n2n-gateway.sh) script for an example. See also the following description of other use cases and in depth explanation.
## Special Scenarios

View File

@ -7,7 +7,7 @@ may be installed with n2n as part of your operating system package.
Short descriptions of these scripts are below.
## `scripts/hack_fakeautoconf`
## `scripts/hack_fakeautoconf.sh`
This shell script is used during development to help build on Windows
systems. An example of how to use it is shown in
@ -23,7 +23,7 @@ the automated lint checks.
This shell script is used to run automated tests during development.
## `scripts/n2nctl`
## `scripts/n2n-ctl`
This python script provides an easy command line interface to the running
n2n processes. It uses UDP communications to talk to the Management API.
@ -31,10 +31,10 @@ By specifying the right UDP port, it can talk to both the edge and the
supernode daemons.
Example:
- `scripts/n2nctl --help`
- `scripts/n2nctl help`
- `scripts/n2n-ctl --help`
- `scripts/n2n-ctl help`
## `scripts/n2nhttpd`
## `scripts/n2n-httpd`
This python script is a simple http gateway to the running edge. It provides
a proxy for REST-like HTTP requests to talk to the Management API.
@ -46,5 +46,10 @@ run with default settings can be seen at http://localhost:8080/ (Also
a http://localhost:8080/supernode.html page for the supernode)
Example:
- `scripts/n2nhttpd --help`
- `scripts/n2nhttpd 8087`
- `scripts/n2n-httpd --help`
- `scripts/n2n-httpd 8087`
## `scripts/n2n-gateway.sh`
A sample script to route all the host traffic towards a remote gateway,
which is reachable via the n2n virtual interface.

View File

@ -3,7 +3,7 @@
# Specifically for windows, where installing autoconf looks suspiciously
# like boiling the ocean.
cat Makefile.in | sed \
sed \
-e "s%@N2N_VERSION_SHORT@%FIXME%g" \
-e "s%@GIT_COMMITS@%FIXME%g" \
-e "s%@CC@%gcc%g" \
@ -11,11 +11,11 @@ cat Makefile.in | sed \
-e "s%@CFLAGS@%$CFLAGS%g" \
-e "s%@LDFLAGS@%$LDFLAGS%g" \
-e "s%@N2N_LIBS@%$LDLIBS%g" \
> Makefile
< Makefile.in > Makefile
cat tools/Makefile.in | sed \
sed \
-e "s%@ADDITIONAL_TOOLS@%%g" \
> tools/Makefile
< tools/Makefile.in > tools/Makefile
cat <<EOF >include/config.h
#define PACKAGE_VERSION "FIXME"

View File

@ -40,7 +40,7 @@ if ! ip route get $N2N_GATEWAY | grep -q $N2N_INTERFACE ; then
fi
# Determine the current internet gateway
internet_gateway=`ip route get 8.8.8.8 | head -n1 | awk '{ print $3 }'`
internet_gateway=$(ip route get 8.8.8.8 | head -n1 | awk '{ print $3 }')
# Backup the DNS resolver configuration and use the specified server
cp /etc/resolv.conf /etc/resolv.conf.my_bak
@ -49,7 +49,7 @@ echo "nameserver $DNS_SERVER" > /etc/resolv.conf
# The public IP of the supernode must be reachable via the internet gateway
# Whereas all the other traffic will go through the new VPN gateway.
ip route add $N2N_SUPERNODE via $internet_gateway
ip route add $N2N_SUPERNODE via "$internet_gateway"
ip route del default
echo "Forwarding traffic via $N2N_GATEWAY"
ip route add default via $N2N_GATEWAY
@ -57,10 +57,10 @@ ip route add default via $N2N_GATEWAY
function stopService {
echo "Deleting custom routes"
ip route del default
ip route del $N2N_SUPERNODE via $internet_gateway
ip route del $N2N_SUPERNODE via "$internet_gateway"
echo "Restoring original gateway $internet_gateway"
ip route add default via $internet_gateway
ip route add default via "$internet_gateway"
echo "Restoring original DNS"
mv /etc/resolv.conf.my_bak /etc/resolv.conf