From 3bf3f74522e26cbf6741b985474266a2bdaa2d37 Mon Sep 17 00:00:00 2001
From: Erhard Rank <erank@sipwise.com>
Date: Wed, 14 Sep 2011 16:36:02 +0000
Subject: [PATCH] use profile configuration directory

get profile configuration from file(s) in directory (instead of from one file
only), assume there is a file "default.sh" which is sourced in deployment.sh
+ minimal example profile setting for my SPPRO/CE VMs
---
 deployment.sh            | 24 +++++++++++++++++-------
 profile_erank/default.sh | 27 +++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 7 deletions(-)
 create mode 100644 profile_erank/default.sh

diff --git a/deployment.sh b/deployment.sh
index 8dc128e..5e9e648 100755
--- a/deployment.sh
+++ b/deployment.sh
@@ -291,11 +291,11 @@ fi
 # load site specific profile if specified
 if [ -n "$PROFILE" ] && [ -n "$NETSCRIPT_SERVER" ] ; then
   getconfig() {
-    wget --timeout=10 --dns-timeout=10  --connect-timeout=10 --tries=1 \
-         --read-timeout=10 ${NETSCRIPT_SERVER}/$PROFILE -O ${PROFILE} && return 0 || return 1
+    wget -r --no-parent --timeout=10 --dns-timeout=10  --connect-timeout=10 --tries=1 \
+         --read-timeout=10 ${NETSCRIPT_SERVER}/$PROFILE/ && return 0 || return 1
   }
 
-  echo "Trying to get ${NETSCRIPT_SERVER}/$PROFILE"
+  echo "Trying to get ${NETSCRIPT_SERVER}/$PROFILE/*"
   counter=10
   while ! getconfig && [[ "$counter" != 0 ]] ; do
     echo -n "Sleeping for 1 second and trying to get config again... "
@@ -303,11 +303,21 @@ if [ -n "$PROFILE" ] && [ -n "$NETSCRIPT_SERVER" ] ; then
     echo "$counter tries left" ; sleep 1
   done
 
-  if [ -s "$PROFILE" ] ; then
-    echo "Loading profile $PROFILE"
-    . $PROFILE
+  DOWNLOADDIR=$(echo ${NETSCRIPT_SERVER}/$PROFILE | sed 's|^http://||')
+  echo $DOWNLOADDIR
+  if [ -d "$DOWNLOADDIR" ] ; then
+    if [ -s "$DOWNLOADDIR/default.sh" ] ; then
+      rm -f $DOWNLOADDIR/index.html*
+      mv $DOWNLOADDIR/* ./
+      rmdir -p $DOWNLOADDIR
+      echo "Loading profile $PROFILE"
+      . default.sh
+    else
+      echo "Error: No default.sh in profile $PROFILE from $NETSCRIPT_SERVER" >&2
+      exit 1
+    fi
   else
-    echo "Error: Could not get profile file $PROFILE from $NETSCRIPT_SERVER" >&2
+    echo "Error: Could not get profile $PROFILE from $NETSCRIPT_SERVER" >&2
     exit 1
   fi
 fi
diff --git a/profile_erank/default.sh b/profile_erank/default.sh
new file mode 100644
index 0000000..0a0d43b
--- /dev/null
+++ b/profile_erank/default.sh
@@ -0,0 +1,27 @@
+# example profile
+#
+# profiles contain deployment site specific configurations
+# this one is for erank's VMs
+
+
+# SP_VERSION=2.3
+# INSTALLER_VERSION=0.5.3
+
+# internal IP addresses of sp1/sp2 (on eth1)
+IP1=192.168.51.133
+IP2=192.168.51.134
+# INTERNAL_NETMASK=192.168.255.248      # TODO: has to be enabled in deployment.sh
+
+if "$PRO_EDITION" ; then
+  case "$ROLE" in
+    sp1) EADDR=77.244.249.112 ;     # external IP address of sp1
+    	 EIFACE=eth0 ;;             # on interface ...
+    sp2) EADDR=77.244.249.113 ;     # external IP address of sp2
+    	 EIFACE=eth0 ;;             # on interface ...
+  esac
+  MCASTADDR=226.94.1.1 ;            # multicast address
+else
+  EADDR=77.244.249.109 ;            # external IP address of ce server
+  EIFACE=eth0 ;                     # on interface ...
+fi
+