summaryrefslogtreecommitdiffstats
path: root/dhcp_wizard
diff options
context:
space:
mode:
Diffstat (limited to 'dhcp_wizard')
-rwxr-xr-xdhcp_wizard/Dhcp.pm11
-rw-r--r--dhcp_wizard/dhcp.wiz324
-rw-r--r--dhcp_wizard/scripts/Dhcpconf.pm158
-rwxr-xr-xdhcp_wizard/scripts/do_it_dhcp.sh124
4 files changed, 7 insertions, 610 deletions
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 <adesmons@mandrakesoft.com>
-# 2003 Florent Villard <warly@mandrakesoft.com>
+# Copyright (C) 2002, 2003 Mandrakesoft
+#
+# Authors: Arnaud Desmons <adesmons@mandrakesoft.com>
+# Florent Villard <warly@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
@@ -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 @@
-<?xml version="1.0"?>
-
-
-<Wizard
- name="general"
- libScript="__WIZ_HOME__/common/scripts/functions.sh"
- wizardTitle="DHCP Wizard"
- imagePosition="top"
- defaultImage="__WIZ_HOME__/dhcp_wizard/images/DHCP.png"
- perlModule="__WIZ_HOME__/dhcp_wizard/scripts/Dhcpconf.pm"
- rpm="dhcp-server"
- summaryFunc="do_it"
->
-
- <Variable
- name="dhcp_range_low"
- comment="Low end of the DHCP server IP range"
- shellVariable="wiz_ip_range1"
- defaultValue="192.168.0.100"
- >
- </Variable>
-
- <Variable
- name="dhcp_range_high"
- comment="High end of the DHCP server IP range"
- shellVariable="wiz_ip_range2"
- defaultValue="192.168.0.254"
- >
- </Variable>
-
- <Variable
- name="varIsAuthoritative"
- shellVariable="wiz_authoritative"
- >
- </Variable>
-
- <Page
- helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-dhcp.html"
- name="welcome"
- func="check_dhcp"
- executionLevel="NORMAL"
- nextFinish="false"
- canBack="true"
- canCancel="true"
- >
- <Target
- targetName="ask_dhcp_ip_range"
- jumpIndex="0"
- >
- </Target>
-
- <Target
- targetName="error_dhcp"
- jumpIndex="1"
- >
- </Target>
-
- <Info
- helpText="DHCP Configuration Wizard"
- >
- </Info>
-
-
- <Info
- helpText="DHCP is a service that automatically assigns networking addresses to your workstations."
- >
- </Info>
-
- <Info
- helpText="This wizard will help you configuring the DHCP services of your server."
- >
- </Info>
- </Page>
-
- <Page
- helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-dhcp.html"
- name="ask_dhcp_ip_range"
- comment="Ask the dhcp ip range"
- func="check"
- executionLevel="NORMAL"
- nextFinish="false"
- canBack="true"
- canCancel="true"
- >
-
- <Target
- targetName="error_in_dhcp_ip_range"
- jumpIndex="1"
- >
- </Target>
-
- <Target
- targetName="range_not_in_network"
- jumpIndex="2"
- >
- </Target>
-
- <Target
- targetName="server_in_range"
- jumpIndex="3"
- >
- </Target>
-
-
- <Target
- targetName="doit"
- jumpIndex="10"
- >
- </Target>
-
- <Info
- helpText="Range of addresses used by dhcp"
- >
- </Info>
-
-
- <Info
- helpText="Select the range of addresses assigned to the workstations by the DHCP service; unless you have special needs, you can safely accept the proposed values."
- >
- </Info>
-
- <Freetext
- name="dhcpIpLow"
- variableName="dhcp_range_low"
- fillfunc="compute_range"
- helpText="Lowest IP Address:"
- editable="true"
- >
- </Freetext>
-
- <Freetext
- name="dhcpIpHigh"
- variableName="dhcp_range_high"
- fillfunc="compute_range2"
- helpText="Highest IP Address:"
- editable="true"
- >
- </Freetext>
-
- <Boolean
- variableName="varIsAuthoritative"
- helpText="Is the server authoritative ? Ask your system administrator."
- >
- </Boolean>
-
- <Info
- helpText="IP addresses are a dotted list of four numbers smaller than 256."
- >
- </Info>
- </Page>
- <Page
- helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-web.html"
- name="error_dhcp"
- jumpPage="ask_dhcp_ip_range"
- executionLevel="NORMAL"
- canBack="true"
- canCancel="true"
- >
-
- <Info
- helpText="Warning\nYou are in dhcp, server may not work with your configuration."
- >
- </Info>
- </Page>
-
- <Page
- helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-dhcp.html"
- name="error_in_dhcp_ip_range"
- jumpPage="ask_dhcp_ip_range"
- nextButtonText="Fix it"
- executionLevel="NORMAL"
- nextFinish="false"
- canBack="true"
- canCancel="true"
- >
-
- <Info
- helpText="The IP range specified is not correct"
- >
- </Info>
- </Page>
-
- <Page
- helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-dhcp.html"
- name="range_not_in_network"
- jumpPage="ask_dhcp_ip_range"
- nextButtonText="Fix it"
- executionLevel="NORMAL"
- nextFinish="false"
- canBack="true"
- canCancel="true"
- >
-
- <Info
- helpText="The IP range specified is not in server network address range"
- >
- </Info>
- </Page>
-
- <Page
- helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-dhcp.html"
- name="server_in_range"
- jumpPage="ask_dhcp_ip_range"
- nextButtonText="Fix it"
- executionLevel="NORMAL"
- nextFinish="false"
- canBack="true"
- canCancel="true"
- >
-
- <Info
- helpText="The IP of the server must not be in range"
- >
- </Info>
- </Page>
-
- <Page
- helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-dhcp.html"
- name="doit"
- func="do_it"
- nextButtonText="Configure"
- executionLevel="NORMAL"
- nextFinish="false"
- canBack="true"
- canCancel="true"
- >
-
- <Target
- targetName="done"
- jumpIndex="10"
- >
- </Target>
-
- <Target
- targetName="system_error"
- jumpIndex="1"
- >
- </Target>
-
- <Info
- helpText="Configuring the DHCP Server"
- >
- </Info>
-
-
- <Info
- helpText="The wizard collected the following parameters
-needed to configure your DHCP service:"
- >
- </Info>
-
-
- <Freetext
- name="freetext"
- variableName="dhcp_range_low"
- helpText="Lowest IP Address:"
- editable="false"
- >
- </Freetext>
-
- <Freetext
- name="freetext1"
- variableName="dhcp_range_high"
- helpText="Highest IP Address:"
- editable="false"
- >
- </Freetext>
-
-
- <Info
- helpText="To accept these values, and configure your server, click the Next button or use the Back button to correct them."
- >
- </Info>
- </Page>
-
- <Page
- helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-dhcp.html"
- name="done"
- nextButtonText="Quit"
- executionLevel="NORMAL"
- nextFinish="true"
- canBack="false"
- canCancel="false"
- >
-
- <Info
- helpText="Congratulations"
- >
- </Info>
-
-
- <Info
- helpText="The wizard successfully configured the DHCP services of your server."
- >
- </Info>
- </Page>
-
- <Page
- helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-dhcp.html"
- name="server launcher"
- jumpPage="ask_dhcp_ip_range"
- executionLevel="DEBUG"
- nextFinish="false"
- canBack="true"
- canCancel="true"
- >
- </Page>
-
- <Page
- helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-dhcp.html"
- name="system_error"
- nextButtonText="OK"
- executionLevel="NORMAL"
- nextFinish="true"
- canBack="false"
- canCancel="true"
- >
-
- <Info
- helpText="System error, no configuration done"
- >
- </Info>
- </Page>
-</Wizard>
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 <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 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 (<OLD>) {
- 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 <ln@mandrakesoft.com>
-# <corporate@mandrakesoft.com> 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
-
-
-