From d9d770dd60b48eb5a615d2949a909319c5ecce03 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Thu, 22 Mar 2007 23:27:12 +0000 Subject: * adjusted argument conventions to a more sensible separation between options and actions * finished PODs git-svn-id: http://svn.openslx.org/svn/openslx/trunk@802 95ad53e4-c205-0410-b2fa-d234c58c8868 --- installer/slxos-export | 107 ++++++++++++++------------ installer/slxos-setup | 199 ++++++++++++++++++++++++++++--------------------- 2 files changed, 174 insertions(+), 132 deletions(-) (limited to 'installer') diff --git a/installer/slxos-export b/installer/slxos-export index d2a139d9..cd9f763a 100755 --- a/installer/slxos-export +++ b/installer/slxos-export @@ -33,18 +33,12 @@ use OpenSLX::OSExport::Engine; my ( $helpReq, $manReq, - $listExportedReq, - $listInstalledReq, - $listTypesReq, $verbose, $versionReq, ); GetOptions( 'help|?' => \$helpReq, - 'list-exported' => \$listExportedReq, - 'list-installed' => \$listInstalledReq, - 'list-types' => \$listTypesReq, 'man' => \$manReq, 'verbose' => \$verbose, 'version' => \$versionReq, @@ -58,7 +52,9 @@ if ($versionReq) { openslxInit(); -if ($listExportedReq) { +my $action = shift @ARGV; + +if ($action =~ m[^list-ex]i) { print _tr("List of exported vendor-OSes:\n"); foreach my $type (sort keys %supportedExportTypes) { print join('', map { @@ -67,44 +63,45 @@ if ($listExportedReq) { } sort <$openslxConfig{'export-path'}/$type/*>); } - exit 1; -} -if ($listInstalledReq) { +} elsif ($action =~ m[^list-in]i) { print _tr("List of installed vendor-OSes:\n"); print join('', map { s[^.+/][]; "\t$_\n"; } sort <$openslxConfig{'stage1-path'}/*>); - exit 1; -} -if ($listTypesReq) { +} elsif ($action =~ m[^list-ty]i) { print _tr("List of supported export types:\n\t"); print join("\n\t", sort keys %supportedExportTypes)."\n"; - exit 1; -} - -if (scalar(@ARGV) != 2) { - print STDERR _tr("You need to specify exactly one vendor-os-name and one export-type!\n"); - pod2usage(2); -} -my $vendorOSName = $ARGV[0]; -my $exportType = $ARGV[1]; - -# we chdir into the script's folder such that all relative paths have -# a known starting point: -chdir($FindBin::RealBin) - or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); - - -# create OSExport-engine for given export type and start it: -my $engine = OpenSLX::OSExport::Engine->new; -$engine->initialize($vendorOSName, $exportType); -if (!-e $engine->{'vendor-os-path'}) { - die _tr("vendor-OS '%s' doesn't exist, giving up!\n", - $engine->{'vendor-os-path'}); +} elsif ($action =~ m[^export]i) { + if (scalar(@ARGV) != 2) { + print STDERR _tr("You need to specify exactly one vendor-os-name and one export-type!\n"); + pod2usage(2); + } + my $vendorOSName = shift @ARGV; + my $exportType = shift @ARGV; + + # we chdir into the script's folder such that all relative paths have + # a known starting point: + chdir($FindBin::RealBin) + or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); + + # create OSExport-engine for given export type and start it: + my $engine = OpenSLX::OSExport::Engine->new; + $engine->initialize($vendorOSName, $exportType); + if (!-e $engine->{'vendor-os-path'}) { + die _tr("vendor-OS '%s' doesn't exist, giving up!\n", + $engine->{'vendor-os-path'}); + } + $engine->exportVendorOS(); +} else { + print STDERR _tr("You need to specify exactly one action: + export + list-exported + list-installed + list-types +Try '$0 --help' for more info.\n"); } -$engine->exportVendorOS(); __END__ @@ -117,14 +114,25 @@ via a squashfs inside of a network block device. =head1 SYNOPSIS -slxos-export [options] +slxos-export [options] Options: --help brief help message - --list show available export-types --man show full documentation + --verbose show more information during execution --version show version + Actions: + export + exports the vendor-OS with the given name via + the given export type + list-exported + list all exported vendor-OSes + list-installed + list all installed vendor-OSes + list-types + list all supported export types + =head1 OPTIONS =over 8 @@ -133,26 +141,27 @@ slxos-export [options] Prints a brief help message and exits. -=item B<--list-exported> +=item B<--man> -Lists all exported vendor-OSes and exits. +Prints the manual page and exits. -=item B<--list-installed> +=item B<--verbose> -Lists all installed vendor-OSes and exits. +Prints more information during execution of any action. -=item B<--list-types> +=item B<--version> -Lists all supported export types and exits. +Prints the version and exits. -=item B<--man> +=back -Prints the manual page and exits. +=head1 EXAMPLES -=item B<--version> +=head2 Exporting a Vendor-OS -Prints the version and exits. + slxos-export export suse-10.2 nfs -=back + exports the installed vendor-OS suse-10.2 via nfs, the resulting + NFS-export will live in '/srv/openslx/export/nfs/suse-10.2' =cut \ No newline at end of file diff --git a/installer/slxos-setup b/installer/slxos-setup index b43c7e1e..9a14921d 100755 --- a/installer/slxos-setup +++ b/installer/slxos-setup @@ -29,26 +29,16 @@ use lib "$FindBin::RealBin/../config-db"; use OpenSLX::Basics; use OpenSLX::OSSetup::Engine; -if ($> != 0) { - die _tr("Sorry, this script can only be executed by the superuser!\n"); -} - my ( $helpReq, - $listInstalledReq, - $listSupportedReq, $manReq, - $source, $verbose, $versionReq, ); GetOptions( 'help|?' => \$helpReq, - 'list-installed' => \$listInstalledReq, - 'list-supported' => \$listSupportedReq, 'man' => \$manReq, - 'source=s' => \$source, 'verbose' => \$verbose, 'version' => \$versionReq, ) or pod2usage(2); @@ -59,67 +49,96 @@ if ($versionReq) { exit 1; } -openslxInit(); - -if ($listSupportedReq) { - print _tr("List of supported distros:\n"); - print join('', map { - "\t$_" - .(' 'x(20-length($_))) - ."\t($supportedDistros{$_}->{support})\n" - } - sort keys %supportedDistros); - exit 1; -} -if ($listInstalledReq) { - print _tr("List of installed vendor-OSes:\n"); - print join('', map { - s[^.+/][]; - "\t$_\n"; - } - sort <$openslxConfig{'stage1-path'}/*>); - exit 1; +if ($> != 0) { + die _tr("Sorry, this script can only be executed by the superuser!\n"); } -if (scalar(@ARGV) != 2) { - print STDERR _tr("You need to specify exactly one action and one vendor-OS name!\n"); - pod2usage(2); -} -my $action = $ARGV[0]; -if ($action !~ m[^clone|import-into-db|install|update$]i) { - print STDERR _tr("You need to specify exactly one action:\n\tinstall, update, clone or import-into-db\n"); - pod2usage(2); -} -my $vendorOSName = $ARGV[1]; +openslxInit(); -# we chdir into the script's folder such that all relative paths have -# a known starting point: -chdir($FindBin::RealBin) - or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); +my $action = shift @ARGV; # create ossetup-engine for given distro and start it: my $engine = OpenSLX::OSSetup::Engine->new; if ($action =~ m[import]i) { + my $vendorOSName = shift @ARGV; + if (!defined $vendorOSName) { + print STDERR _tr("You need to give the name of the vendor-os you'd like to import!\n"); + pod2usage(2); + } + # we chdir into the script's folder such that all relative paths have + # a known starting point: + chdir($FindBin::RealBin) + or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); $engine->initialize($vendorOSName, 'import'); if (!-e $engine->{'vendor-os-path'}) { die _tr("'%s' doesn't exist, giving up!\n", $engine->{'vendor-os-path'}); } $engine->addInstalledVendorOSToConfigDB(); } elsif ($action =~ m[update]i) { + my $vendorOSName = shift @ARGV; + if (!defined $vendorOSName) { + print STDERR _tr("You need to give the name of the vendor-os you'd like to update!\n"); + pod2usage(2); + } + # we chdir into the script's folder such that all relative paths have + # a known starting point: + chdir($FindBin::RealBin) + or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); $engine->initialize($vendorOSName, 'update'); $engine->updateVendorOS(); } elsif ($action =~ m[install]i) { + my $vendorOSName = shift @ARGV; + if (!defined $vendorOSName) { + print STDERR _tr("You need to give the name of the vendor-os you'd like to install!\n"); + pod2usage(2); + } + # we chdir into the script's folder such that all relative paths have + # a known starting point: + chdir($FindBin::RealBin) + or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); $engine->initialize($vendorOSName, 'install'); $engine->installVendorOS(); } elsif ($action =~ m[clone]i) { - if (!length($source)) { - die _tr("You need to specify a source you'd like to clone!\n"); + my $vendorOSName = shift @ARGV; + my $srcString = shift @ARGV; + if ($srcString !~ m[^\s*source=(.+?)\s*$]) { + print STDERR _tr("You need to specify a source you'd like to clone!\n"); + pod2usage(2); } + my $source = $1; if ($source !~ m[^.+::?.+$]) { die _tr("Unkown source format given, expected ':' or '::'!\n"); } + # we chdir into the script's folder such that all relative paths have + # a known starting point: + chdir($FindBin::RealBin) + or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); $engine->initialize($vendorOSName, 'clone'); $engine->cloneVendorOS($source); +} elsif ($action =~ m[list-su]i) { + print _tr("List of supported distros:\n"); + print join('', map { + "\t$_" + .(' 'x(20-length($_))) + ."\t($supportedDistros{$_}->{support})\n" + } + sort keys %supportedDistros); +} elsif ($action =~ m[list-in]i) { + print _tr("List of installed vendor-OSes:\n"); + print join('', map { + s[^.+/][]; + "\t$_\n"; + } + sort <$openslxConfig{'stage1-path'}/*>); +} else { + print STDERR _tr("You need to specify exactly one action: + clone + import-into-db + install + list-supported + list-installed + update +Try '$0 --help' for more info.\n"); } __END__ @@ -131,39 +150,27 @@ will be used as a OpenSLX-stage1-system (a.k.a. vendor-OS). =head1 SYNOPSIS -=head2 Installing a Vendor-OS - - slxos-setup install - -=head2 Cloning an Operating System to Make a New Vendor-OS - - slxos-setup clone --source= - -=head2 Updating a Vendor-OS - - slxos-setup update - -=head2 Importing an Existing Vendor-OS into the Config-DB - - slxos-setup import-into-db - -=head2 General Format - slxos-setup [options] Options: --help brief help message - --list-installed show installed vendor-OSes - --list-supported show supported distros --man show full documentation - --source= (rsync-)source to clone vendor-OS from + --verbose show more information during execution --version show version Actions: - clone clones an existing operating system via rsync - import-into-db imports a vendor-OS into the openslx-db - install installs a vendor-OS into a folder - update updates an installed vendor-OS + clone source= + clones an existing operating system via rsync + import-into-db + imports a vendor-OS into the openslx-db + install + installs a vendor-OS into a folder + list-installed + show installed vendor-OSes + list-supported + show supported distros + update + updates an installed vendor-OS =head1 OPTIONS @@ -173,23 +180,13 @@ will be used as a OpenSLX-stage1-system (a.k.a. vendor-OS). Prints a brief help message and exits. -=item B<--list-installed> - -Lists all installed vendor-OSes and exits. - -=item B<--list-supported> - -Lists all supported distros and exits. - =item B<--man> Prints the manual page and exits. -=item B<--source=> +=item B<--verbose> -When cloning a vendor-OS, slxos-setup needs to know where to fetch -the existing OS-files from. You can specify the rsync-uri with this -option. +Prints more information during execution of any action. =item B<--version> @@ -222,6 +219,42 @@ In clone-mode, it is a good idea to specify some unqiue string as the selection part of the vendor-os-name, such that you will easily recognize the vendor-OS at a later stage. We recommend something like '-cloned-from-'. +=item B + +When cloning a vendor-OS, slxos-setup needs to know where to fetch +the existing OS-files from. Please check the 'rsync' docs for what +format an rsync-uri has. + =back +=head1 EXAMPLES + +=head2 Installing a Vendor-OS + + slxos-setup install suse-10.2 + + installs the distro suse-10.2 as a new vendor-OS + + slxos-setup install suse-10.2-gnome + + installs the 'gnome'-selection of distro suse-10.2 as a new vendor-OS + +=head2 Cloning an Operating System to Make a New Vendor-OS + + slxos-setup clone suse-10.2 --source=my_server:/ + + clones the suse-10.2 system from server 'my_server' + +=head2 Updating a Vendor-OS + + slxos-setup update suse-10.2 + + updates the (existing) vendor-OS 'suse-10.2' + +=head2 Importing an Existing Vendor-OS into the Config-DB + + slxos-setup import-into-db suse-10.2 + + imports the (existing) vendor-OS 'suse-10.2' into the config-DB + =cut \ No newline at end of file -- cgit v1.2.3-55-g7522