mirror of
https://github.com/plantroon/acme.sh.git
synced 2024-12-22 05:01:40 +00:00
support multiple cronjobs
This commit is contained in:
parent
d84665cb64
commit
bbcc9d4b8e
32
acme.sh
32
acme.sh
@ -4601,29 +4601,31 @@ installcronjob() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
_c_cron_param="--home \"$LE_WORKING_DIR\""
|
||||||
|
if [ "$_c_home" ]; then
|
||||||
|
_c_entry="--config-home \"$_c_home\""
|
||||||
|
_c_cron_param="--home \"$LE_WORKING_DIR\" $_c_entry"
|
||||||
|
fi
|
||||||
|
_debug "_c_cron_param" "$_c_cron_param"
|
||||||
_info "Installing cron job"
|
_info "Installing cron job"
|
||||||
if ! $_CRONTAB -l | grep "$PROJECT_ENTRY --cron"; then
|
if ! $_CRONTAB -l | grep -- "$PROJECT_ENTRY --cron $_c_cron_param >"; then
|
||||||
if [ -f "$LE_WORKING_DIR/$PROJECT_ENTRY" ]; then
|
if [ -f "$LE_WORKING_DIR/$PROJECT_ENTRY" ]; then
|
||||||
lesh="\"$LE_WORKING_DIR\"/$PROJECT_ENTRY"
|
lesh="\"$LE_WORKING_DIR\"/$PROJECT_ENTRY"
|
||||||
else
|
else
|
||||||
_err "Can not install cronjob, $PROJECT_ENTRY not found."
|
_err "Can not install cronjob, $PROJECT_ENTRY not found."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$_c_home" ]; then
|
|
||||||
_c_entry="--config-home \"$_c_home\" "
|
|
||||||
fi
|
|
||||||
_t=$(_time)
|
_t=$(_time)
|
||||||
random_minute=$(_math $_t % 60)
|
random_minute=$(_math $_t % 60)
|
||||||
if _exists uname && uname -a | grep SunOS >/dev/null; then
|
if _exists uname && uname -a | grep SunOS >/dev/null; then
|
||||||
$_CRONTAB -l | {
|
$_CRONTAB -l | {
|
||||||
cat
|
cat
|
||||||
echo "$random_minute 0 * * * $lesh --cron --home \"$LE_WORKING_DIR\" $_c_entry> /dev/null"
|
echo "$random_minute 0 * * * $lesh --cron $_c_cron_param > /dev/null"
|
||||||
} | $_CRONTAB --
|
} | $_CRONTAB --
|
||||||
else
|
else
|
||||||
$_CRONTAB -l | {
|
$_CRONTAB -l | {
|
||||||
cat
|
cat
|
||||||
echo "$random_minute 0 * * * $lesh --cron --home \"$LE_WORKING_DIR\" $_c_entry> /dev/null"
|
echo "$random_minute 0 * * * $lesh --cron $_c_cron_param > /dev/null"
|
||||||
} | $_CRONTAB -
|
} | $_CRONTAB -
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -4636,6 +4638,7 @@ installcronjob() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uninstallcronjob() {
|
uninstallcronjob() {
|
||||||
|
_c_home="$1"
|
||||||
_CRONTAB="crontab"
|
_CRONTAB="crontab"
|
||||||
if ! _exists "$_CRONTAB" && _exists "fcrontab"; then
|
if ! _exists "$_CRONTAB" && _exists "fcrontab"; then
|
||||||
_CRONTAB="fcrontab"
|
_CRONTAB="fcrontab"
|
||||||
@ -4644,13 +4647,20 @@ uninstallcronjob() {
|
|||||||
if ! _exists "$_CRONTAB"; then
|
if ! _exists "$_CRONTAB"; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
_c_cron_param="--home \"$LE_WORKING_DIR\""
|
||||||
|
if [ "$_c_home" ]; then
|
||||||
|
_c_entry="--config-home \"$_c_home\""
|
||||||
|
_c_cron_param="--home \"$LE_WORKING_DIR\" $_c_entry"
|
||||||
|
fi
|
||||||
|
_debug "_c_cron_param" "$_c_cron_param"
|
||||||
_info "Removing cron job"
|
_info "Removing cron job"
|
||||||
cr="$($_CRONTAB -l | grep "$PROJECT_ENTRY --cron")"
|
cr="$($_CRONTAB -l | grep "$PROJECT_ENTRY --cron $_c_cron_param >")"
|
||||||
|
_debug "cr" "$cr"
|
||||||
if [ "$cr" ]; then
|
if [ "$cr" ]; then
|
||||||
if _exists uname && uname -a | grep solaris >/dev/null; then
|
if _exists uname && uname -a | grep solaris >/dev/null; then
|
||||||
$_CRONTAB -l | sed "/$PROJECT_ENTRY --cron/d" | $_CRONTAB --
|
$_CRONTAB -l | grep -v "$PROJECT_ENTRY --cron $_c_cron_param >" | $_CRONTAB --
|
||||||
else
|
else
|
||||||
$_CRONTAB -l | sed "/$PROJECT_ENTRY --cron/d" | $_CRONTAB -
|
$_CRONTAB -l | grep -v "$PROJECT_ENTRY --cron $_c_cron_param >" | $_CRONTAB -
|
||||||
fi
|
fi
|
||||||
LE_WORKING_DIR="$(echo "$cr" | cut -d ' ' -f 9 | tr -d '"')"
|
LE_WORKING_DIR="$(echo "$cr" | cut -d ' ' -f 9 | tr -d '"')"
|
||||||
_info LE_WORKING_DIR "$LE_WORKING_DIR"
|
_info LE_WORKING_DIR "$LE_WORKING_DIR"
|
||||||
@ -6009,7 +6019,7 @@ _process() {
|
|||||||
list "$_listraw"
|
list "$_listraw"
|
||||||
;;
|
;;
|
||||||
installcronjob) installcronjob "$_confighome" ;;
|
installcronjob) installcronjob "$_confighome" ;;
|
||||||
uninstallcronjob) uninstallcronjob ;;
|
uninstallcronjob) uninstallcronjob "$_confighome" ;;
|
||||||
cron) cron ;;
|
cron) cron ;;
|
||||||
toPkcs)
|
toPkcs)
|
||||||
toPkcs "$_domain" "$_password" "$_ecc"
|
toPkcs "$_domain" "$_password" "$_ecc"
|
||||||
|
Loading…
Reference in New Issue
Block a user