yggdrasil: fix startup and generate nodeInfo info
authorWilliam Fleurant <redacted>
Sun, 24 Mar 2019 03:50:04 +0000 (23:50 -0400)
committerWilliam Fleurant <redacted>
Sun, 24 Mar 2019 03:50:04 +0000 (23:50 -0400)
- init: fix no start
- defaults: apply ubus system board info to nodeInfo
- defaults: fix missing yggdrasil interface
- defaults: call uci commit

Signed-off-by: William Fleurant <redacted>
net/yggdrasil/Makefile
net/yggdrasil/files/yggdrasil.defaults
net/yggdrasil/files/yggdrasil.init

index ae1afc6bf8275aba465e4019fc00ea11783b934b..9c35acec28101b8a1496c53c1459f05fd9f93655 100644 (file)
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=yggdrasil
 PKG_VERSION:=0.3.5
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 
 PKG_SOURCE_URL:=https://codeload.github.com/yggdrasil-network/yggdrasil-go/tar.gz/v$(PKG_VERSION)?
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
index 2f2bb1dba3d131971278bc6dc6411a62f0296f4b..3687500130312e29a67adfaa03f5a8e0ffce9631 100644 (file)
@@ -2,9 +2,42 @@
 
 yggConfig="/etc/yggdrasil.conf"
 
+first_boot_genConfig()
+{
+  . /usr/share/libubox/jshn.sh
+  boardcfg=$(ubus call system board)
+  yggcfg=$(yggdrasil -genconf -json | grep NodeInfo -v)
+
+  json_load "$boardcfg"
+  json_get_var kernel     kernel
+  json_get_var hostname   hostname
+  json_get_var system     system
+  json_get_var model      model
+  json_get_var board_name board_name
+
+  json_load "$yggcfg"
+  json_add_string "IfName" "ygg0"
+  json_add_object "NodeInfo"
+  json_add_string "kernel"      "$kernel"
+  json_add_string "hostname"    "$hostname"
+  json_add_string "system"      "$system"
+  json_add_string "model"       "$model"
+  json_add_string "board_name"  "$board_name"
+  json_close_object
+  json_dump
+}
+
 if [ ! -e ${yggConfig} ]; then
+  echo "first_boot: adding system board details to NodeInfo[] in NEW config: ${yggConfig}" | logger -t yggdrasil
 
-  yggdrasil -genconf -json > ${yggConfig}
+  first_boot_genConfig > ${yggConfig}
+
+  # create the network interface
+  uci -q batch <<-EOF >/dev/null
+    set network.yggdrasil=interface
+    set network.yggdrasil.ifname=ygg0
+    set network.yggdrasil.proto=none
+EOF
 
   # create the firewall zone
   uci -q batch <<-EOF >/dev/null
@@ -58,6 +91,8 @@ EOF
     set firewall.@rule[-1].target=ACCEPT
 EOF
 
+  uci commit firewall
+  uci commit network
 
 else
   :
index 82c209b4e2249496d6193b4d7544727625c4010a..afdcdb4335e6818a02bd244d223748a0302cc6db 100755 (executable)
@@ -11,7 +11,6 @@ start_service()
 
        procd_open_instance
        procd_set_param respawn
-       procd_set_param command /usr/sbin/yggdrasil -useconffile /etc/yggdrasil.conf
        procd_set_param command /bin/ash -c "/usr/sbin/yggdrasil -useconffile /etc/yggdrasil.conf | logger -t yggdrasil"
 
        procd_close_instance
git clone https://git.99rst.org/PROJECT