summaryrefslogtreecommitdiffstats
path: root/installer/slxos-setup
blob: b43c7e1e312635098211435873709016f4b4f6dc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#! /usr/bin/perl
#
# slxos-setup
#
# (c) 2006 - OpenSLX.com
#
# Oliver Tappe <ot@openslx.com>
#
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;

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);
pod2usage(-msg => $abstract, -verbose => 0, -exitval => 1) if $helpReq;
pod2usage(-verbose => 2) if $manReq;
if ($versionReq) {
	system('slxversion');
	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 (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];

# 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 ossetup-engine for given distro and start it:
my $engine = OpenSLX::OSSetup::Engine->new;
if ($action =~ m[import]i) {
	$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) {
	$engine->initialize($vendorOSName, 'update');
	$engine->updateVendorOS();
} elsif ($action =~ m[install]i) {
	$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");
	}
	if ($source !~ m[^.+::?.+$]) {
		die _tr("Unkown source format given, expected '<hostname>:<path>' or '<hostname>::<module>'!\n");
	}
	$engine->initialize($vendorOSName, 'clone');
	$engine->cloneVendorOS($source);
}

__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

=head2 Installing a Vendor-OS

  slxos-setup install <vendor-os-name>

=head2 Cloning an Operating System to Make a New Vendor-OS

  slxos-setup clone <vendor-os-name> --source=<rsync-source>

=head2 Updating a Vendor-OS

  slxos-setup update <vendor-os-name>

=head2 Importing an Existing Vendor-OS into the Config-DB

  slxos-setup import-into-db <vendor-os-name>

=head2 General Format

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

  Options:
      --help                   brief help message
      --list-installed         show installed vendor-OSes
      --list-supported         show supported distros
      --man                    show full documentation
      --source=<string>        (rsync-)source to clone vendor-OS from
      --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

=head1 OPTIONS

=over 8

=item B<--help>

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=<string>>

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.

=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>'.

=back

=cut