#!/usr/bin/perl -w ############################################################################### # cleanhttpdconf.txt - # A script to remove the "Added by cpanel" lines from httpd.conf # Version 0.1 beta (first public release) - 16/MAR/2003 # (c) 2003 Juan R. Pozo # http://html.conclase.net/cp/scripts/ # mailto:jrpozo@conclase.net ############################################################################### # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free # Software Foundation; either version 2 of the License, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################### # Save it somewhere in your server as cleanhttpdconf.pl # (e.g. /root/cleanhttpdconf.pl) chown root.root, chmod 0700 and # add it to your crontab ############################################################################### # Please consider making a donation today. Visit my amazon.com wishlist at: # http://html.conclase.net/link/wishlist # Thank you :) ############################################################################### use strict; if (-r "/usr/local/cpanel/version") { my $version = `cat /usr/local/cpanel/version`; chomp($version); `cp -f /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.preclean`; open(IN, "/usr/local/apache/conf/httpd.conf.tmpclean") or die("Cannot open httpd.tmpclean"); while () { print OUT if not (/^#\s*Added by cpanel/ && !/$version/); } close OUT; close IN; `cp -f /usr/local/apache/conf/httpd.conf.tmpclean /usr/local/apache/conf/httpd.conf`; `rm -f /usr/local/apache/conf/httpd.conf.tmpclean`; } else { print "Error: couldn't find cpanel version file\n"; }