mirror of
https://github.com/YunoHost-Apps/unattended_upgrades_ynh.git
synced 2024-10-01 13:35:00 +02:00
Try to fix broken cron
This commit is contained in:
parent
915bcd0cf6
commit
6a38db1bbe
1 changed files with 15 additions and 15 deletions
|
@ -31,22 +31,22 @@ _apticron_set_config() {
|
||||||
# Create a backup of the cron file for the reset action
|
# Create a backup of the cron file for the reset action
|
||||||
cp "$apticron_cron" "$apticron_cron_backup"
|
cp "$apticron_cron" "$apticron_cron_backup"
|
||||||
|
|
||||||
# Copy and comment the current cron
|
# Clear everything, keep only the first (official) one. Uncomment.
|
||||||
ynh_replace_string --match_string="^.* root if.*" --replace_string="#&\n&" --target_file="$apticron_cron"
|
origin_line=$(grep -m 1 "apticron --cron" "$apticron_cron" | sed 's/^#* *//')
|
||||||
# Modify the time to set at 20:00 every day
|
|
||||||
ynh_replace_string --match_string="^[[:digit:]].*\( root if.*\)" --replace_string="0 20 * * *\1" --target_file="$apticron_cron"
|
|
||||||
# Copy the new cron and set the time to 2:00 every night
|
|
||||||
ynh_replace_string --match_string="^0 20\(.*\)" --replace_string="&\n0 2\1" --target_file="$apticron_cron"
|
|
||||||
|
|
||||||
if [ "$previous_apticron" -eq 0 ]; then
|
# Remove all lines matching
|
||||||
# Comment the first cron
|
ynh_replace_string --match_string=".*apticron --cron.*" --replace_string="" --target_file="$apticron_cron"
|
||||||
ynh_replace_string --match_string="^0 20 .*" --replace_string="#&" --target_file="$apticron_cron"
|
# Remove empty lines
|
||||||
|
sed -i '/^\s*$/d' "$apticron_cron"
|
||||||
|
(
|
||||||
|
echo "# $origin_line"
|
||||||
|
if [ "$previous_apticron" -eq 1 ]; then
|
||||||
|
echo "$origin_line" | sed 's|^.*\( root if.*\)|0 20 * * *\1|'
|
||||||
fi
|
fi
|
||||||
|
if [ "$after_apticron" -eq 1 ]; then
|
||||||
if [ "$after_apticron" -eq 0 ]; then
|
echo "$origin_line" | sed 's|^.*\( root if.*\)|0 2 * * *\1|'
|
||||||
# Comment the second cron
|
|
||||||
ynh_replace_string --match_string="^0 2 .*" --replace_string="#&" --target_file="$apticron_cron"
|
|
||||||
fi
|
fi
|
||||||
|
) >> "$apticron_cron"
|
||||||
}
|
}
|
||||||
|
|
||||||
_apticron_restore_config() {
|
_apticron_restore_config() {
|
||||||
|
|
Loading…
Reference in a new issue