escape special characters used in sed

This commit is contained in:
Wenkai Yin 2016-12-02 17:31:52 +08:00
parent f4e0d3c774
commit 01dc77b606
2 changed files with 9 additions and 13 deletions

View File

@ -92,7 +92,8 @@ function configureHarborCfg {
if [ -n "$cfg_key" ]
then
sed -i -r s%"#?$cfg_key\s*=\s*.*"%"$cfg_key = $cfg_value"% $cfg_file
cfg_value=$(echo "$cfg_value" | sed -r -e 's%[\/&%]%\\&%g')
sed -i -r "s%#?$cfg_key\s*=\s*.*%$cfg_key = $cfg_value%" $cfg_file
fi
}

View File

@ -184,16 +184,11 @@ do
echo "Read attribute using ovfenv: [ $attr ]"
value=$(ovfenv -k $attr)
#ldap search password and email password can be null
if [ -n "$value" ] || [ "$attr" = "ldap_search_pwd" ] \
|| [ "$attr" = "email_password" ]
then
#if [ "$attr" = ldap_search_pwd ] \
# || [ "$attr" = email_password ]
#then
# bs=$(echo $value | base64)
# value={base64}$bs
#fi
configureHarborCfg $attr $value
fi
#if [ "$attr" = ldap_search_pwd ] \
# || [ "$attr" = email_password ]
#then
# bs=$(echo $value | base64)
# value={base64}$bs
#fi
configureHarborCfg "$attr" "$value"
done