]>
git.proxmox.com Git - dab.git/blob - dab
13 print STDERR
"ERROR: $msg\n";
15 print STDERR
"dab <command> [parameters]\n";
19 if (scalar (@ARGV) == 0) {
24 my $cmdline = join (' ', @ARGV);
26 my $cmd = shift @ARGV;
29 print_usage
("no command specified");
33 my $dab = PVE
::DAB-
>new();
35 $dab->writelog ("dab: $cmdline\n");
37 $SIG{INT
} = $SIG{TERM
} = $SIG{QUIT
} = $SIG{HUP
} = sub {
38 die "interrupted by signal\n";
45 die "command '$cmd' expects no arguments.\n" if scalar (@ARGV) != 0;
49 } elsif ($cmd eq 'bootstrap') {
53 if (!GetOptions
($opts, 'exim', 'minimal')) {
58 die "command 'bootstrap' expects no arguments.\n" if scalar (@ARGV) != 0;
62 $dab->bootstrap ($opts);
64 } elsif ($cmd eq 'finalize') {
68 if (!GetOptions
($opts, 'keepmycnf')) {
73 die "command '$cmd' expects no arguments.\n" if scalar (@ARGV) != 0;
75 $dab->finalize($opts);
77 } elsif ($cmd eq 'veid') {
79 die "command '$cmd' expects no arguments.\n" if scalar (@ARGV) != 0;
81 print $dab->{veid
} . "\n";
83 } elsif ($cmd eq 'basedir') {
85 die "command '$cmd' expects no arguments.\n" if scalar (@ARGV) != 0;
87 print $dab->vz_priv_dir() . "\n";
89 } elsif ($cmd eq 'packagefile') {
91 die "command '$cmd' expects no arguments.\n" if scalar (@ARGV) != 0;
93 print "$dab->{targetname}.tar.gz\n";
95 } elsif ($cmd eq 'list') {
99 if (!GetOptions
('verbose' =>\
$verbose)) {
104 die "command '$cmd' expects no arguments.\n" if scalar (@ARGV) != 0;
106 my $instpkgs = $dab->read_installed ();
108 foreach my $pkg (sort keys %$instpkgs) {
110 my $version = $instpkgs->{$pkg}->{version
};
111 print "$pkg $version\n";
117 } elsif ($cmd eq 'task') {
119 my $task = shift @ARGV;
122 print_usage
("no task specified");
128 if ($task eq 'mysql') {
130 if (!GetOptions
($opts, 'password=s', 'start')) {
135 die "task '$task' expects no arguments.\n" if scalar (@ARGV) != 0;
137 $dab->task_mysql ($opts);
139 } elsif ($task eq 'postgres') {
141 if (!GetOptions
($opts, 'version=s', 'start')) {
146 die "task '$task' expects no arguments.\n" if scalar (@ARGV) != 0;
148 $dab->task_postgres ($opts);
150 } elsif ($task eq 'php') {
152 if (!GetOptions
($opts, 'memlimit=i')) {
157 die "task '$task' expects no arguments.\n" if scalar (@ARGV) != 0;
159 $dab->task_php ($opts);
163 print_usage
("unknown task '$task'");
168 } elsif ($cmd eq 'install' || $cmd eq 'unpack') {
171 foreach my $arg (@ARGV) {
172 if ($arg =~ m/\.pkglist$/) {
174 die "cant open package list '$arg' - $!";
175 while (defined (my $line = <TMP
>)) {
177 next if $line =~ m/^\s*$/;
178 next if $line =~ m/\#/;
179 if ($line =~ m/^\s*(\S+)\s*$/) {
182 die "invalid package name in '$arg' - $line\n";
186 push @$required, $arg;
192 $dab->install ($required, $cmd eq 'unpack');
194 } elsif ($cmd eq 'exec') {
196 $dab->ve_exec (@ARGV);
198 } elsif ($cmd eq 'enter') {
200 die "command '$cmd' expects no arguments.\n" if scalar (@ARGV) != 0;
204 } elsif ($cmd eq 'clean') {
206 die "command '$cmd' expects no arguments.\n" if scalar (@ARGV) != 0;
210 } elsif ($cmd eq 'dist-clean') {
212 die "command '$cmd' expects no arguments.\n" if scalar (@ARGV) != 0;
217 print_usage
("invalid command '$cmd'");
234 dab - Debian OpenVZ Appliance Builder
240 =item B<dab> I<command> I<[OPTIONS]>
244 Downloads the package descriptions form the
245 repository. Also truncates the C<logfile>.
247 =item B<dab bootstrap>
249 Bootstrap a debian system and allocate a
250 temporary container (we use IDs 90000 and above).
256 Use exim as MTA (we use postfix by default)
260 Do not install standard packages.
266 Print used container ID.
270 Print container private directory.
272 =item B<dab packagefile>
274 Print the appliance file name.
276 =item B<dab install I<pkg ...>>
278 Install one or more packages. I<pkg> can also refer to a file named
279 C<xyz.pkglist> which contains a list of packages. All dependencies
280 are automatically installed.
282 =item B<dab unpack I<pkg ...>>
284 Unpack one or more packages. I<pkg> can also refer to a file named
285 C<xyz.pkglist> which contains a list of packages. All dependencies
286 are automatically unpacked.
288 =item B<dab exec I<CMD> I<ARGS>>
290 Executes command CMD inside the container.
294 Calls C<vzctl enter CTID> - this is for debugging only.
296 =item B<dab task mysql>
298 Install a mysql database server. During appliance generation we use
299 C<admin> as mysql root password (also stored in /root/.my.cnf).
303 =item I<--password=XXX>
305 Specify the mysql root password. The special value C<random> can be
306 use to generate a random root password when the appliance is started
307 first time (stored in /root/.my.cnf)
311 Start the mysql server (if you want to execute sql commands during
312 appliance generation).
316 =item B<dab task postgres>
318 Install a postgres database server.
322 =item I<--version=XXX>
324 Select Postgres version. Posible values are C<7.4>, C<8.1> and C<8.3>
325 (depends on the selected suite).
329 Start the postgres server (if you want to execute sql commands during
330 appliance generation).
334 =item B<dab task php>
340 =item I<--memlimit=i>
342 Set the php I<memory_limit>.
346 =item B<dab finalize>
348 Cleanup everything inside the container and generate the final
355 Do not delete file C</root/.my.cfg> (mysql).
361 List installed packages.
367 Also print package versions.
373 Remove all temporary file and destroy the used OpenVZ container.
375 =item B<dab dist-clean>
377 Like clean, but also removes the package cache (except when you
378 specified your own cache directory in the config file)
384 dab is a script to automate the creation of OpenVZ appliances. It is
385 basically a rewrite of debootstrap in perl, but uses OpenVZ instead of
386 chroot and generates OpenVZ templates. Another difference is that it
387 supports multi-stage building of templates. That way you can execute
388 arbitrary scripts between to accomplish what you want.
390 Furthermore some common tasks are fully automated, like setting up a
391 database server (mysql or postgres).
393 To accomplish minimal template creation time, packages are cached to a
394 local directory, so you do not need a local debian mirror (although
395 this would speed up the first run).
397 See http://pve.proxmox.com/wiki/Debian_Appliance_Builder for examples.
399 This script need to be run as root, so it is not recommended to start
400 it on a production machine with running container. Proxmox VE
401 (http://pve.proxmox.com) is the preferred environment, because it is
402 able to log the console output when a container starts. You wont be
403 able to detect errors during container startup when running on
404 standard OpenVZ. So many people run Proxmox VE inside a KVM or VMWare
405 64bit virtual machine to build appliances.
407 All generated templates includes an appliance description file. Those
408 can be used to build appliance repositories.
412 Configuration is read from the file C<dab.conf> inside the current working
413 directory. The files contains key value pairs, separated by colon.
417 =item B<Suite:> I<etch|lenny|squeeze|hardy|intrepid|jaunty>
419 The Debian or Ubuntu suite.
421 =item B<Source:> I<URL [components]>
423 Defines a source location. By default we use the following for debian:
425 Source: http://ftp.debian.org/debian SUITE main contrib
426 Source: http://security.debian.org SUITE/updates main contrib
428 Note: SUITE is a variable and will be substituted.
430 There are also reasonable defaults for Ubuntu. If you do not specify
431 any source the defaults are used.
433 =item B<Depends:> I<dependencies>
435 Debian like package dependencies. This can be used to make sure that
436 speific package versions are available.
438 =item B<CacheDir>: I<path>
440 Allows you to specify the directory where downloaded packages are
443 =item B<Mirror:> I<SRCURL> => I<DSTURL>
445 Define a mirror location. for example:
447 Mirror: http://ftp.debian.org/debian => ftp://mirror/debian
451 All other settings in this files are also included into the appliance
456 =item B<Name:> I<name>
458 The name of the appliance.
460 Appliance names must consist only of lower case letters (a-z), digits
461 (0-9), plus (+) and minus (-) signs, and periods (.). They must be at
462 least two characters long and must start with an alphanumeric
465 =item B<Architecture:> I<i386|amd64>
469 =item B<Version:> I<upstream_version[-build_revision]>
471 The version number of an appliance.
473 =item: B<Section:> I<section>
475 This field specifies an application area into which the appliance has
476 been classified. Currently we use the following section names: system,
479 =item B<Maintainer:> I<name <email>>
481 The appliance maintainer's name and email address. The name should
482 come first, then the email address inside angle brackets <> (in RFC822
485 =item B<Infopage:> I<URL>
487 Link to web page containing more informations about this appliance.
489 =item B<Description:> I<single line synopsis>
491 extended description over several lines (indended by space) may follow.
495 =head1 Appliance description file
497 All generated templates includes an appliance description file called
501 this is the first file inside the tar archive. That way it can be
502 easily exctracted without scanning the whole archive. The file itself
503 contains informations like a debian C<control> file. It can be used to
504 build appliance repositories.
506 Most fields are directly copied from the configuration file C<dab.conf>.
508 Additionally there are some auto-generated files:
512 =item B<Installed-Size:> I<bytes>
514 It gives the total amount of disk space required to install the named
515 appliance. The disk space is represented in megabytes as a simple
518 =item B<Type:> I<type>
520 This is always C<openvz>.
522 =item B<OS:> I<[debian-4.0|debian-5.0|ubuntu-8.0]>
528 Appliance repositories usually add additional fields:
532 =item B<md5sum:> I<md5sum>
540 The following files are created inside your working directory:
542 dab.conf appliance configuration file
544 logfile contains installation logs
546 .veid stores the used container ID
548 cache/* default package cache directory
550 info/* package information cache
554 Dietmar Maurer <dietmar@proxmox.com>
556 Many thanks to Proxmox Server Solutions (www.proxmox.com) for sponsoring
559 =head1 COPYRIGHT AND DISCLAIMER
561 Copyright (C) 2007-2012 Proxmox Server Solutions GmbH
563 Copyright: dab is under GNU GPL, the GNU General Public License.
565 This program is free software; you can redistribute it and/or modify
566 it under the terms of the GNU General Public License as published by
567 the Free Software Foundation; version 2 dated June, 1991.
569 This program is distributed in the hope that it will be useful,
570 but WITHOUT ANY WARRANTY; without even the implied warranty of
571 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
572 GNU General Public License for more details.
574 You should have received a copy of the GNU General Public License
575 along with this program; if not, write to the
576 Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,