netopeer2-server: init recovery
authorAntonio Paunovic <redacted>
Tue, 6 Jun 2017 14:47:46 +0000 (14:47 +0000)
committerAntonio Paunovic <redacted>
Tue, 6 Jun 2017 14:47:46 +0000 (14:47 +0000)
Signed-off-by: Antonio Paunovic <redacted>
net/netopeer2/files/netopeer2-server.init

index cdc2550031d293eb9852f0f9d21bb2690f01f694..59f7699673a1d1a68521d0555a380390aed3edba 100644 (file)
@@ -1,17 +1,38 @@
 #!/bin/sh /etc/rc.common
 
-START=90
-STOP=10
+START=99
+STOP=11
 
 USE_PROCD=1
 PROG=/bin/netopeer2-server
 
 start_service() {
 
-    # netopeer2-server requires sysrepo daemon
-    /etc/init.d/sysrepo start
+    PERSIST_FILE=/etc/sysrepo/data/ietf-keystore.persist
 
-    sleep 1
+    while [ ! -f $PERSIST_FILE ]
+    do
+        echo "no persist file yet"
+        sleep 3
+    done
+
+    RETRY_CNT=5
+    LAST_LINE=$(tail -n1 $PERSIST_FILE)
+
+    while [[ -f $PERSIST_FILE && $LAST_LINE != "</module>" ]]
+    do
+        sleep 1
+
+        echo "$RETRY_CNT: $LAST_LINE"
+        LAST_LINE=$(tail -n1 $PERSIST_FILE)
+        RETRY_CNT=$(($RETRY_CNT-1))
+
+        if [ $RETRY_CNT -le 0 ];
+        then
+            rm $PERSIST_FILE
+            RETRY_CNT=5
+        fi
+         done
 
     procd_open_instance
     procd_set_param command $PROG
git clone https://git.99rst.org/PROJECT