mirror of
https://github.com/YunoHost-Apps/unattended_upgrades_ynh.git
synced 2024-10-01 13:35:00 +02:00
74 lines
2.6 KiB
Bash
74 lines
2.6 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC STARTING
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
#=================================================
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
#=================================================
|
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
|
|
|
# If overwrite_periodic doesn't exist, create it
|
|
if [ -z "${overwrite_periodic:-}" ]; then
|
|
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
|
|
if [ ! -e "$apticron_config_backup" ]; then
|
|
# Create a backup of the config file for the reset action
|
|
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"
|
|
fi
|
|
|
|
# Make a non perfect backup for apticron cron file if non existent
|
|
if [ ! -e "$apticron_cron" ]; then
|
|
# Create a backup of the config file for the reset action
|
|
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"
|
|
fi
|
|
|
|
# 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
|
|
|
|
#=================================================
|
|
# CONFIGURE APTICRON
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring Apticron..."
|
|
|
|
_apticron_set_config
|
|
|
|
#=================================================
|
|
# CONFIGURE UNATTENDED-UPGRADES
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring Unattended-Upgrades..."
|
|
|
|
_unattended_upgrades_set_config
|
|
|
|
#=================================================
|
|
# CONFIGURE APT PERIODIC FOR UNATTENDED
|
|
#=================================================
|
|
# Overwrite 02periodic config file only if it's allowed
|
|
if [ "$overwrite_periodic" -eq 1 ]; then
|
|
ynh_script_progression --message="Upgrading APT Periodic for Unattended..."
|
|
|
|
_02periodic_set_config
|
|
fi
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|