Skip to content

Commit

Permalink
Select the correct TSUGI branch based on version of PHP
Browse files Browse the repository at this point in the history
  • Loading branch information
torinfo committed Oct 17, 2023
1 parent 367a446 commit 3623647
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions setuptsugi/index.php
Expand Up @@ -294,6 +294,8 @@ function require_auth() {

function preflightchecks($mode)
{
global $branch;

echo "<br>Running pre-flight checks<br>\n";
flush();
// Check OS
Expand All @@ -307,12 +309,27 @@ function preflightchecks($mode)

// Check PHP version
$phpversion = phpversion();
if ($phpversion < "7.2.0" || $phpversion >= "8.1.0")
if ($phpversion < "7.2.0")
{
echo "<span style='color:#F41F15;'>Your PHP version (". $phpversion . ") is not supported by TSUGI. Please update to a PHP version 7.4 or higher but lower than PHP 8.1.</span> <br>\n";
echo "<span style='color:#F41F15;'>Your PHP version (". $phpversion . ") is not supported by TSUGI. Please update to a PHP version 7.2 or higher. </span> <br>\n";
echo "Aborting!";
exit(-1);
}
else if ($phpversion < "8.0")
{
echo "Your PHP version is ". $phpversion . ". Using branch php-72-x.<br>";
$branch = "php-72-x";
}
else if ($phpversion < "8.1")
{
echo "Your PHP version is ". $phpversion . ". Using branch php-80-x.<br>";
$branch = "php-80-x";
}
else
{
$branch = "master";
}
flush();
// Check zip extension
$zipextension = phpversion("zip");
if ($zipextension === false)
Expand All @@ -331,6 +348,7 @@ function preflightchecks($mode)
exit(-1);
}
echo "<span style='color:#099E12;'>All pre-flight checks are Ok!</span> <br>\n";
flush();
}

function backup()
Expand Down Expand Up @@ -385,18 +403,20 @@ function backup()
{
echo "<span style='color:#099E12;'>Existing TSUGI folder has been removed</span><br> \n";
}
flush();
}

function install()
{
global $xerte_toolkits_site;
global $xerte_toolkits_site, $branch;

// Download Tsugi bestanden
echo "<br>Download the TSUGI installer package<br>\n";
flush();
flush();
global $xerte_toolkits_site;
//$url = "https://github.com/$u/$repo/archive/master.zip";
$url = "https://github.com/tsugiproject/tsugi/archive/refs/heads/master.zip";
$tsugizip = __DIR__.'/../import/tsugi-master.zip';
$url = "https://github.com/tsugiproject/tsugi/archive/refs/heads/{$branch}.zip";
$tsugizip = __DIR__."/../import/tsugi-{$branch}.zip";
$ch = curl_init();
$f = fopen($tsugizip, 'w+');
$opt = [
Expand Down Expand Up @@ -434,15 +454,17 @@ function install()
}
$res = $zip->close();
echo "<span style='color:#099E12;'>TSUGI package successfully extracted</span><br>\n";
flush();
} else {
echo "<span style='color:#F41F15;'>Couldn't open $tsugizip!</span><br>\n";
echo "Aborting!";
exit(-1);
}

rename($xerte_toolkits_site->root_file_path . "tsugi-master", $xerte_toolkits_site->root_file_path . "tsugi");
rename($xerte_toolkits_site->root_file_path . "tsugi-{$branch}", $xerte_toolkits_site->root_file_path . "tsugi");

echo "<span style='color:#099E12;'>TSUGI package successfully installed</span><br>\n";
flush();

}

Expand Down Expand Up @@ -471,6 +493,7 @@ function install_config_file($config_file)
{
echo "<span style='color:#099E12;'>config.php has been copied!</span> <br>\n";
}
flush();
}

function copy_config_template()
Expand Down Expand Up @@ -498,6 +521,7 @@ function upgrade_database()
}
$upgrade_log .= "</div></div>";
echo $upgrade_log;
flush();
}
}

Expand Down

0 comments on commit 3623647

Please sign in to comment.