View Single Post
  #1   (View Single Post)  
Old 18th May 2021
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,132
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:

Code:
 #!/bin/sh

DAEMON=httpd

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
done
In action:
Code:
root@nedrag[~]./ehttpd.sh   
/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
httpd(ok)
httpd(ok)
Press <CNTRL-C to stop, any other key to re-edit /etc/httpd.conf : ^C
root@nedrag[~]
By changing DAEMON=relayd and renaming to erelayd.sh 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 ehttpd.sh (212 Bytes, 52 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