summaryrefslogtreecommitdiffstats
path: root/nisautofs_wizard/Nisautofs.pm
diff options
context:
space:
mode:
authorNicolas Vigier <nvigier@mandriva.com>2008-03-05 16:34:38 +0000
committerNicolas Vigier <nvigier@mandriva.com>2008-03-05 16:34:38 +0000
commit1ea920072c09c49c019188e7d30b7fca1e6e8391 (patch)
tree433600c92ac24c915f53e9bd981e19cbcc965c5f /nisautofs_wizard/Nisautofs.pm
parentde522045836b90f9067ebbd04ee2895e3c5e7e11 (diff)
downloaddrakwizard-1ea920072c09c49c019188e7d30b7fca1e6e8391.tar
drakwizard-1ea920072c09c49c019188e7d30b7fca1e6e8391.tar.gz
drakwizard-1ea920072c09c49c019188e7d30b7fca1e6e8391.tar.bz2
drakwizard-1ea920072c09c49c019188e7d30b7fca1e6e8391.tar.xz
drakwizard-1ea920072c09c49c019188e7d30b7fca1e6e8391.zip
remove and don't install disabled wizards so that mcc doesn't offer to run them
Diffstat (limited to 'nisautofs_wizard/Nisautofs.pm')
-rw-r--r--nisautofs_wizard/Nisautofs.pm319
1 files changed, 0 insertions, 319 deletions
diff --git a/nisautofs_wizard/Nisautofs.pm b/nisautofs_wizard/Nisautofs.pm
deleted file mode 100644
index 771dde4a..00000000
--- a/nisautofs_wizard/Nisautofs.pm
+++ /dev/null
@@ -1,319 +0,0 @@
-#/usr/bin/perl -w
-# version 0.3
-#
-# Copyright (C) 2002,2005 Mandrakesoft
-#
-# Author: aginies _at_ mandriva.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 MDK::Wizard::Nisautofs;
-use lib qw(/usr/lib/libDrakX);
-use strict;
-#use standalone;
-use common;
-use services;
-#use MDK::Wizard::Varspaceval;
-use MDK::Wizard::Wizcommon;
-
-
-# test root capa
-my $wiz = new MDK::Wizard::Wizcommon;
-my $in = interactive->vnew;
-
-#my $NISDOMAIN = $wiz->{net}->network_get("NISDOMAIN");
-my $NISDOMAIN = chomp_(`nisdomainname`);
-my @HOST = split('\.', $wiz->{net}->network_get("HOSTNAME"));
-my $HOST = @HOST[0]; # just need basename and not full qualified computer hostname (with domainaname)
-my $NIS_DIRMAKEFILE = "/var/yp/";
-my $HOMENIS = "/home/nis";
-my $NETWORKFILE = "/etc/sysconfig/network";
-my $NFSEXPORTS = "/etc/exports";
-my $AUTOMASTER = "/etc/auto.master";
-my $AUTOHOME = "/etc/auto.home";
-my $YPCONF = "/etc/yp.conf";
-
-my $o = {
- name => 'NIS Configuration Wizard',
- var => {
- NISDOMAIN => chomp_($NISDOMAIN),
- NISSERVER => chomp_($HOST),
- NIS_DIRMAKEFILE => $NIS_DIRMAKEFILE,
- HOMENIS => $HOMENIS,
- NETWORKFILE => $NETWORKFILE,
- NFSEXPORTS => $NFSEXPORTS,
- AUTOMASTER => $AUTOMASTER,
- AUTOHOME => $AUTOHOME,
- create_missing_directory => '',
- },
- needed_rpm => [ 'ypserv', 'ypbind', 'nfs-utils', 'yp-tools', 'nfs-utils-clients' ],
- defaultimage => "/usr/share/mcc/themes/default/nisautofs.png",
- init => sub {
- my ($err, $msg) = test_host_domain($SHORTHOSTNAME, $DOMAINNAME);
- if (!$err) {
- $in->ask_warn(N('Error'), $msg);
- die 'wizcancel';
- }
- },
- };
-
-$o->{pages} = {
- welcome => {
- name => N("NIS server with autofs map") . "\n\n" . N("Setup a NIS server with autofs map, auto.home and auto.master files.") . "\n\n" . N("Users automatically mount their home directory from server, when they log on a NIS client computer network."),
- no_back => 1,
- next => 'nis_server',
- },
- nis_server => {
- name => N("NIS server with autofs map") . "\n" . N("A NIS server is useful to create user, hostname database. The wizard builds autofs map, so it will provide the capabilities for NIS user to automount their home directory on a NIS client computer.") . "\n\n" . N("NIS server: name of your computer.") . "\n" . N("NIS domain: NIS domain to use (generally same as your DNS domain name)."),
- data => [
- { label => N("NIS server:"), val => $HOST },
- { label => N("NIS domainname:"), val => \$o->{var}{NISDOMAIN} },
- ],
- complete => sub {
- if ($o->{var}{NISDOMAIN} eq '(none)' || !$o->{var}{NISDOMAIN}) { return 'error_nisd' }
- },
- next => 'nis_server2',
- },
- nis_server2 => {
- name => N("Home NIS: home base directory for users on NIS server. This directory will be exported through NFS server."),
- data => [
- { label => N("Home NIS:"), val => \$o->{var}{HOMENIS} },
- { label => N("Create home NIS directory if it doesn't exist"), type => 'bool', val => \$o->{var}{create_missing_directory} },
- ],
- complete => sub {
- if (!-d $o->{var}{HOMENIS} and $o->{var}{create_missing_directory}) {
- mkdir_p($o->{var}{HOMENIS});
- } elsif (!-d $o->{var}{HOMENIS}) {
- $in->ask_warn(N("Warning"), N("Directory doesn't exist. Please create it manually."));
- return 1; }
- },
- next => 'summaryserver',
- },
- summaryserver => {
- name => N("The wizard will set your NIS server with autofs map"),
- data => [
- { label => N("NIS server:"), val_ref => \$HOST },
- { label => N("Home NIS:"), val_ref => \$o->{var}{HOMENIS} },
- { label => N("NIS domainname:"), val_ref => \$o->{var}{NISDOMAIN} },
- { label => N("NIS directory:"), val_ref => \$o->{var}{NIS_DIRMAKEFILE} },
-# { label => N("Network file:"), val_ref => \$o->{var}{NETWORKFILE} },
-# { label => N("NFS exports:"), val_ref => \$o->{var}{NFSEXPORTS} },
-# { label => N("Auto master:"), val_ref => \$o->{var}{AUTOMASTER} },
-# { label => N("Auto home:"), val_ref => \$o->{var}{AUTOHOME} },
- ],
- post => \&do_it_server,
- next => 'endserver',
- },
- error_nisd => {
- name => N("Error: nisdomainname should not be 'none' or 'localdomain'.") . "\n\n" . N("Please adjust it."),
- no_back => 1,
- next => 'nis_server',
- },
- endserver => {
- name => N("Congratulations"),
- data => [ { label => N("The wizard successfully configured your machine to be a NIS server with autofs map.") } ],
- no_back => 1,
- end => 1,
- next => 0
- },
- error_end => {
- name => N("Failed"),
- data => [ { label => N("Relaunch drakwizard, and try to change some parameters.") } ],
- no_back => 1,
- end => 1,
- next => 0,
- },
- };
-
-
-sub test_set {
- if (member($o->{var}{NISDOMAIN}, qw(localdomain (none)))) { return 'error_nisd' }
- !-d $o->{var}{HOMENIS} or return 'error_dir';
- !-d $o->{var}{NIS_DIRMAKEFILE} or return 'error_dir';
-}
-# update /etc/sysconfig/network
-sub update_network {
- save_config($NETWORKFILE);
- if (any { /NISDOMAIN/ } cat_($NETWORKFILE)) {
- substInFile { s/NISDOMAIN.*/NISDOMAIN=$o->{var}{NISDOMAIN}/g } $NETWORKFILE;
- } else {
- append_to_file($NETWORKFILE, "NISDOMAIN=$o->{var}{NISDOMAIN}\n");
- }
-}
-
-# Setting nisdomainname
-sub set_nisdomain {
- system("nisdomainname $o->{var}{NISDOMAIN}");
-}
-
-
-sub nfs_home_nis {
- # test directory
- $HOMENIS = $o->{var}{HOMENIS};
- if (-d $HOMENIS) {
- print " - $HOMENIS directory exist\n";
- } else {
- print " - Creating $HOMENIS directory\n";
- mkdir_p($HOMENIS);
- }
-
- # check nis home
- if (any { /$HOMENIS/ } cat_($NFSEXPORTS)) {
- print " - " . $NFSEXPORTS . " ready\n";
- } else {
- print " - Adjusting " . $NFSEXPORTS . "\n";
- append_to_file($NFSEXPORTS, "$HOMENIS *(async,rw,no_root_squash)\n");
- }
-}
-
-# configure /etc/auto.*
-sub configure_auto {
- $HOMENIS = $o->{var}{HOMENIS};
- save_config($AUTOMASTER);
- my $nisserver = chomp_($o->{var}{NISSERVER});
- output($AUTOMASTER, <<EOF);
-$HOMENIS auto.home --timeout=60
-EOF
-
- save_config($AUTOHOME);
- output($AUTOHOME, <<EOF);
-* -rw,nfs,soft,intr,nosuid,rsize=8192,wsize=8192 $nisserver:$HOMENIS/&
-EOF
-}
-
-sub adjust_makefile {
-# Makefile parameter
- print " - Updating " . $NIS_DIRMAKEFILE . " to add autofs\n";
- mkdir_p('/etc/mail');
- system('touch /etc/mail/aliases');
- substInFile {
- s!^ALIASES!#ALIASES=/etc/aliases!g;
- s/^all.*/all: passwd group shadow hosts rpc services netid protocols auto.master auto.home/g;
- } $NIS_DIRMAKEFILE . '/Makefile';
-}
-
-# create yp base
-sub make_yp {
- system("make -C $NIS_DIRMAKEFILE");
-}
-
-sub needed_service {
- my ($service) = @_;
- if (services::is_service_running($service)) {
- services::restart($service);
- } else { services::start($service) }
-}
-
-sub get_nis_users {
- my @unwanted = qw(install maui nobody mpi);
- my @users;
- local *PASS;
- open(PASS, "ypcat passwd|") or die " cant exec ypcat passwd!";
- while (<PASS>) {
- my ($login) = split(':');
- if (!member($login, @unwanted)) {
- push(@users, $login);
- }
- }
- close(PASS);
- [ @users ];
-}
-
-sub update_yp {
- my ($nd, $yps) = @_;
- save_config($YPCONF);
- output($YPCONF, <<EOF);
-# /etc/yp.conf - ypbind configuration file
-# domain NISDOMAIN server HOSTNAME
-# Use server HOSTNAME for the domain NISDOMAIN.
-#domain NISDOMAIN broadcast
-# Use broadcast on the local net for domain NISDOMAIN
-#
-#ypserver HOSTNAME
-# Use server HOSTNAME for the local domain. The
-# IP-address of server must be listed in /etc/hosts.
-#
-domain $nd server $yps
-EOF
-}
-
-sub test_autofile {
- map { if (-e $_) { rm_rf($_) }; $_ } $AUTOHOME, $AUTOMASTER;
-}
-
-sub save_config {
- my ($old) = @_;
- my $DATE = chomp_(`date +%d-%m-20%y`);
- if (-f $old) {
- cp_af($old, $old . '.' . $DATE);
- }
- return($old . '.' . $DATE);
-}
-
-sub update_network_nisdomain {
- my ($nd) = @_;
- my $nf = cluster_commonconf::system_network()->{NETWORKFILE};
- my %conf = getVarsFromSh($nf);
- save_config($nf);
- setVarsInSh($nf, { %conf, NISDOMAIN => $nd });
-}
-
-sub update_nsswitch {
- substInFile {
- s/automount:.*/automount: nis nisplus files/g;
- s/hosts.*/hosts: dns nis files/;
- } '/etc/nsswitch.conf';
-}
-
-sub uninstall_rpm {
- my ($rpm) = @_;
- system("urpme $rpm --auto");# if (system('/bin/rpm', '>/dev/null', '-q', $rpm));
-}
-
-sub do_it_server {
- return if $::testing;
- my $in = 'interactive'->vnew('su', 'nisautofsconfig');
- my $w = $in->wait_message(N("NIS with Autofs map"), N("Configuring your system to be a NIS server with Autofs map..."));
-# system("urpme --auto autofs") if (system("/bin/rpm -q autofs >/dev/null"));
- uninstall_rpm('autofs');
- # configure autofs to fit nis
- configure_auto();
- # set correct nis
- set_nisdomain();
- # create all make file needed
- adjust_makefile();
- make_yp();
- # update client conf file (also on server)
- update_yp(chomp_($o->{var}{NISDOMAIN}), chomp_($HOST));
- # update conf file
- update_network();
- # update nsswitch.conf
- update_nsswitch();
- # update nfs to fit nis
- nfs_home_nis();
- # restart all needed services
- needed_service($_) foreach qw(ypserv nfs);
- undef $w;
- needed_service("ypbind");
- check_started($_) foreach qw(ypserv nfsd);
-}
-
-sub new {
- my ($class) = @_;
- bless $o, $class;
-}
-
-1;