summaryrefslogtreecommitdiffstats
path: root/proxy_wizard/scripts/Squidconf.pm
diff options
context:
space:
mode:
Diffstat (limited to 'proxy_wizard/scripts/Squidconf.pm')
-rw-r--r--proxy_wizard/scripts/Squidconf.pm121
1 files changed, 0 insertions, 121 deletions
diff --git a/proxy_wizard/scripts/Squidconf.pm b/proxy_wizard/scripts/Squidconf.pm
deleted file mode 100644
index 56548652..00000000
--- a/proxy_wizard/scripts/Squidconf.pm
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/usr/bin/perl
-
-# Drakwizard
-
-# Copyright (C) 2002 MandrakeSoft Arnaud Desmons (adesmons@mandrakesoft.com)
-#
-# 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, 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.
-
-
-package Squidconf;
-use lib '/usr/lib/libDrakX';
-require "__WIZ_HOME__/common/scripts/Vareqval.pm";
-require "__WIZ_HOME__/common/scripts/Varspaceval.pm";
-require "__WIZ_HOME__/common/scripts/IFCFG.pm";
-use MDK::Common;
-use services;
-use strict;
-use standalone;
-
-sub network_mask {
- my $o = IFCFG->new();
- my $wiz_ip_server = $o->itf_get("IPADDR");
- my $mask = $o->itf_get("NETMASK");
- "$1.$2.$3.0/$mask" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
-}
-
-sub testport {
- if ($ENV{wiz_squid_port} == 3128 || $ENV{wiz_squid_port} == 8080) {
- return 0;
- }
- elsif ($ENV{wiz_squid_port} <= 1024 || $ENV{wiz_squid_port} >= 65536) {
- return 2;
- }
- 1;
-}
-
-sub port {
- my $ret;
- my @lines = grep(/$ENV{wiz_squid_port}\/tcp/, cat_("/etc/services"));
- foreach (@lines) {
- s/\t/ /g;
- $ret .= "\n$_";
- }
- $ret;
-}
-
-sub do_it_squid {
- my $file="/etc/squid/squid.conf";
- -f $file and MDK::Common::cp_af($file, $file.".orig");
- MDK::Common::cp_af("__WIZ_HOME__/proxy_wizard/scripts/squid.conf.default", $file);
- substInFile {
- s|^\s*\#?\s*(cache_dir.*$ENV{wiz_squid_defdir}\s*)\d*(.*)|$1$ENV{wiz_squid_disk}$2|;
- s|^\s*\#?\s*(acl\s*mynetwork\s*src\s*).*$|$1$ENV{wiz_squid_mynetw}\n|;
- s|^\s*\#?\s*(cache_mem\s*)\d*(\s*MB.*)|$1$ENV{wiz_squid_mem}$2|;
- s|^\s*\#?\s*(http_port\s*)\d*(.*)|$1$ENV{wiz_squid_port}$2|;
- } $file;
- print "LEVEL $ENV{'wiz_squid_level'}\n\n";
- exit;
- standalone::explanations("$file: cache_dir = $ENV{wiz_squid_defdir} $ENV{wiz_squid_disk}
-mynetw = $ENV{wiz_squid_mynetw} cache_mem = $ENV{wiz_squid_mem} http_port = $ENV{wiz_squid_port}
-level = $ENV{wiz_squid_level}");
- if ($ENV{wiz_squid_level} == 1) {
- substInFile {
- s|^\s*\#?\s*(http_access\s*)deny(\s*all.*)|\#$&\n$1allow$2|;
- } $file;
- }
- elsif ($ENV{wiz_squid_level} == 2) {
- substInFile {
- s|^\s*\#?\s*(http_access\s*)allow(\s*all.*)|\#$&\n$1deny$2|;
- s|^\s*\#?\s*(http_access\s*allow\s*)localhost|\#$&\n$1mynetwork|;
- } $file;
- }
- elsif ($ENV{wiz_squid_level} == 3) {
- substInFile {
- s|^\s*\#?\s*(http_access\s*)allow(\s*all.*)|\#$&\n$1deny$2|;
- s|^\s*\#?\s*(http_access\s*allow\s*)mynetwork|\#$&\n$1localhost|;
- } $file;
- } else { # should not happen
- die "wiz_squid_level error";
- }
- my $t = 0;
- foreach (cat_($file)) {
- if (/^\s*cache_peer.*/) {
- $t = $_;;
- last;
- }
- }
- if ($ENV{wiz_squid_menupeer} == 1 && length $t) {
- substInFile {
- s|^\s*!\#\s*(cache_peer.*)|\#$&|;
- } $file;
- }
- elsif ($ENV{wiz_squid_menupeer} == 2 && length $ENV{wiz_squid_cachepeer}) {
- if (lenght $t) {
- substInFile {
- s|^\s*\#?\s*(cache_peer.*)|\#$&|;
- } $file;
- }
- append_to_file($file, "cache_peer $ENV{wiz_squid_cachepeer} parent $ENV{wiz_squid_peerport} 3130");
- }
- system("/sbin/chkconfig --level 345 squid on");
- if (services::is_service_running('squid')) {
- services::restart('squid')
- } else {
- services::start('squid')
- }
- 10;
-}
-1;