Skip to content

Instantly share code, notes, and snippets.

@bmoussaud
Created August 29, 2012 13:12
Show Gist options
  • Save bmoussaud/3512269 to your computer and use it in GitHub Desktop.
Save bmoussaud/3512269 to your computer and use it in GitHub Desktop.
Deployit: Patch an existing file during a deployment
echo "patching ${deployed.configurationFile}"
touch snippet.conf
echo "${deployed.comment} ${deployed.beginMarkup}" >> snippet.conf
echo "aValue ${deployed.avalue}" >> snippet.conf
echo "anotherValue ${deployed.anotherValue}" >> snippet.conf
echo "${deployed.comment} ${deployed.endMarkup}" >> snippet.conf
cat snippet.conf
cat snippet.conf >> ${deployed.configurationFile}
<type type="filex.PatchedFile" extends="generic.ExecutedScript"
deployable-type="filex.Resource" container-type="overthere.Host">
<generate-deployable type="filex.Resource" extends="generic.Resource"/>
<property name="avalue" />
<property name="anotherValue" />
<property name="home" default="/tmp"/>
<property name="configurationFile" default="${deployed.home}/config.conf"/>
<property name="comment" hidden="true" default="#"/>
<property name="beginMarkup" hidden="true" default="patched by deployit"/>
<property name="endMarkup" hidden="true" default="/patched by deployit"/>
<property name="createScript" hidden="true" default="filex/patch"/>
<property name="destroyScript" hidden="true" default="filex/unpatch"/>
</type>
echo "unpatching ${deployed.configurationFile}"
sed --in-place '/${deployed.comment} ${deployed.beginMarkup}/,/${deployed.comment} \${deployed.endMarkup}/d' ${deployed.configurationFile}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment