Skip to content

Commit 59e6910

Browse files
committed
add doc for openwrt setup
1 parent 6070881 commit 59e6910

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

docs/openwrt/setup.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Setup Ziti Edge Tunnel on Teltonica RUT240
2+
------------------------------------------
3+
4+
# Download and install
5+
1. get ziti-edge-tunnel bundle from https://ziti-public.s3.us-east-2.amazonaws.com/mips-teltonica/ziti-edge-tunnel-Linux_mips.zip
6+
1. unzip and copy `ziti-edge-tunnel` executable to `/usr/sbin` (location could be different with appropriate adjustments to init script)
7+
1. get ziti init script from https://ziti-public.s3.us-east-2.amazonaws.com/mips-teltonica/ziti.init
8+
1. put init script as `/etc/init.d/ziti`
9+
10+
# Configure Ziti identity
11+
1. create folder '/etc/ziti'
12+
1. copy CA auto-enrollment JWT as `/etc/ziti/ca.jwt`
13+
1. generate unique device SSL client certificate and copy to '/etc/ziti' along with private key:
14+
- key should be saved as `/etc/ziti/id.key`
15+
- certificate should be saved as `/etc/ziti/id.crt`
16+
17+
# Configure Ziti service to autostart
18+
`# /etc/init.s/ziti enable`
19+
The first time ziti service starts it enrolls with controller specified by `ca.jwt`
20+
21+
# Alternative enrollment
22+
It is possible to enroll with OTT (one time token) JWT manually.
23+
- create endpoint in MOP and download enrollment key -- JWT file
24+
- move JWT file to the device somewhere (e.g. `/tmp/enroll.jwt`)
25+
- enroll with the following command:
26+
`# /usr/sbin/ziti-edge-tunnel enroll -j /tmp/enroll.jwt -i /etc/ziti/id.json`
27+
- this create `/etc/ziti/id.json` file and ziti service can be started normally or automatically on next power up
28+

docs/openwrt/ziti.init

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/sh /etc/rc.common
2+
# Copyright (C) 2020 NetFoundry, Inc
3+
4+
START=65
5+
STOP=65
6+
USE_PROCD=1
7+
8+
prog=/usr/sbin/ziti-edge-tunnel
9+
10+
idfile=/etc/ziti/id.json
11+
jwtfile=/etc/ziti/ca.jwt
12+
certfile=/etc/ziti/id.crt
13+
keyfile=/etc/ziti/id.key
14+
15+
log_opts="-s -t ziti"
16+
17+
start_service() {
18+
enroll
19+
# commands to launch application
20+
if [ ! -f "$idfile" ]; then
21+
logger -p err $log_opts "identity is not enrolled"
22+
return 1
23+
fi
24+
25+
procd_open_instance ziti-edge-tunnel
26+
procd_set_param command ${prog} run
27+
procd_append_param command -c ${idfile}
28+
procd_append_param command --dns=dnsmasq:/tmp/hosts
29+
30+
procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
31+
procd_set_param stderr 1
32+
procd_set_param stdout 1
33+
procd_set_param pidfile /var/run/${prog}.pid
34+
procd_close_instance
35+
}
36+
37+
enroll() {
38+
if [ -f "$idfile" ]; then
39+
logger $log_opts "enrollment $idfile exists"
40+
else
41+
logger $log_opts "enrolling with Ziti.."
42+
${prog} enroll -i ${idfile} -j ${jwtfile} -c ${certfile} -k ${keyfile} 2>&1 | logger -p info $log_opts
43+
fi
44+
}

0 commit comments

Comments
 (0)