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 | |
Davide Pesavento | d69070e | 2021-06-04 18:50:52 -0400 | [diff] [blame] | 40 | if ! ndnsec get-default &>/dev/null |
Junxiao Shi | 262f531 | 2014-05-03 10:45:12 -0700 | [diff] [blame] | 41 | then |
Davide Pesavento | d69070e | 2021-06-04 18:50:52 -0400 | [diff] [blame] | 42 | ndnsec key-gen /localhost/operator | ndnsec cert-install - |
Junxiao Shi | 262f531 | 2014-05-03 10:45:12 -0700 | [diff] [blame] | 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 |
Alexander Afanasyev | 5c47597 | 2015-12-20 16:16:56 -0800 | [diff] [blame] | 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 |
| 58 | |
| 59 | if [ -f @SYSCONFDIR@/ndn/autoconfig.conf ]; then |
| 60 | sleep 2 # post-start is executed just after nfd process starts, but there is no guarantee |
| 61 | @BINDIR@/ndn-autoconfig -d -c "@SYSCONFDIR@/ndn/autoconfig.conf" & |
Alexander Afanasyev | f08a737 | 2015-02-09 21:28:19 -0800 | [diff] [blame] | 62 | fi |