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..c24e217 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 web/skel conf bin/search/crawl_sample.sh \
+		"$(MIOGA_BUILDINST)"
+
+slapos-instantiation ::
+	rm -Rf web/conf/apache; (cd web/conf && $(MAKE) apache)
+
+	for i in web/conf conf web/skel sql ; \
+	do \
+		(cd $$i && $(MAKE) install) || exit 1;\
+	done
+
 doc:
 	for i in ' . $docsubdirs . ' ; \
 	do \
@@ -176,9 +202,18 @@ installall: install install-all
 # 
 # ----------------------------------------------------------------------------
 
+my $Mioga2_pm = 'lib/Mioga2.pm';
+if ((not -e $Mioga2_pm) and exists($ENV{MIOGA_SITEPERL})) {
+    my $findfile = sub {
+        if ($_ eq 'Mioga2.pm') {
+            $Mioga2_pm = $File::Find::name;
+        }
+    };
+    find($findfile, $ENV{MIOGA_SITEPERL});
+}; 
 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..3a9b7e3 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"/>              
@@ -462,7 +475,6 @@
 	<app ident="Portal" package="Mioga2::Portal"/>
   	<app ident="Search" package="Mioga2::Search"/>
     <app ident="Magellan" package="Mioga2::Magellan"/>
-    <app ident="Mermoz" package="Mioga2::Mermoz"/>
     <app ident="RSS" package="Mioga2::RSS"/>
     <app ident="Narkissos" package="Mioga2::Narkissos"/>
     <app ident="Colbert" package="Mioga2::Colbert"/>
@@ -476,7 +488,7 @@
   	<mioglet ident="Workspace" package="Mioga2::Portal::WSMioglet"/>
   	<mioglet ident="Organizer" package="Mioga2::Portal::OrgMioglet"/>
   	<mioglet ident="News" package="Mioga2::Portal::NewsMioglet"/>
-  	<mioglet ident="File" package="Mioga2::Portal::FileMioglet"/>
+  	<mioglet ident="File" package="Miorouga2::Portal::FileMioglet"/>
   	<mioglet ident="Articles" package="Mioga2::Portal::ArticlesMioglet"/>
     <mioglet ident="Poll" package="Mioga2::Portal::PollMioglet"/>
 	<mioglet ident="Search" package="Mioga2::Portal::SearchMioglet"/>
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..dd29d83 100644
--- a/lib/Mioga2/Exception/DB.pm
+++ b/lib/Mioga2/Exception/DB.pm
@@ -1,3 +1,4 @@
+
 # ============================================================================
 # Mioga2 Project (C) 2003-2007 The Mioga2 Project
 #
@@ -53,6 +54,7 @@ sub new {
     my($class, $function, $errDB, $errStr, $sql) = @_;
 	my $self = $class->SUPER::new(-text => "$errStr : $errDB");
 	$self->{errDB} = $errDB;
+    $self->{errStr} =  $errStr;
 	$self->{sql} = $sql;
 	$self->{function} = $function;
 	return $self;
@@ -76,6 +78,27 @@ sub as_string
 	return $string;
 }
 
+# ----------------------------------------------------------------------------
+=head2 getDBerr ()
+Return the error code as sent by the database connector.
+=cut 
+# ----------------------------------------------------------------------------
+sub getDBerr {
+    my ($self) = @_;
+    return $self->{errDB};
+}
+
+# ----------------------------------------------------------------------------
+=head2 getDBerrstr ()
+Return the error string as sent by the database connector.
+=cut 
+# ----------------------------------------------------------------------------
+sub getDBerrstr {
+    my ($self) = @_;
+    return $self->{errStr};
+}
+
+
 # ============================================================================
 
 =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..3d79b1b 100644
--- a/sql/Makefile
+++ b/sql/Makefile
@@ -15,19 +15,21 @@ 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' ] ; \
+	DB_STATE=`perl -w testdb.pl`; \
+	if [ "$$DB_STATE" = "nodb" -o "$$DB_STATE" = "empty" ] ; \
 	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..1952891
--- /dev/null
+++ b/sql/testdb.pl
@@ -0,0 +1,64 @@
+#!/usr/bin/perl -w
+
+# Tests the availability of the Mioga2 database.
+# Returns on stdout one of:
+# 'present'  - The Mioga2 database has been found and contains data.
+# 'empty'    - The Mioga2 database exists but the table "m_mioga" is empty or nonexistent.
+# '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 DBI;
+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";
+
+my $result = 'undefined';
+try {
+    my $config = new Mioga2::MiogaConf($miogaconf);
+    my $dbh = $config->GetDBH();
+    my $sql = 'SELECT COUNT(*) FROM m_mioga';
+    my $sth = $dbh->prepare($sql);
+    my $exec_result = $sth->execute();
+    if (not defined($exec_result)) {
+        throw Mioga2::Exception::DB("testdb.pl 0", $sth->err, $sth->errstr, $sql);
+    }
+    my $res = $sth->fetchrow_arrayref();
+    if (not defined($res)) {
+        throw Mioga2::Exception::DB("testdb.pl 1", $sth->err, $sth->errstr, $sql);
+    }
+    my $count = $res->[0];
+    if (not defined($count)) {
+        throw Mioga2::Exception::DB("testdb.pl 2", $sth->err, $sth->errstr, $sql);
+    } elsif ($count == 0) {
+        $result = 'empty';
+    } else {
+        $result = 'present';
+    }   
+} catch Mioga2::Exception::DB with {
+    my $err = shift;
+    my $errstr = $err->getDBerrstr();
+    if ($errstr =~ m#database "mioga2" does not exist#) {
+        $result = 'nodb';
+    } elsif ($errstr =~ m#relation "m_mioga" does not exist#) {
+        $result = 'empty';
+    } else {
+        $result = 'noserver';
+    }
+} otherwise {
+    my $err = shift;
+    $result = 'noserver';
+};
+
+print $result;
diff --git a/sql/updatedb.pl b/sql/updatedb.pl
index 67921e7..bb4db1a 100644
--- a/sql/updatedb.pl
+++ b/sql/updatedb.pl
@@ -25,7 +25,7 @@ foreach my $var qw(configxml miogaconf timezonexml dir) {
 
 my $config = new Mioga2::MiogaConf($miogaconf);
 
-my $conf = new MiogaConf( dir => $dir, config => $configxml);
+my $conf = new MiogaConf( dir => $dir, config => $configxml, force_init_sql => 0);
 $conf->Install($config);
 
 
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/Makefile b/web/conf/Makefile
index 1573e5c..189f2fd 100644
--- a/web/conf/Makefile
+++ b/web/conf/Makefile
@@ -14,5 +14,6 @@ install:
 # is done in ../Makefile
 
 clean:
+	echo "VHH DEBUG: web/conf make clean, deleting apache/ !"
 	rm -Rf apache Mioga.conf .memdump
 
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)
diff --git a/web/skel/src/en_US/group/50-standard.xml b/web/skel/src/en_US/group/50-standard.xml
index 6cf89e5..e1ef140 100644
--- a/web/skel/src/en_US/group/50-standard.xml
+++ b/web/skel/src/en_US/group/50-standard.xml
@@ -12,7 +12,6 @@
 	<applications>
 		<application ident="AnimGroup" active="1"/>
 		<application ident="Magellan" active="1"/>
-		<application ident="Mermoz" active="1"/>
 		<application ident="Organizer"/>
 		<application ident="Contact"/>
 		<application ident="Tasks"/>
@@ -38,9 +37,6 @@
 			<application ident="Magellan">
 				<all_functions/>
 			</application>
-			<application ident="Mermoz">
-				<all_functions/>
-			</application>
 			<application ident="Portal">
 				<all_functions/>
 			</application>
@@ -53,10 +49,6 @@
 			<application ident="Magellan">	
 				<function>Read</function>
 			</application>
-			<application ident="Mermoz">	
-				<function>Base</function>
-				<function>Standard</function>
-			</application>
 			<application ident="Portal">
 				<function>Portal</function>
 			</application>
@@ -69,9 +61,6 @@
 			<application ident="Magellan">	
 				<function>Read</function>
 			</application>
-			<application ident="Mermoz">	
-				<function>Base</function>
-			</application>
 			<application ident="Portal">
 				<function>Portal</function>
 			</application>
diff --git a/web/skel/src/en_US/group/60-admin.xml b/web/skel/src/en_US/group/60-admin.xml
index c73b700..d3f368b 100644
--- a/web/skel/src/en_US/group/60-admin.xml
+++ b/web/skel/src/en_US/group/60-admin.xml
@@ -12,7 +12,6 @@
 	<applications>
 		<application ident="AnimGroup" active="1"/>
 		<application ident="Magellan" active="1"/>
