From 23404e9c708a1f5960a1ae7ec54234117c6b39d9 Mon Sep 17 00:00:00 2001 From: Florent Villard Date: Wed, 5 Mar 2003 17:38:49 +0000 Subject: various fixes in server wizard deactivate firewall wizard --- server_wizard/scripts/Serverconf.pm | 71 ++++++++++++++++++++++++++++------- server_wizard/scripts/check_config.sh | 2 +- server_wizard/scripts/liste_device.sh | 2 +- server_wizard/server.wiz | 70 +++++++++++++++++----------------- 4 files changed, 95 insertions(+), 50 deletions(-) (limited to 'server_wizard') diff --git a/server_wizard/scripts/Serverconf.pm b/server_wizard/scripts/Serverconf.pm index 4f70e74a..23a0eb91 100644 --- a/server_wizard/scripts/Serverconf.pm +++ b/server_wizard/scripts/Serverconf.pm @@ -1,10 +1,51 @@ #!/usr/bin/perl package Serverconf; -require "__WIZ_HOME__/common/scripts/Vareqval.pm"; +require "/usr/share/wizards/common/scripts/Vareqval.pm"; +require "/usr/share/wizards/common/scripts/IFCFG.pm"; use MDK::Common; use strict; +my $o = IFCFG->new(); + +sub get_hostname { + my $host = $o->network_get("HOSTNAME"); + return $host if $host; + "host.domain" +} + +sub check_domain { + $ENV{wiz_host_name} =~ /\S+\.\S+/ and return 10; + 1 +} + +sub check_network { + print "$ENV{wiz_ip_net}\n"; + foreach (split '\.', $ENV{wiz_ip_net}) { + $_ >= 0 && $_ < 256 or return 1 + } + return 10 +} + +sub get_net { + $o->itf_get('NET_ADDR') or "192.168.1.0"; +} + +sub compute_server_ip { + $o->itf_get('ADDR') or "192.168.1.1" +} + +sub set_ip { + +} + +sub check_server_ip { + my @net = split '\.', $ENV{wiz_ip_net}; + my @ip = split '\.', $ENV{wiz_ip_server}; + mapn { $_[0] == $_[1] || $_[0] == 0 or return 0 } \@net, \@ip; + return 10 +} + sub do_it_last { my $file = "/etc/sysconfig/mdk_serv"; MDK::Common::cp_af($file, $file.".orig"); @@ -17,6 +58,18 @@ wiz_host_name=$ENV{wiz_host_name} wiz_domain_name=$ENV{wiz_domain_name}"; } +sub get_gateway_dev { + $o->network_get('GATEWAYDEV') or "eth0" +} + +sub get_device { + "eth0" +} + +sub get_gateway { + $o->network_get('GATEWAY') +} + sub do_it { my $old_ip; my $date = `date`; @@ -39,9 +92,9 @@ sub do_it { $file = "/etc/sysconfig/network-scripts/ifcfg-$ENV{wiz_device}" if defined $ENV{wiz_device} or die "wiz_device not in env"; if (-f $file) { - MDK::Common::cp_af($file, $file . ".orig"); + MDK::Common::cp_af($file, "mdk_$file.orig"); %mdk = Vareqval->get($file); - $old_ip = $mdk{IPADDR} if defined $mdk{IPADDR} or die "IPADDR not found in $file"; + $old_ip = $mdk{IPADDR} || $o->network_get('IPADDR') } else { system("touch $file"); @@ -72,14 +125,6 @@ sub do_it { # chg_val sequence ended Vareqval->commit($file, \%mdk); - $file = "/etc/HOSTNAME"; - MDK::Common::cp_af($file, $file . ".orig"); - open(NEW, "> $file") or die "can not open $file"; - print NEW "$hostname"; - close(NEW) or die "can not close $file"; - system("hostname $hostname"); - my ($hostalias) = ($hostname =~ /^([^.]*)\..*$/); - $file = "/etc/hosts"; MDK::Common::cp_af($file, $file . ".orig"); if (defined $old_ip && $old_ip ne $new_ip) { @@ -91,7 +136,7 @@ sub do_it { if (/^\s*(?!\#)*\s*$old_ip.*$/) { print NEW "# removed by mdk_serv script on $date #$_ -$new_ip\t$hostname\t$hostalias\n"; +$new_ip\t$hostname\n"; next; } print NEW $_; @@ -102,7 +147,7 @@ $new_ip\t$hostname\t$hostalias\n"; } else { open(NEW, ">> $file"); - print NEW "$new_ip\t$hostname\t$hostalias\n"; + print NEW "$new_ip\t$hostname\n"; close NEW; } do_it_last(); diff --git a/server_wizard/scripts/check_config.sh b/server_wizard/scripts/check_config.sh index f44bd42c..512fd7da 100755 --- a/server_wizard/scripts/check_config.sh +++ b/server_wizard/scripts/check_config.sh @@ -28,7 +28,7 @@ # checking if the provided domain value is correct : # strip the @, need at least a dot -echo_debug "$(date) begin $0" +echo_debug "$(/bin/date) begin $0" fic=/etc/sysconfig/mdk_serv if [ ! -f "$fic" ] ;then diff --git a/server_wizard/scripts/liste_device.sh b/server_wizard/scripts/liste_device.sh index 0f830728..0dbdba9b 100755 --- a/server_wizard/scripts/liste_device.sh +++ b/server_wizard/scripts/liste_device.sh @@ -31,7 +31,7 @@ liste="" -liste=$liste"`ifconfig -a | awk ' /^eth/ { print $1"\n"$1, $4,":",$5 } '`\n" +liste=$liste"`/sbin/ifconfig -a | /bin/awk ' /^eth/ { print $1"\n"$1, $4,":",$5 } '`\n" # display only configured device #for i in 0 1 2 3 ;do diff --git a/server_wizard/server.wiz b/server_wizard/server.wiz index 9a63fd80..301d31fd 100644 --- a/server_wizard/server.wiz +++ b/server_wizard/server.wiz @@ -14,7 +14,6 @@ name="hostname" comment="The host name of the server" shellVariable="wiz_host_name" - defaultValue="host.domain.net" valueIsTranslated="false" > @@ -32,7 +31,6 @@ name="network_address" comment="The network address" shellVariable="wiz_ip_net" - defaultValue="192.168.0.0" valueIsTranslated="false" > @@ -41,7 +39,6 @@ name="server_address" comment="The server IP address" shellVariable="wiz_ip_server" - defaultValue="192.168.0.1" valueIsTranslated="false" > @@ -50,7 +47,6 @@ name="net_device" comment="The device used to the network connection" shellVariable="wiz_device" - defaultValue="eth0" valueIsTranslated="false" > @@ -177,7 +173,7 @@ @@ -186,7 +182,7 @@ - - - - - - - - @@ -308,7 +285,7 @@ @@ -336,7 +313,7 @@ @@ -345,7 +322,7 @@ @@ -426,7 +403,7 @@ @@ -471,7 +448,7 @@ @@ -570,6 +548,7 @@ name="get_gatewaydev" variableName="wiz_extn_device" helpText="Gateway device:" + fillfunc="get_gateway_dev" editable="true" > @@ -577,6 +556,7 @@ @@ -631,6 +611,7 @@ @@ -722,4 +703,23 @@ > + + + + + + + -- cgit v1.2.1