Skip to content
Snippets Groups Projects
Commit f2c80eeb authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Merge branch 'task-1680-fix-surl' into 'master'

Task 1680 fix surl

See merge request !57
parents e3605e6f c7ad2cbf
No related branches found
No related tags found
No related merge requests found
...@@ -15,18 +15,41 @@ ...@@ -15,18 +15,41 @@
// functions // 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) { function drawbox($s, $sClass) {
return '<div class="box ' . $sClass . '">' . $s . '</div>'; return '<div class="box ' . $sClass . '">' . $s . '</div>';
} }
/**
* show an alert box with error message
* @param type $s
* @return type
*/
function showerror($s) { function showerror($s) {
return drawbox($s, 'error'); return drawbox($s, 'error');
} }
/**
* show green box with ok message
* @param type $s
* @return type
*/
function showok($s) { function showok($s) {
return drawbox($s, 'ok'); 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) { function checkdir($sDir, $sKey = false) {
global $aErrors; global $aErrors;
...@@ -48,6 +71,12 @@ function checkdir($sDir, $sKey = false) { ...@@ -48,6 +71,12 @@ function checkdir($sDir, $sKey = false) {
return 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()){ function checkModule($aRequiredMods=array()){
global $aErrors; global $aErrors;
$sReturn=''; $sReturn='';
...@@ -74,6 +103,29 @@ function checkModule($aRequiredMods=array()){ ...@@ -74,6 +103,29 @@ function checkModule($aRequiredMods=array()){
return true; 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 // main
...@@ -149,6 +201,27 @@ checkModule(array( ...@@ -149,6 +201,27 @@ checkModule(array(
'PDO','curl', 'json', 'ldap', 'pdo_sqlite' '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>'; echo '<h2>Result</h2>';
if (count($aErrors)) { if (count($aErrors)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment