Skip to content

Instantly share code, notes, and snippets.

@Alexhha
Last active April 18, 2017 14:29
Show Gist options
  • Save Alexhha/abff3eb967241e03ad36a84ba48029f8 to your computer and use it in GitHub Desktop.
Save Alexhha/abff3eb967241e03ad36a84ba48029f8 to your computer and use it in GitHub Desktop.
if [[ "A" == "A" ]]; then
sed -r "s/^(#)?labels=.*/labels=PROJECT:Venice;SERVER-STACK:${APP_NAME}-${ENV};\
EC2-TYPE:${INSTANCE_TYPE};VPC:${VPC_ID}/" newrelic.cfg | grep labels
fi
if [[ "A" == "A" ]]; then
sed -r "s/^(#)?labels=.*/labels=PROJECT:Venice;SERVER-STACK:${APP_NAME}-${ENV};\
EC2-TYPE:${INSTANCE_TYPE};VPC:${VPC_ID}/" newrelic.cfg | grep labels
fi
SED_REPLACE_EXPR="labels=PROJECT:Venice;SERVER-STACK:${APP_NAME}-${ENV};EC2-TYPE:${INSTANCE_TYPE};VPC:${VPC_ID}"
SED_MATCH_EXPR='s/^(#)?labels=.*'
if [[ "A" == "A" ]]; then
sed -r "${SED_MATCH_EXPR}/${SED_REPLACE_EXPR}/" newrelic.cfg
fi
SED_REPLACE_EXPR="s/^(#)?labels=.*/labels=PROJECT:Venice;\
SERVER-STACK:${APP_NAME}-${ENV};\
EC2-TYPE:${INSTANCE_TYPE};VPC:${VPC_ID}"
sed -r "${SED_REPLACE_EXPR//[$'\t\r\n ']}/" newrelic.cfg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment