Updated Branches: refs/heads/4.1 5d8c59ca2 -> 4612656de
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/4612656d Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4612656d Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4612656d Branch: refs/heads/4.1 Commit: 4612656de86a4a0258852c3fb89724bda6b612b3 Parents: 5d8c59c Author: ilya musayev <i...@apache.org> Authored: Thu Jun 13 18:38:32 2013 -0400 Committer: ilya musayev <i...@apache.org> Committed: Thu Jun 13 18:38:32 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/4612656d/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() {