|
@@ -78,18 +78,30 @@ function randomize_cron {
|
78
|
78
|
}
|
79
|
79
|
|
80
|
80
|
function schedule_stig_tests {
|
81
|
|
- echo '#!/bin/bash' > /etc/cron.daily/stig_tests
|
82
|
|
- echo "ADMIN_EMAIL_ADDRESS=${MY_USERNAME}@\${HOSTNAME}" >> /etc/cron.daily/stig_tests
|
83
|
|
- echo "pkill ${PROJECT_NAME}-tests" >> /etc/cron.daily/stig_tests
|
84
|
|
- echo 'rm -rf /tmp/*' >> /etc/cron.daily/stig_tests
|
85
|
|
- echo "${PROJECT_NAME}-tests --stig yes > /tmp/daily-stig-tests" >> /etc/cron.daily/stig_tests
|
86
|
|
- echo 'if [ ! "$?" = "0" ]; then' >> /etc/cron.daily/stig_tests
|
87
|
|
- echo " echo \"\$(cat /tmp/daily-stig-tests)\" | mail -s \"${PROJECT_NAME} STIG test failures\" \$ADMIN_EMAIL_ADDRESS" >> /etc/cron.daily/stig_tests
|
88
|
|
- echo 'fi' >> /etc/cron.daily/stig_tests
|
89
|
|
- echo 'if [ -f /tmp/daily-stig-tests ]; then' >> /etc/cron.daily/stig_tests
|
90
|
|
- echo ' rm /tmp/daily-stig-tests' >> /etc/cron.daily/stig_tests
|
91
|
|
- echo 'fi' >> /etc/cron.daily/stig_tests
|
92
|
|
- chmod +x /etc/cron.daily/stig_tests
|
|
81
|
+ stig_tests_script=/tmp/stig_tests_script
|
|
82
|
+ echo '#!/bin/bash' > $stig_tests_script
|
|
83
|
+ echo "ADMIN_EMAIL_ADDRESS=${MY_USERNAME}@\${HOSTNAME}" >> $stig_tests_script
|
|
84
|
+ echo "pkill ${PROJECT_NAME}-tests" >> $stig_tests_script
|
|
85
|
+ echo 'rm -rf /tmp/*' >> $stig_tests_script
|
|
86
|
+ echo "${PROJECT_NAME}-tests --stig yes > /tmp/daily-stig-tests" >> $stig_tests_script
|
|
87
|
+ echo 'if [ ! "$?" = "0" ]; then' >> $stig_tests_script
|
|
88
|
+ echo " echo \"\$(cat /tmp/daily-stig-tests)\" | mail -s \"${PROJECT_NAME} STIG test failures\" \$ADMIN_EMAIL_ADDRESS" >> $stig_tests_script
|
|
89
|
+ echo 'fi' >> $stig_tests_script
|
|
90
|
+ echo 'if [ -f /tmp/daily-stig-tests ]; then' >> $stig_tests_script
|
|
91
|
+ echo ' rm /tmp/daily-stig-tests' >> $stig_tests_script
|
|
92
|
+ echo 'fi' >> $stig_tests_script
|
|
93
|
+ chmod +x $stig_tests_script
|
|
94
|
+
|
|
95
|
+ if [ ! -f /etc/cron.daily/stig_tests ]; then
|
|
96
|
+ cp $stig_tests_script /etc/cron.daily/stig_tests
|
|
97
|
+ else
|
|
98
|
+ HASH1=$(sha256sum $stig_tests_script | awk -F ' ' '{print $1}')
|
|
99
|
+ HASH2=$(sha256sum /etc/cron.daily/stig_tests | awk -F ' ' '{print $1}')
|
|
100
|
+ if [[ "$HASH1" != "$HASH2" ]]; then
|
|
101
|
+ cp $stig_tests_script /etc/cron.daily/stig_tests
|
|
102
|
+ fi
|
|
103
|
+ fi
|
|
104
|
+ rm $stig_tests_script
|
93
|
105
|
}
|
94
|
106
|
|
95
|
107
|
# NOTE: deliberately there is no "exit 0"
|