# version 0.2 # # Copyright (C) 2004 Mandrakesoft # # Author: aginies _at_ 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 MDK::Wizard::Installsrv; use lib qw(/usr/lib/libDrakX); use ugtk2 qw(:ask :helpers :wrappers :create :dialogs); 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 $INSTALLDIR = "/var/install/"; my $NFSEXPORTS = "/etc/exports"; my $WWWDIR = "/var/www/html"; my $testy; my $o = { name => 'Install Server Wizard', var => { DESTDIR => '/var/install/clic', SOURCEDIR => '/home/nis/install/clic', }, needed_rpm => [ 'nfs-utils', 'apache-mpm-prefork' ], defaultimage => "$ENV{__WIZ_HOME__}/installsrv_wizard/images/Install.png" }; $o->{pages} = { welcome => { name => N("Configure an install server (via NFS and HTTP)") . "\n\n" . N("Easily configure a server installation directory, with NFS and HTTP access."), no_back => 1, next => 'install_srv', }, install_srv => { name => N("Install server configuration") . "\n\n" . N("Path to data: specify your source directory, should be base of a Linux installation.") . "\n\n" . N("Destination directory: copy files in which directory?"), pre => sub { $o->{var}{wiz_nfs} ||= 1; $o->{var}{wiz_http} ||= 1; }, data => [ { label => "Path to data:", val => \$o->{var}{SOURCEDIR}, help => N("Please provide path to Mandriva installation disk") }, { label => "Destination directory:", val => \$o->{var}{DESTDIR}, help => N("Files will be copied in this place.") }, # { label => N("Enable NFS install server:"), type => 'bool', val => \$o->{var}{wiz_nfs} }, # { label => N("Enable HTTP install server:"), type => 'bool', val => \$o->{var}{wiz_http} }, ], post => \&test_data, next => 'summary_srv', }, error_dir_dest => { name => N("The destination directory could not be '/var/install/'") . "\n\n" . N("ie use: /var/install/mdk-release"), next => 'install_srv', }, error_dir => { name => N("Error, the source path must be a directory with full Linux installation directory."), next => 'install_srv', }, dir_already_use => { name => N("The destination directory is already in use. Please choose another one."), next => 'install_srv', }, summary_srv => { name => N("Your install server will be configured with these parameters"), pre => sub { $o->{var}{nfs} = $o->{var}{wiz_nfs} ? N("enabled") : N("disabled"); $o->{var}{http} = $o->{var}{wiz_http} ? N("enabled") : N("disabled"); }, data => [ { label => "Path to data:", fixed_val => \$o->{var}{SOURCEDIR} }, { label => "Destination directory:", fixed_val => \$o->{var}{DESTDIR} }, { label => N("Enable NFS install server:"), fixed_val => \$o->{var}{nfs} }, { label => N("Enable HTTP install server:"), fixed_val => \$o->{var}{http} }, ], post => \&do_it, no_back => 1, next => 'end', }, wait => { name => N("Configuring your system, please wait..."), next => 'end', }, end => { name => N("Congratulations, Install server is now ready. You can now configure a DHCP server with PXE support, and a PXE server. So it will be very easy to install Linux through a network. Use drakpxelinux to configure your PXE server, and drakwizard DHCP to configure a DHCPD server."), end => 1, no_back => 1, next => 0 }, }; sub add_install_dir { if (any { /$o->{var}{DESTDIR}/ } cat_($NFSEXPORTS)) { print " - " . $NFSEXPORTS . " ready\n"; } else { append_to_file($NFSEXPORTS, "$->{var}{DESTDIR} *(async,rw,no_root_squash)\n"); check_started($_) foreach qw(nfs nfsd); } } sub test_data { -d $o->{var}{SOURCEDIR} && -f "$o->{var}{SOURCEDIR}/VERSION" or return 'error_dir'; if ($o->{var}{DESTDIR} eq $INSTALLDIR) { return 'error_dir_dest' } if (-e $o->{var}{DESTDIR}) { return 'dir_already_use' } } sub add_ftpuser { system("/usr/sbin/useradd -u 12383 -d install -r -s /bin/bash install"); } sub add_http_link { my ($PATH) = @_; my $LINK = $WWWDIR . '/' . basename($PATH); if (! -f $LINK) { symlink $PATH, $LINK; } check_started("httpd"); } sub cp_data { my ($SRCDIR, $DEST) = @_; mkdir_p($DEST); system("cp -av $SRCDIR/* $DEST"); } sub do_it { return if $::testing; my $in = 'interactive'->vnew('su', 'install'); my $w = $in->wait_message(N("Copying data"), N("Configuring your system as Linux install server via NFS or HTTP, this can take a while, so be patient please...")); my $S = $o->{var}{SOURCEDIR}; my $D = $o->{var}{DESTDIR}; if (! -d $D) { mkdir_p($D) } cp_data($o->{var}{SOURCEDIR}, $o->{var}{DESTDIR}); add_install_dir(); add_http_link($o->{var}{DESTDIR}); undef $w; } sub new { my ($class) = @_; bless { o => $o, }, $class; } 1;