mirror of
https://github.com/inspec/inspec
synced 2024-12-21 18:43:13 +00:00
bf748d8478
Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
32 lines
909 B
Text
32 lines
909 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 exec ${PROFILE_PATH} --json-config ${CONFIG} 2>&1 | tee ${LOG_FILE}
|
|
|
|
exit_code=$?
|
|
if [ $exit_code -eq 1 ]; then
|
|
echo "InSpec run failed."
|
|
else
|
|
echo "InSpec 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
|