Junxiao Shi | d71d84c | 2014-04-18 17:22:50 -0700 | [diff] [blame] | 1 | #!@BASH@ |
| 2 | |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 3 | VERSION="@VERSION@" |
| 4 | |
| 5 | case "$1" in |
| 6 | -h) |
| 7 | echo Usage |
| 8 | echo $0 |
| 9 | echo " Start NFD and RIB Management daemon" |
| 10 | exit 0 |
| 11 | ;; |
| 12 | -V) |
| 13 | echo $VERSION |
| 14 | exit 0 |
| 15 | ;; |
| 16 | "") ;; # do nothing |
| 17 | *) |
| 18 | echo "Unrecognized option $1" |
| 19 | exit 1 |
| 20 | ;; |
| 21 | esac |
| 22 | |
Junxiao Shi | d71d84c | 2014-04-18 17:22:50 -0700 | [diff] [blame] | 23 | hasProcess() { |
| 24 | local processName=$1 |
| 25 | |
| 26 | if pgrep -x $processName >/dev/null |
| 27 | then |
| 28 | echo $processName |
| 29 | fi |
| 30 | } |
| 31 | |
| 32 | hasNFD=$(hasProcess nfd) |
| 33 | hasNRD=$(hasProcess nrd) |
| 34 | |
| 35 | if [[ -n $hasNFD$hasNRD ]] |
| 36 | then |
| 37 | echo 'NFD or NRD is already running...' |
| 38 | exit 1 |
| 39 | fi |
| 40 | |
Junxiao Shi | 262f531 | 2014-05-03 10:45:12 -0700 | [diff] [blame] | 41 | if ! ndnsec-get-default &>/dev/null |
| 42 | then |
| 43 | ndnsec-keygen /localhost/operator | ndnsec-install-cert - |
| 44 | fi |
| 45 | |
| 46 | if ! sudo true |
| 47 | then |
| 48 | echo 'Unable to obtain superuser privilege' |
| 49 | exit 2 |
| 50 | fi |
| 51 | |
Junxiao Shi | d71d84c | 2014-04-18 17:22:50 -0700 | [diff] [blame] | 52 | sudo nfd & |
| 53 | sleep 2 |
| 54 | nrd & |
| 55 | sleep 2 |