12
by johnw
Add cli-wrapper to list logging locations (de-duped list) |
1 |
<?php
|
2 |
||
3 |
/**
|
|
4 |
* @desc shell wrapper to display all
|
|
5 |
* directives that are associated with specifying logging locations:
|
|
6 |
(CustomLog|ErrorLog|ForensicLog)
|
|
7 |
* within all apache conf files
|
|
8 |
*/
|
|
9 |
||
10 |
exec( |
|
11 |
//invoke list-apache-conf-files
|
|
12 |
dirname(__FILE__) . '/list-apache-conf-files.php ' |
|
13 |
||
14 |
//pipe those conf file paths to grep to inversly match comment lines
|
|
15 |
. '| xargs grep -h -v -E \'^[[:space:]]*#\' ' |
|
16 |
||
17 |
//pipe uncommented lines to grep matching lines of logging directives
|
|
18 |
. '| grep -E "^[[:space:]]*CustomLog|ErrorLog|ForensicLog" ' |
|
19 |
||
20 |
//pipe thru sed to trim white-space
|
|
21 |
. '| sed \'s/^[[:space:]]*\(.*\)[[:space:]]*$/\1/\' ' |
|
22 |
||
23 |
//define the field delimter as white-space then cut and return the 2nd field
|
|
24 |
. '| cut -d" " -f2', |
|
25 |
||
26 |
$outputLines
|
|
27 |
);
|
|
28 |
||
29 |
//de-duplicate the lines
|
|
30 |
$outputLines = array_unique( $outputLines ); |
|
31 |
||
32 |
//print them out
|
|
33 |
foreach( $outputLines as $path ) |
|
34 |
{
|
|
35 |
fwrite( STDOUT, $path . PHP_EOL ); |
|
36 |
}
|
|
37 |
||
38 |
//exit ok
|
|
39 |
exit( 0 ); |