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