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
c7ad2cbf
Commit
c7ad2cbf
authored
7 years ago
by
hahn
Browse files
Options
Downloads
Patches
Plain Diff
add check for required commands
parent
e1232a8c
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
+73
-0
73 additions, 0 deletions
public_html/check-config.php
with
73 additions
and
0 deletions
public_html/check-config.php
+
73
−
0
View file @
c7ad2cbf
...
...
@@ -15,18 +15,41 @@
// functions
// ----------------------------------------------------------------------
/**
* get html code to draw a colored box
* @param string $s message
* @param string $sClass css class; one of ok|info|error
* @return string
*/
function
drawbox
(
$s
,
$sClass
)
{
return
'<div class="box '
.
$sClass
.
'">'
.
$s
.
'</div>'
;
}
/**
* show an alert box with error message
* @param type $s
* @return type
*/
function
showerror
(
$s
)
{
return
drawbox
(
$s
,
'error'
);
}
/**
* show green box with ok message
* @param type $s
* @return type
*/
function
showok
(
$s
)
{
return
drawbox
(
$s
,
'ok'
);
}
/**
* check a directory if it exists and is writtable
* @global array $aErrors found errors
* @param string $sDir directory to check
* @param string $sKey key in config (for output only)
* @return boolean
*/
function
checkdir
(
$sDir
,
$sKey
=
false
)
{
global
$aErrors
;
...
...
@@ -48,6 +71,12 @@ function checkdir($sDir, $sKey = false) {
return
false
;
}
/**
* check if a php module was found
* @global array $aErrors found errors
* @param array $aRequiredMods array with needed php modules; default: empty = list all current php modules
* @return boolean
*/
function
checkModule
(
$aRequiredMods
=
array
()){
global
$aErrors
;
$sReturn
=
''
;
...
...
@@ -74,6 +103,29 @@ function checkModule($aRequiredMods=array()){
return
true
;
}
/**
* check if a command can be executed
* @global array $aErrors found errors
* @param array $aCommands array with key=command + value=description
* @return boolean
*/
function
checkCommands
(
$aCommands
){
global
$aErrors
;
foreach
(
$aCommands
as
$sCommand
=>
$sDescription
){
echo
'command ['
.
$sCommand
.
'] ('
.
$sDescription
.
') - '
;
system
(
"
$sCommand
"
,
$iReturn
);
if
(
$iReturn
===
0
){
echo
'<span class="ok">OK</span> '
;
}
else
{
echo
'<span class="error">does not exist</span>'
;
$aErrors
[]
=
"* command
$sCommand
was not found or failed.
\n
"
;
}
echo
'<br>'
;
}
return
true
;
}
// ----------------------------------------------------------------------
//
// main
...
...
@@ -149,6 +201,27 @@ checkModule(array(
'PDO'
,
'curl'
,
'json'
,
'ldap'
,
'pdo_sqlite'
));
echo
'<h2>Check executable commands</h2>'
.
'<p>remark: if the apache user has no login shell then all commands will fail.</p>'
;
echo
'<h3>basic tools</h3>'
;
checkCommands
(
array
(
'which bash'
=>
'shell interpreter to execute hook scripts'
,
'which cat'
=>
'show content of files'
,
'which cp'
=>
'copy files'
,
'which ln'
=>
'create softlinks for version handling'
,
'which ls'
=>
'list files'
,
'which mkdir'
=>
'create working directories'
,
'which mv'
=>
'move files'
,
'which ps'
=>
'process list'
,
'which rm'
=>
'remove files and directories'
,
));
echo
'<h3>more tools</h3>'
;
checkCommands
(
array
(
'which ssh'
=>
'connect with ssh for remote execution'
,
'which rsync'
=>
'sync packages to puppet master'
,
'which git'
=>
'connect to git repositories'
,
));
echo
'<h2>Result</h2>'
;
if
(
count
(
$aErrors
))
{
...
...
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