diff --git a/config/inc_projects_config.php b/config/inc_projects_config.php index 8344d4400b1b31031718b8df86d0809899ffc711..83c949ba32886282bda76006e0b13b95ef39c140 100644 --- a/config/inc_projects_config.php +++ b/config/inc_projects_config.php @@ -1,9 +1,12 @@ <?php -$aConfig = array_replace_recursive( - include('config_defaults.php'), - include('config_custom.php') -) -; + +$aConfig = include('config_defaults.php'); +if (file_exists('config_custom.php')){ + $aConfig = array_replace_recursive( + $aConfig, + include('config_custom.php') + ); +} // ---------------------------------------------------------------------- // generate some vars diff --git a/config/inc_roles.php b/config/inc_roles.php index 58188673f6878d3872b87e68dfc54c3cdbb2c7e9..018c7205c96d4777d145db93a0f91f410af3a9fd 100644 --- a/config/inc_roles.php +++ b/config/inc_roles.php @@ -46,6 +46,7 @@ return [ "page_deploy", "page_doc", "page_htmltest", + "page_installer", "page_phase", "page_setup", "page_checkssh", diff --git a/public_html/deployment/classes/user.class.php b/public_html/deployment/classes/user.class.php index a35178288842b1881c855917ce11611f0d73853d..33ac0c66f2d1e4eaf776fa562fd6851f5efe0510 100644 --- a/public_html/deployment/classes/user.class.php +++ b/public_html/deployment/classes/user.class.php @@ -72,11 +72,19 @@ class user { // UNUSED SO FAR private function _getUser2Projects(){ - return require(__DIR__ . '/../../../config/inc_user2projects.php'); + $sFile=__DIR__ . '/../../../config/inc_user2projects.php'; + return file_exists($sFile) + ? require $sFile + : [] + ; } private function _getUser2Roles(){ - return require(__DIR__ . '/../../../config/inc_user2roles.php'); + $sFile=__DIR__ . '/../../../config/inc_user2roles.php'; + return file_exists($sFile) + ? require $sFile + : ['admin'=>['admin']] + ; } /** * TODO: reimplement diff --git a/public_html/deployment/index.php b/public_html/deployment/index.php index 4a45b7f11726863615d127816892b6ceec635d36..82384c6ba4d970b65cb520a4f08cce2ed8d6685a 100644 --- a/public_html/deployment/index.php +++ b/public_html/deployment/index.php @@ -23,6 +23,10 @@ ini_set('display_startup_errors', 1); error_reporting(E_ALL); require_once("./classes/page.class.php"); + +// detect first run +$bFirstRun=!file_exists("../../config/config_custom.php") || !file_exists("../../config/inc_user2roles.php"); + require_once("../../config/inc_projects_config.php"); require_once("./classes/logger.class.php"); require_once("./classes/user.class.php"); @@ -52,7 +56,10 @@ $oCLog->add("parsing params " . '<pre>aParams: '.print_r($aParams, true).'</pre>' ); - +if($bFirstRun){ + $sAction='installer'; +} + // ------ Ausgabe $sHeader = '<style>'; foreach ($aConfig["phases"] as $sPhase => $aData) { diff --git a/public_html/deployment/pages/act_installer.php b/public_html/deployment/pages/act_installer.php new file mode 100644 index 0000000000000000000000000000000000000000..8b0c5326ee2f7bab898c7644452be081cca3438b --- /dev/null +++ b/public_html/deployment/pages/act_installer.php @@ -0,0 +1,38 @@ +<?php + +/* ###################################################################### + + IML DEPLOYMENT + + INSTALLER + + --------------------------------------------------------------------- + 2022-07-25 Axel <axel.hahn@iml.unibe.ch> + ###################################################################### */ + +require_once("./inc_functions.php"); +$sOut = '' +.' + +<h2>Welcome to the IML CI SERVER!</h2> + +<p> + This page appears on the first run. Or better: as long no configuration exists.<br> + + <br> + <br> + Go to the directory <code>'.dirname($_SERVER['DOCUMENT_ROOT']).'/config/</code>.<br> + <br> + Copy 2 <code>*.dist</code> files <code>config_custom.php</code> and <code>inc_user2roles.php</code>.<br> + <br> + <a href="?" class="btn btn-default">Reload</a><br> + <br> +</p> +<script> + window.setTimeout("location.reload()", 5000); +</script> +' +; + +// -- Ausgabe +echo $sOut;