Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Imldeployment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
Imldeployment
Commits
b07785e2
Commit
b07785e2
authored
7 years ago
by
hahn
Browse files
Options
Downloads
Patches
Plain Diff
added check with required php modules and dirs
parent
00e7c769
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
public_html/check-config.php
+161
-0
161 additions, 0 deletions
public_html/check-config.php
with
161 additions
and
0 deletions
public_html/check-config.php
0 → 100644
+
161
−
0
View file @
b07785e2
<?php
/* ######################################################################
IML DEPLOYMENT
CONFIG CHECKER for new setups
---------------------------------------------------------------------
2017-12-01 Axel <axel.hahn@iml.unibe.ch>
###################################################################### */
// ----------------------------------------------------------------------
// functions
// ----------------------------------------------------------------------
function
drawbox
(
$s
,
$sClass
)
{
return
'<div class="box '
.
$sClass
.
'">'
.
$s
.
'</div>'
;
}
function
showerror
(
$s
)
{
return
drawbox
(
$s
,
'error'
);
}
function
showok
(
$s
)
{
return
drawbox
(
$s
,
'ok'
);
}
function
checkdir
(
$sDir
,
$sKey
=
false
)
{
global
$aErrors
;
echo
'check directory ['
.
$sDir
.
'] '
;
if
(
!
is_dir
(
$sDir
))
{
echo
'<span class="error">does not exist</span><br>'
;
$aErrors
[]
=
"*
\$
aConfig['
$sKey
'] points to a non existing directory ("
.
$sDir
.
").
\n
"
;
return
false
;
}
else
{
if
(
!
is_writable
(
$sDir
))
{
echo
'<span class="error">not writable</span><br>'
;
$aErrors
[]
=
"*
\$
aConfig['
$sKey
'] = "
.
$sDir
.
" is NOT writable.
\n
"
;
return
false
;
}
else
{
echo
'<span class="ok">OK</span> exists and is writable<br>'
;
return
true
;
}
}
return
false
;
}
function
checkModule
(
$aRequiredMods
=
array
()){
global
$aErrors
;
$sReturn
=
''
;
$aAllMods
=
get_loaded_extensions
(
false
);
asort
(
$aAllMods
);
if
(
!
count
(
$aRequiredMods
)){
echo
'<strong>List of all installes php modules</strong><br>'
;
foreach
(
$aAllMods
as
$sMod
){
echo
$sMod
.
'<br>'
;
}
}
else
{
foreach
(
$aRequiredMods
as
$sMod
){
echo
$sMod
.
' - '
;
if
(
!
array_search
(
$sMod
,
$aAllMods
)
===
false
){
echo
'<span class="ok">OK</span> installed'
;
}
else
{
echo
'<span class="error">does not exist</span>'
;
$aErrors
[]
=
"* php module
$sMod
was not found.
\n
"
;
}
echo
'<br>'
;
}
}
return
true
;
}
// ----------------------------------------------------------------------
//
// main
//
// ----------------------------------------------------------------------
echo
'
<style>
body{font-family: arial; background: #f8f8f8; color:#345;}
.box{border: 2px solid rgba(0,0,0,0.2); padding: 1em; margin-bottom: 1em;}
.ok{color:#383; background:#cfd;}
.error{color:#833; background:#fdd;}
</style>
<h1>Config Checker</h1>
'
;
$aErrors
=
array
();
include
(
"../config/inc_projects_config.php"
);
if
(
!
isset
(
$aConfig
)
||
!
is_array
(
$aConfig
))
{
// echo showerror("\$aConfig does not exist. The config was not included before including " . __FILE__ . " in the request/ script.");
$aErrors
[]
=
"*
\$
aConfig does not exist. The config was not included before including "
.
__FILE__
.
" in the request/ script."
;
}
else
{
// ----------------------------------------------------------------------
echo
'<h2>Check keys with directories</h2>'
;
foreach
(
array
(
'appRootDir'
,
'configDir'
,
'workDir'
,
'dataDir'
,
'buildDir'
,
'buildDefaultsDir'
,
'packageDir'
,
'archiveDir'
,
)
as
$sKey
)
{
checkdir
(
$aConfig
[
$sKey
],
$sKey
);
}
echo
'<h2>Check subdirs of key dataDir</h2>'
;
foreach
(
array
(
$aConfig
[
'dataDir'
]
.
'/database'
,
$aConfig
[
'dataDir'
]
.
'/projects'
,
$aConfig
[
'dataDir'
]
.
'/sshkeys'
,
)
as
$sDir2Check
)
{
checkdir
(
$sDir2Check
,
'dataDir + [subdir]'
);
}
// ----------------------------------------------------------------------
echo
'<h2>Check keys</h2>'
;
// check required keys in the config
foreach
(
array
(
'auth'
,
'hooks'
,
'installPackages'
,
'lang'
,
'phases'
,
'projects'
,
)
as
$sKey
)
{
echo
"Key [
$sKey
] "
;
if
(
!
array_key_exists
(
$sKey
,
$aConfig
))
{
echo
'<span class="error">failed</span> missing key [$sKey] in config<br>'
;
$aErrors
[]
=
"* missing key [
$sKey
] in config
\n
"
;
}
else
{
echo
'<span class="ok">OK</span> exists<br>'
;
}
}
}
echo
'<h2>Check required PHP modules</h2>'
;
echo
'PHP version: '
.
PHP_VERSION
.
'<br>'
.
'<br>'
;
checkModule
(
array
(
'PDO'
,
'curl'
,
'json'
,
'ldap'
,
'pdo_sqlite'
));
echo
'<h2>Result</h2>'
;
if
(
count
(
$aErrors
))
{
echo
showerror
(
"FATAL ERROR in config.<br>"
.
implode
(
"<br>
\n
"
,
$aErrors
));
}
else
{
echo
showok
(
'OK, check was successfully finished.'
);
}
// do not enable - it shows passwords...
// echo 'DEBUG: <pre>' . print_r($aConfig, 1) . '</pre>';
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment