Skip to content

Instantly share code, notes, and snippets.

@darconeous
Created September 2, 2015 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darconeous/494906fa4acb117f9313 to your computer and use it in GitHub Desktop.
Save darconeous/494906fa4acb117f9313 to your computer and use it in GitHub Desktop.
removing a section from a configuration file using bash
AMAVIS_CONFIG_HEADER="# Amavis - dockermail - start"
AMAVIS_CONFIG_FOOTER="# Amavis - dockermail - end"
function remove_amavis () {
# main.cf
if grep -q "$AMAVIS_CONFIG_HEADER" "$POSTFIX_MAIN_CF"; then
sed "/$AMAVIS_CONFIG_HEADER/,/$AMAVIS_CONFIG_FOOTER/d" "$POSTFIX_MAIN_CF" -i
fi
# master.cf
sed '/^pickup/,/^cleanup/{//!d}' "$POSTFIX_MASTER_CF" -i
sed "/$AMAVIS_CONFIG_HEADER/,/$AMAVIS_CONFIG_FOOTER/d" "$POSTFIX_MASTER_CF" -i
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment