mirror of
https://github.com/inspec/inspec
synced 2024-12-20 18:13:20 +00:00
e468c592ca
Signed-off-by: Artem Sidorenko <artem.sidorenko@t-systems.com>
32 lines
987 B
Text
32 lines
987 B
Text
#!/bin/sh
|
|
|
|
exec 2>&1
|
|
|
|
CONFIG="{{pkg.svc_config_path}}/inspec_exec_config.json"
|
|
INTERVAL="{{cfg.interval}}"
|
|
LOG_FILE="{{pkg.svc_path}}/logs/inspec_log.txt"
|
|
PROFILE_IDENT="{{pkg.origin}}/{{pkg.name}}"
|
|
PROFILE_PATH="{{pkg.path}}/{{pkg.name}}-{{pkg.version}}.tar.gz"
|
|
|
|
while true; do
|
|
echo "Executing ${PROFILE_IDENT}"
|
|
exec <%= Inspec::Dist::EXEC_NAME %> exec ${PROFILE_PATH} --json-config ${CONFIG} 2>&1 | tee ${LOG_FILE}
|
|
|
|
exit_code=$?
|
|
if [ $exit_code -eq 1 ]; then
|
|
echo "<%= Inspec::Dist::PRODUCT_NAME %> run failed."
|
|
else
|
|
echo "<%= Inspec::Dist::PRODUCT_NAME %> run completed successfully."
|
|
if [ $exit_code -eq 0 ]; then
|
|
echo "No controls failed or were skipped."
|
|
elif [ $exit_code -eq 100 ]; then
|
|
echo "At least 1 control failed."
|
|
elif [ $exit_code -eq 101 ]; then
|
|
echo "No controls failed but at least 1 skipped."
|
|
fi
|
|
fi
|
|
echo "Results are logged here: ${LOG_FILE}"
|
|
|
|
echo "Sleeping for ${INTERVAL} seconds"
|
|
sleep ${INTERVAL}
|
|
done
|