]>
git.proxmox.com Git - dab.git/blob - dab
14 'bootstrap' => '[--exim] [--minimal]',
15 'finalize' => '[--keepmycnf]',
19 'list' => '[--verbose]',
20 'task' => '<postgres|mysql|php> [--version] [--password] [--memlimit]',
21 'install' => '<package or *.pkglist file> ...',
22 'exec' => '<cmd> ...',
33 print STDERR
"\nERROR: $msg\n\n";
35 print STDERR
"USAGE: dab <command> [parameters]\n\n";
37 for my $cmd (sort keys %$commands) {
38 if (my $opts = $commands->{$cmd}) {
39 print STDERR
" dab $cmd $opts\n";
41 print STDERR
" dab $cmd\n";
46 if (scalar (@ARGV) == 0) {
47 print_usage
("no command specified");
51 my $cmdline = join (' ', @ARGV);
52 my $cmd = shift @ARGV;
55 print_usage
("no command specified");
57 } elsif (!exists $commands->{$cmd}) {
58 print_usage
("unknown command '$cmd'");
60 } elsif ($cmd eq 'help') {
67 $dab = PVE
::DAB-
>new() if !$dab;
71 dab-
>writelog ("dab: $cmdline\n");
73 $SIG{INT
} = $SIG{TERM
} = $SIG{QUIT
} = $SIG{HUP
} = sub {
74 die "interrupted by signal\n";
79 die "command '$cmd' expects no arguments.\n" if scalar (@ARGV) != 0;
83 } elsif ($cmd eq 'bootstrap') {
85 if (!GetOptions
($opts, 'exim', 'minimal')) {
89 die "command 'bootstrap' expects no arguments.\n" if scalar (@ARGV) != 0;
92 $dab->bootstrap ($opts);
94 } elsif ($cmd eq 'finalize') {
96 if (!GetOptions
($opts, 'keepmycnf')) {
100 die "command '$cmd' expects no arguments.\n" if scalar (@ARGV) != 0;
102 $dab->finalize($opts);
104 } elsif ($cmd eq 'veid') {
105 die "command '$cmd' expects no arguments.\n" if scalar (@ARGV) != 0;
107 print $dab->{veid
} . "\n";
109 } elsif ($cmd eq 'basedir') {
110 die "command '$cmd' expects no arguments.\n" if scalar (@ARGV) != 0;
112 print $dab->{rootfs
} . "\n";
114 } elsif ($cmd eq 'packagefile') {
115 die "command '$cmd' expects no arguments.\n" if scalar (@ARGV) != 0;
117 print "$dab->{targetname}.tar.gz\n";
119 } elsif ($cmd eq 'list') {
121 if (!GetOptions
('verbose' =>\
$verbose)) {
125 die "command '$cmd' expects no arguments.\n" if scalar (@ARGV) != 0;
127 my $instpkgs = $dab->read_installed ();
129 foreach my $pkg (sort keys %$instpkgs) {
131 my $version = $instpkgs->{$pkg}->{version
};
132 print "$pkg $version\n";
138 } elsif ($cmd eq 'task') {
139 my $task = shift @ARGV;
141 print_usage
("no task specified");
146 if ($task eq 'mysql') {
147 if (!GetOptions
($opts, 'password=s', 'start')) {
151 die "task '$task' expects no arguments.\n" if scalar (@ARGV) != 0;
153 $dab->task_mysql ($opts);
155 } elsif ($task eq 'postgres') {
156 if (!GetOptions
($opts, 'version=s', 'start')) {
160 die "task '$task' expects no arguments.\n" if scalar (@ARGV) != 0;
162 $dab->task_postgres ($opts);
164 } elsif ($task eq 'php') {
165 if (!GetOptions
($opts, 'memlimit=i')) {
169 die "task '$task' expects no arguments.\n" if scalar (@ARGV) != 0;
171 $dab->task_php ($opts);
174 print_usage
("unknown task '$task'");
179 } elsif ($cmd eq 'install' || $cmd eq 'unpack') {
181 foreach my $arg (@ARGV) {
182 if ($arg =~ m/\.pkglist$/) {
184 die "cant open package list '$arg' - $!";
185 while (defined (my $line = <TMP
>)) {
187 next if $line =~ m/^\s*$/;
188 next if $line =~ m/\#/;
189 if ($line =~ m/^\s*(\S+)\s*$/) {
192 die "invalid package name in '$arg' - $line\n";
196 push @$required, $arg;
202 $dab->install ($required, $cmd eq 'unpack');
204 } elsif ($cmd eq 'exec') {
206 $dab->ve_exec (@ARGV);
208 } elsif ($cmd eq 'enter') {
209 die "command '$cmd' expects no arguments.\n" if scalar (@ARGV) != 0;
213 } elsif ($cmd eq 'clean') {
214 die "command '$cmd' expects no arguments.\n" if scalar (@ARGV) != 0;
218 } elsif ($cmd eq 'dist-clean') {
219 die "command '$cmd' expects no arguments.\n" if scalar (@ARGV) != 0;
224 print_usage
("invalid command '$cmd'");
240 dab - Debian LXC Appliance Builder
246 =item B<dab> I<command> I<[OPTIONS]>
250 Downloads the package descriptions form the repository. Also truncates the
253 =item B<dab bootstrap>
255 Bootstrap a debian system and allocate a temporary container (we use IDs 90000
262 Use exim as MTA (we use postfix by default)
266 Do not install standard packages.
272 Print used container ID.
276 Print container private directory.
278 =item B<dab packagefile>
280 Print the appliance file name.
282 =item B<dab install I<pkg ...>>
284 Install 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 are
286 automatically installed.
288 =item B<dab unpack I<pkg ...>>
290 Unpack one or more packages. I<pkg> can also refer to a file named
291 C<xyz.pkglist> which contains a list of packages. All dependencies are
292 automatically unpacked.
294 =item B<dab exec I<CMD> I<ARGS>>
296 Executes command CMD inside the container.
300 Calls C<lxc-attach> - this is for debugging only.
302 =item B<dab task mysql>
304 Install a mysql database server. During appliance generation we use C<admin> as
305 mysql root password (also stored in /root/.my.cnf).
309 =item I<--password=XXX>
311 Specify the mysql root password. The special value C<random> can be use to
312 generate a random root password when the appliance is started first time
313 (stored in /root/.my.cnf)
317 Start the mysql server (if you want to execute sql commands during
318 appliance generation).
322 =item B<dab task postgres>
324 Install a postgres database server.
328 =item I<--version=XXX>
330 Select Postgres version. Posible values are C<7.4>, C<8.1> and C<8.3> (depends
331 on the selected suite).
335 Start the postgres server (if you want to execute sql commands during appliance
340 =item B<dab task php>
346 =item I<--memlimit=i>
348 Set the php I<memory_limit>.
352 =item B<dab finalize>
354 Cleanup everything inside the container and generate the final appliance
361 Do not delete file C</root/.my.cfg> (mysql).
367 List installed packages.
373 Also print package versions.
379 Remove all temporary files and destroy the container.
381 =item B<dab dist-clean>
383 Like clean, but also removes the package cache (except when you specified your
384 own cache directory in the config file)
390 dab is a script to automate the creation of LXC appliances. It is basically a
391 rewrite of debootstrap in perl, but uses LXC instead of chroot and generates
392 LXC templates. Another difference is that it supports multi-stage building of
393 templates. That way you can execute arbitrary scripts between to accomplish
396 Furthermore some common tasks are fully automated, like setting up a database
397 server (mysql or postgres).
399 To accomplish minimal template creation time, packages are cached to a local
400 directory, so you do not need a local debian mirror (although this would speed
403 See http://pve.proxmox.com/wiki/Debian_Appliance_Builder for examples.
405 This script need to be run as root, so it is not recommended to start it on a
406 production machine with running containers. So many people run Proxmox VE
407 inside a KVM or VMWare 64bit virtual machine to build appliances.
409 All generated templates includes an appliance description file. Those can be
410 used to build appliance repositories.
414 Configuration is read from the file C<dab.conf> inside the current working
415 directory. The files contains key value pairs, separated by colon.
419 =item B<Suite:> I<squeeze|wheezy|jessie|trusty|vivid>
421 The Debian or Ubuntu suite.
423 =item B<Source:> I<URL [components]>
425 Defines a source location. By default we use the following for debian:
427 Source: http://ftp.debian.org/debian SUITE main contrib
428 Source: http://security.debian.org SUITE/updates main contrib
430 Note: SUITE is a variable and will be substituted.
432 There are also reasonable defaults for Ubuntu. If you do not specify any source
433 the defaults are used.
435 =item B<Depends:> I<dependencies>
437 Debian like package dependencies. This can be used to make sure that speific
438 package versions are available.
440 =item B<CacheDir>: I<path>
442 Allows you to specify the directory where downloaded packages are cached.
444 =item B<Mirror:> I<SRCURL> => I<DSTURL>
446 Define a mirror location. for example:
448 Mirror: http://ftp.debian.org/debian => ftp://mirror/debian
452 All other settings in this files are also included into the appliance
457 =item B<Name:> I<name>
459 The name of the appliance.
461 Appliance names must consist only of lower case letters (a-z), digits (0-9),
462 plus (+) and minus (-) signs, and periods (.). They must be at least two
463 characters long and must start with an alphanumeric character.
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 been
476 classified. Currently we use the following section names: system, mail
478 =item B<Maintainer:> I<name <email>>
480 The appliance maintainer's name and email address. The name should come first,
481 then the email address inside angle brackets <> (in RFC822 format).
483 =item B<Infopage:> I<URL>
485 Link to web page containing more informations about this appliance.
487 =item B<Description:> I<single line synopsis>
489 extended description over several lines (indended by space) may follow.
493 =head1 Appliance description file
495 All generated templates includes an appliance description file called
499 this is the first file inside the tar archive. That way it can be easily
500 exctracted without scanning the whole archive. The file itself contains
501 informations like a debian C<control> file. It can be used to build appliance
504 Most fields are directly copied from the configuration file C<dab.conf>.
506 Additionally there are some auto-generated files:
510 =item B<Installed-Size:> I<bytes>
512 It gives the total amount of disk space required to install the named
513 appliance. The disk space is represented in megabytes as a simple decimal
516 =item B<Type:> I<type>
518 This is always C<lxc>.
520 =item B<OS:> I<[debian-4.0|debian-5.0|ubuntu-8.0]>
526 Appliance repositories usually add additional fields:
530 =item B<md5sum:> I<md5sum>
538 The following files are created inside your working directory:
540 dab.conf appliance configuration file
542 logfile contains installation logs
544 .veid stores the used container ID
546 cache/* default package cache directory
548 info/* package information cache
552 Dietmar Maurer <dietmar@proxmox.com>
554 Many thanks to Proxmox Server Solutions (www.proxmox.com) for sponsoring this
557 =head1 COPYRIGHT AND DISCLAIMER
559 Copyright (C) 2007-2020 Proxmox Server Solutions GmbH
561 Copyright: dab is under GNU GPL, the GNU General Public License.
563 This program is free software; you can redistribute it and/or modify
564 it under the terms of the GNU General Public License as published by
565 the Free Software Foundation; version 2 dated June, 1991.
567 This program is distributed in the hope that it will be useful,
568 but WITHOUT ANY WARRANTY; without even the implied warranty of
569 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
570 GNU General Public License for more details.
572 You should have received a copy of the GNU General Public License
573 along with this program; if not, write to the
574 Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,