summaryrefslogblamecommitdiffstats
path: root/installer/slxos-setup
blob: 50b12f826060761972863d397721e216118e1da1 (plain) (tree)
1
2
3
4
5
6
7
8
9
                

                                                                               
 

                                                                    
 

                                                                         
 

                                                                               
















                                                                              


                                         


                             


                 





                              
                          



                                                                       





                                                                                   




                             

                                                                               
 
 
              
 
                         
 
                                                      
                                           
                             








                                                                                                       
                                                     

                                                                                         

                                                  
                                  








                                                                                                       
                                                     
                                  
                                   








                                                                                                        
                                                      
                                   
                                 




                                                                                        
         
                        


                                                                                                                 



                                                                                         
                                                    
                                        
                                   






                                                                                  
                                   













                                                                           
                                       






                                                                               
                                                           


               
                                                 



                                                      
                                                                     

                                           
          











                                                                            
 











                                      
                  
 
                                                       
 



                             






















                                                                             


                                                                                    
 





                                                                  

     













                                                                           
                                                                
 

                                                                             












                                                                     
   
#! /usr/bin/perl
# -----------------------------------------------------------------------------
# Copyright (c) 2006, 2007 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your suggestions, praise, or complaints to feedback@openslx.org
#
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
use strict;

my $abstract = q[
slxos-setup
    This script installs an operating system into a folder that can be used as
    a stage1 system for OpenSLX.
];

use Getopt::Long qw(:config pass_through);
use Pod::Usage;

# add the folder this script lives in and the lib-folder to perl's
# search path for modules:
use FindBin;
use lib "$FindBin::RealBin";
use lib "$FindBin::RealBin/../lib";

use lib "$FindBin::RealBin/../config-db";
	# development path to config-db

use OpenSLX::Basics;
use OpenSLX::OSSetup::Engine;

my (
	$helpReq,
	$manReq,
	$verbose,
	$versionReq,
);

GetOptions(
	'help|?' => \$helpReq,
	'man' => \$manReq,
	'verbose' => \$verbose,
	'version' => \$versionReq,
) or pod2usage(2);
pod2usage(-msg => $abstract, -verbose => 0, -exitval => 1) if $helpReq;
if ($manReq) {
	$ENV{LANG} = 'en_EN';
		# avoid dubious problem with perldoc in combination with UTF-8 that
		# leads to strange dashes and single-quotes being used
	pod2usage(-verbose => 2)
}
if ($versionReq) {
	system('slxversion');
	exit 1;
}

if ($> != 0) {
	die _tr("Sorry, this script can only be executed by the superuser!\n");
}

openslxInit();

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) {
	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 '<hostname>:<path>' or '<hostname>::<module>'!\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 '%s --help' for more info.\n", $0);
}

__END__

=head1 NAME

slxos-setup - OpenSLX-script to install an operating system into a folder which
will be used as a OpenSLX-stage1-system (a.k.a. vendor-OS).

=head1 SYNOPSIS

  slxos-setup [options] <action> <vendor-os-name>

  Options:
      --help                   brief help message
      --man                    show full documentation
      --verbose                show more information during execution
      --version                show version

  Actions:
      clone <vendor-os-name> source=<rsync-uri>
                               clones an existing operating system via rsync
      import-into-db <vendor-os-name>
                               imports a vendor-OS into the openslx-db
      install <vendor-os-name>
                               installs a vendor-OS into a folder
      list-installed
                               show installed vendor-OSes
      list-supported
                               show supported distros
      update <vendor-os-name>
                               updates an installed vendor-OS

=head1 OPTIONS

=over 8

=item B<--help>

Prints a brief help message and exits.

=item B<--man>

Prints the manual page and exits.

=item B<--verbose>

Prints more information during execution of any action.

=item B<--version>

Prints the version and exits.

=item B<vendor-os-name>

The vendor-os-name is the name of the vendor-OS that shall be installed,
cloned, imported or updated. It corresponds to a folder in the OpenSLX-
stage1-path (usually /var/opt/openslx/stage1).
The general format of a vendor-os-name is this:

	<distro-name>-<release-version>
or
	<distro-name>-<release-version>-<selection>

The distro-name is something like 'suse' or 'fedora', and the release-version
is a numerical version, e.g. '10.1' or '6'.

If you specify a selection, too, you state that you want all the packages
that are provided by the specific selection (many distributions offer several
different package selections for installation, like 'kde' or 'gnome').
If you do not specify any selection, you will get the default selection of
that distribution.

If you pass an unknown selection, you will see a list of the selections
that are available.

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-<name-of-rsync-source>'.

=item B<rsync-uri>

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-clone-my_server source=my_server:/

      clones the suse-10.2 system from server 'my_server' as a new vendor-OS,
      which will be named 'suse-10.2-clone-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