diff --git a/README.md b/README.md index ba20b77f24c39a5e7decddfc1ad69921a8a60cd7..c0ce57022ee45d14c4bb1977b3b149576672969c 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,20 @@ ## List of Local scripts Local scripts are located in /usr/lib/check_mk/local/ -### git_pull_check.sh +### php_syntax_check.sh * Attributes to be filled: <pre> # List of paths to check separated by space paths="" </pre> +### git_pull_check.sh +* Attributes to be filled: +<pre> +# The root directory to check +dir="" +</pre> + ### services_running_check.sh * Attributes to be filled: <pre> diff --git a/php_syntax_check.sh b/php_syntax_check.sh new file mode 100644 index 0000000000000000000000000000000000000000..b6dd7d29141267291186fb885f6544c7bafe9227 --- /dev/null +++ b/php_syntax_check.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +#The root directory to check +dir="/etc/simplesamlphp" + +cd $dir + +paths=$(find . -type f -name "*.php") +globalResult="" + +for path in $paths +do + if [[ -f $path ]] ; then + result=$(php -l $path 2>&1) + if [[ ! $result =~ ^No.syntax.errors.*$ ]] ; then + globalResult+="$result | " + fi + fi +done + +if [[ -z $globalResult ]] ; then + echo "0 php_syntax_check - OK" +else + echo "2 php_syntax_check - $globalResult" +fi