gnunet-gns-import.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/bin/sh
  2. # This shell-script will import some GNS authorities into your GNS
  3. # namestore.
  4. LOCATION=$(which gnunet-config)
  5. if [ -z $LOCATION ]
  6. then
  7. LOCATION="gnunet-config"
  8. fi
  9. $LOCATION --version 1> /dev/null
  10. if test $? != 0
  11. then
  12. echo "GNUnet command line tools not found, check environmental variables PATH and GNUNET_PREFIX"
  13. exit 1
  14. fi
  15. gnunet-arm -I 1> /dev/null 2>/dev/null
  16. if [ ! $? -eq 0 ]
  17. then
  18. echo "GNUnet is not running, please start GNUnet before running import"
  19. exit 1
  20. fi
  21. options=''
  22. while getopts "c:" opt; do
  23. case $opt in
  24. c)
  25. options+="-c $OPTARG"
  26. ;;
  27. \?)
  28. echo "Invalid option: -$OPTARG" >&2
  29. exit 1
  30. ;;
  31. :)
  32. echo "Option -$OPTARG requires an argument." >&2
  33. exit 1
  34. ;;
  35. esac
  36. done
  37. # By default, we create three GNS zones:
  38. gnunet-identity -C master-zone $options
  39. gnunet-identity -C short-zone $options
  40. gnunet-identity -C private-zone $options
  41. # Additionally, we create the FS SKS zone
  42. gnunet-identity -C sks-zone $options
  43. # Integrate those with the respective subsystems.
  44. gnunet-identity -e short-zone -s gns-short $options
  45. gnunet-identity -e master-zone -s gns-master $options
  46. gnunet-identity -e master-zone -s namestore $options
  47. gnunet-identity -e master-zone -s gns-proxy $options
  48. gnunet-identity -e private-zone -s gns-private $options
  49. gnunet-identity -e sks-zone -s fs-sks $options
  50. # Get the public keys as strings (so we can create PKEY records)
  51. MASTER=`gnunet-identity -d $options | grep master-zone | awk '{print $3}'`
  52. SHORT=`gnunet-identity -d $options | grep short-zone | awk '{print $3}'`
  53. PRIVATE=`gnunet-identity -d $options | grep private-zone | awk '{print $3}'`
  54. PIN=72QC35CO20UJN1E91KPJFNT9TG4CLKAPB4VK9S3Q758S9MLBRKOG
  55. # Link short and private zones into master zone
  56. if (gnunet-namestore -z master-zone -D -n private -t PKEY | grep "PKEY: $PRIVATE" 1>/dev/null)
  57. then
  58. echo "Private zone link exists, skipping"
  59. else
  60. gnunet-namestore -z master-zone -a -e never -n private -p -t PKEY -V $PRIVATE $options
  61. fi
  62. if (gnunet-namestore -z master-zone -D -n short -t PKEY | grep "PKEY: $SHORT" 1>/dev/null)
  63. then
  64. echo "Shorten zone link exists, skipping"
  65. else
  66. gnunet-namestore -z master-zone -a -e never -n short -p -t PKEY -V $SHORT $options
  67. fi
  68. # Link GNUnet's FCFS zone into master zone under label "pin"
  69. if (gnunet-namestore -z master-zone -D -n pin -t PKEY | grep "PKEY: $PIN" 1>/dev/null)
  70. then
  71. echo "Pin zone link exists, skipping"
  72. else
  73. gnunet-namestore -z master-zone -a -e never -n pin -p -t PKEY -V $PIN $options
  74. fi