Obaid Amin | efeef03 | 2013-04-09 17:58:15 -0500 | [diff] [blame] | 1 | #Use this script to setup your keys. |
Obaid Amin | 08ff45d | 2013-04-09 17:49:09 -0500 | [diff] [blame] | 2 | #!/bin/bash |
| 3 | |
| 4 | EXPECTED_ARGS=3 #site, operator, router |
| 5 | E_BADARGS=65 |
| 6 | if [ $# -ne $EXPECTED_ARGS ] |
| 7 | then |
| 8 | echo "Usage: `basename $0` <site name> <operator name> <router name>" |
Obaid Amin | 47a9435 | 2013-04-10 14:52:39 -0500 | [diff] [blame^] | 9 | echo "Example: `basename $0` memphis.edu user1 memphis.edu/cs/rtr1 (full router name without /ndn/ prefix" |
Obaid Amin | 08ff45d | 2013-04-09 17:49:09 -0500 | [diff] [blame] | 10 | exit $E_BADARGS |
| 11 | fi |
| 12 | |
| 13 | |
| 14 | RESULT=`ps -a | sed -n /ccnr/p` |
| 15 | |
| 16 | if [ "${RESULT:-null}" = null ]; then |
| 17 | echo "ccnr not running, quitting" |
| 18 | exit |
| 19 | fi |
| 20 | |
| 21 | |
Obaid Amin | 47a9435 | 2013-04-10 14:52:39 -0500 | [diff] [blame^] | 22 | KSUITE=${HOME}ndn-testbed-key-suite/ |
| 23 | echo $KSUITE |
Obaid Amin | efeef03 | 2013-04-09 17:58:15 -0500 | [diff] [blame] | 24 | if [ ! -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 Amin | 8f04195 | 2013-04-09 19:13:31 -0500 | [diff] [blame] | 28 | exit |
Obaid Amin | efeef03 | 2013-04-09 17:58:15 -0500 | [diff] [blame] | 29 | fi |
| 30 | |
Obaid Amin | 08ff45d | 2013-04-09 17:49:09 -0500 | [diff] [blame] | 31 | SITE=$1 |
| 32 | OP=$2 |
| 33 | RTR=$3 |
| 34 | |
| 35 | if [ ! -d ${SITE}_key ]; then |
| 36 | mkdir ${SITE}_key |
| 37 | ccninitkeystore ${SITE}_key |
| 38 | fi |
| 39 | |
| 40 | if [ ! -d ${OP}_key ]; then |
| 41 | mkdir ${OP}_key |
| 42 | ccninitkeystore ${OP}_key |
| 43 | fi |
| 44 | |
| 45 | if [ ! -d "router_key" ]; then |
| 46 | mkdir router_key |
| 47 | ccninitkeystore router_key |
| 48 | fi |
| 49 | |
| 50 | if [ ! -d "nlsr_key" ]; then |
| 51 | mkdir nlsr_key |
| 52 | ccninitkeystore nlsr_key |
| 53 | fi |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
Obaid Amin | 47a9435 | 2013-04-10 14:52:39 -0500 | [diff] [blame^] | 58 | $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 Amin | 08ff45d | 2013-04-09 17:49:09 -0500 | [diff] [blame] | 62 | |
Obaid Amin | 47a9435 | 2013-04-10 14:52:39 -0500 | [diff] [blame^] | 63 | .$KSUITE/sign.sh -s |
Obaid Amin | 08ff45d | 2013-04-09 17:49:09 -0500 | [diff] [blame] | 64 | |
| 65 | #signing operator key |
Obaid Amin | 47a9435 | 2013-04-10 14:52:39 -0500 | [diff] [blame^] | 66 | echo "$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 Amin | 08ff45d | 2013-04-09 17:49:09 -0500 | [diff] [blame] | 68 | |
| 69 | #signing routing key |
Obaid Amin | 47a9435 | 2013-04-10 14:52:39 -0500 | [diff] [blame^] | 70 | echo "$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 Amin | 08ff45d | 2013-04-09 17:49:09 -0500 | [diff] [blame] | 72 | |
| 73 | #signing nlsr key |
Obaid Amin | 47a9435 | 2013-04-10 14:52:39 -0500 | [diff] [blame^] | 74 | echo "$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 |