Moved default parameter values from scripts to cdist parameter handling.
For more generalisation, the default parameter values are now handled by cdist instead of trying to get a value and use a default if parameter is not given. It handles the default values in a more general way, instead of write one default in (possibly) multiple places. Problem occurred when checking the 'state' parameter, which required to set a default value in two places.
This commit is contained in:
parent
a761d4842c
commit
5e6e17b3e5
8 changed files with 13 additions and 7 deletions
|
@ -31,11 +31,11 @@ if [ -f "$__object/parameter/raw" ]; then
|
||||||
elif [ -f "$__object/parameter/raw_command" ]; then
|
elif [ -f "$__object/parameter/raw_command" ]; then
|
||||||
entry="$command"
|
entry="$command"
|
||||||
else
|
else
|
||||||
minute="$(cat "$__object/parameter/minute" 2>/dev/null || echo "*")"
|
minute="$(cat "$__object/parameter/minute")"
|
||||||
hour="$(cat "$__object/parameter/hour" 2>/dev/null || echo "*")"
|
hour="$(cat "$__object/parameter/hour")"
|
||||||
day_of_month="$(cat "$__object/parameter/day_of_month" 2>/dev/null || echo "*")"
|
day_of_month="$(cat "$__object/parameter/day_of_month")"
|
||||||
month="$(cat "$__object/parameter/month" 2>/dev/null || echo "*")"
|
month="$(cat "$__object/parameter/month")"
|
||||||
day_of_week="$(cat "$__object/parameter/day_of_week" 2>/dev/null || echo "*")"
|
day_of_week="$(cat "$__object/parameter/day_of_week")"
|
||||||
entry="$minute $hour $day_of_month $month $day_of_week $command # $name"
|
entry="$minute $hour $day_of_month $month $day_of_week $command # $name"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ else
|
||||||
state_is=absent
|
state_is=absent
|
||||||
fi
|
fi
|
||||||
|
|
||||||
state_should="$(cat "$__object/parameter/state" 2>/dev/null || echo "present")"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
|
|
||||||
[ "$state_is" = "$state_should" ] && exit 0
|
[ "$state_is" = "$state_should" ] && exit 0
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ if [ -f "$__object/parameter/raw" ] && [ -f "$__object/parameter/raw_command" ];
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$(cat "$__object/parameter/state" 2>/dev/null || echo "present")" in
|
case "$(cat "$__object/parameter/state")" in
|
||||||
present) ;;
|
present) ;;
|
||||||
absent) ;;
|
absent) ;;
|
||||||
|
|
||||||
|
|
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