From 25019ee4d3236b9eee46ff4e6661730a5cce3364 Mon Sep 17 00:00:00 2001
From: Roman Khlopkov <roman.khlopkov@demlabs.net>
Date: Sat, 9 Apr 2022 19:56:36 +0300
Subject: [PATCH] [*] Add backbone network

---
 linux/debian/essentials/config    |  8 ++++++++
 linux/debian/essentials/postinst  | 21 +++++++++++++++++++++
 linux/debian/essentials/templates | 21 ++++++++++++++++++++-
 3 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/linux/debian/essentials/config b/linux/debian/essentials/config
index 0736088..b48c83a 100755
--- a/linux/debian/essentials/config
+++ b/linux/debian/essentials/config
@@ -62,6 +62,14 @@ reconfigure|configure)
       db_go || true
    fi
 
+   db_input critical cellframe-node/backbone_enabled || true 
+   db_go || true 
+
+   db_get cellframe-node/backbone_enabled
+   if [ "$RET" = "true" ]; then
+      db_input critical cellframe-node/backbone_node_type || true 
+      db_go || true
+   fi
 ;;
 *)
    echo "config called with unknown argument \`$1'" >&2
diff --git a/linux/debian/essentials/postinst b/linux/debian/essentials/postinst
index d8b0c50..5d8a21e 100755
--- a/linux/debian/essentials/postinst
+++ b/linux/debian/essentials/postinst
@@ -147,6 +147,27 @@ if [ "$RET" = "true" ]; then
     echo "[*] Enabled subzero"
 fi
 
+# Init Backbone
+NET_NAME="Backbone"
+
+db_get cellframe-node/backbone_enabled || true
+if [ "$RET" = "true" ]; then
+    DAP_CFG_NET="$DAP_PREFIX/etc/network/$NET_NAME.cfg"
+    DAP_CFG_NET_TPL="$DAP_PREFIX/share/configs/network/$NET_NAME.cfg.tpl"
+    DAP_NET_CFG=""
+    if [ -e "$DAP_CFG_NET" ]; then
+	DAP_NET_CFG="$DAP_PREFIX/etc/network/$NET_NAME.cfg.dpkg-new"
+    else
+	DAP_NET_CFG="$DAP_PREFIX/etc/network/$NET_NAME.cfg"
+    fi
+
+    cat $DAP_CFG_NET_TPL > $DAP_NET_CFG || true
+    db_get cellframe-node/backbone_node_type || true
+    NODE_TYPE=$RET
+    sed -i "s/{NODE_TYPE}/$NODE_TYPE/g" $DAP_NET_CFG  || true
+    echo "[*] Enabled Backbone"
+fi
+
 mkdir -p $DAP_PREFIX/var/log     || true
 mkdir -p $DAP_PREFIX/var/plugins || true
 
diff --git a/linux/debian/essentials/templates b/linux/debian/essentials/templates
index 04ac413..b95dd06 100755
--- a/linux/debian/essentials/templates
+++ b/linux/debian/essentials/templates
@@ -118,4 +118,23 @@ Description: Kelvpn Minkowski: Node role
  full - sync all its cell
  master - allow to store values in chains and take comission, sync all shards that will need to be synced
  archive - Sync all the network
- root - Special predefined root nodes, usualy produces zerochain and act like archive as well  
+ root - Special predefined root nodes, usualy produces zerochain and act like archive as well 
+
+Template: cellframe-node/backbone_enabled
+Default: true
+Choices: true, false
+Type: select
+Description: Backbone: Enable network
+ Subzero Testnet: Enable network auto load on start
+
+Template: cellframe-node/backbone_node_type
+Type: select
+Default: full
+Choices: full, light, master, archive, root
+Description: Backbone: Node role
+ Select node role:. 
+ Light - syncronize only local wallets 
+ full - sync all its cell
+ master - allow to store values in chains and take comission, sync all shards that will need to be synced
+ archive - Sync all the network
+ root - Special predefined root nodes, usualy produces zerochain and act like archive as well 
-- 
GitLab