From 306951e28791b261f894a8b71255b4c45d105661 Mon Sep 17 00:00:00 2001 From: Florent Villard Date: Mon, 20 Oct 2003 10:51:59 +0000 Subject: change copyright remove old xml related files --- dhcp_wizard/Dhcp.pm | 11 +- dhcp_wizard/dhcp.wiz | 324 -------------------------------------- dhcp_wizard/scripts/Dhcpconf.pm | 158 ------------------- dhcp_wizard/scripts/do_it_dhcp.sh | 124 --------------- 4 files changed, 7 insertions(+), 610 deletions(-) delete mode 100644 dhcp_wizard/dhcp.wiz delete mode 100644 dhcp_wizard/scripts/Dhcpconf.pm delete mode 100755 dhcp_wizard/scripts/do_it_dhcp.sh (limited to 'dhcp_wizard') diff --git a/dhcp_wizard/Dhcp.pm b/dhcp_wizard/Dhcp.pm index b38ba025..3bb73ef1 100755 --- a/dhcp_wizard/Dhcp.pm +++ b/dhcp_wizard/Dhcp.pm @@ -2,8 +2,10 @@ # Drakwizard -# Copyright (C) 2002 Arnaud Desmons -# 2003 Florent Villard +# Copyright (C) 2002, 2003 Mandrakesoft +# +# Authors: Arnaud Desmons +# Florent Villard # # 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 @@ -37,7 +39,8 @@ my $o = { var => { ip1 => '', ip2 => '', - interface => $wiz->{net}->default_itf() + wiz_authoritative => 0, + einterface => $wiz->{net}->default_itf() }, needed_rpm => [ 'dhcp-server' ], defaultimage => "$ENV{__WIZ_HOME__}dhcp_wizard/images/DHCP.png" @@ -217,7 +220,7 @@ mask = $wiz_ip_netmask, rng1 = $wiz_ip_range1, rng2 = $wiz_ip_range2, dname = $w $mdk{interfaces} = $wiz_device; standalone::explanations("$file: lease_file = $mdk{lease_file}, interfaces = $mdk{interfaces}"); MDK::Wizard::Varspaceval->commit($file, \%mdk); - !$ENV{wiz_authoritative} and output($file, map { + !$o-{var}{wiz_authoritative} and output($file, map { s|^\s*not\s*authoritative.*|\#$&|i; $_ } cat_ ("/etc/dhcpd.conf")); diff --git a/dhcp_wizard/dhcp.wiz b/dhcp_wizard/dhcp.wiz deleted file mode 100644 index 93164559..00000000 --- a/dhcp_wizard/dhcp.wiz +++ /dev/null @@ -1,324 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dhcp_wizard/scripts/Dhcpconf.pm b/dhcp_wizard/scripts/Dhcpconf.pm deleted file mode 100644 index e75cd855..00000000 --- a/dhcp_wizard/scripts/Dhcpconf.pm +++ /dev/null @@ -1,158 +0,0 @@ -#!/usr/bin/perl - -# DHCP Conf Parser - -# Copyright (C) 2002 MandrakeSoft Arnaud Desmons -# -# 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 Dhcpconf; -require "__WIZ_HOME__/common/scripts/IFCFG.pm"; -#require "__WIZ_HOME__/common/scripts/DrakconnectConf.pm"; -use MDK::Common; -use strict; -use standalone; - -my $o = IFCFG->new(); -my $wiz_ip_server = $o->itf_get("IPADDR"); -my $d = "$4" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; -my $s = "$1.$2.$3" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; - -sub compute_range { - my $n; - if ($d <= 64) { $n = "65" } - elsif ($d <= 128) { $n = "129" } - else { $n = "1"} - "$s.$n"; -} - -sub compute_range2 { - my $n; - if ($d <= 128) { $n = "254" } - elsif ($d > 192) { $n = "192" } - else { $n = "128"} - "$s.$n"; -} - -sub check { -# FIXME : see check_range.sh - my $r1_trunc = "$1.$2.$3" if $o->{var}{ip1} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; - my $r2_trunc = "$1.$2.$3" if $o->{var}{ip2} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; - my $d1 = "$4" if $ENV{wiz_ip_range1} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; - my $d2 = "$4" if $ENV{wiz_ip_range2} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; - my $s_trunc = "$1.$2.$3" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; - my $ds = "$4" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; - if (!$r1_trunc) { standalone::explanations("DHCP wizard : incorrect adress range 1"); return 1} - if (!$r2_trunc) { standalone::explanations("DHCP wizard : incorrect adress range 2"); return 1} - if ($r1_trunc ne $s_trunc || $r2_trunc ne $s_trunc) { - standalone::explanations("DHCP wizard : range not in network"); - return 2; - } - if (!$d1 || !$d2 || $d1 > $d2) { standalone::explanations("DHCP wizard : bad range"); return 1} - if ($ds >= $d1 && $ds <= $d2) { standalone::explanations("DHCP wizard : server in range"); return 3} - 10; -} - -sub check_dhcp { - $o->is_dhcp() and return 1; - 0; -} - -sub do_it { - my $wiz_domain_name = $o->network_get("DOMAINNAME"); - my $wiz_host_name = $o->network_get("HOSTNAME"); - my $wiz_gateway = $o->network_get("GATEWAY"); - my $wiz_dns = $o->network_get("dnsServer"); - if ($wiz_dns eq '127.0.0.1') { - $wiz_dns = $wiz_ip_server - } - if (!$wiz_gateway) { - my $t = `LC_ALL=C /sbin/ip route list scope global`; - ($wiz_gateway) = $t =~ /default via (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) dev/; - } - my $wiz_ip_net = "$1.$2.$3.0" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; - my $err = check(); - return $err if $err != 10; - my $wiz_ip_range1 = $ENV{wiz_ip_range1}; - my $wiz_ip_range2 = $ENV{wiz_ip_range2}; - my $wiz_ip_netmask = $o->itf_get("NETMASK"); - my $wiz_device = $o->default_itf(); -# patch to rewrite when got new file about dhcp with INTERFACES value -# currently, I put the device to configure as dhcp server -# in /etc/sysconfig/dhcpd - -#[ -f /etc/sysconfig/dhcpd ] && cp -f /etc/sysconfig/dhcpd /var/tmp/wiz_bck/orig/dhcpd - my $file = "/etc/sysconfig/dhcpd"; - -f $file and MDK::Common::cp_af($file, $file.".orig"); - - $file = "/etc/rc.d/init.d/dhcpd"; -# now patching etc/rc.d/init.d/dhcpd - standalone::explanations("now patching etc/rc.d/init.d/dhcpd"); - if (!`grep INTERFACES $file`){ - MDK::Common::append_to_file($file, "\nINTERFACES=$wiz_device"); - MDK::Common::cp_af($file, $file . ".orig"); - my $tmp = `/bin/mktemp /tmp/Dhcpconf.XXXXXX` or die "can't make a temp file: $!"; - open(NEW, "> $tmp") or die "can't open $tmp: $!"; - open(OLD, "< $file") or die "can't open default: $!"; - while () { - if (m|daemon\s*/usr/sbin/dhcp|) { - print NEW "\tif [ -f /etc/sysconfig/dhcpd ]; then -\t\t. /etc/sysconfig/dhcpd -\t\tDEV=\$INTERFACES -\tfi\n"; - } - print NEW $_; - } - close(OLD); - close(NEW); - chomp($tmp); - system("mv $tmp $file"); - } - $file = "/etc/dhcpd.conf"; - -f $file and MDK::Common::cp_af($file, $file.".orig"); - output($file, map { - s|__hname__|$wiz_host_name|g; - s|__dns__|$wiz_dns|g; - s|__net__|$wiz_ip_net|g; - s|__ip__|$wiz_ip_server|g; - s|__mask__|$wiz_ip_netmask|g; - s|__rng1__|$wiz_ip_range1|g; - s|__rng2__|$wiz_ip_range2|g; - s|__dname__|$wiz_domain_name|g; - s|__gateway__|$wiz_gateway|g; - $_; - } cat_ ("__WIZ_HOME__/dhcp_wizard/scripts/dhcpd.conf.default")); - standalone::explanations("$file: hname = $wiz_host_name, net = $wiz_ip_net, ip = $wiz_ip_server, -mask = $wiz_ip_netmask, rng1 = $wiz_ip_range1, rng2 = $wiz_ip_range2, dname = $wiz_domain_name"); - MDK::Common::touch("/var/dhcpd/dhcpd.leases"); -# modifying webmin config - $file="/etc/webmin/dhcpd/config"; - if (-f $file) { - my %mdk = Vareqval->get($file); - $mdk{lease_file} = "/var/dhcpd/dhcpd.leases"; - $mdk{interfaces} = $wiz_device; - standalone::explanations("$file: lease_file = $mdk{lease_file}, interfaces = $mdk{interfaces}"); - Vareqval->commit($file, \%mdk); - !$ENV{wiz_authoritative} and output($file, map { - s|^\s*not\s*authoritative.*|\#$&|i; - $_ - } cat_ ("/etc/dhcpd.conf")); - } - - system("/etc/rc.d/init.d/dhcpd restart"); - 10; -} -1; - diff --git a/dhcp_wizard/scripts/do_it_dhcp.sh b/dhcp_wizard/scripts/do_it_dhcp.sh deleted file mode 100755 index 5141b8c0..00000000 --- a/dhcp_wizard/scripts/do_it_dhcp.sh +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/bash -# -# Wizard -# -# Copyright (C) 2000 Mandrakesoft. -# -# 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. -# See file LICENSE for further informations on licensing terms. -# -# 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. -# -# Authors: Jerome Dumonteil, Maurizio De Cecco, Enzo Maggi -# icons: Helene Durosini -# http://www.mandrakesoft.com - -# script for wizard network configuration -# -# install default dhcpd configuration for dhcp server -# assuming all dependencies are ok - -echo_debug "in $0" - -cfg_file=/etc/sysconfig/mdk_serv -# loading var -wiz_device=`get_var wiz_device` -echo_debug "wiz_device=$wiz_device" -wiz_host_name=`get_var wiz_host_name` -echo_debug "wiz_host_name=$wiz_host_name" -wiz_ip_net=`get_var wiz_ip_net` -echo_debug "wiz_ip_net=$wiz_ip_net" -wiz_ip_netmask=`get_var wiz_ip_netmask` -echo_debug "wiz_ip_netmask=$wiz_ip_netmask" -wiz_domain_name=`get_var wiz_domain_name` -echo_debug "wiz_domain_name=$wiz_domain_name" -wiz_ip_server=`get_var wiz_ip_server` -echo_debug "=wiz_ip_server=$wiz_ip_server" - -echo_debug "wiz_ip_range1 is $wiz_ip_range1" -echo_debug "wiz_ip_range2 is $wiz_ip_range2" -chg_val ${cfg_file} wiz_ip_range1 "${wiz_ip_range1}" s -chg_val ${cfg_file} wiz_ip_range2 "${wiz_ip_range2}" s - -# patch to rewrite when got new file about dhcp with INTERFACES value -# currently, I put the device to configure as dhcp server -# in /etc/sysconfig/dhcpd - -# ok, the new init.d/dhcp is not as wanted, still need a patch - -#[ -f /etc/sysconfig/dhcpd ] && cp -f /etc/sysconfig/dhcpd /var/tmp/wiz_bck/orig/dhcpd -bck_file /etc/sysconfig/dhcpd -echo "INTERFACES=${wiz_device}" > /etc/sysconfig/dhcpd - -# ok, the new init.d/dhcp is not as wanted, still need a patch -# now patching /etc/rc.d/init.d/dhcpd if needed - -if [ -z "`grep INTERFACES /etc/rc.d/init.d/dhcpd`" ]; then - echo_debug "now patching etc/rc.d/init.d/dhcpd" - bck_file /etc/rc.d/init.d/dhcpd - cat /etc/rc.d/init.d/dhcpd.mdk_orig.1 \ -|sed -e '/daemon \/usr\/sbin\/dhcpd/{ -i \ - if [ -f /etc/sysconfig/dhcpd ]; then\ - . /etc/sysconfig/dhcpd\ - DEV=$INTERFACES\ - fi - }' > /etc/rc.d/init.d/dhcpd - -#old version patch /etc/rc.d/init.d/dhcpd < ${CWD}/scripts/dhcpd.patch - -fi - - -# dhcpd.conf - -bck_file /etc/dhcpd.conf - -echo_debug "now putting dhcpd config file" - -cat ${CWD}/scripts/dhcpd.conf.default \ -|sed "s|__hname__|${wiz_host_name}|g" \ -|sed "s|__net__|${wiz_ip_net}|g" \ -|sed "s|__ip__|${wiz_ip_server}|g" \ -|sed "s|__mask__|${wiz_ip_netmask}|g" \ -|sed "s|__rng1__|${wiz_ip_range1}|g" \ -|sed "s|__rng2__|${wiz_ip_range2}|g" \ -|sed "s|__dname__|${wiz_domain_name}|g" \ -> /etc/dhcpd.conf - -touch /var/dhcpd/dhcpd.leases - - -# modifying webmin config - -echo_debug "modifying webmin config" - -file="/etc/webmin/dhcpd/config" -if [ -f ${file} ]; then - chg_val ${file} lease_file "/var/dhcpd/dhcpd.leases" - chg_val ${file} interfaces "${wiz_device}" -fi - - -# this part of script to be played at the very end - -echo_debug "restarting services" - -/etc/rc.d/init.d/dhcpd restart - - -# all is ok -exit 10 - - - -- cgit v1.2.1