-		<application ident="Mermoz" active="1"/>
 		<application ident="Colbert" active="1"/>
 		<application ident="Organizer"/>
 		<application ident="Contact"/>
@@ -39,9 +38,6 @@
 			<application ident="Magellan">
 				<all_functions/>
 			</application>
-			<application ident="Mermoz">
-				<all_functions/>
-			</application>
 			<application ident="Colbert">
 				<all_functions/>
 			</application>
@@ -57,10 +53,6 @@
 			<application ident="Magellan">	
 				<function>Read</function>
 			</application>
-			<application ident="Mermoz">	
-				<function>Base</function>
-				<function>Standard</function>
-			</application>
 			<application ident="Colbert">
 				<function>UsersWrite</function>
 				<function>GroupsWrite</function>
@@ -79,9 +71,6 @@
 			<application ident="Magellan">	
 				<function>Read</function>
 			</application>
-			<application ident="Mermoz">	
-				<function>Base</function>
-			</application>
 			<application ident="Colbert">
 				<function>UsersRead</function>
 				<function>GroupsRead</function>
diff --git a/web/skel/src/en_US/instance/50-standard.xml b/web/skel/src/en_US/instance/50-standard.xml
index cdb1e88..82a125b 100644
--- a/web/skel/src/en_US/instance/50-standard.xml
+++ b/web/skel/src/en_US/instance/50-standard.xml
@@ -102,10 +102,6 @@
 		</application>
 		<application ident="MailingList">
 		</application>
-		<application ident="Mermoz">
-			<all_users/>
-			<all_groups/>
-		</application>
 		<application ident="Narkissos">
 			<all_users/>
 		</application>
diff --git a/web/skel/src/en_US/user/50-standard.xml b/web/skel/src/en_US/user/50-standard.xml
index c8983bb..256400d 100644
--- a/web/skel/src/en_US/user/50-standard.xml
+++ b/web/skel/src/en_US/user/50-standard.xml
@@ -92,7 +92,6 @@
 		<application ident="FileBrowser"/>
 		<application ident="Portal"/>
 		<application ident="Search" active="1"/>
-		<application ident="Mermoz"/>
 		<application ident="RSS" active="1"/>
 	</applications>
 
diff --git a/web/skel/src/en_US/user/60-admin.xml b/web/skel/src/en_US/user/60-admin.xml
index 9083b6f..e246d19 100644
--- a/web/skel/src/en_US/user/60-admin.xml
+++ b/web/skel/src/en_US/user/60-admin.xml
@@ -101,7 +101,6 @@
 		<application ident="FileBrowser"/>
 		<application ident="Portal"/>
 		<application ident="Search" active="1"/>
-		<application ident="Mermoz"/>
 		<application ident="RSS" active="1"/>
 	</applications>
 
diff --git a/web/skel/src/fr_FR/group/50-standard.xml b/web/skel/src/fr_FR/group/50-standard.xml
index 954f71d..dfc79b1 100644
--- a/web/skel/src/fr_FR/group/50-standard.xml
+++ b/web/skel/src/fr_FR/group/50-standard.xml
@@ -35,9 +35,6 @@
 		<!-- Le navigateur de fichiers est accessible et actif. -->
 		<application ident="Magellan" active="1"/>
 
-		<!-- L'application de rédaction d'e-mails est accessible et active. -->
-		<application ident="Mermoz" active="1"/>
-
 		<!-- Le portail est accessible et actif. -->
 		<application ident="Portal" active="1"/>
 
@@ -77,11 +74,6 @@
 				<all_functions/>
 			</application>
 
-			<!-- Le profil "Animation" donne accès à toutes les fonctions de l'application Mermoz d'envoi d'e-mail. -->
-			<application ident="Mermoz">
-				<all_functions/>
-			</application>
-
 			<!-- Le profil "Animation" donne accès à toutes les fonctions du portail de groupe. -->
 			<application ident="Portal">
 				<all_functions/>
@@ -102,12 +94,6 @@
 				<function>Read</function>
 			</application>
 
-			<!-- Le profil "Membre" donne accès uniquement à l'envoi d'e-mail au groupe ou indépendamment aux différentes équipes du groupe via l'application d'envoi d'e-mail Mermoz. -->
-			<application ident="Mermoz">	
-				<function>Base</function>
-				<function>Standard</function>
-			</application>
-
 			<!-- Le profil "Membre" donne accès uniquement à la consultation du portail de groupe. -->
 			<application ident="Portal">
 				<function>Portal</function>
