blob: 46f5d4cd3c710766e89a9b2954bc8f212055b165 [file] [log] [blame]
Obaid Aminefeef032013-04-09 17:58:15 -05001#Use this script to setup your keys.
Obaid Amin08ff45d2013-04-09 17:49:09 -05002#!/bin/bash
3
4EXPECTED_ARGS=3 #site, operator, router
5E_BADARGS=65
6if [ $# -ne $EXPECTED_ARGS ]
7then
8 echo "Usage: `basename $0` <site name> <operator name> <router name>"
9 echo "Example: `basename $0` memphis.edu user1 cs/rtr1"
10 exit $E_BADARGS
11fi
12
13
14RESULT=`ps -a | sed -n /ccnr/p`
15
16if [ "${RESULT:-null}" = null ]; then
17 echo "ccnr not running, quitting"
18 exit
19fi
20
21
22KSUITE=/home/"$(whoami)"/ndn-testbed-key-suite/bin
Obaid Aminefeef032013-04-09 17:58:15 -050023if [ ! -d ${KSUITE} ]; then
24 echo "This script requires key signing suite available at:"
25 echo "git://github.com/named-data/ndn-testbed-key-suite.git"
26 echo "If you already have it, set the variable KSUITE of the script accordingly"
Obaid Amin8f041952013-04-09 19:13:31 -050027 exit
Obaid Aminefeef032013-04-09 17:58:15 -050028fi
29
Obaid Amin08ff45d2013-04-09 17:49:09 -050030SITE=$1
31OP=$2
32RTR=$3
33
34if [ ! -d ${SITE}_key ]; then
35 mkdir ${SITE}_key
36 ccninitkeystore ${SITE}_key
37fi
38
39if [ ! -d ${OP}_key ]; then
40 mkdir ${OP}_key
41 ccninitkeystore ${OP}_key
42fi
43
44if [ ! -d "router_key" ]; then
45 mkdir router_key
46 ccninitkeystore router_key
47fi
48
49if [ ! -d "nlsr_key" ]; then
50 mkdir nlsr_key
51 ccninitkeystore nlsr_key
52fi
53
54
55
56
57$KSUITE/ndn-extract-public-key.sh -i ${SITE}_key/.ccnx/.ccnx_keystore -o ${SITE}_key/$SITE.pem
58$KSUITE/ndn-extract-public-key.sh -i ${OP}_key/.ccnx/.ccnx_keystore -o ${OP}_key/$OP.pem
59$KSUITE/ndn-extract-public-key.sh -i router_key/.ccnx/.ccnx_keystore -o router_key/router.pem
60$KSUITE/ndn-extract-public-key.sh -i nlsr_key/.ccnx/.ccnx_keystore -o nlsr_key/nlsr.pem
61
62./sign.sh -s
63
64#signing operator key
65echo "$KSUITE/ndn-publish-key.sh -i "$OP" -a "$SITE" -f ${OP}_key/$OP.pem -F ${SITE}_key/.ccnx/ -P /ndn/keys/$SITE -p /ndn/keys/$SITE/%C1.O.N.Start/$OP -x 365"
66$KSUITE/ndn-publish-key.sh -i "$OP" -a "$SITE" -f ${OP}_key/$OP.pem -F ${SITE}_key/.ccnx/ -P /ndn/keys/$SITE -p /ndn/keys/$SITE/%C1.O.N.Start/$OP -x 365
67
68#signing routing key
69echo "$KSUITE/ndn-publish-key.sh -i "$RTR" -a "$SITE" -f router_key/router.pem -F ${OP}_key/.ccnx/ -P /ndn/keys/$SITE/%C1.O.N.Start/$OP -p /ndn/keys/$SITE/%C1.R.N.Start/ndn/$SITE/$RTR -x 365"
70$KSUITE/ndn-publish-key.sh -i "$RTR" -a "$SITE" -f router_key/router.pem -F ${OP}_key/.ccnx/ -P /ndn/keys/$SITE/%C1.O.N.Start/$OP -p /ndn/keys/$SITE/%C1.R.N.Start/ndn/$SITE/$RTR -x 365
71
72#signing nlsr key
73echo "$KSUITE/ndn-publish-key.sh -i "NLSR" -a "$RTR" -f nlsr_key/nlsr.pem -F router_key/.ccnx/ -P /ndn/keys/$SITE/%C1.R.N.Start/ndn/$SITE/$RTR -p /ndn/keys/$SITE/%C1.R.N.Start/ndn/$SITE/$RTR/nlsr -x 365"
74$KSUITE/ndn-publish-key.sh -i "NLSR" -a "$RTR" -f nlsr_key/nlsr.pem -F router_key/.ccnx/ -P /ndn/keys/$SITE/%C1.R.N.Start/ndn/$SITE/$RTR -p /ndn/keys/$SITE/%C1.R.N.Start/ndn/$SITE/$RTR/nlsr -x 365