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 |
Alexander Afanasyev | f08a737 | 2015-02-09 21:28:19 -0800 | [diff] [blame] | 9 | echo " Start NFD" |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 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) |
Junxiao Shi | d71d84c | 2014-04-18 17:22:50 -0700 | [diff] [blame] | 33 | |
Alexander Afanasyev | f08a737 | 2015-02-09 21:28:19 -0800 | [diff] [blame] | 34 | if [[ -n $hasNFD ]] |
Junxiao Shi | d71d84c | 2014-04-18 17:22:50 -0700 | [diff] [blame] | 35 | then |
Alexander Afanasyev | f08a737 | 2015-02-09 21:28:19 -0800 | [diff] [blame] | 36 | echo 'NFD is already running...' |
Junxiao Shi | d71d84c | 2014-04-18 17:22:50 -0700 | [diff] [blame] | 37 | exit 1 |
| 38 | fi |
| 39 | |
Junxiao Shi | 262f531 | 2014-05-03 10:45:12 -0700 | [diff] [blame] | 40 | if ! ndnsec-get-default &>/dev/null |
| 41 | then |
| 42 | ndnsec-keygen /localhost/operator | ndnsec-install-cert - |
| 43 | fi |
| 44 | |
| 45 | if ! sudo true |
| 46 | then |
| 47 | echo 'Unable to obtain superuser privilege' |
| 48 | exit 2 |
| 49 | fi |
| 50 | |
Alexander Afanasyev | f08a737 | 2015-02-09 21:28:19 -0800 | [diff] [blame] | 51 | sudo @BINDIR@/nfd & |
| 52 | |
| 53 | if [ -f @SYSCONFDIR@/ndn/nfd-init.sh ]; then |
| 54 | sleep 2 # post-start is executed just after nfd process starts, but there is no guarantee |
| 55 | # that all initialization has been finished |
| 56 | . @SYSCONFDIR@/ndn/nfd-init.sh |
| 57 | fi |