diff --git a/cdist/conf/type/__cron/explorer/entry b/cdist/conf/type/__cron/explorer/entry old mode 100755 new mode 100644 diff --git a/cdist/conf/type/__cron/gencode-remote b/cdist/conf/type/__cron/gencode-remote old mode 100755 new mode 100644 index c04a7245..6f1feb90 --- a/cdist/conf/type/__cron/gencode-remote +++ b/cdist/conf/type/__cron/gencode-remote @@ -26,6 +26,8 @@ command="$(cat "$__object/parameter/command")" if [ -f "$__object/parameter/raw" ]; then raw="$(cat "$__object/parameter/raw")" entry="$raw $command" +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 "*")" @@ -55,8 +57,9 @@ state_should="$(cat "$__object/parameter/state" 2>/dev/null || echo "present")" # These are the old markers prefix="#cdist:__cron/$__object_id" suffix="#/cdist:__cron/$__object_id" +filter="^# DO NOT EDIT THIS FILE|^# \(.* installed on |^# \(Cron version V" cat << DONE -crontab -u $user -l | awk -v prefix="$prefix" -v suffix="$suffix" ' +crontab -u $user -l | grep -v -E "$filter" | awk -v prefix="$prefix" -v suffix="$suffix" ' { if (index(\$0,prefix)) { triggered=1 @@ -75,12 +78,12 @@ DONE case "$state_should" in present) echo "(" - echo "crontab -u $user -l 2>/dev/null || true" + echo "crontab -u $user -l | grep -v -E "$filter" 2>/dev/null || true" echo "echo '$entry'" echo ") | crontab -u $user -" ;; absent) - echo "( crontab -u $user -l 2>/dev/null || true ) | \\" + echo "( crontab -u $user -l | grep -v -E "$filter" 2>/dev/null || true ) | \\" echo "grep -v \"# $name\\$\" | crontab -u $user -" ;; esac diff --git a/cdist/conf/type/__cron/man.text b/cdist/conf/type/__cron/man.text index 22627234..f4e80a08 100644 --- a/cdist/conf/type/__cron/man.text +++ b/cdist/conf/type/__cron/man.text @@ -41,6 +41,10 @@ raw:: Can for example be used to specify cron EXTENSIONS like reboot, yearly etc. See crontab(5) for the extensions if any that your cron implementation implements. +raw_command:: + Take whatever the user has given in the commmand and ignore everything else. + If given, the command will be added to crontab. + Can for example be used to define variables like SHELL or MAILTO. EXAMPLES @@ -57,6 +61,10 @@ __cron some-id --user root --command "/path/to/script" \ # remove cronjob __cron some-id --user root --command "/path/to/script" --state absent + +# define default shell +__cron some-id --user root --raw_command --command "SHELL=/bin/bash" \ + --state present -------------------------------------------------------------------------------- diff --git a/cdist/conf/type/__cron/parameter/boolean b/cdist/conf/type/__cron/parameter/boolean new file mode 100644 index 00000000..54cfb0b3 --- /dev/null +++ b/cdist/conf/type/__cron/parameter/boolean @@ -0,0 +1 @@ +raw_command