I'd like to add a series of commands to a Makefile that append config lines when they are not already present. I've done this in the past in a manner like so:
grep -vq "keyword" /a/b/c.conf && echo "abc keyword" >> /a/b/c.conf
But, I'm clearly overlooking something. The command as-is causes the config line to be duplicated when re-run.
A manual test shows the pattern works as expected:
grep -vq "keyword" /a/b/c.conf && echo "the line is absent"
... prints the line is absent only when the line is actually absent. And, the echo command is correctly not executed when the line is present.
What am I missing?
Note: The examples above are condensed for readability. In reality, there will be many similar commands. Here's the particular command I've tried:
grep -vq "md_module" /etc/httpd/conf.modules.d/00-ssl.conf && echo "LoadModule md_module modules/mod_md.so" >> /etc/httpd/conf.modules.d/00-ssl.conf