forked from ungleich-public/cdist
Merge branch 'fix/__cron' into 'master'
[__cron] Fix cronjob removal if `is` and `should` don't match See merge request ungleich-public/cdist!841
This commit is contained in:
commit
b898412faf
8 changed files with 27 additions and 8 deletions
|
@ -31,24 +31,28 @@ if [ -f "$__object/parameter/raw" ]; then
|
|||
elif [ -f "$__object/parameter/raw_command" ]; then
|
||||
entry="$command"
|
||||
else
|
||||
minute="$(cat "$__object/parameter/minute" 2>/dev/null || echo "*")"
|
||||
hour="$(cat "$__object/parameter/hour" 2>/dev/null || echo "*")"
|
||||
day_of_month="$(cat "$__object/parameter/day_of_month" 2>/dev/null || echo "*")"
|
||||
month="$(cat "$__object/parameter/month" 2>/dev/null || echo "*")"
|
||||
day_of_week="$(cat "$__object/parameter/day_of_week" 2>/dev/null || echo "*")"
|
||||
minute="$(cat "$__object/parameter/minute")"
|
||||
hour="$(cat "$__object/parameter/hour")"
|
||||
day_of_month="$(cat "$__object/parameter/day_of_month")"
|
||||
month="$(cat "$__object/parameter/month")"
|
||||
day_of_week="$(cat "$__object/parameter/day_of_week")"
|
||||
entry="$minute $hour $day_of_month $month $day_of_week $command # $name"
|
||||
fi
|
||||
|
||||
mkdir "$__object/files"
|
||||
echo "$entry" > "$__object/files/entry"
|
||||
|
||||
if diff -q "$__object/files/entry" "$__object/explorer/entry" >/dev/null; then
|
||||
state_is=present
|
||||
if [ -s "$__object/explorer/entry" ]; then
|
||||
if diff -q "$__object/files/entry" "$__object/explorer/entry" >/dev/null; then
|
||||
state_is=present
|
||||
else
|
||||
state_is=modified
|
||||
fi
|
||||
else
|
||||
state_is=absent
|
||||
fi
|
||||
|
||||
state_should="$(cat "$__object/parameter/state" 2>/dev/null || echo "present")"
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
|
||||
[ "$state_is" = "$state_should" ] && exit 0
|
||||
|
||||
|
|
|
@ -22,3 +22,12 @@ if [ -f "$__object/parameter/raw" ] && [ -f "$__object/parameter/raw_command" ];
|
|||
echo "ERROR: both raw and raw_command specified" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$(cat "$__object/parameter/state")" in
|
||||
present) ;;
|
||||
absent) ;;
|
||||
|
||||
*)
|
||||
echo "ERROR: unkown cron state" >&2
|
||||
exit 2
|
||||
esac
|
||||
|
|
1
cdist/conf/type/__cron/parameter/default/day_of_month
Normal file
1
cdist/conf/type/__cron/parameter/default/day_of_month
Normal file
|
@ -0,0 +1 @@
|
|||
*
|
1
cdist/conf/type/__cron/parameter/default/day_of_week
Normal file
1
cdist/conf/type/__cron/parameter/default/day_of_week
Normal file
|
@ -0,0 +1 @@
|
|||
*
|
1
cdist/conf/type/__cron/parameter/default/hour
Normal file
1
cdist/conf/type/__cron/parameter/default/hour
Normal file
|
@ -0,0 +1 @@
|
|||
*
|
1
cdist/conf/type/__cron/parameter/default/minute
Normal file
1
cdist/conf/type/__cron/parameter/default/minute
Normal file
|
@ -0,0 +1 @@
|
|||
*
|
1
cdist/conf/type/__cron/parameter/default/month
Normal file
1
cdist/conf/type/__cron/parameter/default/month
Normal file
|
@ -0,0 +1 @@
|
|||
*
|
1
cdist/conf/type/__cron/parameter/default/state
Normal file
1
cdist/conf/type/__cron/parameter/default/state
Normal file
|
@ -0,0 +1 @@
|
|||
present
|
Loading…
Reference in a new issue