1 #!/bin/sh /etc/rc.common
7 PROG
=/usr
/bin
/zerotier-one
8 CONFIG_PATH
=/var
/lib
/zerotier-one
11 config_get_bool enabled
"$1" 'enabled' 0
17 local port secret interface config_path
20 section_enabled
"$cfg" ||
return 1
22 config_get config_path
$cfg 'config_path'
23 config_get_bool port
$cfg 'port'
24 config_get secret
$cfg 'secret'
25 config_get interface
$cfg 'interface'
27 # Remove existing link or folder
30 # Create link from CONFIG_PATH to config_path
31 if [ -n "$config_path" -a "$config_path" != $CONFIG_PATH ]; then
32 if [ ! -d "$config_path" ]; then
33 echo "ZeroTier config_path does not exist: $config_path"
37 ln -s $config_path $CONFIG_PATH
40 mkdir
-p $CONFIG_PATH/networks.d
42 if [ -n "$port" ]; then
46 if [ "$secret" = "generate" ]; then
47 echo "Generate secret - please wait..."
48 local tmp
="/tmp/zt.$cfg.secret"
49 zerotier-idtool generate
"$tmp" > /dev
/null
53 uci
set zerotier.
$cfg.secret
="$secret"
57 if [ -n "$secret" ]; then
58 echo "$secret" > $CONFIG_PATH/identity.secret
59 # make sure there is not previous identity.public
60 rm -f $CONFIG_PATH/identity.public
64 # an (empty) config file will cause ZT to join a network
65 touch $CONFIG_PATH/networks.d
/$1.conf
68 config_list_foreach
$cfg 'join' add_join
71 procd_add_reload_interface_trigger
"$interface"
72 procd_set_param
command $PROG $ARGS $CONFIG_PATH
77 procd_add_reload_trigger zerotier
81 config_load
'zerotier'
82 config_foreach start_instance
'zerotier'
88 # Remove existing link or folder
93 config_load
'zerotier'
94 config_foreach stop_instance
'zerotier'