ccnx: adding autoconfiguration scripts
diff --git a/net/ccnx/Portfile b/net/ccnx/Portfile
index 81063e8..b5b0509 100644
--- a/net/ccnx/Portfile
+++ b/net/ccnx/Portfile
@@ -12,7 +12,7 @@
 homepage                http://www.ccnx.org/
 license                 GPL-2+ LGPL-2.1+
 version                 0.6.2
-revision                0
+revision                1
 epoch                   0
 
 categories              net ccnx
@@ -57,7 +57,7 @@
     configure.env-delete   BUILD_APPS=false
 }
 
-# patchfiles              patch-macports-customizations.diff
+patchfiles              autoconfig.patch
 
 post-patch {
     reinplace   "s|\$HOME/.ccnx/|${prefix}/etc/ccnx/|g" ${worksrcpath}/csrc/util/ccndstart.sh 
@@ -106,9 +106,9 @@
 }
 
 startupitem.pidfile     none
-startupitem.start       "su ${ccnxuser} -c \"${prefix}/bin/ccndstart\""
+startupitem.start       "su ${ccnxuser} -c \"${prefix}/bin/ccndstart\" && sleep 1 && \"${prefix}/bin/ccnd-autoconfig\""
 startupitem.stop        "su ${ccnxuser} -c \"${prefix}/bin/ccndstop\""
-startupitem.restart     "su ${ccnxuser} -c \"${prefix}/bin/ccndc -f ${prefix}/etc/ccnx/ccnd.conf\""
+startupitem.restart     "su ${ccnxuser} -c \"${prefix}/bin/ccndc -f ${prefix}/etc/ccnx/ccnd.conf\" && su ${ccnxuser} -c \"${prefix}/bin/ccnd-autoconfig\""
 
 startupitem.create      yes
 startupitem.name        ${name}
diff --git a/net/ccnx/files/autoconfig.patch b/net/ccnx/files/autoconfig.patch
new file mode 100644
index 0000000..9c0d116
--- /dev/null
+++ b/net/ccnx/files/autoconfig.patch
@@ -0,0 +1,97 @@
+diff --git csrc/util/ccnd-autoconfig.sh csrc/util/ccnd-autoconfig.sh
+new file mode 100755
+index 0000000..de31ba8
+--- /dev/null
++++ csrc/util/ccnd-autoconfig.sh
+@@ -0,0 +1,34 @@
++# Source file: util/ccnd-autoconfig.sh
++# 
++# Script that tries to (automatically) discover of a local ccnd gateway
++#
++# Part of the CCNx distribution.
++#
++# Copyright (C) 2012 Palo Alto Research Center, Inc.
++#
++# This work is free software; you can redistribute it and/or modify it under
++# the terms of the GNU General Public License version 2 as published by the
++# Free Software Foundation.
++# This work is distributed in the hope that it will be useful, but WITHOUT ANY
++# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
++# FOR A PARTICULAR PURPOSE.
++
++# This script should be installed in the same place as ccnd, ccndc, ccndsmoketest, ...
++# adjust the path to get consistency.
++D=`dirname "$0"`
++export PATH="$D:$PATH"
++
++# Set temporary multicast face
++ccndc -t 10 add "/local/ndn" udp  224.0.23.170 59695 
++
++# Get info from local hub, if available
++info=`ccncat -s 2 /local/ndn/udp`
++if [ "x$info" = "x" ]; then
++   echo "Local hub is not availble, trying to use DNS to get local configuration"
++   # Try to use DNS search list to get default route information
++   ccndc srv
++   exit 1
++fi
++
++echo Setting default route to a local hub: "$info"
++echo "$info" | xargs ccndc add / udp
+diff --git csrc/util/ccnd-publish-local-info.sh csrc/util/ccnd-publish-local-info.sh
+new file mode 100755
+index 0000000..056ebde
+--- /dev/null
++++ csrc/util/ccnd-publish-local-info.sh
+@@ -0,0 +1,34 @@
++# Source file: util/ccnd-autoconfig.sh
++# 
++# Script to publish information about local ccnd gateway in local repo (should be run only on ccnd gateway nodes)
++#
++# Part of the CCNx distribution.
++#
++# Copyright (C) 2012 Palo Alto Research Center, Inc.
++#
++# This work is free software; you can redistribute it and/or modify it under
++# the terms of the GNU General Public License version 2 as published by the
++# Free Software Foundation.
++# This work is distributed in the hope that it will be useful, but WITHOUT ANY
++# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
++# FOR A PARTICULAR PURPOSE.
++
++# This script should be installed in the same place as ccnd, ccndc, ccndsmoketest, ...
++# adjust the path to get consistency.
++D=`dirname "$0"`
++export PATH="$D:$PATH"
++
++#
++
++udp_face_info=$1
++local_prefix=$2
++
++if [ "x$udp_face_info" = "x" -o "x$local_prefix" = "x" ]; then
++   echo "Usage: "
++   echo "      " $0 " <udp_face_info> <routable_prefix>"
++   exit 1
++fi
++
++echo $udp_face_info | ccnseqwriter -r -x 5 "/local/ndn/udp"
++echo $local_prefix  | ccnseqwriter -r -x 5 "/local/ndn/prefix"
++
+diff --git csrc/util/dir.mk csrc/util/dir.mk
+index f29038f..94bc7b6 100644
+--- csrc/util/dir.mk
++++ csrc/util/dir.mk
+@@ -14,8 +14,10 @@
+ 
+ SCRIPTSRC = shebang \
+ 	ccndstart.sh ccndstop.sh ccndstatus.sh ccndlogging.sh ccnget.sh ccnput.sh \
+-	ccntestloop-trampoline
+-PROGRAMS = ccndstart ccndstop ccndstatus ccntestloop ccndlogging ccnget ccnput
++	ccntestloop-trampoline \
++	ccnd-autoconfig.sh ccnd-publish-local-info.sh
++
++PROGRAMS = ccndstart ccndstop ccndstatus ccntestloop ccndlogging ccnget ccnput ccnd-autoconfig ccnd-publish-local-info
+ INSTALLED_PROGRAMS = $(PROGRAMS)
+ 
+ default all: $(SCRIPTSRC) $(PROGRAMS)