blob: 65a653a18f9063b0d58f58034ecf7a11eb41b015 [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>"
Obaid Amin47a94352013-04-10 14:52:39 -05009 echo "Example: `basename $0` memphis.edu user1 memphis.edu/cs/rtr1 (full router name without /ndn/ prefix"
Obaid Amin08ff45d2013-04-09 17:49:09 -050010 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
Obaid Amin47a94352013-04-10 14:52:39 -050022KSUITE=${HOME}ndn-testbed-key-suite/
23echo $KSUITE
Obaid Aminefeef032013-04-09 17:58:15 -050024if [ ! -d ${KSUITE} ]; then
25 echo "This script requires key signing suite available at:"
26 echo "git://github.com/named-data/ndn-testbed-key-suite.git"
27 echo "If you already have it, set the variable KSUITE of the script accordingly"
Obaid Amin8f041952013-04-09 19:13:31 -050028 exit
Obaid Aminefeef032013-04-09 17:58:15 -050029fi
30
Obaid Amin08ff45d2013-04-09 17:49:09 -050031SITE=$1
32OP=$2
33RTR=$3
34
35if [ ! -d ${SITE}_key ]; then
36 mkdir ${SITE}_key
37 ccninitkeystore ${SITE}_key
38fi
39
40if [ ! -d ${OP}_key ]; then
41 mkdir ${OP}_key
42 ccninitkeystore ${OP}_key
43fi
44
45if [ ! -d "router_key" ]; then
46 mkdir router_key
47 ccninitkeystore router_key
48fi
49
50if [ ! -d "nlsr_key" ]; then
51 mkdir nlsr_key
52 ccninitkeystore nlsr_key
53fi
54
55
56
57
Obaid Amin47a94352013-04-10 14:52:39 -050058$KSUITE/bin/ndn-extract-public-key.sh -i ${SITE}_key/.ccnx/.ccnx_keystore -o ${SITE}_key/$SITE.pem
59$KSUITE/bin/ndn-extract-public-key.sh -i ${OP}_key/.ccnx/.ccnx_keystore -o ${OP}_key/$OP.pem
60$KSUITE/bin/ndn-extract-public-key.sh -i router_key/.ccnx/.ccnx_keystore -o router_key/router.pem
61$KSUITE/bin/ndn-extract-public-key.sh -i nlsr_key/.ccnx/.ccnx_keystore -o nlsr_key/nlsr.pem
Obaid Amin08ff45d2013-04-09 17:49:09 -050062
Obaid Amin47a94352013-04-10 14:52:39 -050063.$KSUITE/sign.sh -s
Obaid Amin08ff45d2013-04-09 17:49:09 -050064
65#signing operator key
Obaid Amin47a94352013-04-10 14:52:39 -050066echo "$KSUITE/bin/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$KSUITE/bin/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
Obaid Amin08ff45d2013-04-09 17:49:09 -050068
69#signing routing key
Obaid Amin47a94352013-04-10 14:52:39 -050070echo "$KSUITE/bin/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/$RTR -x 365"
71$KSUITE/bin/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/$RTR -x 365
Obaid Amin08ff45d2013-04-09 17:49:09 -050072
73#signing nlsr key
Obaid Amin47a94352013-04-10 14:52:39 -050074echo "$KSUITE/bin/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/$RTR/nlsr -x 365"
75$KSUITE/bin/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/$RTR/nlsr -x 365