diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/IFCFG.pm | 4 | ||||
-rw-r--r-- | common/Varspaceval.pm | 8 | ||||
-rw-r--r-- | common/Wizcommon.pm | 6 | ||||
-rw-r--r-- | common/scripts/DrakconnectConf.pm | 71 | ||||
-rw-r--r-- | common/scripts/IFCFG.pm | 88 | ||||
-rwxr-xr-x | common/scripts/Vareqval.pm | 89 | ||||
-rw-r--r-- | common/scripts/Varspaceval.pm | 88 | ||||
-rwxr-xr-x | common/scripts/check.sh | 64 | ||||
-rwxr-xr-x | common/scripts/check_root.sh | 51 | ||||
-rwxr-xr-x | common/scripts/functions.sh | 534 | ||||
-rw-r--r-- | common/scripts/test.pl | 12 |
11 files changed, 11 insertions, 1004 deletions
diff --git a/common/IFCFG.pm b/common/IFCFG.pm index 81b7f0e5..24441494 100644 --- a/common/IFCFG.pm +++ b/common/IFCFG.pm @@ -2,7 +2,9 @@ # Interfaces Conf Parser -# Copyright (C) 2002 MandrakeSoft Arnaud Desmons <adesmons@mandrakesoft.com> +# Copyright (C) 2002,2003 Mandrakesoft +# +# Author: 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 diff --git a/common/Varspaceval.pm b/common/Varspaceval.pm index fd5500d1..2f087f03 100644 --- a/common/Varspaceval.pm +++ b/common/Varspaceval.pm @@ -1,8 +1,10 @@ #!/usr/bin/perl -w -# Author Philippe Hétroy, phetroy@mandrakesoft.com -# $Id: Varspaceval.pm,v 1.2 2003-08-22 21:29:12 warly Exp $ - +# Copyright (C) 2002,2003 Mandrakesoft +# +# Author: Philippe Hétroy, phetroy@mandrakesoft.com +# +# $Id: Varspaceval.pm,v 1.3 2003-10-20 10:51:59 warly Exp $ # Module for loding and committing informations in a VAR = value file type package MDK::Wizard::Varspaceval; diff --git a/common/Wizcommon.pm b/common/Wizcommon.pm index 6b7c172d..b06838eb 100644 --- a/common/Wizcommon.pm +++ b/common/Wizcommon.pm @@ -1,8 +1,8 @@ #!/usr/bin/perl -# Interfaces Conf Parser - -# Copyright (C) 2003 Florent Villard <warly@mandrakesoft.com> +# Copyright (C) 2003 Mandrakesoft +# +# Author: 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 diff --git a/common/scripts/DrakconnectConf.pm b/common/scripts/DrakconnectConf.pm deleted file mode 100644 index a1b4fbf8..00000000 --- a/common/scripts/DrakconnectConf.pm +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/perl - -# Drakconnect 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 DrakconnectConf; -require "__WIZ_HOME__/common/scripts/Vareqval.pm"; -use strict; - -my $file = "/etc/sysconfig/network-scripts/drakconnect_conf"; -!-f $file and die "no such $file"; -sub new { - my $self = {}; - - my %mdk = Vareqval->get($file); - $self->{mdk} = \%mdk; - foreach (keys %{$self->{mdk}}) { - if (/.*(Eth\d)Known.*/) { - my $device = $1; - $self->{mdk}{$_} =~ /.*true.*/ and $self->{device} = $device; - } - } - !$self->{device} and return -1; - bless $self; -} - -sub get_device { - my $self = shift; - - $self->{device}; -} - -sub is_dhcp { - my $self = shift; - - $self->get_from_known_dev("BootProto") =~ /.*dhcp.*/; -} - -sub get { - my $self = shift; - my $key = shift; - - exists $self->{mdk}->{$key} or die "no $key field in $file"; - $self->{mdk}->{$key}; -} - -sub get_from_known_dev { - my $self = shift; - my $arg = shift; - - my $device = $self->{device}; - exists $self->{mdk}{$device.$arg} or die "no $arg for $device in $file"; - $self->{mdk}{$device.$arg}; -} - -10; diff --git a/common/scripts/IFCFG.pm b/common/scripts/IFCFG.pm deleted file mode 100644 index e86128d1..00000000 --- a/common/scripts/IFCFG.pm +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/perl - -# Interfaces 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 IFCFG; -use strict; -use lib qw(/usr/lib/libDrakX); -use Data::Dumper; -use MDK::Common; -use network::network; - -#my $file = "/etc/sysconfig/network-scripts/drakconnect_conf"; -#!-f $file and die "no such $file"; -sub new { - my $self = {}; - - $ENV{PATH} = ""; - my $ifconfig = `LC_ALL=C /sbin/ifconfig -a`; - my $device = 'NONE'; - my @interfaces; - foreach (split('\n', $ifconfig)) { - my ($temp) = /(^eth[0-9]*:?[0-9]*).*/; - $device = $temp if defined $temp; - my ($ip, $bcast, $netmask) = /\s*inet addr:([0-9\.]*)\s*Bcast:([0-9\.]*)\s*Mask:([0-9\.]*).*/; - if (defined $ip && defined $bcast && defined $netmask) { - $self->{itf}{$device} = {IPADDR => $ip, BROADCAST => $bcast, NETMASK => $netmask}; - my %conf = getVarsFromSh("/etc/sysconfig/network-scripts/ifcfg-$device"); - $self->{itf}{$device}{$_} = $conf{$_} foreach ('BOOTPROTO'); - } - } - %{$self->{network}} = getVarsFromSh("/etc/sysconfig/network"); - my $r = read_resolv_conf(); - foreach my $k (keys %$r) { - $self->{network}{$k} ||= $r->{$k} - } - $self->{network}{HOSTNAME} ||= `/bin/hostname` and chomp $self->{network}{HOSTNAME}; - ($self->{network}{DOMAINNAME}) = $self->{network}{HOSTNAME} =~ /\.(.*)/; - $self->{network}{DOMAINNAME} ||= `/bin/dnsdomainname` and chomp $self->{network}{DOMAINNAME}; - bless $self; -} - -sub is_dhcp { - my $self = shift; - my ($itf) = @_; - - $itf ||= default_itf(); - $self->{itf}{$itf}{BOOTPROTO} eq 'dhcp'; -} - -#- TODO : return the main interface -sub default_itf { - "eth0"; -} - -sub itf_get { - my $self = shift; - my ($key, $itf) = @_; - - $itf ||= default_itf; - exists $self->{itf}{$itf}{$key} or die "no $key field in $itf hash"; - $self->{itf}{$itf}{$key} -} - -sub network_get { - my $self = shift; - my ($key) = @_; - - exists $self->{network}{$key} or die "no $key field in network hash"; - $self->{network}{$key}; -} - -10; diff --git a/common/scripts/Vareqval.pm b/common/scripts/Vareqval.pm deleted file mode 100755 index 110ad4ec..00000000 --- a/common/scripts/Vareqval.pm +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/perl -w - -# Author Philippe Hétroy, phetroy@mandrakesoft.com -# $Id: Vareqval.pm,v 1.3 2002-09-03 15:11:43 adesmons Exp $ - -# Module for loding and committing informations in a VAR = value file type - -package Vareqval; -use lib('./'); -use strict; -use Data::Dumper; - - -# Get all useful content of the config file -# Return a hash containg the key and the value -# ATTENTION : in the conf file, an empty value is returnes as a spaced value (mandatory because of XML compatibility) -sub get { - my $self = shift; - my $file = shift; - my %l; - local *F; open F, $file or return; - local $_; - - while (<F>) { - - my ($v, $val, $val2) = - /^\s* # leading space - (\w+)\s*=\s* # variable - ( - "(.*)" # double-quoted text - | '(.*)' # single-quoted text - | [^'"\s]* # normal text - ) - \s*$ # end of line - /x; - no warnings; - next if (!defined $v || $v eq ""); - $l{$v} = defined $val2 ? $val2 : $val; - } - - %l; -} - -# Commits changes in conf files and ifconfig -sub commit { - my $self = shift; - my ($file, $hash) = @_; - local *F; - - my $output = ""; - if (open(F, $file)) { - local $_; - - while (<F>) { - my ($pre, $key, $eq, $val, $rest) = /(^\s*)(\w+)(\s*=\s*"*'*)([^'"\s]*)(.*)/x; - - if (!defined $key) { - $output .= $_; - next; - }; - next if (!exists $hash->{$key}); #Elt has been removed - no warnings; - $val = $hash->{$key}; - delete $hash->{$key}; - $output .= defined $val ? $pre . $key . $eq . $val . $rest . "\n" : $pre . $key . $eq . $val . $rest; -# $output .= $pre . $key . $eq . $val . $rest . "\n"; - } - #appending added parameters - foreach (keys %$hash) { - $output .= $_ . "=" . $hash->{$_} . "\n"; - } - - } else { #the file does not exist - print STDERR "File $file will be created\n"; - foreach (keys %$hash) { - $output .= defined $hash->{$_} ? $_ . "=" . $hash->{$_} . "\n" : $_ . "=\n"; - } - } - -#print $output; -#print "\n------------------\n"; - - # outputing the new conf - open(F, "> $file") or return; - print F $output; - close(F); -} - -1; diff --git a/common/scripts/Varspaceval.pm b/common/scripts/Varspaceval.pm deleted file mode 100644 index 7e385d8a..00000000 --- a/common/scripts/Varspaceval.pm +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/perl -w - -# Author Philippe Hétroy, phetroy@mandrakesoft.com -# $Id: Varspaceval.pm,v 1.1 2002-07-26 09:19:56 adesmons Exp $ - -# Module for loding and committing informations in a VAR = value file type - -package Varspaceval; -use lib('./'); -use strict; -use Data::Dumper; - - -# Get all useful content of the config file -# Return a hash containg the key and the value -# ATTENTION : in the conf file, an empty value is returnes as a spaced value (mandatory because of XML compatibility) -sub get { - my $self = shift; - my $file = shift; - my %l; - local *F; open F, $file or return; - local $_; - - while (<F>) { - - my ($v, $val, $val2) = - /^\s* # leading space - (\w+)\s* # variable - ( - "(.*)" # double-quoted text - | '(.*)' # single-quoted text - | [^'"\s]* # normal text - ) - \s*$ # end of line - /x; - no warnings; - $l{$v} = defined $val2 ? $val2 : $val; - } - - %l; -} - -# Commits changes in conf files and ifconfig -sub commit { - my $self = shift; - my ($file, $hash) = @_; - local *F; - - my $output = ""; - if (open(F, $file)) { - local $_; - - while (<F>) { - my ($pre, $key, $eq, $val, $rest) = /(^\s*)(\w+)(\s*"*'*)([^'"\s]*)(.*)/x; - - if (!defined $key) { - $output .= $_; - next; - }; - next if (!exists $hash->{$key}); #Elt has been removed - no warnings; - $val = $hash->{$key}; - delete $hash->{$key}; - $output .= defined $val ? $pre . $key . $eq . $val . $rest . "\n" : $pre . $key . $eq . $val . $rest; -# $output .= $pre . $key . $eq . $val . $rest . "\n"; - } - #appending added parameters - foreach (keys %$hash) { - $output .= $_ . " " . $hash->{$_} . "\n"; - } - - } else { #the file does not exist - print STDERR "File $file will be created\n"; - foreach (keys %$hash) { - $output .= defined $hash->{$_} ? $_ . "=" . $hash->{$_} . "\n" : $_ . "=\n"; - } - } - -#print $output; -#print "\n------------------\n"; - - # outputing the new conf - open(F, "> $file") or return; - print F $output; - close(F); -} - -1; diff --git a/common/scripts/check.sh b/common/scripts/check.sh deleted file mode 100755 index 1a96052e..00000000 --- a/common/scripts/check.sh +++ /dev/null @@ -1,64 +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 configuration -# -# $1, $2, ... : root wiz_ip_net wiz_... -# -# exit 0 if all is ok, else exit nb , where nb is the arg number that fails - -typeset -i cpt -cpt=0 - -for test in $@ ; do - - cpt=$cpt+1 - - case "$test" in - - root) - if [ ! -z "${_WIZ_DO_AS_ROOT}" ]; then - echo_debug "Emulating Root login , no problem" - else - if [ `id|sed 's/^uid=\([0-9]*\)[^0-9]*.*$/\1/'` -ne 0 ]; then - echo_debug "need to be root, exit $cpt" - exit $cpt - fi - fi - ;; - *) - ret=`get_var ${test}` - if [ -z "$ret" ]; then - echo_debug "no value for $test , exit $cpt" - exit $cpt - fi - ;; - esac - -done - -# all seems to be ok -exit 0 - diff --git a/common/scripts/check_root.sh b/common/scripts/check_root.sh deleted file mode 100755 index 98ae2839..00000000 --- a/common/scripts/check_root.sh +++ /dev/null @@ -1,51 +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 basic network configuration -# -# are we root ? - -if [ ! -z "${_WIZ_DO_AS_ROOT}" ]; then - echo_debug "Emulating Root login" - exit 10 -fi - -if [ `id|sed 's/^uid=\([0-9]*\)[^0-9]*.*$/\1/'` -ne 0 ]; then - echo_debug "need to be root" - exit 1 -fi - -file=/etc/sysconfig/system -if [ ! -f ${file} ]; then - echo_debug "no ${file} ... not Mandrake system" - exit 1 -fi - - - - -# all seems to be ok -exit 10 - diff --git a/common/scripts/functions.sh b/common/scripts/functions.sh deleted file mode 100755 index deca8a0a..00000000 --- a/common/scripts/functions.sh +++ /dev/null @@ -1,534 +0,0 @@ -#!/bin/bash -# -# Wizard -# -# Copyright (C) 2000,2001 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 - -# include for a few functions used in various scripts -# -# - this should be loaded at the beginning of every wizard - -# (wiz load it for you) - - -#[ "${wiz_loaded_function}" = "yes" ] && return 0 - - -# assume not multi line values -#(sed -e :a -e '/\\$/N; s/\\\n//; ta') -#debug function -# $1 : message -echo_debug () { -([ -n "${DEBUG_VAL}" ] && echo $1 >> ${DEBUG_VAL})||: -} - - -# back up the specified file -bck_file(){ -# $1 file -fic=$1 -if [ -f ${fic} ]; then - j=3 - for i in 2 1 ; do - [ -f ${fic}.mdk_orig.$i ] && mv -f ${fic}.mdk_orig.$i ${fic}.mdk_orig.$j - j=$i - done - cp -f ${fic} ${fic}.mdk_orig.1 -fi -} - - -rm_val(){ - grep -v -E "^[[:space:]]*$1[[:space:]]*=" -} - - -# retrive a value from config file -get_val(){ -# $1 : config file -# $2 : variable -if [ ! -f "${1}" -o -z "$2" ]; then - return 1 -fi -sed -n "s£^[[:space:]]*$2[[:space:]]*=[[:space:]]*\(.*\)[[:space:]]*$£\1£p" $1 2>/dev/null\ -|sed 's£^\"\(.*\)\"$£\1£' -} - -# retrive a value from config file, other version without "=" -get_val2(){ -# $1 : config file -# $2 : variable -if [ ! -f "${1}" -o -z "$2" ]; then - return 1 -fi -sed -n "s£^[[:space:]]*$2[[:space:]]\+\(.*\)[[:space:]]*$£\1£p" $1 2>/dev/null\ -|sed 's£^\"\(.*\)\"$£\1£' -} - - - -comment_val(){ -sed "s/^[[:space:]]*$1[[:space:]]*=.*$/#&/" -} - - -mod_val(){ -sed -e '\£^[[:space:]]*'"$1"'[[:space:]]*=.*$£{ -i \ -# removed by mdk_serv script on '"$(date)"' -s££#&£ -a \ -'"$1=\"$2\""' -} -' -} - -mod_val2(){ -# same as chg_val, but without "=" symbol neither "" -sed -e '\£^[[:space:]]*'"$1"'[[:space:]]\+.*$£{ -i \ -# removed by mdk_serv script on '"$(date)"' -s££#&£ -a \ -'"$1 $2"' -} -' -} - - -chg_val(){ -# $1 : config file -# $2 : variable -# $3 : new value -# $4 : "s" : silent mode - -[ -f "$1" ] || exit 1 - -#if [ -n "`grep -E \"^\[\[:space:\]\]*$2\[\[:space:\]\]*=\" \"$1\"`" ]; then - -t=`grep -c -E "^[[:space:]]*$2[[:space:]]*=" $1` - -if [ $t -ge 1 ]; then - TMPFILE=`mktemp /tmp/temp.XXXXXX` || exit 1 - cat "$1" > ${TMPFILE} - (cat ${TMPFILE}|mod_val "$2" "$3" > "$1") && rm -f ${TMPFILE} -else - if [ "$4" = "s" ]; then - echo -e "\ -$2=\"$3\"\n\ -" >> "$1" - else - echo -e "\ -# added by mdk_serv script on $(date)\n\ -$2=\"$3\"\n\ -" >> "$1" - fi -fi -} - -chg_val2(){ -# same as chg_val, but without "=" symbol neither "" - -# $1 : config file -# $2 : variable -# $3 : new value -# $4 : "s" : silent mode - -[ -f "$1" ] || exit 1 - -t=`grep -c -E "^[[:space:]]*$2[[:space:]]+" $1` -if [ $t -ge 1 ]; then - TMPFILE=`mktemp /tmp/temp.XXXXXX` || exit 1 - cat "$1" > ${TMPFILE} - (cat ${TMPFILE}|mod_val2 "$2" "$3" > "$1") && rm -f ${TMPFILE} -else - if [ "$4" = "s" ]; then - echo -e "\ -$2 $3\n\ -" >> "$1" - else - echo -e "\ -# added by mdk_serv script on $(date)\n\ -$2 $3\n\ -" >> "$1" - fi -fi -} - - -# get_var $1 : function to retrieve stored value of wiz_variables -# - if $2 is provided, returns $2 (ok, it's a hack) -# - if the stored value is empty, returns the current one (in memory) -# - this function may return a null string if value is really not found - -get_var(){ -# $1 : name of the variable -# $2 : forcing value - -[ -z "$1" ] && return 1 - -if [ -n "$2" ]; then - echo "$2" - return 0 -fi - -file=/etc/sysconfig/mdk_serv - -case "$1" in - wiz_host_name) - t=`get_val ${file} wiz_host_name` - if [ -z "$t" ]; then - echo ${wiz_host_name} - else - echo "$t" - fi - ;; - wiz_domain_name) - t=`get_val ${file} wiz_domain_name` - if [ -z "$t" ]; then - echo ${wiz_domain_name} - else - echo "$t" - fi - ;; - wiz_device) - t=`get_val ${file} wiz_device` - if [ -z "$t" ]; then - echo ${wiz_device} - else - echo "$t" - fi - ;; - wiz_ext_dns1) - t=`get_val ${file} wiz_ext_dns1` - if [ -z "$t" ]; then - echo ${wiz_ext_dns1} - else - echo "$t" - fi - ;; - wiz_ext_dns2) - t=`get_val ${file} wiz_ext_dns2` - if [ -z "$t" ]; then - echo ${wiz_ext_dns2} - else - echo "$t" - fi - ;; - wiz_web_internal) - t=`get_val ${file} wiz_web_internal` - if [ -z "$t" ]; then - echo ${wiz_web_internal} - else - echo "$t" - fi - ;; - wiz_web_external) - t=`get_val ${file} wiz_web_external` - if [ -z "$t" ]; then - echo ${wiz_web_external} - else - echo "$t" - fi - ;; - wiz_ftp_internal) - t=`get_val ${file} wiz_ftp_internal` - if [ -z "$t" ]; then - echo ${wiz_ftp_internal} - else - echo "$t" - fi - ;; - wiz_ftp_external) - t=`get_val ${file} wiz_ftp_external` - if [ -z "$t" ]; then - echo ${wiz_ftp_external} - else - echo "$t" - fi - ;; - wiz_news_freq) - t=`get_val ${file} wiz_news_freq` - if [ -z "$t" ]; then - echo ${wiz_news_freq} - else - echo "$t" - fi - ;; - wiz_news_server) - t=`get_val ${file} wiz_news_server` - if [ -z "$t" ]; then - echo ${wiz_news_server} - else - echo "$t" - fi - ;; - wiz_banner) - t=`get_val ${file} wiz_banner` - if [ -z "$t" ]; then - echo ${wiz_banner} - else - echo "$t" - fi - ;; - wiz_workgroup) - t=`get_val ${file} wiz_workgroup` - if [ -z "$t" ]; then - echo ${wiz_workgroup} - else - echo "$t" - fi - ;; - wiz_do_printer_sharing) - t=`get_val ${file} wiz_do_printer_sharing` - if [ -z "$t" ]; then - echo ${wiz_do_printer_sharing} - else - echo "$t" - fi - ;; - wiz_do_file_sharing) - t=`get_val ${file} wiz_do_file_sharing` - if [ -z "$t" ]; then - echo ${wiz_do_file_sharing} - else - echo "$t" - fi - ;; - wiz_ip_net) - wdevice=`get_val ${file} wiz_device` - nfile="/etc/sysconfig/network-scripts/ifcfg-${wdevice}" - t=`get_val ${nfile} NETWORK` - if [ -z "$t" ]; then - echo ${wiz_ip_net} - else - echo "$t" - fi - ;; - wiz_ip_netmask) - wdevice=`get_val ${file} wiz_device` - nfile="/etc/sysconfig/network-scripts/ifcfg-${wdevice}" - t=`get_val ${nfile} NETMASK` - if [ -z "$t" ]; then - echo ${wiz_ip_netmask} - else - echo "$t" - fi - ;; - wiz_ip_server) - wdevice=`get_val ${file} wiz_device` - nfile="/etc/sysconfig/network-scripts/ifcfg-${wdevice}" - t=`get_val ${nfile} IPADDR` - if [ -z "$t" ]; then - echo ${wiz_ip_server} - else - echo "$t" - fi - ;; - wiz_ip_range1) - wdevice=`get_val ${file} wiz_device` - nfile="/etc/sysconfig/network-scripts/ifcfg-${wdevice}" - twnet=`get_val ${nfile} NETWORK` - nfile=/etc/dhcpd.conf - rnge= - if [ -f ${nfile} ]; then - rnge=`sed -n -e 's/^[[:space:]]*range[[:space:]]*\([1-9\.]*\)[[:space:]].*$/\1/p' ${nfile}` - fi - [ "${rnge%.*}" == "${twnet%.*}" ] || rnge="" - if [ -z "$rnge" ]; then - echo ${wiz_ip_range1} - else - echo "$rnge" - fi - ;; - wiz_ip_range2) - wdevice=`get_val ${file} wiz_device` - nfile="/etc/sysconfig/network-scripts/ifcfg-${wdevice}" - twnet=`get_val ${nfile} NETWORK` - nfile=/etc/dhcpd.conf - rnge= - if [ -f ${nfile} ]; then - rnge=`sed -n -e 's/^[[:space:]]*range[[:space:]]*[1-9\.]*[[:space:]]*\([1-9\.]*\)[^1-9\.].*$/\1/p' ${nfile}` - fi - [ "${rnge%.*}" == "${twnet%.*}" ] || rnge="" - if [ -z "$rnge" ]; then - echo ${wiz_ip_range2} - else - echo "$rnge" - fi - ;; - wiz_ext_device) - t=`get_val ${file} wiz_ext_device` - if [ -z "$t" ]; then - echo ${wiz_ext_device} - else - echo "$t" - fi - ;; - wiz_extn_device) - t=`get_val /etc/sysconfig/network GATEWAYDEV` - if [ -z "$t" ]; then - echo ${wiz_extn_device} - else - echo "$t" - fi - ;; - wiz_extn_gateway) - t=`get_val /etc/sysconfig/network GATEWAY` - if [ -z "$t" ]; then - echo ${wiz_extn_gateway} - else - echo "$t" - fi - ;; - wiz_firewall_level) - t=`get_val ${file} wiz_firewall_level` - if [ -z "$t" ]; then - echo ${wiz_firewall_level} - else - echo "$t" - fi - ;; - wiz_ext_mail_relay) - postconf -h relayhost - ;; - wiz_mail_masquerade) - nfile=/etc/postfix/canonical - wdname=`get_val ${file} wiz_domain_name` - t="" - if [ -f ${nfile} ]; then - t=`sed -n -e 's/^[[:space:]]*@'"${wdname}"'[[:space:]]*@\([^[:space:]]*\)[[:space:]]*$/\1/p' ${nfile}` - fi - if [ -z "$t" -o -z "wdname" ]; then - echo ${wiz_mail_masquerade} - else - echo "$t" - fi - ;; - wiz_timezone) - nfile=/etc/sysconfig/clock - t=`get_val ${nfile} ZONE` - if [ -z "$t" ]; then - echo ${wiz_timezone} - else - echo "$t" - fi - ;; - wiz_squid_port) - nfile=/etc/squid/squid.conf - t=`get_val2 ${nfile} http_port` - if [ -z "$t" ]; then - echo ${wiz_squid_port} - else - echo "$t" - fi - ;; - wiz_squid_mem) - nfile=/etc/squid/squid.conf - t=`get_val2 ${nfile} cache_mem` - if [ -z "$t" ]; then - echo ${wiz_squid_mem} - else - t1=`echo $t|awk '{print $1}'` - t2=`echo $t|awk '{print $2}'` - if [ "$t2" == "MB" ]; then - echo $t1 - else - echo ${wiz_squid_mem} - fi - fi - ;; - wiz_squid_disk) - nfile=/etc/squid/squid.conf - # nota : only one dir : wiz_squid_defdir - export wiz_squid_defdir=`get_var wiz_squid_defdir` - t=`sed -n "s£^[[:space:]]*cache_dir[[:space:]]\+[a-z]\+[[:space:]]\+$wiz_squid_defdir[[:space:]]\+\([0-9]\+\)[[:space:]]*.*$£\1£p" $nfile 2>/dev/null` - if [ -z "$t" ]; then - echo ${wiz_squid_disk} - else - echo $t - fi - ;; - wiz_squid_level) - t=`get_val ${file} wiz_squid_level` - if [ -z "$t" ]; then - echo ${wiz_squid_level} - else - echo "$t" - fi - ;; - wiz_squid_defdir) - t=`get_val ${file} wiz_squid_defdir` - if [ -z "$t" ]; then - [ -z "${wiz_squid_defdir}" ] && wiz_squid_defdir="/var/spool/squid" - echo ${wiz_squid_defdir} - else - echo "$t" - fi - ;; - wiz_squid_mynetw) - nfile=/etc/squid/squid.conf - t=`get_val2 ${nfile} "acl mynetwork src"` - if [ -z "$t" ]; then - echo `get_var wiz_ip_net`"/"`get_var wiz_ip_netmask` - else - echo $t - fi - ;; - wiz_squid_cachepeer) - nfile=/etc/squid/squid.conf - t=`get_val2 ${nfile} "cache_peer"` - if [ -z "$t" ]; then - echo ${wiz_squid_cachepeer} - else - echo $t|awk '{print $1}' - fi - ;; - wiz_squid_peerport) - nfile=/etc/squid/squid.conf - t=`get_val2 ${nfile} "cache_peer"` - if [ -z "$t" ]; then - echo ${wiz_squid_peerport} - else - echo $t|awk '{print $3}' - fi - ;; - - *) - return 1 - ;; -esac -} - - - - -export -f echo_debug -export -f rm_val -export -f get_val -export -f get_val2 -export -f mod_val -export -f mod_val2 -export -f chg_val -export -f chg_val2 -export -f bck_file - -export -f get_var -#export wiz_loaded_function=yes diff --git a/common/scripts/test.pl b/common/scripts/test.pl deleted file mode 100644 index 5fbba3cb..00000000 --- a/common/scripts/test.pl +++ /dev/null @@ -1,12 +0,0 @@ -use lib qw(/usr/lib/libDrakX); -package Dhcpconf; -require "IFCFG.pm"; -#require "__WIZ_HOME__/common/scripts/DrakconnectConf.pm"; -use MDK::Common; -use strict; -use standalone; - -my $o = IFCFG->new(); -print $o->is_dhcp() ? "toto\n" : "tata\n"; -print $o->itf_get("IPADDR"); -print $o->network_get("DOMAINNAME"); |