unattended_upgrades_ynh/scripts/upgrade

75 lines
2.6 KiB
Text
Raw Normal View History

2018-02-24 21:03:40 +01:00
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2020-04-23 20:44:27 +02:00
source _common.sh
source /usr/share/yunohost/helpers
2018-07-13 17:38:14 +02:00
upgrade_type=$(ynh_check_app_version_changed)
2018-02-24 21:03:40 +01:00
2018-09-30 12:02:50 +02:00
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
2020-04-23 20:44:27 +02:00
ynh_script_progression --message="Ensuring downward compatibility..."
2018-09-30 12:02:50 +02:00
# If overwrite_periodic doesn't exist, create it
2024-01-09 17:53:54 +01:00
if [ -z "${overwrite_periodic:-}" ]; then
2020-04-23 20:44:27 +02:00
overwrite_periodic=1
ynh_app_setting_set --app=$app --key=overwrite_periodic --value=$overwrite_periodic
fi
# Make a non perfect backup for apticron.conf if non existent
2024-01-09 17:53:54 +01:00
if [ ! -e "$apticron_config_backup" ]; then
2020-04-23 20:44:27 +02:00
# Create a backup of the config file for the reset action
2024-01-09 17:53:54 +01:00
cp "$apticron_config" "$apticron_config_backup"
sed --in-place '/^CUSTOM_SUBJECT=/d' "$apticron_config_backup"
sed --in-place '/^CUSTOM_NO_UPDATES_SUBJECT=/d' "$apticron_config_backup"
2020-04-23 20:44:27 +02:00
fi
# Make a non perfect backup for apticron cron file if non existent
2024-01-09 17:53:54 +01:00
if [ ! -e "$apticron_cron" ]; then
2020-04-23 20:44:27 +02:00
# Create a backup of the config file for the reset action
2024-01-09 17:53:54 +01:00
cp "$apticron_cron" "$apticron_cron"
sed --in-place '/^[[:digit:]]/d' "$apticron_cron"
ynh_replace_string --match_string="^#\([[:digit:]].*\)" --replace_string="\1" --target_file="$apticron_cron"
2018-09-30 12:02:50 +02:00
fi
2024-01-09 17:53:54 +01:00
# Make a non perfect backup for apticron cron file if non existent
if [ ! -e "$unattended_upgrades_config" ]; then
cp "$unattended_upgrades_config" "$unattended_upgrades_config_backup"
fi
2018-02-24 21:03:40 +01:00
#=================================================
2024-01-09 17:53:54 +01:00
# CONFIGURE APTICRON
2018-02-24 21:03:40 +01:00
#=================================================
2024-01-09 17:53:54 +01:00
ynh_script_progression --message="Configuring Apticron..."
2018-02-24 21:03:40 +01:00
2024-01-09 17:53:54 +01:00
_apticron_set_config
2018-02-24 21:03:40 +01:00
#=================================================
2024-01-09 17:53:54 +01:00
# CONFIGURE UNATTENDED-UPGRADES
2018-02-24 21:03:40 +01:00
#=================================================
2024-01-09 17:53:54 +01:00
ynh_script_progression --message="Configuring Unattended-Upgrades..."
2018-02-24 21:03:40 +01:00
2024-01-09 17:53:54 +01:00
_unattended_upgrades_set_config
2018-02-24 21:03:40 +01:00
#=================================================
2024-01-09 17:53:54 +01:00
# CONFIGURE APT PERIODIC FOR UNATTENDED
2018-02-24 21:03:40 +01:00
#=================================================
2018-09-30 12:02:50 +02:00
# Overwrite 02periodic config file only if it's allowed
2024-01-09 17:53:54 +01:00
if [ "$overwrite_periodic" -eq 1 ]; then
ynh_script_progression --message="Upgrading APT Periodic for Unattended..."
2024-01-09 17:31:18 +01:00
2024-01-09 18:07:57 +01:00
_02periodic_set_config
2018-09-30 12:02:50 +02:00
fi
2018-02-24 21:03:40 +01:00
2019-01-30 19:18:18 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2020-04-23 20:44:27 +02:00
ynh_script_progression --message="Upgrade of $app completed" --last