mirror of
https://github.com/m8tin/cis.git
synced 2025-12-08 08:38:25 +01:00
Added first checks to check hosts configuration
This commit is contained in:
33
script/check/host/runAllChecks.sh
Executable file
33
script/check/host/runAllChecks.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
_OWN_PATH="$(dirname $(readlink -f $0))"
|
||||
|
||||
function run_as_root() {
|
||||
[ "0" == "$(id -u)" ] \
|
||||
&& echo OK \
|
||||
&& return 0
|
||||
|
||||
echo FAIL
|
||||
return 1
|
||||
}
|
||||
|
||||
function scripts_are_updateable_by_git() {
|
||||
git -C "${_OWN_PATH:?"Missing OWN_PATH"}" pull > /dev/null 2>&1 \
|
||||
&& echo OK \
|
||||
&& return 0
|
||||
|
||||
echo FAIL
|
||||
return 1
|
||||
}
|
||||
|
||||
echo "PRECONDITION run as root: $(run_as_root)"
|
||||
echo "PRECONDITION scripts are updateable by git: $(scripts_are_updateable_by_git)"
|
||||
echo
|
||||
echo "Check all:"
|
||||
for _CURRENT_CHECK in ${_OWN_PATH}/checks/*.check.sh; do
|
||||
_NAME="$(basename ${_CURRENT_CHECK} | cut -d'.' -f1)"
|
||||
_CONTEXT="$(echo ${_NAME} | cut -d'_' -f1)"
|
||||
_CHECK="$(echo ${_NAME} | cut -d'_' -f2- | tr '_' ' ')"
|
||||
_RESULT="$("${_CURRENT_CHECK}" && echo OK || echo FAIL)"
|
||||
echo " ${_CONTEXT^^} ${_CHECK}: ${_RESULT}"
|
||||
done
|
||||
Reference in New Issue
Block a user