[
https://issues.apache.org/jira/browse/CLOUDSTACK-2053?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13682851#comment-13682851
]
ASF subversion and git services commented on CLOUDSTACK-2053:
-------------------------------------------------------------
Commit 4612656de86a4a0258852c3fb89724bda6b612b3 in branch refs/heads/4.1 from
[~serverchief]
[ https://git-wip-us.apache.org/repos/asf?p=cloudstack.git;h=4612656 ]
CLOUDSTACK-2053: Fixed userdata.sh redundancy and cloud-init support
> [BUG] userdata.sh on router VM fixes for if else logic and missing meta-data
> ----------------------------------------------------------------------------
>
> Key: CLOUDSTACK-2053
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-2053
> Project: CloudStack
> Issue Type: Bug
> Security Level: Public(Anyone can view this level - this is the
> default.)
> Components: Network Controller
> Affects Versions: 4.0.0, 4.1.0, 4.2.0
> Environment: VSphere 5.0 and ACS 4.1
> Reporter: ilya musayev
> Assignee: ilya musayev
> Labels: ROUTERVM
> Fix For: 4.2.0
>
>
> Logic in userdata.sh for bash if / else is not optimal and is based on exit
> codes VS using native "if grep" support. Current logic is causing multiple
> redundant entries in .htaccess files.
> Moreover, we are missing the meta-data rewrite rule in .htaccess file for
> cloud-init/boto component to configure the vm.
> Details:
> Instead of doing:
> grep -F `echo $entry` $htaccessFile
>
> if [ $? -gt 0 ]; then
> echo -e $entry >> $htaccessFile;
> 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=$?
> fi
> We should do:
> if ! grep -Fq "$entry" $htaccessFile
> then
> echo -e $entry >> $htaccessFile;
> result=$?
> else
> 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 "echo -e $entry \> $htaccessFile"
> echo -e $entry > $htaccessFile
> result=$?
> fi
> I'm still keeping the "result=$?", because the logic is based on exit codes -
> in other places, however, it is unnecessary.
> Also, we are missing Rewrite rule in .htaccess file:
> RewriteRule ^meta-data/$ ../metadata/%{REMOTE_ADDR}/meta-data [L,NC,QSA]
> RewriteRule ^meta-data/(.*)$ ../metadata/%{REMOTE_ADDR}/$1 [L,NC,QSA]
> As boto is looking for meta-data under /var/www/html/latest, but cant find it
> and fails to proceed.
> I will add a function to check if entry exists, and if not, append.
> Overall, this fix will keep the .htaccess file much cleaner with only 1 entry
> per file and dir.
> Regards
> ilya
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira