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>" |
| 9 | echo "Example: `basename $0` memphis.edu user1 cs/rtr1" |
| 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 | |
| 22 | KSUITE=/home/"$(whoami)"/ndn-testbed-key-suite/bin |
Obaid Amin | efeef03 | 2013-04-09 17:58:15 -0500 | [diff] [blame] | 23 | if [ ! -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 Amin | 8f04195 | 2013-04-09 19:13:31 -0500 | [diff] [blame^] | 27 | exit |
Obaid Amin | efeef03 | 2013-04-09 17:58:15 -0500 | [diff] [blame] | 28 | fi |
| 29 | |
Obaid Amin | 08ff45d | 2013-04-09 17:49:09 -0500 | [diff] [blame] | 30 | SITE=$1 |
| 31 | OP=$2 |
| 32 | RTR=$3 |
| 33 | |
| 34 | if [ ! -d ${SITE}_key ]; then |
| 35 | mkdir ${SITE}_key |
| 36 | ccninitkeystore ${SITE}_key |
| 37 | fi |
| 38 | |
| 39 | if [ ! -d ${OP}_key ]; then |
| 40 | mkdir ${OP}_key |
| 41 | ccninitkeystore ${OP}_key |
| 42 | fi |
| 43 | |
| 44 | if [ ! -d "router_key" ]; then |
| 45 | mkdir router_key |
| 46 | ccninitkeystore router_key |
| 47 | fi |
| 48 | |
| 49 | if [ ! -d "nlsr_key" ]; then |
| 50 | mkdir nlsr_key |
| 51 | ccninitkeystore nlsr_key |
| 52 | fi |
| 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 |
| 65 | echo "$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 |
| 69 | echo "$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 |
| 73 | echo "$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 |