Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
freedombone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Context Sensitive Group
freedombone
Commits
4e655ae8
Commit
4e655ae8
authored
7 years ago
by
Bob Mottram
Browse files
Options
Downloads
Patches
Plain Diff
Tidying cron utils
parent
34e59ae0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/freedombone-utils-cron
+26
-26
26 additions, 26 deletions
src/freedombone-utils-cron
with
26 additions
and
26 deletions
src/freedombone-utils-cron
+
26
−
26
View file @
4e655ae8
...
...
@@ -31,7 +31,7 @@
function
cron_add_mins
{
if
!
grep
-q
"
${
2
}
"
/etc/crontab
;
then
job_user
=
'root'
if
[
$3
]
;
then
if
[
"
$3
"
]
;
then
job_user
=
$3
fi
echo
"*/
${
1
}
* * * *
${
job_user
}
${
2
}
"
>>
/etc/crontab
...
...
@@ -48,29 +48,29 @@ function randomize_cron {
fi
# randomize the day on which the weekly cron job runs
randdow
=
$((
$
RANDOM
%
6
+
1
))
sed
-i
"s|
\*
\*
7|* *
$randdow
|g"
/etc/crontab
randdow
=
$((
RANDOM%6+1
))
sed
-i
"s|
\
\
*
\
\
* 7|* *
$randdow
|g"
/etc/crontab
# randomize the time when the weekly cron job runs
randmin
=
$((
$
RANDOM
%
60
))
randhr
=
$((
$
RANDOM
%
3
+
1
))
randmin
=
$((
RANDOM%60
))
randhr
=
$((
RANDOM%3+1
))
sed
-i
"s|47 6|
$randmin
$randhr
|g"
/etc/crontab
# randomize the time when the daily cron job runs
randmin
=
$((
$
RANDOM
%
60
))
randhr
=
$((
$
RANDOM
%
3
+
4
))
sed
-i
"s|25 6
\
t
\*
\*
\*
|
$randmin
$randhr
\t
* * *|g"
/etc/crontab
randmin
=
$((
RANDOM%60
))
randhr
=
$((
RANDOM%3+4
))
sed
-i
"s|25 6
\
\
t
\
\
*
\
\
*
\
\
*|
$randmin
$randhr
\
\
t* * *|g"
/etc/crontab
# randomize the time when the hourly cron job runs
randmin
=
$((
$
RANDOM
%
60
))
sed
-i
"s|17
\
*
\t
|
$randmin
*
\t
|g"
/etc/crontab
randmin
=
$((
RANDOM%60
))
sed
-i
"s|17
\
\
*
\
\
t|
$randmin
*
\
\
t|g"
/etc/crontab
# randomize monthly cron job time and day
randmin
=
$((
$
RANDOM
%
60
))
randhr
=
$((
$
RANDOM
%
22
+
1
))
randdom
=
$((
$
RANDOM
%
27
+
1
))
sed
-i
"s|52 6
\t
|
$randmin
$randhr
\t
|g"
/etc/crontab
sed
-i
"s|
\t
1
\*
\*
|
\t
$randdom
* *|g"
/etc/crontab
randmin
=
$((
RANDOM%60
))
randhr
=
$((
RANDOM%22+1
))
randdom
=
$((
RANDOM%27+1
))
sed
-i
"s|52 6
\
\
t|
$randmin
$randhr
\
\
t|g"
/etc/crontab
sed
-i
"s|
\
\
t1
\
\
*
\
\
*|
\
\
t
$randdom
* *|g"
/etc/crontab
systemctl restart cron
...
...
@@ -79,17 +79,17 @@ function randomize_cron {
function
schedule_stig_tests
{
stig_tests_script
=
/tmp/stig_tests_script
echo
'#!/bin/bash'
>
$stig_tests_script
echo
"ADMIN_EMAIL_ADDRESS=
${
MY_USERNAME
}
@
\$
{HOSTNAME}"
>>
$stig_tests_script
echo
"pkill
${
PROJECT_NAME
}
-tests"
>>
$stig_tests_script
echo
'rm -rf /tmp/*'
>>
$stig_tests_script
echo
"
${
PROJECT_NAME
}
-tests --stig yes > /tmp/daily-stig-tests"
>>
$stig_tests_script
echo
'if [ ! "$?" = "0" ]; then'
>>
$stig_tests_script
echo
" echo
\"\$
(cat /tmp/daily-stig-tests)
\"
| mail -s
\"
${
PROJECT_NAME
}
STIG test failures
\"
\$
ADMIN_EMAIL_ADDRESS"
>>
$stig_tests_script
echo
'fi'
>>
$stig_tests_script
echo
'if [ -f /tmp/daily-stig-tests ]; then'
>>
$stig_tests_script
echo
' rm /tmp/daily-stig-tests'
>>
$stig_tests_script
echo
'fi'
>
>
$stig_tests_script
{
echo
'#!/bin/bash'
;
echo
"ADMIN_EMAIL_ADDRESS=
${
MY_USERNAME
}
@
\$
{HOSTNAME}"
;
echo
"pkill
${
PROJECT_NAME
}
-tests"
;
echo
'rm -rf /tmp/*'
;
echo
"
${
PROJECT_NAME
}
-tests --stig yes > /tmp/daily-stig-tests"
;
echo
'if [ ! "$?" = "0" ]; then'
;
echo
" echo
\"\$
(cat /tmp/daily-stig-tests)
\"
| mail -s
\"
${
PROJECT_NAME
}
STIG test failures
\"
\$
ADMIN_EMAIL_ADDRESS"
;
echo
'fi'
;
echo
'if [ -f /tmp/daily-stig-tests ]; then'
;
echo
' rm /tmp/daily-stig-tests'
;
echo
'fi'
;
}
>
$stig_tests_script
chmod
+x
$stig_tests_script
if
[
!
-f
/etc/cron.daily/stig_tests
]
;
then
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment