|
|
@ -14,15 +14,17 @@ section_enabled() { |
|
|
|
|
|
|
|
start_instance() { |
|
|
|
local cfg="$1" |
|
|
|
local port secret interface config_path |
|
|
|
local port secret config_path |
|
|
|
local ARGS="" |
|
|
|
|
|
|
|
section_enabled "$cfg" || return 1 |
|
|
|
if ! section_enabled "$cfg"; then |
|
|
|
echo "disabled in config" |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
|
|
|
|
config_get config_path $cfg 'config_path' |
|
|
|
config_get_bool port $cfg 'port' |
|
|
|
config_get secret $cfg 'secret' |
|
|
|
config_get interface $cfg 'interface' |
|
|
|
|
|
|
|
# Remove existing link or folder |
|
|
|
rm -rf $CONFIG_PATH |
|
|
@ -45,10 +47,13 @@ start_instance() { |
|
|
|
|
|
|
|
if [ "$secret" = "generate" ]; then |
|
|
|
echo "Generate secret - please wait..." |
|
|
|
local tmp="/tmp/zt.$cfg.secret" |
|
|
|
zerotier-idtool generate "$tmp" > /dev/null |
|
|
|
secret="$(cat $tmp)" |
|
|
|
rm "$tmp" |
|
|
|
local sf="/tmp/zt.$cfg.secret" |
|
|
|
|
|
|
|
zerotier-idtool generate "$sf" > /dev/null |
|
|
|
[ $? -ne 0 ] && return 1 |
|
|
|
|
|
|
|
secret="$(cat $sf)" |
|
|
|
rm "$sf" |
|
|
|
|
|
|
|
uci set zerotier.$cfg.secret="$secret" |
|
|
|
uci commit zerotier |
|
|
@ -68,15 +73,11 @@ start_instance() { |
|
|
|
config_list_foreach $cfg 'join' add_join |
|
|
|
|
|
|
|
procd_open_instance |
|
|
|
procd_add_reload_interface_trigger "$interface" |
|
|
|
procd_set_param command $PROG $ARGS $CONFIG_PATH |
|
|
|
procd_set_param stderr 1 |
|
|
|
procd_close_instance |
|
|
|
} |
|
|
|
|
|
|
|
service_triggers() { |
|
|
|
procd_add_reload_trigger zerotier |
|
|
|
} |
|
|
|
|
|
|
|
start_service() { |
|
|
|
config_load 'zerotier' |
|
|
|
config_foreach start_instance 'zerotier' |
|
|
|