Skip to content

Commit

Permalink
Merge pull request #89 from jaysonsantos/zerotier-without-entware
Browse files Browse the repository at this point in the history
Add zerotier without entware depdenency
  • Loading branch information
stefaang authored Dec 29, 2021
2 parents dbe1a36 + 9468965 commit 93b87e9
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 28 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ wdpk/*/work*
wdpk/*/*.sign
wdpk/*/*.xml

wdpk/zerotier/bin/

.env

toolchains/*/work*
Expand Down
5 changes: 5 additions & 0 deletions wdpk/zerotier/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM rustembedded/cross:arm-unknown-linux-gnueabihf
RUN cd /usr/src && curl -sLO https://github.com/zerotier/ZeroTierOne/archive/refs/tags/1.6.4.tar.gz && tar zxvf 1.6.4.tar.gz && rm 1.6.4.tar.gz
ENV CC=arm-linux-gnueabihf-gcc
ENV CXX=arm-linux-gnueabihf-g++
ENV STRIP=arm-linux-gnueabihf-strip
8 changes: 8 additions & 0 deletions wdpk/zerotier/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SRC := compile-in-docker.sh Dockerfile
all: bin/zerotier-one

.PHONY: all

bin/zerotier-one: $(SRC)
./compile-in-docker.sh

2 changes: 1 addition & 1 deletion wdpk/zerotier/apkg.rc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: zerotier
Version: 1.6.3
Version: 1.6.4
Packager: TFL
Email:
Homepage: http://www.zerotier.com
Expand Down
5 changes: 2 additions & 3 deletions wdpk/zerotier/build.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#!/bin/sh

set -e
APP_NAME="$(basename $(pwd))"
DATE="$(date +"%m%d%Y")"
CWD="$(pwd)"
VERSION="$(awk '/Version/{print $NF}' apkg.rc)"

echo "Building ${APP_NAME} version ${VERSION}"

MODELS="MyCloudEX2Ultra"

for model in $MODELS; do
make
../../mksapkg-OS5 -E -s -m $model > /dev/null
done

Expand Down
40 changes: 23 additions & 17 deletions wdpk/zerotier/cgi-bin/zerotier.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
#!/usr/bin/env python3
import cgitb
import re

cgitb.enable()

import cgi
import os
import re
import subprocess

print('Content-type: text/plain')
print('')
os.environ["PATH"] += os.path.pathsep + "/mnt/HD/HD_a2/Nas_Prog/zerotier/bin/"
os.environ["ZEROTIER_HOME"] = "/mnt/HD/HD_a2/.systemfile/zerotier"
print("Content-type: text/plain")
print("")


def list_networks():
print('<pre>')
print('command output')
output = subprocess.check_output(["/opt/bin/zerotier-cli", "listnetworks"])
print(output.decode('utf-8'))
print('</pre>')
print("<pre>")
print("command output")
output = subprocess.check_output(["zerotier-cli", "listnetworks"])
print(output.decode("utf-8"))
print("</pre>")


def join_network():
print('<pre>')
print("<pre>")
form = cgi.FieldStorage()
network_name = form['network_name'].value.strip()
match = re.match('^[0-9a-f]+$', network_name)
network_name = form["network_name"].value.strip()
match = re.match("^[0-9a-f]+$", network_name)
if not match:
print(f'Not a valid network name {network_name!r}')
print(f"Not a valid network name {network_name!r}")
exit(0)

print(f'trying to join {network_name!r}')
output = subprocess.check_output(["/opt/bin/zerotier-cli", "join", network_name])
print(output.decode('utf-8'))
print('</pre>')
print(f"trying to join {network_name!r}")
output = subprocess.check_output(["zerotier-cli", "join", network_name])
print(output.decode("utf-8"))
print("</pre>")


if os.environ['REQUEST_METHOD'] != 'GET':
if os.environ["REQUEST_METHOD"] != "GET":
join_network()
exit(0)

Expand Down
15 changes: 15 additions & 0 deletions wdpk/zerotier/compile-in-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -e
docker build -t zerotier .
docker run \
-v $PWD/bin:/usr/src/bin --rm -it \
-e ME="$(id -u):$(id -g)" \
zerotier \
bash -exc 'cd /usr/src/ZeroTier* && make -j8 ZT_DISABLE_COMPRESSION=1 && cp zerotier-one /usr/src/bin/ && chown -R $ME /usr/src/bin/'

cd bin
for link in zerotier-cli zerotier-idtool;
do
ln -sf zerotier-one $link
done
cd ..
2 changes: 0 additions & 2 deletions wdpk/zerotier/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ NAS_PROG=$(readlink -f $2)

# install all package scripts to the proper location
cp -rfv ${INSTALL_DIR} ${NAS_PROG} &2>&1 >> $DEBUG_FILE

/opt/bin/opkg install zerotier &2>&1 >> $DEBUG_FILE
2 changes: 0 additions & 2 deletions wdpk/zerotier/remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@

path=$1

/opt/bin/opkg remove zerotier

rm -rf $path
rm -rf "/var/www/apps/zerotier/"
9 changes: 6 additions & 3 deletions wdpk/zerotier/start.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#! /bin/sh
[ -f /tmp/debug_apkg ] && echo "APKG_DEBUG: $0 $@" >> /tmp/debug_apkg
#!/bin/bash
[ -f /tmp/debug_apkg ] && echo "APKG_DEBUG: $0 $@ $PWD" >> /tmp/debug_apkg

/opt/bin/zerotier-one -d
export ZEROTIER_HOME=/mnt/HD/HD_a2/.systemfile/zerotier
mkdir -p "$ZEROTIER_HOME"

$1/bin/zerotier-one -d

0 comments on commit 93b87e9

Please sign in to comment.