Created
September 2, 2015 19:45
-
-
Save darconeous/494906fa4acb117f9313 to your computer and use it in GitHub Desktop.
removing a section from a configuration file using bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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