diff --git a/INSTALL b/INSTALL index ef0f369..b275a48 100644 --- a/INSTALL +++ b/INSTALL @@ -382,6 +382,8 @@ A default init script is provided in file web/conf/mioga2.init.d. This script wo Additional configuration for the Search engine ---------------------------------------------- +The default init script starts the search engine daemon. + You must edit the crawl_sample.sh to specify default location for configuration files and rename it to crawl.sh. This script must be run by cron in a day basis with apache user (www-data for Debian) diff --git a/Makefile.PL b/Makefile.PL index 3582d20..46608ca 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -20,8 +20,10 @@ # ============================================================================ +use Cwd; use ExtUtils::MakeMaker; use ExtUtils::MakeMaker::Config; +use File::Find; # **************************************************************************** # @@ -67,6 +69,7 @@ sub CheckPreDepends { my $disable_check = grep {lc($_) eq 'disable_check'} @ARGV; +if (! $disable_check) { CheckPreDepends({ # 'Data::Dumper' => '2.101', # 'DBI' => '1.13', # 'DBD::Pg' => '1.01', @@ -75,7 +78,8 @@ CheckPreDepends({ # 'Data::Dumper' => '2.101', 'Error' => '0.15', # 'Net::LDAP' => '0.25', # 'Unicode::String' => '2.06', - }); + }) +} require MiogaConf; @@ -115,7 +119,7 @@ my $docsubdirs = "docs"; # ---------------------------------------------------------------------------- sub MY::processPL { return ' -# Not realy in the good section, but at a good place: +# Not really in the good section, but at a good place: # between "all" and next "tardist" include config.mk @@ -124,10 +128,7 @@ tardist: doc dist: doc install :: if test -e $(TMP_DIR) ; then \ - if test -d $(TMP_DIR) ; then \ - ( su - $(APACHE_USER) -c "id" -s /bin/sh || \ - ( echo "===> Problem with \"$(APACHE_USER)\" user" ; exit 1 ) ) \ - else \ + if ! test -d $(TMP_DIR) ; then \ echo "===> File $(TMP_DIR) exists but is not a directory ..." ; \ exit 1 ; \ fi \ @@ -156,6 +157,31 @@ install-all :: (cd web && $(MAKE) setperms) || exit 1; +slapos-compilation :: install + for i in bin locales web ; \ + do \ + (cd $$i && $(MAKE) install) || exit 1;\ + done + # Create symlinks for static content that can be shared among all SlapOS instances + for i in var/lib/Mioga2/static var/lib/Mioga2/conf/themes/default var/lib/Mioga2/conf/xsl; do \ + mkdir -p `dirname "$(MIOGA_STATIC)/$$i"` && \ + mv "$(MIOGA_BASE)/$$i" "$(MIOGA_STATIC)/$$i" && \ + ln -s "$(MIOGA_STATIC)/$$i" "$(MIOGA_BASE)/$$i"; \ + done + # copy a minimal build system into mioga/build + mkdir -p "$(MIOGA_BUILDINST)" + cp -R --parents \ + Makefile.PL sql web/conf conf bin/search/crawl_sample.sh \ + "$(MIOGA_BUILDINST)" + +slapos-instantiation :: + for i in web/conf conf sql ; \ + do \ + (cd $$i && $(MAKE) install) || exit 1;\ + done + + (cd web && $(MAKE) setperms) || exit 1; + doc: for i in ' . $docsubdirs . ' ; \ do \ @@ -176,9 +202,26 @@ installall: install install-all # # ---------------------------------------------------------------------------- +my $Mioga2_pm = 'lib/Mioga2.pm'; +foreach my $envkey (keys %ENV) { + print "VHH DEBUG: found envvar $envkey\n"; +} +if ((not -e $Mioga2_pm) and exists($ENV{MIOGA_SITEPERL})) { + print "VHH DEBUG: looking into SITEPERL\n"; + my $findfile = sub { + if ($_ eq 'Mioga2.pm') { + $Mioga2_pm = $File::Find::name; + print "VHH DEBUG: Found Mioga2.pm in $Mioga2_pm\n"; + } + }; + find($findfile, $ENV{MIOGA_SITEPERL}); +}; +print "VHH DEBUG: Found finally: $Mioga2_pm\n"; +print 'VHH DEBUG: SIZE = ' . ( stat($Mioga2_pm) )[8] . "\n"; +print "VHH DEBUG: Current directory is ".getcwd."\n"; WriteMakefile( 'NAME' => 'Mioga', 'DIR' => ['bin', 'web', 'locales', 'docs', 'sql'], - 'VERSION_FROM' => 'lib/Mioga2.pm', + 'VERSION_FROM' => $Mioga2_pm, ); diff --git a/bin/mailinglist/miogamailinglist.pl b/bin/mailinglist/miogamailinglist.pl index 80668e2..fa1603a 100755 --- a/bin/mailinglist/miogamailinglist.pl +++ b/bin/mailinglist/miogamailinglist.pl @@ -205,11 +205,11 @@ sub MsgSendStock sub CheckUTF8 { my ($str) = @_; - my $conv = Text::Iconv->new('utf8', 'utf8'); + my $conv = Text::Iconv->new('UTF-8', 'UTF-8'); my $tmp_str = $conv->convert($str); unless ($tmp_str) { my $charset = detect($str) || 'iso-8859-15'; # defaults to latin9 - $conv = Text::Iconv->new($charset, "utf8"); + $conv = Text::Iconv->new($charset, "UTF-8"); $str = $conv->convert($str); } return $str; diff --git a/bin/notifier/searchengine.pl b/bin/notifier/searchengine.pl index efd1ca2..fc5ba67 100755 --- a/bin/notifier/searchengine.pl +++ b/bin/notifier/searchengine.pl @@ -39,8 +39,7 @@ if (!open(FIFO, "+>$fifo")) { syslog('err', "Can't open fifo: $!. Exiting..."); } my $flags = fcntl(FIFO, F_GETFL, 0); - - +my $crawler = $config->GetBinariesDir()."/crawl.sh"; # MAIN LOOP my %instances; @@ -53,7 +52,7 @@ while (1) { $instances{$line} += 1; } foreach my $inst (keys(%instances)) { - system("/usr/local/bin/crawl.sh $inst"); + system("$crawler $inst"); } fcntl(FIFO, F_SETFL, $flags); } diff --git a/conf/Config.xml b/conf/Config.xml index e614cda..3dcccf5 100644 --- a/conf/Config.xml +++ b/conf/Config.xml @@ -3,6 +3,9 @@ <version module="Mioga2"/> <config> + <parameter name="init_sql" question="Initialize database ?" + type="bool" default="no" xpath="/init_sql"/> + <parameter name="instance_ident" question="First Mioga instance Identifier ?" type="text" default="Mioga" xpath="/instance_ident"/> @@ -35,8 +38,18 @@ <parameter name="authentication" question="Authentification method ?" type="enum" default="Mioga2" values="Mioga2" xpath="/authentication"/> - + + <parameter name="bin_dir" question="Directory for helper scripts and binaries ?" + type="text" default="/usr/local/bin" + xpath="/bin_dir"/> + <parameter name="Database settings" type="submenu"> + <parameter name="db_host" question=" Mioga database server name or address ?" + type="text" default="localhost" + xpath="/database/DBhost"/> + <parameter name="db_port" question=" Mioga database server port ?" + type="text" default="5432" + xpath="/database/DBport"/> <parameter name="db_name" question=" Name of Mioga database ?" type="text" default="mioga2" xpath="/database/DBname"/> diff --git a/lib/Mioga2/Bottin.pm b/lib/Mioga2/Bottin.pm index ba4cd8d..0db5651 100644 --- a/lib/Mioga2/Bottin.pm +++ b/lib/Mioga2/Bottin.pm @@ -1742,11 +1742,11 @@ sub InitSuperAdminMode { sub CheckUTF8 { my ($str) = @_; - my $conv = Text::Iconv->new('utf8', 'utf8'); + my $conv = Text::Iconv->new('UTF-8', 'UTF-8'); my $tmp_str = $conv->convert($str); unless ($tmp_str) { - my $charset = detect($str) || 'iso-8859-15'; # defaults to latin9 - $conv = Text::Iconv->new($charset, "utf8"); + my $charset = detect($str) || 'ISO-8859-15'; # defaults to latin9 + $conv = Text::Iconv->new($charset, "UTF-8"); $str = $conv->convert($str); } return $str; diff --git a/lib/Mioga2/Classes/URI.pm b/lib/Mioga2/Classes/URI.pm index 8678b33..bf97e71 100644 --- a/lib/Mioga2/Classes/URI.pm +++ b/lib/Mioga2/Classes/URI.pm @@ -75,15 +75,16 @@ sub new { # convert uri to UTF-8 my $uri = uri_unescape($options{uri}); + # attempt to see if uri is utf8 to avoid detection - my $conv = Text::Iconv->new('utf8', 'utf8'); + my $conv = Text::Iconv->new('UTF-8', 'UTF-8'); my $tmp_uri = $conv->convert($uri); - + unless ($tmp_uri) { - my $charset = detect($uri) || 'iso-8859-15'; # defaults to latin9 + my $charset = detect($uri) || 'ISO-8859-15'; # defaults to latin9 warn "charset = '$charset' for uri = '$uri'" if $debug; - $conv = Text::Iconv->new($charset, "utf8"); + $conv = Text::Iconv->new($charset, "UTF-8"); $uri = $conv->convert($uri); warn "==> converted uri = '$uri'" if $debug; } diff --git a/lib/Mioga2/Config.pm b/lib/Mioga2/Config.pm index b088823..4edac62 100644 --- a/lib/Mioga2/Config.pm +++ b/lib/Mioga2/Config.pm @@ -28,7 +28,7 @@ Config.pm: Access class to the current Mioga instance configuration. This module permits to access to the current Mioga instance configuration parameters. -=head1 METHODS DESRIPTION +=head1 METHODS DESCRIPTION =cut diff --git a/lib/Mioga2/DAVFS.pm b/lib/Mioga2/DAVFS.pm index b56c4ad..7810f82 100644 --- a/lib/Mioga2/DAVFS.pm +++ b/lib/Mioga2/DAVFS.pm @@ -141,10 +141,11 @@ use Mioga2::tools::APIAuthz; use Mioga2::tools::database; use Mioga2::tools::string_utils; use Mioga2::tools::Convert; +use Net::INET6Glue::INET_is_INET6; use XML::LibXML (); use Mioga2::Constants; -my $debug = 0; +my $debug = 5; my $MULTI_STATUS = 207; # code DAV for the Multi-status response @@ -756,13 +757,17 @@ sub make_request { my $host = $self->{host}; my $port = $self->{port}; + my $hostport = $host; + $hostport = '['.$hostport.']' if $host =~ /:.*:/; + $hostport .= ':'.$port; + my $dav_uri = $config->GetDAVBasePath; my $mioga_uri = $config->GetBasePath; my $orig_uri = Mioga2::Classes::URI->new( uri => $callbacks->{uri}->() ); my $uri = $orig_uri->as_string; $uri =~ s/^$mioga_uri/$dav_uri/; - $uri = Mioga2::Classes::URI->new( uri => "$protocol://$host:$port$uri" ) + $uri = Mioga2::Classes::URI->new( uri => "$protocol://$hostport$uri" ) ->as_string; print STDERR "[Mioga2::DAVFS::make_request] uri = $uri\n" if $debug; @@ -774,7 +779,7 @@ sub make_request { # process headers if ( $header =~ /^destination/i && $value !~ $dav_uri ) { - $value =~ s!(//)[^/]+$mioga_uri!$1$host$dav_uri!; + $value =~ s!(//)[^/]+$mioga_uri!$1$hostport$dav_uri!; # was only $host before! $value = Mioga2::Classes::URI->new( uri => $value )->as_string; $value = $self->escapeSpecialChars($value); } diff --git a/lib/Mioga2/Database.pm b/lib/Mioga2/Database.pm index 4afa54b..ca8368c 100644 --- a/lib/Mioga2/Database.pm +++ b/lib/Mioga2/Database.pm @@ -61,7 +61,7 @@ sub new { my $self = { }; bless($self, $class); - for my $attr (qw/DBIlogin DBIpasswd DBIdriver DBname/) { + for my $attr (qw/DBhost DBport DBIlogin DBIpasswd DBIdriver DBname/) { if (!defined ($attributes{$attr})) { throw Mioga2::Exception::DB ("[Mioga2::Database::new]", "Cannot connect to database: " . $DBI::errstr); } @@ -72,8 +72,10 @@ sub new { my $dbiPassword = $self->{database}->{DBIpasswd}; my $dbDriver = $self->{database}->{DBIdriver}; my $dbName = $self->{database}->{DBname}; + my $dbHost = $self->{database}->{DBhost}; + my $dbPort = $self->{database}->{DBport}; - my $datasource = "dbi:$dbDriver:dbname=$dbName"; + my $datasource = "dbi:$dbDriver:dbname=$dbName;host=$dbHost;port=$dbPort"; $self->{dbh} = DBI->connect($datasource, $dbiUser, $dbiPassword); diff --git a/lib/Mioga2/Exception/DB.pm b/lib/Mioga2/Exception/DB.pm index 7ce5020..bee00ca 100644 --- a/lib/Mioga2/Exception/DB.pm +++ b/lib/Mioga2/Exception/DB.pm @@ -76,6 +76,17 @@ sub as_string return $string; } +# ---------------------------------------------------------------------------- +=head2 getDBerror () +Return the error as sent by the database connector. +=cut +# ---------------------------------------------------------------------------- +sub getDBerror { + my ($self) = @_; + return $self->{errDB} +} + + # ============================================================================ =head1 PRIVATE METHODS DESCRIPTION diff --git a/lib/Mioga2/InstanceList.pm b/lib/Mioga2/InstanceList.pm index 3e2cf7a..a676a1b 100644 --- a/lib/Mioga2/InstanceList.pm +++ b/lib/Mioga2/InstanceList.pm @@ -423,7 +423,9 @@ sub Store { $conf->RunHooks($self->{config}->{miogaconf}); # Run crawl.sh to initialize search engine database - my $crawlcmd = $self->{config}->{miogaconf}->GetMiogaPrefix () . "/bin/mioga2_index.pl --conf=" . $self->{config}->GetMiogaConfPath () . ' --search_conf=' . $self->{config}->GetInstallPath . "/conf/search_conf.xml" . ' ' . $self->Get ('ident'); + my $crawlcmd = $self->{config}->{miogaconf}->GetMiogaPrefix () . "/bin/mioga2_index.pl --conf=" . $self->{config}->GetMiogaConfPath () + . ' --search_conf=' . $self->{config}->{miogaconf}->GetInstallDir()."/conf/search_conf.xml" + . ' '. $self->Get ('ident'); system ("$crawlcmd"); } elsif (scalar (keys (%{$self->{update}}))) { diff --git a/lib/Mioga2/Magellan.pm b/lib/Mioga2/Magellan.pm index 86e2e42..4b3814a 100644 --- a/lib/Mioga2/Magellan.pm +++ b/lib/Mioga2/Magellan.pm @@ -327,10 +327,13 @@ sub GetNodes { $mygroup = $group; } + my $host = $config->GetMiogaConf()->GetDAVHost(); + $host = "[${host}]" if $host =~ /:.*?:/; + my $resources = Mioga2::Magellan::DAV::GetCollection( $context, $context->GetSessionToken, - $config->GetMiogaConf ()->GetDAVProtocol () . "://" . $config->GetMiogaConf ()->GetDAVHost () . ":" . $config->GetMiogaConf ()->GetDAVPort (), $node + $config->GetMiogaConf ()->GetDAVProtocol () . "://" . $host . ":" . $config->GetMiogaConf ()->GetDAVPort (), $node ); $inconsistent = pop (@$resources); @@ -853,7 +856,7 @@ sub GetResource { ); print STDERR "mime = $mime\n content= $content\n" if ($debug); if ($mime) { - #my $conv = Text::Iconv->new( 'utf8', 'utf8' ); + #my $conv = Text::Iconv->new( 'UTF-8', 'UTF-8' ); #my $encoding = $conv->convert($content); #if ($encoding) { if ($mime =~ /(application\/xml)|(text\/)|(application\/xsl)/) diff --git a/lib/Mioga2/Magellan/Archive.pm b/lib/Mioga2/Magellan/Archive.pm index 842ae90..3b9e7f7 100644 --- a/lib/Mioga2/Magellan/Archive.pm +++ b/lib/Mioga2/Magellan/Archive.pm @@ -163,7 +163,7 @@ sub Content return undef; } - my $conv = Text::Iconv->new('utf8', 'utf8'); + my $conv = Text::Iconv->new('UTF-8', 'UTF-8'); my %folders; while(my $file = <PRG>) { chomp($file); diff --git a/lib/Mioga2/Magellan/DAV.pm b/lib/Mioga2/Magellan/DAV.pm index cdf77f1..116ebf4 100644 --- a/lib/Mioga2/Magellan/DAV.pm +++ b/lib/Mioga2/Magellan/DAV.pm @@ -106,7 +106,7 @@ sub ExecuteRequest } if ($response->code >= 500) { - warn "Mioga2::Magellan::ExecuteRequest Failed: " . $response->content; + warn "Mioga2::Magellan::DAV::ExecuteRequest Failed: " . $response->content; } return $response; diff --git a/lib/Mioga2/MailingList.pm b/lib/Mioga2/MailingList.pm index c7d631c..3a92466 100644 --- a/lib/Mioga2/MailingList.pm +++ b/lib/Mioga2/MailingList.pm @@ -749,11 +749,11 @@ sub MailDeleteMsg sub CheckUTF8 { my ($str) = @_; - my $conv = Text::Iconv->new('utf8', 'utf8'); + my $conv = Text::Iconv->new('UTF-8', 'UTF-8'); my $tmp_str = $conv->convert($str); unless ($tmp_str) { - my $charset = detect($str) || 'iso-8859-15'; # defaults to latin9 - $conv = Text::Iconv->new($charset, "utf8"); + my $charset = detect($str) || 'ISO-8859-15'; # defaults to latin9 + $conv = Text::Iconv->new($charset, "UTF-8"); $str = $conv->convert($str); } return $str; diff --git a/lib/Mioga2/MiogaConf.pm b/lib/Mioga2/MiogaConf.pm index 5b74a96..a46e27c 100644 --- a/lib/Mioga2/MiogaConf.pm +++ b/lib/Mioga2/MiogaConf.pm @@ -258,7 +258,7 @@ sub GetFilenameEncoding { sub GetBinariesDir { my ($self) = @_; - return $self->{binaries_dir}; + return $self->{bin_dir}; } # ============================================================================ diff --git a/lib/Mioga2/Search.pm b/lib/Mioga2/Search.pm index 2c20259..292f864 100644 --- a/lib/Mioga2/Search.pm +++ b/lib/Mioga2/Search.pm @@ -447,13 +447,13 @@ sub CheckArgs elsif (exists($context->{args}->{query})) { $query_string = $context->{args}->{query}; } - my $conv = Text::Iconv->new('utf8', 'utf8'); + my $conv = Text::Iconv->new('UTF-8', 'UTF-8'); my $tmp_query = $conv->convert($query_string); unless ($tmp_query) { - my $charset = detect($query_string) || 'iso-8859-15'; # defaults to latin9 + my $charset = detect($query_string) || 'ISO-8859-15'; # defaults to latin9 warn "charset = '$charset' for query_string = '$query_string'" if $debug; - $conv = Text::Iconv->new($charset, "utf8"); + $conv = Text::Iconv->new($charset, "UTF-8"); $query_string = $conv->convert($query_string); warn "==> converted query_string = '$query_string'" if $debug; } diff --git a/lib/Mioga2/tools/string_utils.pm b/lib/Mioga2/tools/string_utils.pm index c56cc3b..36bfa5a 100644 --- a/lib/Mioga2/tools/string_utils.pm +++ b/lib/Mioga2/tools/string_utils.pm @@ -46,6 +46,7 @@ use Mioga2::Content::XSLT; use Mioga2::XML::Simple; use Exporter; use Text::Iconv; +use Encode; use Encode::Detect::Detector; use Data::Dumper; use HTML::TokeParser::Simple; @@ -715,11 +716,11 @@ Check if string is UTF8 and convert it if needed sub st_CheckUTF8 { my ($str) = @_; - my $conv = Text::Iconv->new('utf8', 'utf8'); + my $conv = Text::Iconv->new('UTF-8', 'UTF-8'); my $tmp_str = $conv->convert($str); unless ($tmp_str) { - my $charset = detect($str) || 'iso-8859-15'; # defaults to latin9 - $conv = Text::Iconv->new($charset, "utf8"); + my $charset = detect($str) || 'ISO-8859-15'; # defaults to latin9 + $conv = Text::Iconv->new($charset, "UTF-8"); $str = $conv->convert($str); utf8::decode ($str); } diff --git a/lib/MiogaConf.pm b/lib/MiogaConf.pm index 0870174..bbcc80a 100644 --- a/lib/MiogaConf.pm +++ b/lib/MiogaConf.pm @@ -836,6 +836,10 @@ sub CheckDepends my @missing; my @missing_clib; + # Some modules rewrite $ENV{PATH} without hesitation when "require"d, + # we need to put the old one back in place. + my $oldpath = $ENV{PATH}; + foreach my $dep (@{$self->{CONFIG}->{dependencies}->[0]->{dep}}) { my $version; if(exists $dep->{version}) { @@ -858,6 +862,7 @@ sub CheckDepends } } + $ENV{PATH} = $oldpath; foreach my $dep (@{$self->{CONFIG}->{dependencies}->[0]->{clib}}) { my $version; diff --git a/sql/Makefile b/sql/Makefile index 07b26f5..f6b6c0f 100644 --- a/sql/Makefile +++ b/sql/Makefile @@ -1,4 +1,5 @@ include ../config.mk +DB_STATE=`perl -w testdb.pl` all: @@ -15,19 +16,20 @@ install: cp upgradeMiogletDesc.pl $(DESTDIR)$(INSTALL_DIR)/conf/Config.hook.d chmod a+x $(DESTDIR)$(INSTALL_DIR)/conf/Config.hook.d/upgradeMiogletDesc.pl - if [ $(INIT_SQL) = 'yes' ] ; \ + if [ $(DB_STATE) = 'nodb' ] ; \ then \ echo "Initialize database"; \ - su - $(POSTGRES_USER) -c "dropdb $(DB_NAME)" ; \ - su - $(POSTGRES_USER) -c "createdb --encoding UTF8 $(DB_NAME)" && \ - su $(POSTGRES_USER) -c "psql $(DB_NAME) < create_lang.sql" && \ - perl -w -I../lib initdb.pl ; \ - elif [ $(INIT_SQL) != 'noupdate' ]; then \ + dropdb -h $(DB_HOST) -p $(DB_PORT) -U $(DBI_LOGIN) $(DB_NAME) ; \ + createdb --encoding UTF8 -h $(DB_HOST) -p $(DB_PORT) -U $(DBI_LOGIN) $(DB_NAME) && \ + psql -h $(DB_HOST) -p $(DB_PORT) -U $(DBI_LOGIN) $(DB_NAME) < create_lang.sql && \ + perl -w -I../lib initdb.pl force_init_sql=1; \ + elif [ $(DB_STATE) = 'present' ]; then \ echo "Update database"; \ perl -w -I../lib updatedb.pl configxml=$(DESTDIR)$(INSTALL_DIR)/conf/Config.xml; \ + elif [ $(DB_STATE) = 'noserver' ]; then \ + echo "ERROR: Cannot connect to the database server!"; \ fi - clean: rm -f *~ diff --git a/sql/schema_base.sql b/sql/schema_base.sql index b7d8cc2..88d5e2d 100644 --- a/sql/schema_base.sql +++ b/sql/schema_base.sql @@ -429,10 +429,6 @@ CREATE OR REPLACE FUNCTION check_group_base_default_profile_id () RETURNS trigge END; ' LANGUAGE 'plpgsql'; -CREATE TRIGGER m_group_base_default_profile_id_check - BEFORE DELETE ON m_profile FOR EACH ROW - EXECUTE PROCEDURE check_group_base_default_profile_id (); - CREATE OR REPLACE FUNCTION check_group_base_mioga_id () RETURNS trigger AS ' DECLARE @@ -839,6 +835,10 @@ create table m_profile ( ); create unique index m_profile_ident_group_index on m_profile (ident, group_id); +CREATE TRIGGER m_group_base_default_profile_id_check + BEFORE DELETE ON m_profile FOR EACH ROW + EXECUTE PROCEDURE check_group_base_default_profile_id (); + -- -- Add referencial integrity on default_profile_id in m_group_base diff --git a/sql/testdb.pl b/sql/testdb.pl new file mode 100755 index 0000000..2fa3fe7 --- /dev/null +++ b/sql/testdb.pl @@ -0,0 +1,37 @@ +#!/usr/bin/perl -w + +# Tests the availability of the Mioga2 database. +# Returns on stdout one of: +# 'present' - The Mioga2 database has been found. +# 'nodb' - There is no Mioga2 database but the database server is working fine +# (i.e. one can try to create the database) +# 'noserver' - Connection to the database server failed. + +# This has been written for Mioga2/SlapOS, to avoid overwriting the database +# when re-instantiating the Apache/mod_perl partition. + +use strict; +use lib "../lib"; + +use Data::Dumper; +use Error qw(:try); +use Mioga2::Exception::DB; +use Mioga2::MiogaConf; + +# TODO: get this through a parameter? +# my $configxml = "../conf/Config.xml"; +my $miogaconf = "../web/conf/Mioga.conf"; + +try { + my $config = new Mioga2::MiogaConf($miogaconf); + print 'present'; +} catch Mioga2::Exception::DB with { + my $err = shift; + if ($err->getDBerror() =~ m#database "mioga2" does not exist#) { + print 'nodb'; + } else { + print 'noserver'; + } +} otherwise { + print 'noserver'; +} diff --git a/web/Makefile b/web/Makefile index 66af45f..9649a02 100644 --- a/web/Makefile +++ b/web/Makefile @@ -16,11 +16,11 @@ all :: install :: - if [ $(INIT_SQL) = 'yes' -a -d $(INSTALL_DIR) ] ; \ - then \ - su - $(POSTGRES_USER) -c "pg_dump -b -Ft --column-inserts $(DB_NAME) | gzip" > ${INSTALL_DIR}/db_dump.tar.gz ; \ - mv $(INSTALL_DIR) $(BACKUP_DIR) ; \ - fi +# if [ $(INIT_SQL) = 'yes' -a -d $(INSTALL_DIR) ] ; \ +# then \ +# su - $(POSTGRES_USER) -c "pg_dump -b -Ft --column-inserts $(DB_NAME) | gzip" > ${INSTALL_DIR}/db_dump.tar.gz ; \ +# mv $(INSTALL_DIR) $(BACKUP_DIR) ; \ +# fi mkdir -p $(TMP_DIR) mkdir -p $(DESTDIR)$(INSTALL_DIR)/$(INSTANCE_IDENT)/$(MIOGA_FILES) diff --git a/web/conf/startup.pl b/web/conf/startup.pl index a9dc968..6558061 100644 --- a/web/conf/startup.pl +++ b/web/conf/startup.pl @@ -29,6 +29,7 @@ use MIME::Entity (); use MIME::Parser (); use MIME::QuotedPrint (); use MiogaConf (); +use Net::INET6Glue::INET_is_INET6; use Net::LDAP (); use Parse::Yapp::Driver (); use Storable (); diff --git a/web/skel/Makefile b/web/skel/Makefile index e604e7d..fbaad2d 100644 --- a/web/skel/Makefile +++ b/web/skel/Makefile @@ -33,7 +33,7 @@ fr_FR : $(SRC_FR_FILES) install: rsync $(RSYNC_OPTS) $(SUBDIRS) $(DESTDIR)$(INSTALL_DIR)/conf/skel/ # Update instance default skeletons - for i in `mioga2_info.pl --conf=$(DESTDIR)$(INSTALL_DIR)/conf/Mioga.conf instances`; do if [ ! -d /var/lib/Mioga2/$$i/MiogaFiles/skel/ ]; then mkdir $(DESTDIR)$(INSTALL_DIR)/$$i/MiogaFiles/skel/; fi; cp -R $(DESTDIR)$(INSTALL_DIR)/conf/skel/* $(DESTDIR)$(INSTALL_DIR)/$$i/MiogaFiles/skel/; done +# for i in `mioga2_info.pl --conf=$(DESTDIR)$(INSTALL_DIR)/conf/Mioga.conf instances`; do if [ ! -d /var/lib/Mioga2/$$i/MiogaFiles/skel/ ]; then mkdir $(DESTDIR)$(INSTALL_DIR)/$$i/MiogaFiles/skel/; fi; cp -R $(DESTDIR)$(INSTALL_DIR)/conf/skel/* $(DESTDIR)$(INSTALL_DIR)/$$i/MiogaFiles/skel/; done clean: rm -rf $(SUBDIRS)