Skip to content
Snippets Groups Projects
Commit 3108523f authored by Juanjo Menent's avatar Juanjo Menent
Browse files

Merge pull request #3361 from hregis/3.7_bug

Fix: remove custom dir creation and update script
parents 7d18adeb 94ac0f53
No related branches found
No related tags found
No related merge requests found
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# \file dolibarr.pl # \file dolibarr.pl
# \brief Dolibarr script install for Virtualmin Pro # \brief Dolibarr script install for Virtualmin Pro
# \author (c)2009-2012 Regis Houssin <regis.houssin@capnetworks.com> # \author (c)2009-2015 Regis Houssin <regis.houssin@capnetworks.com>
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
...@@ -30,8 +30,7 @@ return "Regis Houssin"; ...@@ -30,8 +30,7 @@ return "Regis Houssin";
# script_dolibarr_versions() # script_dolibarr_versions()
sub script_dolibarr_versions sub script_dolibarr_versions
{ {
# TODO Replace this with version of Dolibar we want to install return ( "3.7.2", "3.6.3", "3.5.6" );
return ( "x.y.z", "3.6.0");
} }
sub script_dolibarr_category sub script_dolibarr_category
...@@ -57,6 +56,26 @@ local ($d, $ver) = @_; ...@@ -57,6 +56,26 @@ local ($d, $ver) = @_;
return ("mysql", "postgres"); return ("mysql", "postgres");
} }
# script_dolibarr_depends(&domain, version)
sub script_dolibarr_depends
{
local ($d, $ver, $sinfo, $phpver) = @_;
local @rv;
if ($ver >= 3.6) {
# Check for PHP 5.3+
local $phpv = &get_php_version($phpver || 5, $d);
if (!$phpv) {
push(@rv, "Could not work out exact PHP version");
}
elsif ($phpv < 5.3) {
push(@rv, "Dolibarr requires PHP version 5.3 or later");
}
}
return @rv;
}
# script_dolibarr_params(&domain, version, &upgrade-info) # script_dolibarr_params(&domain, version, &upgrade-info)
# Returns HTML for table rows for options for installing dolibarr # Returns HTML for table rows for options for installing dolibarr
sub script_dolibarr_params sub script_dolibarr_params
...@@ -78,8 +97,7 @@ else { ...@@ -78,8 +97,7 @@ else {
$rv .= &ui_table_row("Database for Dolibarr tables", $rv .= &ui_table_row("Database for Dolibarr tables",
&ui_database_select("db", undef, \@dbs, $d, "dolibarr")); &ui_database_select("db", undef, \@dbs, $d, "dolibarr"));
$rv .= &ui_table_row("Install sub-directory under <tt>$hdir</tt>", $rv .= &ui_table_row("Install sub-directory under <tt>$hdir</tt>",
&ui_opt_textbox("dir", "dolibarr", 30, &ui_opt_textbox("dir", &substitute_scriptname_template("dolibarr", $d), 30, "At top level"));
"At top level"));
if ($d->{'ssl'} && $ver >= 3.0) { if ($d->{'ssl'} && $ver >= 3.0) {
$rv .= &ui_table_row("Force https connection?", $rv .= &ui_table_row("Force https connection?",
&ui_yesno_radio("forcehttps", 0)); &ui_yesno_radio("forcehttps", 0));
...@@ -159,7 +177,8 @@ if ($opts->{'newdb'} && !$upgrade) { ...@@ -159,7 +177,8 @@ if ($opts->{'newdb'} && !$upgrade) {
local ($dbtype, $dbname) = split(/_/, $opts->{'db'}, 2); local ($dbtype, $dbname) = split(/_/, $opts->{'db'}, 2);
local $dbuser = $dbtype eq "mysql" ? &mysql_user($d) : &postgres_user($d); local $dbuser = $dbtype eq "mysql" ? &mysql_user($d) : &postgres_user($d);
local $dbpass = $dbtype eq "mysql" ? &mysql_pass($d) : &postgres_pass($d, 1); local $dbpass = $dbtype eq "mysql" ? &mysql_pass($d) : &postgres_pass($d, 1);
local $dbphptype = $dbtype eq "mysql" ? "mysqli" : "pgsql"; local $dbphptype = $dbtype eq "mysql" && $version >= 3.6 ? "mysql" :
$dbtype eq "mysql" ? "mysqli" : "pgsql";
local $dbhost = &get_database_host($dbtype); local $dbhost = &get_database_host($dbtype);
local $dberr = &check_script_db_connection($dbtype, $dbname, $dbuser, $dbpass); local $dberr = &check_script_db_connection($dbtype, $dbname, $dbuser, $dbpass);
return (0, "Database connection failed : $dberr") if ($dberr); return (0, "Database connection failed : $dberr") if ($dberr);
...@@ -201,12 +220,10 @@ if ($opts->{'path'} =~ /\w/) { ...@@ -201,12 +220,10 @@ if ($opts->{'path'} =~ /\w/) {
if (!$upgrade) { if (!$upgrade) {
local $cdef = "$opts->{'dir'}/conf/conf.php.example"; local $cdef = "$opts->{'dir'}/conf/conf.php.example";
&run_as_domain_user($d, "cp ".quotemeta($cdef)." ".quotemeta($cfile)); &run_as_domain_user($d, "cp ".quotemeta($cdef)." ".quotemeta($cfile));
&set_ownership_permissions(undef, undef, 0777, $cfiledir); &set_permissions_as_domain_user($d, 0777, $cfiledir);
&set_ownership_permissions(undef, undef, 0666, $cfile); &set_permissions_as_domain_user($d, 0666, $cfile);
&run_as_domain_user($d, "mkdir ".quotemeta($docdir)); &run_as_domain_user($d, "mkdir ".quotemeta($docdir));
&set_ownership_permissions(undef, undef, 0777, $docdir); &set_permissions_as_domain_user($d, 0777, $docdir);
&run_as_domain_user($d, "mkdir ".quotemeta($altdir));
&set_ownership_permissions(undef, undef, 0777, $altdir);
} }
else { else {
# Preserve old config file, documents and custom directory # Preserve old config file, documents and custom directory
...@@ -289,8 +306,8 @@ else { ...@@ -289,8 +306,8 @@ else {
local $dinstall = "$opts->{'dir'}/install"; local $dinstall = "$opts->{'dir'}/install";
$dinstall =~ s/\/$//; $dinstall =~ s/\/$//;
$out = &run_as_domain_user($d, "rm -rf ".quotemeta($dinstall)); $out = &run_as_domain_user($d, "rm -rf ".quotemeta($dinstall));
&set_ownership_permissions(undef, undef, 0644, $cfile); &set_permissions_as_domain_user($d, 0644, $cfile);
&set_ownership_permissions(undef, undef, 0755, $cfiledir); &set_permissions_as_domain_user($d, 0755, $cfiledir);
} }
# Return a URL for the user # Return a URL for the user
...@@ -309,6 +326,7 @@ local $ipage = $opts->{'path'}."/install/".$page.".php"; ...@@ -309,6 +326,7 @@ local $ipage = $opts->{'path'}."/install/".$page.".php";
local ($iout, $ierror); local ($iout, $ierror);
&post_http_connection($d, $ipage, $params, \$iout, \$ierror); &post_http_connection($d, $ipage, $params, \$iout, \$ierror);
print STDERR $iout;
if ($ierror) { if ($ierror) {
return $ierror; return $ierror;
...@@ -329,10 +347,10 @@ local $derr = &delete_script_install_directory($d, $opts); ...@@ -329,10 +347,10 @@ local $derr = &delete_script_install_directory($d, $opts);
return (0, $derr) if ($derr); return (0, $derr) if ($derr);
# Remove all llx_ tables from the database # Remove all llx_ tables from the database
# 3 times because of constraints # 4 times because of constraints
&cleanup_script_database($d, $opts->{'db'}, "llx_"); for(my $i=0; $i<4; $i++) {
&cleanup_script_database($d, $opts->{'db'}, "llx_");
&cleanup_script_database($d, $opts->{'db'}, "llx_"); &cleanup_script_database($d, $opts->{'db'}, "llx_");
}
# Take out the DB # Take out the DB
if ($opts->{'newdb'}) { if ($opts->{'newdb'}) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment