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:
matze 2020-02-15 09:46:23 +01:00
parent a761d4842c
commit 5e6e17b3e5
8 changed files with 13 additions and 7 deletions

View File

@ -31,11 +31,11 @@ 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
@ -52,7 +52,7 @@ 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

View File

@ -23,7 +23,7 @@ if [ -f "$__object/parameter/raw" ] && [ -f "$__object/parameter/raw_command" ];
exit 1
fi
case "$(cat "$__object/parameter/state" 2>/dev/null || echo "present")" in
case "$(cat "$__object/parameter/state")" in
present) ;;
absent) ;;

View File

@ -0,0 +1 @@
*

View File

@ -0,0 +1 @@
*

View File

@ -0,0 +1 @@
*

View File

@ -0,0 +1 @@
*

View File

@ -0,0 +1 @@
*

View File

@ -0,0 +1 @@
present