mirror of
https://github.com/YunoHost-Apps/unattended_upgrades_ynh.git
synced 2024-10-01 13:35:00 +02:00
Merge pull request #26 from YunoHost-Apps/fix_cron_apticron
Try to fix broken cron
This commit is contained in:
commit
62f3666be4
3 changed files with 26 additions and 17 deletions
9
doc/PRE_UPGRADE.d/1.1~ynh1.md
Normal file
9
doc/PRE_UPGRADE.d/1.1~ynh1.md
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
## Backup is broken and breaks upgrade with it
|
||||||
|
|
||||||
|
If the backup fails because some file in `/etc/yunohost` does not exist, it will prevent any app upgrade.
|
||||||
|
|
||||||
|
You should run the upgrade with `--no-safety-backup`, like that:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo yunohost app upgrade unattended_upgrades --no-safety-backup
|
||||||
|
```
|
|
@ -7,7 +7,7 @@ name = "Unattended-upgrades"
|
||||||
description.en = "Daily automatic upgrades"
|
description.en = "Daily automatic upgrades"
|
||||||
description.fr = "Mise à jour automatique quotidienne"
|
description.fr = "Mise à jour automatique quotidienne"
|
||||||
|
|
||||||
version = "1.0~ynh7"
|
version = "1.1~ynh1"
|
||||||
|
|
||||||
maintainers = []
|
maintainers = []
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ admindoc = "https://wiki.debian.org/UnattendedUpgrades"
|
||||||
userdoc = "https://manpages.debian.org/stretch/apticron/apticron.1.en.html"
|
userdoc = "https://manpages.debian.org/stretch/apticron/apticron.1.en.html"
|
||||||
|
|
||||||
[integration]
|
[integration]
|
||||||
yunohost = ">= 4.3.0"
|
yunohost = ">= 11.2"
|
||||||
architectures = "all"
|
architectures = "all"
|
||||||
multi_instance = false
|
multi_instance = false
|
||||||
ldap = "not_relevant"
|
ldap = "not_relevant"
|
||||||
|
|
|
@ -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
|
||||||
fi
|
sed -i '/^\s*$/d' "$apticron_cron"
|
||||||
|
(
|
||||||
if [ "$after_apticron" -eq 0 ]; then
|
echo "# $origin_line"
|
||||||
# Comment the second cron
|
if [ "$previous_apticron" -eq 1 ]; then
|
||||||
ynh_replace_string --match_string="^0 2 .*" --replace_string="#&" --target_file="$apticron_cron"
|
echo "$origin_line" | sed 's|^.*\( root if.*\)|0 20 * * *\1|'
|
||||||
fi
|
fi
|
||||||
|
if [ "$after_apticron" -eq 1 ]; then
|
||||||
|
echo "$origin_line" | sed 's|^.*\( root if.*\)|0 2 * * *\1|'
|
||||||
|
fi
|
||||||
|
) >> "$apticron_cron"
|
||||||
}
|
}
|
||||||
|
|
||||||
_apticron_restore_config() {
|
_apticron_restore_config() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue