Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 68 lines (47 sloc) 1.63 kb
#!/usr/bin/perl -w
=head1 Name - installation script to clone an existing PG database
=head1 Description
This script is called during "make clone" to clone the Bricolage
=head1 Author
Sam Tregar <>
=head1 See Also
use FindBin;
use File::Spec::Functions qw(:ALL);
print "\n\n==> Cloning Bricolage Database <==\n\n";
our $DB;
do "./database.db" or die "Failed to read database.db: $!";
# Make sure that we don't overwrite the existing Pg.sql.
chdir 'dist';
my $file = 'inst/Pg.sql';
# Switch to postgres system user
if (my $sys_user = $DB->{system_user}) {
print "Becoming $sys_user...\n";
# Make sure that the user can write out inst/Pg.sql.
my $to_chown = -e 'inst/Pg.sql' ? 'inst/Pg.sql' : 'inst';
chown $DB->{system_user_uid}, -1, $to_chown
or die "Cannot chown $to_chown to $DB->{system_user_uid} ($sys_user).\n";
# Become the user.
require Config;
$> = $DB->{system_user_uid};
$< = $DB->{system_user_uid} if $Config::Config{d_setruid};
die "Failed to switch EUID to $DB->{system_user_uid} ($sys_user).\n"
unless $> == $DB->{system_user_uid};
$ENV{PGHOST} = $DB->{host_name} if $DB->{host_name};
$ENV{PGPORT} = $DB->{host_port} if $DB->{host_port};
# dump out postgres database
my @pgdump = (
catfile($DB->{bin_dir}, 'pg_dump'),
'-U', $DB->{root_user},
'-f', $file,
# dump out postgres database
system( @pgdump ) and die 'Error executing `' . join(' ', @pgdump), "`\n";
print "\n\n==> Finished cloning Bricolage Database <==\n\n";
Jump to Line
Something went wrong with that request. Please try again.