@@ -128,11 +114,6 @@
 				<function>Read</function>
 			</application>
 
-			<!-- Le profil "Invité" donne accès uniquement à l'envoi d'e-mail au groupe via l'application d'envoi d'e-mail Mermoz. -->
-			<application ident="Mermoz">	
-				<function>Base</function>
-			</application>
-
 			<!-- Le profil "Invité" donne accès uniquement à la consultation du portail de groupe. -->
 			<application ident="Portal">
 				<function>Portal</function>
@@ -151,6 +132,7 @@
 		<space type="private">
 			
 			<!-- La balise "acls" contient les définitions de droits d'accès à la racine de l'espace privé du groupe. -->
+
 			<acls>
 
 				<!-- Les profils "Animation" et "Membre" ont accès en lecture et écriture. -->
diff --git a/web/skel/src/fr_FR/group/60-admin.xml b/web/skel/src/fr_FR/group/60-admin.xml
index d9bd724..1c97ca5 100644
--- a/web/skel/src/fr_FR/group/60-admin.xml
+++ b/web/skel/src/fr_FR/group/60-admin.xml
@@ -12,7 +12,6 @@
 	<applications>
 		<application ident="AnimGroup" active="1"/>
 		<application ident="Magellan" active="1"/>
-		<application ident="Mermoz" active="1"/>
 		<application ident="Colbert" active="1"/>
 		<application ident="Organizer"/>
 		<application ident="Contact"/>
@@ -39,9 +38,6 @@
 			<application ident="Magellan">
 				<all_functions/>
 			</application>
-			<application ident="Mermoz">
-				<all_functions/>
-			</application>
 			<application ident="Colbert">
 				<all_functions/>
 			</application>
@@ -57,10 +53,6 @@
 			<application ident="Magellan">	
 				<function>Read</function>
 			</application>
-			<application ident="Mermoz">	
-				<function>Base</function>
-				<function>Standard</function>
-			</application>
 			<application ident="Colbert">
 				<function>UsersWrite</function>
 				<function>GroupsWrite</function>
@@ -79,9 +71,6 @@
 			<application ident="Magellan">	
 				<function>Read</function>
 			</application>
-			<application ident="Mermoz">	
-				<function>Base</function>
-			</application>
 			<application ident="Colbert">
 				<function>UsersRead</function>
 				<function>GroupsRead</function>
diff --git a/web/skel/src/fr_FR/instance/50-standard.xml b/web/skel/src/fr_FR/instance/50-standard.xml
index 34a8536..f7d1eb1 100644
--- a/web/skel/src/fr_FR/instance/50-standard.xml
+++ b/web/skel/src/fr_FR/instance/50-standard.xml
@@ -215,12 +215,6 @@
 		<application ident="MailingList">
 		</application>
 
-		<!-- L'application d'envoi d'e-mail est accessible à tous les utilisateurs et à tous les groupes. -->
-		<application ident="Mermoz">
-			<all_users/>
-			<all_groups/>
-		</application>
-
 		<!-- L'application de gestion des données personnelles est accessible à tous les utilisateurs. -->
 		<application ident="Narkissos">
 			<all_users/>
diff --git a/web/skel/src/fr_FR/user/50-standard.xml b/web/skel/src/fr_FR/user/50-standard.xml
index c7da5e8..d07b180 100644
--- a/web/skel/src/fr_FR/user/50-standard.xml
+++ b/web/skel/src/fr_FR/user/50-standard.xml
@@ -138,7 +138,6 @@
 		<!-- L'afficheur de fichiers, le portail utilisateur et l'application d'envoi d'e-mails Mermoz sont accessible mais ne sont pas actives. L'utilisateur pourra les activer s'il le souhaite. -->
 		<application ident="FileBrowser"/>
 		<application ident="Portal"/>
-		<application ident="Mermoz"/>
 
 	</applications>
 
diff --git a/web/skel/src/fr_FR/user/60-admin.xml b/web/skel/src/fr_FR/user/60-admin.xml
index afff18d..4d4df04 100644
--- a/web/skel/src/fr_FR/user/60-admin.xml
+++ b/web/skel/src/fr_FR/user/60-admin.xml
@@ -101,7 +101,6 @@
 		<application ident="FileBrowser"/>
 		<application ident="Portal"/>
 		<application ident="Search" active="1"/>
-		<application ident="Mermoz"/>
 		<application ident="RSS" active="1"/>
 	</applications>
 
