#!/bin/bash #================================================= # GENERIC STARTING #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers # Load common variables for all scripts. source _variables #================================================= # LOAD SETTINGS #================================================= ynh_script_progression --message="Load settings" app=$YNH_APP_INSTANCE_NAME unattended_verbosity=$(ynh_app_setting_get $app unattended_verbosity) overwrite_periodic=$(ynh_app_setting_get $app overwrite_periodic) #================================================= # CHECK VERSION #================================================= upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensure downward compatibility" # If overwrite_periodic doesn't exist, create it if [ -z "$overwrite_periodic" ]; then overwrite_periodic=1 ynh_app_setting_set $app overwrite_periodic $overwrite_periodic fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backup the app before upgrading" --weight=3 # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { # restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS #================================================= # INSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Upgrade dependencies" --weight=5 ynh_install_app_dependencies $app_depencencies #================================================= # SPECIFIC UPGRADE #================================================= # UPGRADE APTICRON #================================================= # Nothing to do here... #================================================= # UPGRADE UNATTENDED-UPGRADES #================================================= # Nothing to do here... #================================================= # UPGRADE APT PERIODIC FOR UNATTENDED #================================================= # Overwrite 02periodic config file only if it's allowed if [ $overwrite_periodic -eq 1 ] then ynh_script_progression --message="Upgrade APT Periodic for Unattended" --weight=3 ynh_backup_if_checksum_is_different "/etc/apt/apt.conf.d/02periodic" cp "../conf/02periodic" "/etc/apt/apt.conf.d/02periodic" ynh_replace_string "__VERBOSITY__" "$unattended_verbosity" "/etc/apt/apt.conf.d/02periodic" # This config file is used by /etc/cron.daily/apt ynh_store_file_checksum "/etc/apt/apt.conf.d/02periodic" fi #================================================= # UPGRADE APTICRON CRON FILE #================================================= # Nothing to do here... #================================================= # GENERIC FINALISATION #================================================= # SEND A README FOR THE ADMIN #================================================= # Get main domain and buid the url of the admin panel of the app. admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app" message="To modify any option of unattended-upgrades, please have a look to /etc/apt/apt.conf.d/50unattended-upgrades and /etc/apt/apt.conf.d/02periodic Unattended-upgrades will be executed every day at midnight. To modify the configuration of apticron, please have a look to /etc/apticron/apticron.conf. Apticron will be executed, depending of the requested configuration at 8 p.m. and 2 a.m. If you want to change this schedule, please have a look to the cron file /etc/cron.d/apticron. You can configure this app easily by using the experimental config-panel feature: $admin_panel/config-panel. You can also find some specific actions for this app by using the experimental action feature: $admin_panel/actions. If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/unattended_upgrades_ynh" #================================================= # END OF SCRIPT #================================================= ynh_send_readme_to_admin --app_message="$message" --recipients="root" --type="upgrade" ynh_script_progression --message="Upgrade completed" --last