|
@@ -31,7 +31,7 @@
|
31
|
31
|
function cron_add_mins {
|
32
|
32
|
if ! grep -q "${2}" /etc/crontab; then
|
33
|
33
|
job_user='root'
|
34
|
|
- if [ $3 ]; then
|
|
34
|
+ if [ "$3" ]; then
|
35
|
35
|
job_user=$3
|
36
|
36
|
fi
|
37
|
37
|
echo "*/${1} * * * * ${job_user} ${2}" >> /etc/crontab
|
|
@@ -48,29 +48,29 @@ function randomize_cron {
|
48
|
48
|
fi
|
49
|
49
|
|
50
|
50
|
# randomize the day on which the weekly cron job runs
|
51
|
|
- randdow=$(($RANDOM%6+1))
|
52
|
|
- sed -i "s|\* \* 7|* * $randdow|g" /etc/crontab
|
|
51
|
+ randdow=$((RANDOM%6+1))
|
|
52
|
+ sed -i "s|\\* \\* 7|* * $randdow|g" /etc/crontab
|
53
|
53
|
|
54
|
54
|
# randomize the time when the weekly cron job runs
|
55
|
|
- randmin=$(($RANDOM%60))
|
56
|
|
- randhr=$(($RANDOM%3+1))
|
|
55
|
+ randmin=$((RANDOM%60))
|
|
56
|
+ randhr=$((RANDOM%3+1))
|
57
|
57
|
sed -i "s|47 6|$randmin $randhr|g" /etc/crontab
|
58
|
58
|
|
59
|
59
|
# randomize the time when the daily cron job runs
|
60
|
|
- randmin=$(($RANDOM%60))
|
61
|
|
- randhr=$(($RANDOM%3+4))
|
62
|
|
- sed -i "s|25 6\t\* \* \*|$randmin $randhr\t* * *|g" /etc/crontab
|
|
60
|
+ randmin=$((RANDOM%60))
|
|
61
|
+ randhr=$((RANDOM%3+4))
|
|
62
|
+ sed -i "s|25 6\\t\\* \\* \\*|$randmin $randhr\\t* * *|g" /etc/crontab
|
63
|
63
|
|
64
|
64
|
# randomize the time when the hourly cron job runs
|
65
|
|
- randmin=$(($RANDOM%60))
|
66
|
|
- sed -i "s|17 \*\t|$randmin *\t|g" /etc/crontab
|
|
65
|
+ randmin=$((RANDOM%60))
|
|
66
|
+ sed -i "s|17 \\*\\t|$randmin *\\t|g" /etc/crontab
|
67
|
67
|
|
68
|
68
|
# randomize monthly cron job time and day
|
69
|
|
- randmin=$(($RANDOM%60))
|
70
|
|
- randhr=$(($RANDOM%22+1))
|
71
|
|
- randdom=$(($RANDOM%27+1))
|
72
|
|
- sed -i "s|52 6\t|$randmin $randhr\t|g" /etc/crontab
|
73
|
|
- sed -i "s|\t1 \* \*|\t$randdom * *|g" /etc/crontab
|
|
69
|
+ randmin=$((RANDOM%60))
|
|
70
|
+ randhr=$((RANDOM%22+1))
|
|
71
|
+ randdom=$((RANDOM%27+1))
|
|
72
|
+ sed -i "s|52 6\\t|$randmin $randhr\\t|g" /etc/crontab
|
|
73
|
+ sed -i "s|\\t1 \\* \\*|\\t$randdom * *|g" /etc/crontab
|
74
|
74
|
|
75
|
75
|
systemctl restart cron
|
76
|
76
|
|
|
@@ -79,17 +79,17 @@ function randomize_cron {
|
79
|
79
|
|
80
|
80
|
function schedule_stig_tests {
|
81
|
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
|
|
82
|
+ { echo '#!/bin/bash';
|
|
83
|
+ echo "ADMIN_EMAIL_ADDRESS=${MY_USERNAME}@\${HOSTNAME}";
|
|
84
|
+ echo "pkill ${PROJECT_NAME}-tests";
|
|
85
|
+ echo 'rm -rf /tmp/*';
|
|
86
|
+ echo "${PROJECT_NAME}-tests --stig yes > /tmp/daily-stig-tests";
|
|
87
|
+ echo 'if [ ! "$?" = "0" ]; then';
|
|
88
|
+ echo " echo \"\$(cat /tmp/daily-stig-tests)\" | mail -s \"${PROJECT_NAME} STIG test failures\" \$ADMIN_EMAIL_ADDRESS";
|
|
89
|
+ echo 'fi';
|
|
90
|
+ echo 'if [ -f /tmp/daily-stig-tests ]; then';
|
|
91
|
+ echo ' rm /tmp/daily-stig-tests';
|
|
92
|
+ echo 'fi'; } > $stig_tests_script
|
93
|
93
|
chmod +x $stig_tests_script
|
94
|
94
|
|
95
|
95
|
if [ ! -f /etc/cron.daily/stig_tests ]; then
|