[PLUG] replacing lines in a httpd.conf file

Russell Evans revans at e-z.net
Sun Nov 17 02:26:42 UTC 2002


I thought you had your patterns matching what you wanted, sorry. I believe the
' in 'https' is the issue. Replace the ' with .   .htps.

/$proto = .https.;/a\

Thank you
Russell


On Sat, 16 Nov 2002 12:12:35 -0800, Richard Kurth said:

> Hello Russell,
>  I fix the error I just needed to \ in front of any / in that part of
>  the script.
>  But I still can't get the part working that has 'httpd' and 'http'  in
>  it. It just goes buy it like it could not find the lines that it is
>  looking for.
>  ' -e '/$proto = 'https';/a\
>      $portnumber = '5001';
>  ' -e '/$proto = 'http';/a\
>     $portnumber = '5000';
>  
>     
>  
>  Saturday, November 16, 2002, 10:43:18 AM, you wrote:
>  
>  
>  RE> You can use the option -e multiple times in one call of sed. I didn't see in
>  RE> your pattern matches where the following pattern relied on the proceeding
>  RE> pattern being in the file, so I believe you can combine them into one call. I
>  RE> might have missed something though. 
>  
>  RE> #!/bin/sh
>  
>  RE> ORGINAL=/tmp/TESTSCRIPT/httpd.conf 
>  RE> KOPY=/tmp/TESTSCRIPT/httpd.conf.autocontrol
>  RE> OUTPUT=/tmp/TESTSCRIPT/httpd.conf.new
>  
>  RE> cp $ORGINAL $KOPY
>  
>  RE> sed -e '/my (@ssl_conf,$ip,$group,$rewrite_rules,$proto,$ret);/a\
>  RE> my ($portnumber);
>  RE> ' -e '/$proto = 'https';/a\
>  RE>     $portnumber = '5001';
>  RE> ' -e '/$proto = 'http';/a\
>  RE>    $portnumber = '5000';
>  RE> ' -e '/RewriteRule .*cgi-bin\/.cobalt.* proto:\/\/servername:81.*/a\
>  RE> ### Begin - Autocontrol ###\
>  RE> RewriteCond %{HTTP_HOST}                ^([^:]+)\
>  RE> RewriteRule ^/acp/?$                    
>  RE> proto://servername:portnumber/autocontrol/index.php\
>  RE> RewriteCond %{HTTP_HOST}               ^([^:]+)\
>  RE> RewriteRule ^/ucp/?$                    
>  RE> proto://servername:portnumber/user/index.php\
>  RE> RewriteCond %{HTTP_HOST}                ^([^:]+)\
>  RE> RewriteRule ^/rcp/?$                    
>  RE> proto://servername:portnumber/resellerpanel/index.php\
>  RE> ### End - Autocontrol ###\
>  RE> ' -e '/$rewrite_rules =~ s/proto/$proto/g;/a\
>  RE> $rewrite_rules =~ s/portnumber/$portnumber/g;
>  RE> ' < $ORGINAL > $OUTPUT
>  
>  RE> mv $OUTPUT $ORGINAL
>  
>  RE> exit 0
>  
>  RE> Thank you
>  RE> Russell
>  
>  
>  
>  RE> On Sat, 16 Nov 2002 00:29:54 -0800, Richard Kurth said:
>  
>  >> 
>  >>  I need to replace a series of lines in a httpd.conf file on the fly.
>  >>  So it needs to be done in a bash file. I have been trying a bunch of
>  >>  different ways mostly with sed. It seams there would be a cleaner way
>  >>  to do it. Below is what I have so far. There are five different
>  >>  sections that have to be changed or have lines added to them.
>  >>  Is there a better way of doing this?
>  >>  
>  >>  
>  >>  cp /tmp/TESTSCRIPT/httpd.conf /tmp/TESTSCRIPT/httpd.conf.autocontrol
>  >>  
>  >>  sed -e '/my (@ssl_conf,$ip,$group,$rewrite_rules,$proto,$ret);/a\
>  >>  my ($portnumber);
>  >>  '  < /tmp/TESTSCRIPT/httpd.conf > /tmp/TESTSCRIPT/.httpd.new
>  >>  cp /tmp/TESTSCRIPT/.httpd.new /tmp/TESTSCRIPT/httpd.conf
>  >>  rm /tmp/TESTSCRIPT/.httpd.new
>  >>  
>  >>  
>  >>  sed -e '/$proto = 'https';/a\
>  >>      $portnumber = '5001';
>  >>  '  < /tmp/TESTSCRIPT/httpd.conf > /tmp/TESTSCRIPT/.httpd.new
>  >>  cp /tmp/TESTSCRIPT/.httpd.new /tmp/TESTSCRIPT/httpd.conf
>  >>  rm /tmp/TESTSCRIPT/.httpd.new
>  >>  
>  >>          
>  >>  sed -e '/$proto = 'http';/a\
>  >>     $portnumber = '5000';
>  >>  '  < /tmp/TESTSCRIPT/httpd.conf > /tmp/TESTSCRIPT/.httpd.new
>  >>  cp /tmp/TESTSCRIPT/.httpd.new /tmp/TESTSCRIPT/httpd.conf
>  >>  rm /tmp/TESTSCRIPT/.httpd.new 
>  >>  
>  >>  
>  >>  sed -e '/RewriteRule .*cgi-bin\/.cobalt.* proto:\/\/servername:81.*/a\
>  >>  ### Begin - Autocontrol ###\
>  >>  RewriteCond %{HTTP_HOST}                ^([^:]+)\
>  >>  RewriteRule ^/acp/?$                     proto://servername:portnumber/autocontrol/index.php\
>  >>  RewriteCond %{HTTP_HOST}               ^([^:]+)\
>  >>  RewriteRule ^/ucp/?$                     proto://servername:portnumber/user/index.php\
>  >>  RewriteCond %{HTTP_HOST}                ^([^:]+)\
>  >>  RewriteRule ^/rcp/?$                     proto://servername:portnumber/resellerpanel/index.php\
>  >>  ### End - Autocontrol ###\
>  >>  '  < /tmp/TESTSCRIPT/httpd.conf > /tmp/TESTSCRIPT/.httpd.new
>  >>  cp /tmp/TESTSCRIPT/.httpd.new /tmp/TESTSCRIPT/httpd.conf
>  >>  rm /tmp/TESTSCRIPT/.httpd.new
>  >>  
>  >>  
>  >>  sed -e '/$rewrite_rules =~ s/proto/$proto/g;/a\
>  >>  $rewrite_rules =~ s/portnumber/$portnumber/g;
>  >>  '  < /tmp/TESTSCRIPT/httpd.conf > /tmp/TESTSCRIPT/.httpd.new
>  >>  cp /tmp/TESTSCRIPT/.httpd.new /tmp/TESTSCRIPT/httpd.conf
>  >>  rm /tmp/TESTSCRIPT/.httpd.new
>  >>  
>  >>  
>  >>  
>  >>    
>  >>  
>  
>  
>  RE> _______________________________________________
>  RE> PLUG mailing list
>  RE> PLUG at lists.pdxlinux.org
>  RE> http://lists.pdxlinux.org/mailman/listinfo/plug
>  
>  
>  





More information about the PLUG mailing list