Merge pull request #348 from dheule/bugfix_type__cron

bugfix of raw_command
This commit is contained in:
Darko Poljak 2016-12-14 09:04:54 +01:00 committed by GitHub
commit 0462b4afc9
2 changed files with 15 additions and 6 deletions

View file

@ -22,4 +22,9 @@
name="$__object_name"
user="$(cat "$__object/parameter/user")"
crontab -u $user -l 2>/dev/null | grep "# $name\$" || true
if [ -f "$__object/parameter/raw_command" ]; then
command="$(cat "$__object/parameter/command")"
crontab -u $user -l 2>/dev/null | grep "^$command\$" || true
else
crontab -u $user -l 2>/dev/null | grep "# $name\$" || true
fi

14
cdist/conf/type/__cron/gencode-remote Executable file → Normal file
View file

@ -26,7 +26,7 @@ command="$(cat "$__object/parameter/command")"
if [ -f "$__object/parameter/raw" ]; then
raw="$(cat "$__object/parameter/raw")"
entry="$raw $command"
entry="$raw $command # $name"
elif [ -f "$__object/parameter/raw_command" ]; then
entry="$command"
else
@ -35,10 +35,9 @@ else
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 "*")"
entry="$minute $hour $day_of_month $month $day_of_week $command"
entry="$minute $hour $day_of_month $month $day_of_week $command # $name"
fi
entry="$entry # $name"
mkdir "$__object/files"
echo "$entry" > "$__object/files/entry"
@ -85,7 +84,12 @@ case "$state_should" in
echo ") | crontab -u $user -"
;;
absent)
echo "( crontab -u $user -l 2>/dev/null | grep -v -E \"$filter\" 2>/dev/null || true ) | \\"
echo "grep -v \"# $name\\$\" | crontab -u $user -"
if [ -f "$__object/parameter/raw_command" ]; then
echo "( crontab -u $user -l 2>/dev/null | grep -v -E \"$filter\" 2>/dev/null || true ) | \\"
echo "grep -v \"^$entry\\$\" | crontab -u $user -"
else
echo "( crontab -u $user -l 2>/dev/null | grep -v -E \"$filter\" 2>/dev/null || true ) | \\"
echo "grep -v \"# $name\\$\" | crontab -u $user -"
fi
;;
esac