/usr/bin/openguides-setup-db is in openguides 0.76-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 | #!/usr/bin/perl
use strict;
use warnings;
use OpenGuides::Config;
my $config_file = shift or die "Must specify config file on command line!";
if ( ! -r $config_file ) {
die "Config file specified is not readable: $!";
}
my $config = OpenGuides::Config->new( file => $config_file);
# Initialise the database if necessary.
my $dbname = $config->dbname;
my $dbuser = $config->dbuser;
my $dbpass = $config->dbpass;
my $dbhost = $config->dbhost;
my $dbtype = $config->dbtype;
my %cgi_wiki_exts = ( postgres => "Pg",
mysql => "MySQL",
sqlite => "SQLite" );
my %dbd_exts = ( postgres => "Pg",
mysql => "mysql",
sqlite => "SQLite" );
my $cgi_wiki_module = "Wiki::Toolkit::Setup::" . $cgi_wiki_exts{$dbtype};
my $dbd_module = "DBD::" . $dbd_exts{$dbtype};
eval "require $dbd_module";
if ($@) {
print "The DBD module is probably not installed;\n";
print "we won't set up the database now.\n";
exit 0;
}
eval "require $cgi_wiki_module";
if ($@) {
print "The DBD module is probably not installed;\n";
print "we won't set up the database now.\n";
exit 0;
}
print "Checking database schema...\n";
{
no strict 'refs';
&{$cgi_wiki_module . "::setup"}( $dbname, $dbuser, $dbpass, $dbhost );
}
|