View Single Post
  #1   (View Single Post)  
Old 18th May 2021
J65nko J65nko is offline
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 3,992
Default Automating the "vi /etc/httpd.conf", httpd -n, rcctl restart httpd" treadmill

According to Larry Wall, one of the virtues of a programmer is lazyness.
I think this also applies to a website administrator. So to avoid repetitive typing while editing, checking httpd.conf(5) and restarting the webserver I wrote the following simple script:



while true ; do 
   vi "/etc/${DAEMON}.conf"
   ${DAEMON} -n && rcctl restart ${DAEMON}
   printf "Press <CNTRL-C to stop, any other key to re-edit /etc/${DAEMON}.conf : " ; read A
In action:
/etc/httpd.conf:33: syntax error
/etc/httpd.conf:37: syntax error
Press <CNTRL-C to stop, any other key to re-edit /etc/httpd.conf : 
configuration OK
Press <CNTRL-C to stop, any other key to re-edit /etc/httpd.conf : ^C
By changing DAEMON=relayd and renaming to you can also use it for relayd(8)

The script could be extended or generalized to edit other configuration files, but you already guessed it: I am too lazy for that
Attached Files
File Type: sh (212 Bytes, 46 views)
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump

Last edited by J65nko; 21st May 2021 at 05:19 AM.
Reply With Quote