You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by il...@apache.org on 2013/07/19 17:18:46 UTC

git commit: updated refs/heads/4.0 to 8f4b9bc

Updated Branches:
  refs/heads/4.0 a5723992a -> 8f4b9bccf


CLOUDSTACK-2053: Fixed userdata.sh redundancy and cloud-init support


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/8f4b9bcc
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/8f4b9bcc
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/8f4b9bcc

Branch: refs/heads/4.0
Commit: 8f4b9bccfed63a37762907bdd058506f4e7b6e6d
Parents: a572399
Author: ilya musayev <il...@cloudsand.com>
Authored: Fri Jul 19 11:18:23 2013 -0400
Committer: ilya musayev <il...@cloudsand.com>
Committed: Fri Jul 19 11:18:23 2013 -0400

----------------------------------------------------------------------
 patches/systemvm/debian/config/root/userdata.sh | 55 +++++++++++++-------
 1 file changed, 36 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f4b9bcc/patches/systemvm/debian/config/root/userdata.sh
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/root/userdata.sh b/patches/systemvm/debian/config/root/userdata.sh
index e5d170b..85e36ba 100644
--- a/patches/systemvm/debian/config/root/userdata.sh
+++ b/patches/systemvm/debian/config/root/userdata.sh
@@ -40,34 +40,51 @@ create_htaccess() {
   local vmIp=$1
   local folder=$2
   local file=$3
-  
+
   local result=0
-  
+
   entry="RewriteRule ^$file$ ../$folder/%{REMOTE_ADDR}/$file [L,NC,QSA]"
   htaccessFolder="/var/www/html/latest"
   htaccessFile=$htaccessFolder/.htaccess
   mkdir -p $htaccessFolder
   touch $htaccessFile
-  
-  #grep -w $file $htaccessFile
-  grep -F `echo $entry` $htaccessFile
-  
-  if [ $? -gt 0 ]; then 
-    echo -e $entry >> $htaccessFile; 
+
+# Fixed the issue with checking if record exists, rewrote the else/if logic, reference issue CLOUDSTACK-2053
+
+  if ! grep -Fq "$entry" $htaccessFile
+        then
+                echo -e $entry >> $htaccessFile;
+                result=$?
   fi
-  result=$?
-  
-  if [ $result -eq 0 ]; then
-    entry="Options -Indexes\\nOrder Deny,Allow\\nDeny from all\\nAllow from $vmIp"
-    htaccessFolder="/var/www/html/$folder/$vmIp"
-    htaccessFile=$htaccessFolder/.htaccess
-    
-    mkdir -p $htaccessFolder
-    echo -e $entry > $htaccessFile
-    result=$?
+
+  entry="Options -Indexes\\nOrder Deny,Allow\\nDeny from all\\nAllow from $vmIp"
+  testentry="Allow from $vmIp"
+  htaccessFolder="/var/www/html/$folder/$vmIp"
+  htaccessFile=$htaccessFolder/.htaccess
+  if ! grep -Fq "$testentry" $htaccessFile
+        then
+                mkdir -p $htaccessFolder
+                echo -e $entry > $htaccessFile
+                result=$?
+  fi
+
+
+# Please reference issue CLOUDSTACK-2053, added to fix boto/cloud-init integration
+
+  htaccessFileNoIP="/var/www/html/latest/.htaccess"
+  metadataentry1='RewriteRule ^meta-data/$ ../metadata/%{REMOTE_ADDR}/meta-data [L,NC,QSA]'
+  metadataentry2='RewriteRule ^meta-data/(.*)$ ../metadata/%{REMOTE_ADDR}/$1 [L,NC,QSA]'
+  if ! grep -Fq "$metadataentry1" $htaccessFileNoIP
+        then
+                echo -e "$metadataentry1" >> $htaccessFileNoIP;
+  fi
+
+  if ! grep -Fq "$metadataentry2" $htaccessFileNoIP
+        then
+                echo -e "$metadataentry2" >> $htaccessFileNoIP;
   fi
 
-  return $result  
+  return $result
 }
 
 copy_vm_data_file() {