peerstore: fix
[oweals/gnunet.git] / contrib / gnunet-gns-import.sh
index fd56119d317db1ff5ec41fa3059f7be35fd1b15a..0ad3ab1d284814b041a2671a1fd42075e7b64d33 100755 (executable)
@@ -4,6 +4,11 @@
 
 LOCATION=$(which gnunet-config)
 if [ -z $LOCATION ]
+then
+  LOCATION="gnunet-config"
+fi
+$LOCATION --version 1> /dev/null
+if test $? != 0
 then
        echo "GNUnet command line tools not found, check environmental variables PATH and GNUNET_PREFIX"
        exit 1
@@ -54,11 +59,26 @@ gnunet-identity -e sks-zone -s fs-sks $options
 MASTER=`gnunet-identity -d $options | grep master-zone | awk '{print $3}'`
 SHORT=`gnunet-identity -d $options | grep short-zone | awk '{print $3}'`
 PRIVATE=`gnunet-identity -d $options | grep private-zone | awk '{print $3}'`
+PIN=72QC35CO20UJN1E91KPJFNT9TG4CLKAPB4VK9S3Q758S9MLBRKOG
 
 # Link short and private zones into master zone
-gnunet-namestore -z master-zone -a -e never -n private -p -t PKEY -V $PRIVATE $options
-gnunet-namestore -z master-zone -a -e never -n short -p -t PKEY -V $SHORT $options
+if (gnunet-namestore -z master-zone -D -n private -t PKEY | grep "PKEY: $PRIVATE" 1>/dev/null)
+then
+  echo "Private zone link exists, skipping"
+else
+  gnunet-namestore -z master-zone -a -e never -n private -p -t PKEY -V $PRIVATE $options
+fi
+if (gnunet-namestore -z master-zone -D -n short -t PKEY | grep "PKEY: $SHORT" 1>/dev/null)
+then
+  echo "Shorten zone link exists, skipping"
+else
+  gnunet-namestore -z master-zone -a -e never -n short -p -t PKEY -V $SHORT $options
+fi
 
 # Link GNUnet's FCFS zone into master zone under label "pin"
-gnunet-namestore -z master-zone -a -e never -n pin -p -t PKEY -V 72QC35CO20UJN1E91KPJFNT9TG4CLKAPB4VK9S3Q758S9MLBRKOG $options
-
+if (gnunet-namestore -z master-zone -D -n pin -t PKEY | grep "PKEY: $PIN" 1>/dev/null)
+then
+  echo "Pin zone link exists, skipping"
+else
+  gnunet-namestore -z master-zone -a -e never -n pin -p -t PKEY -V $PIN $options
+fi