blob: 5283f19f9feb48b1352b4aa8db38faedb959939d [file] [log] [blame]
Junxiao Shid71d84c2014-04-18 17:22:50 -07001#!@BASH@
2
Alexander Afanasyevb47d5382014-05-05 14:35:03 -07003VERSION="@VERSION@"
4
5case "$1" in
6 -h)
7 echo Usage
8 echo $0
Alexander Afanasyevf08a7372015-02-09 21:28:19 -08009 echo " Start NFD"
Alexander Afanasyevb47d5382014-05-05 14:35:03 -070010 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 ;;
21esac
22
Junxiao Shid71d84c2014-04-18 17:22:50 -070023hasProcess() {
24 local processName=$1
25
26 if pgrep -x $processName >/dev/null
27 then
28 echo $processName
29 fi
30}
31
32hasNFD=$(hasProcess nfd)
Junxiao Shid71d84c2014-04-18 17:22:50 -070033
Alexander Afanasyevf08a7372015-02-09 21:28:19 -080034if [[ -n $hasNFD ]]
Junxiao Shid71d84c2014-04-18 17:22:50 -070035then
Alexander Afanasyevf08a7372015-02-09 21:28:19 -080036 echo 'NFD is already running...'
Junxiao Shid71d84c2014-04-18 17:22:50 -070037 exit 1
38fi
39
Junxiao Shi262f5312014-05-03 10:45:12 -070040if ! ndnsec-get-default &>/dev/null
41then
42 ndnsec-keygen /localhost/operator | ndnsec-install-cert -
43fi
44
45if ! sudo true
46then
47 echo 'Unable to obtain superuser privilege'
48 exit 2
49fi
50
Alexander Afanasyevf08a7372015-02-09 21:28:19 -080051sudo @BINDIR@/nfd &
52
53if [ -f @SYSCONFDIR@/ndn/nfd-init.sh ]; then
Alexander Afanasyev5c475972015-12-20 16:16:56 -080054 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
57fi
58
59if [ -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 Afanasyevf08a7372015-02-09 21:28:19 -080062fi