mirror of
https://github.com/yavook/kiwi-cron.git
synced 2024-11-24 16:33:00 +00:00
modularity
This commit is contained in:
parent
718ddec618
commit
0cd472a08f
3 changed files with 61 additions and 25 deletions
|
@ -1,9 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# replace crontab
|
exec /usr/local/libexec/kiwi-cron/run_cron \
|
||||||
/usr/local/libexec/kiwi-cron/schedule_dirs \
|
"${@}" \
|
||||||
| /usr/local/libexec/kiwi-cron/print_crontab \
|
/usr/local/libexec/kiwi-cron/schedule_dirs
|
||||||
| crontab -
|
|
||||||
|
|
||||||
# run crond
|
|
||||||
exec crond -fd 8
|
|
||||||
|
|
|
@ -32,22 +32,22 @@ cs_rand_weekday=$(( (6 + RANDOM % 2) % 7 ))
|
||||||
cs_rand_month=$(( RANDOM % 2 + 1 ))
|
cs_rand_month=$(( RANDOM % 2 + 1 ))
|
||||||
|
|
||||||
case "${cs_units}" in
|
case "${cs_units}" in
|
||||||
minute)
|
minute)
|
||||||
echo "*${cs_every}" "*" "*" "*" "*" "${cs_command}"
|
echo "*${cs_every}" "*" "*" "*" "*" "${cs_command}"
|
||||||
;;
|
;;
|
||||||
hour)
|
hour)
|
||||||
echo "${cs_rand_min}" "*${cs_every}" "*" "*" "*" "${cs_command}"
|
echo "${cs_rand_min}" "*${cs_every}" "*" "*" "*" "${cs_command}"
|
||||||
;;
|
;;
|
||||||
day)
|
day)
|
||||||
echo "${cs_rand_min}" "${cs_rand_hour}" "*${cs_every}" "*" "*" "${cs_command}"
|
echo "${cs_rand_min}" "${cs_rand_hour}" "*${cs_every}" "*" "*" "${cs_command}"
|
||||||
;;
|
;;
|
||||||
week)
|
week)
|
||||||
echo "${cs_rand_min}" "${cs_rand_hour}" "*" "*" "${cs_rand_weekday}" "${cs_command}"
|
echo "${cs_rand_min}" "${cs_rand_hour}" "*" "*" "${cs_rand_weekday}" "${cs_command}"
|
||||||
;;
|
;;
|
||||||
month)
|
month)
|
||||||
echo "${cs_rand_min}" "${cs_rand_hour}" "${cs_rand_day}" "*${cs_every}" "*" "${cs_command}"
|
echo "${cs_rand_min}" "${cs_rand_hour}" "${cs_rand_day}" "*${cs_every}" "*" "${cs_command}"
|
||||||
;;
|
;;
|
||||||
year)
|
year)
|
||||||
echo "${cs_rand_min}" "${cs_rand_hour}" "${cs_rand_day}" "${cs_rand_month}" "*" "${cs_command}"
|
echo "${cs_rand_min}" "${cs_rand_hour}" "${cs_rand_day}" "${cs_rand_month}" "*" "${cs_command}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
40
libexec/kiwi-cron/run_cron
Normal file
40
libexec/kiwi-cron/run_cron
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# check for CLI options
|
||||||
|
while getopts ':n' rc_optarg; do
|
||||||
|
case "${rc_optarg}" in
|
||||||
|
n)
|
||||||
|
rc_dry_run="yes"
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "Invalid option: -${OPTARG}."
|
||||||
|
exit 2
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
shift "$(( OPTIND - 1 ))"
|
||||||
|
|
||||||
|
# CLI arguments
|
||||||
|
rc_executable="${1}"
|
||||||
|
|
||||||
|
|
||||||
|
if [ -n "${rc_dry_run}" ]; then
|
||||||
|
# verbose, dry run
|
||||||
|
set -x
|
||||||
|
|
||||||
|
"${rc_executable}" \
|
||||||
|
| /usr/local/libexec/kiwi-cron/print_crontab
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# replace crontab
|
||||||
|
"${rc_executable}" \
|
||||||
|
| /usr/local/libexec/kiwi-cron/print_crontab \
|
||||||
|
| crontab -
|
||||||
|
|
||||||
|
# hand over to crond
|
||||||
|
exec crond -fd 8
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in a new issue