summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Ginies <aginies@mandriva.com>2004-01-15 10:15:23 +0000
committerAntoine Ginies <aginies@mandriva.com>2004-01-15 10:15:23 +0000
commit8ec4124dc0abfc96b20cd01f925baa9768952012 (patch)
treef6b947c13eea47b2e68e4aec83cd49937e72bea9
parentb2f8d6ac7d8acc830af5c5ae232af06498c773b4 (diff)
downloaddrakwizard-8ec4124dc0abfc96b20cd01f925baa9768952012.tar
drakwizard-8ec4124dc0abfc96b20cd01f925baa9768952012.tar.gz
drakwizard-8ec4124dc0abfc96b20cd01f925baa9768952012.tar.bz2
drakwizard-8ec4124dc0abfc96b20cd01f925baa9768952012.tar.xz
drakwizard-8ec4124dc0abfc96b20cd01f925baa9768952012.zip
drak Mandrake Install server
-rw-r--r--installsrv_wizard/Installsrv.pm152
-rw-r--r--installsrv_wizard/Makefile9
2 files changed, 161 insertions, 0 deletions
diff --git a/installsrv_wizard/Installsrv.pm b/installsrv_wizard/Installsrv.pm
new file mode 100644
index 00000000..baa3dded
--- /dev/null
+++ b/installsrv_wizard/Installsrv.pm
@@ -0,0 +1,152 @@
+# version 0.2
+#
+# Copyright (C) 2002,2003 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;
+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 $o = {
+ name => 'Install Server Wizard',
+ var => {
+ DESTDIR => '/var/install/',
+ SOURCEDIR => '/mnt/cdrom/',
+ },
+ needed_rpm => [ 'nfs-utils', 'apache' ],
+ defaultimage => "/usr/share/wizards/dns_wizard/images/Install.png"
+ };
+
+$o->{pages} = {
+ welcome => {
+ name => N("Configure an install server (via NFS and http)") . "\n\n" . N("Easily configure a Mandrake server installation directory, with nfs export 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 an Mandrake installtion.") . "\n\n" . N("Destination Directory: copy file in wich directory ?"),
+ pre => sub {
+ $o->{var}{wiz_nfs} ||= 1;
+ $o->{var}{wiz_http} ||= 1;
+ },
+ data => [
+ { label => "Path to data", val => \$o->{var}{SOURCEDIR} },
+ { label => "Destination Directory:", val => \$o->{var}{DESTDIR} },
+ { 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("Destination directory could not be '/var/install/'") . "\n\n" . N("ie use: /var/install/mdk-release"),
+ next => 'install_srv',
+ },
+ error_dir => {
+ name => N("Error, Source directory must be a directory with full Mandrake installation directory."),
+ next => 'install_srv',
+ },
+ dir_already_use => {
+ name => N("Destination Directory already in use, please choose another one."),
+ next => 'install_srv',
+ },
+ summary_srv => {
+ name => N("I Will configure your install server with those 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,
+ next => 'end',
+ },
+ end => {
+ name => N("Congratulations, Mandrake Install server is now ready."),
+ end => 1,
+ no_back => 1,
+ next => 0
+ },
+ };
+
+
+sub add_install_dir {
+ if (any { /$INSTALLDIR/ } cat_($NFSEXPORTS)) {
+ print " - " . $NFSEXPORTS . " ready\n";
+ } else {
+ append_to_file($NFSEXPORTS, "$INSTALLDIR *(async,rw,no_root_squash)\n");
+ }
+}
+
+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_http_link {
+ my ($PATH) = @_;
+ my $LINK = $WWWDIR . '/' . basename($PATH);
+ if (! -f $LINK) {
+ symlink $PATH, $LINK;
+ }
+}
+
+sub cp_data {
+ my ($SRCDIR, $DEST) = @_;
+ mkdir_p($DEST);
+ cp_af($SRCDIR, $DEST);
+}
+
+sub do_it {
+ return if $::testing;
+ my $in = 'interactive'->vnew('su', 'Install server');
+ my $w = $in->wait_message(N("Install Server"), N("Copying data to destination directory..."));
+ cp_data($o->{var}{SOURCEDIR}, $o->{var}{DESTDIR});
+ add_install_dir();
+ add_http_link($o->{var}{DESTDIR});
+ undef $w;
+}
+
+sub new {
+ my ($class, $conf) = @_;
+ bless {
+ o => $o,
+ }, $class;
+}
+
+1;
diff --git a/installsrv_wizard/Makefile b/installsrv_wizard/Makefile
new file mode 100644
index 00000000..91030b88
--- /dev/null
+++ b/installsrv_wizard/Makefile
@@ -0,0 +1,9 @@
+
+install2:
+ su -c 'make install'
+
+install:
+ mkdir -p --mode=u=rwx,g=rx,o=rx ${prefix}/share/wizards
+ mkdir -p --mode=u=rwx,g=rx,o=rx ${prefix}/share/wizards/installsrv_wizard
+ install --mode=u=rwx,g=rx,o=rx -p ftp.wiz ${prefix}/share/wizards/installsrv_wizard
+