remove the old entries on change
Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
parent
d78dc7af8b
commit
4ae241259f
2 changed files with 33 additions and 0 deletions
|
@ -49,6 +49,29 @@ state_should="$(cat "$__object/parameter/state" 2>/dev/null || echo "present")"
|
|||
|
||||
[ "$state_is" = "$state_should" ] && exit 0
|
||||
|
||||
# If anything is going to change, ensure the old entries are
|
||||
# not present anymore
|
||||
|
||||
# These are the old markers
|
||||
prefix="#cdist:__cron/$__object_id"
|
||||
suffix="#/cdist:__cron/$__object_id"
|
||||
cat << DONE
|
||||
crontab -u $user -l | awk -v prefix="$prefix" -v suffix="$suffix" '
|
||||
{
|
||||
if (index(\$0,prefix)) {
|
||||
triggered=1
|
||||
}
|
||||
if (triggered) {
|
||||
if (index(\$0,suffix)) {
|
||||
triggered=0
|
||||
}
|
||||
} else {
|
||||
print
|
||||
}
|
||||
}
|
||||
' | crontab -u $user -
|
||||
DONE
|
||||
|
||||
case "$state_should" in
|
||||
present)
|
||||
echo "("
|
||||
|
|
10
docs/changelog.2.2
Normal file
10
docs/changelog.2.2
Normal file
|
@ -0,0 +1,10 @@
|
|||
Changelog
|
||||
---------
|
||||
|
||||
* Changes are always commented with their author in (braces)
|
||||
* Exception: No braces means author == Nico Schottelius
|
||||
|
||||
2.2.0:
|
||||
* Type __cron: Dropped support for old internal format
|
||||
Using this version prior to running cdist 2.1.2 will
|
||||
break add the cron entries twice.
|
Loading…
Reference in a new issue