diff --git a/check_process b/check_process index a6f3566..0e71ef0 100644 --- a/check_process +++ b/check_process @@ -1,58 +1,71 @@ ;; Test complet 1/3 - ; Manifest - upgrade_level="Security only" - ynh_update=1 - previous_apticron=1 - after_apticron=1 - unattended_mail="If an upgrade has been done" - unattended_verbosity="1" - ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=0 - setup_nourl=1 - setup_private=0 - setup_public=0 - upgrade=1 - backup_restore=1 - multi_instance=0 - port_already_use=0 - change_url=0 + ; Manifest + upgrade_level="Security only" + ynh_update=1 + previous_apticron=1 + after_apticron=1 + unattended_mail="If an upgrade has been done" + unattended_verbosity="1" + ; Actions + ; Config_panel + main.unattended_configuration.upgrade_level=Security only|Security and updates + main.unattended_configuration.ynh_update=0|1 + main.unattended_configuration.unattended_mail=If an upgrade has been done|Only if there was an error|Never + main.apticron_configuration.previous_apticron=0|1 + main.apticron_configuration.previous_apticron_hour=21 + main.apticron_configuration.after_apticron=0|1 + main.apticron_configuration.after_apticron_hour=5 + main.periodic_configuration.unattended_verbosity=1|2|3 + main.overwrite_files.overwrite_periodic=0|1 + main.global_config.email_type=0|1 + ; Checks + pkg_linter=1 + setup_sub_dir=0 + setup_root=0 + setup_nourl=1 + setup_private=0 + setup_public=0 + upgrade=1 + upgrade=1 from_commit=5a359c6833a5415932ab427a80dbbdc6ca3c8e23 + backup_restore=1 + multi_instance=0 + port_already_use=0 + change_url=0 + actions=1 + config_panel=1 ;; Test complet 2/3 - ; Manifest - upgrade_level="Security and updates" - ynh_update=0 - previous_apticron=0 - after_apticron=1 - unattended_mail="Only if there was an error" - unattended_verbosity="2" - ; Checks - setup_nourl=1 - upgrade=1 - backup_restore=1 + ; Manifest + upgrade_level="Security and updates" + ynh_update=0 + previous_apticron=0 + after_apticron=1 + unattended_mail="Only if there was an error" + unattended_verbosity="2" + ; Checks + setup_sub_dir=0 + setup_root=0 + setup_nourl=1 + upgrade=1 + backup_restore=1 ;; Test complet 3/3 - ; Manifest - upgrade_level="Security only" - ynh_update=0 - previous_apticron=1 - after_apticron=0 - unattended_mail="Never" - unattended_verbosity="3" - ; Checks - setup_nourl=1 - upgrade=1 - backup_restore=1 + ; Manifest + upgrade_level="Security only" + ynh_update=0 + previous_apticron=1 + after_apticron=0 + unattended_mail="Never" + unattended_verbosity="3" + ; Checks + setup_sub_dir=0 + setup_root=0 + setup_nourl=1 + upgrade=1 + backup_restore=1 ;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto - Level 4=na - Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 + Level 5=auto ;;; Options Email= -Notification=down +Notification=change +;;; Upgrade options + ; commit=b86b9d09ed97bf04b7e1afad72376d8d695b418b + name=Mar 14, 2018 Update helpers diff --git a/manifest.json b/manifest.json index f385412..e6bfb16 100644 --- a/manifest.json +++ b/manifest.json @@ -1,83 +1,86 @@ { - "name": "Unattended-upgrades", - "id": "unattended_upgrades", - "packaging_format": 1, - "description": { - "en": "Daily automatic upgrades", - "fr": "Mise à jour automatique quotidienne." - }, - "version": "1.0~ynh4", - "url": "https://wiki.debian.org/UnattendedUpgrades", - "license": "GPL-2.0-or-later", - "maintainer": { - "name": "Maniack Crudelis", - "email": "maniackc_dev@crudelis.fr" - }, - "requirements": { - "yunohost": ">= 3.4" - }, - "multi_instance": false, - "services": [], - "arguments": { - "install" : [ - { - "name": "upgrade_level", - "ask": { - "en": "Choose the sources of packages to automatically upgrade", - "fr": "Choisissez les sources des paquets à mettre à jour automatiquement" - }, - "choices": ["Security only", "Security and updates"], - "default": "Security only" - }, - { - "name": "ynh_update", - "type": "boolean", - "ask": { - "en": "Would you like to update YunoHost packages automatically ?", - "fr": "Souhaitez-vous mettre à jour les paquets YunoHost automatiquement ?" - }, - "default": true - }, - { - "name": "previous_apticron", - "type": "boolean", - "ask": { - "en": "Would you like to receive an email to inform which upgrades need to be done ?", - "fr": "Souhaitez-vous recevoir un email pour vous informer des mises à jour nécessaires ?" - }, - "default": true - }, - { - "name": "after_apticron", - "type": "boolean", - "ask": { - "en": "Would you like to receive an email to verify if there any upgrades left after each auto upgrade ?", - "fr": "Souhaitez-vous recevoir un email pour vérifier s'il reste des mises à jour après chaque mise à niveau automatique ?" - }, - "default": true - }, - { - "name": "unattended_mail", - "ask": { - "en": "Would you like to receive an email from Unattended-Upgrades ?", - "fr": "Souhaitez-vous recevoir un email de Unattended-Upgrades ?" - }, - "choices": ["If an upgrade has been done", "Only if there was an error", "Never"], - "default": "If an upgrade has been done" - }, - { - "name": "unattended_verbosity", - "ask": { - "en": "Choose the level of verbosity of Unattended-Upgrades mail", - "fr": "Choisir le niveau de verbosité du mail de Unattended-Upgrades" - }, - "help": { - "en": "1: Progress report only.
2: Progress report and command outputs.
3: Progress report and command outputs and trace.
", - "fr": "1: Rapport d'avancement seulement.
2: Rapport d'avancement et sortie de commandes.
3: Rapport d'avancement, sortie de commandes et trace." - }, - "choices": ["1", "2", "3"], - "default": "1" - } - ] - } + "name": "Unattended-upgrades", + "id": "unattended_upgrades", + "packaging_format": 1, + "description": { + "en": "Daily automatic upgrades", + "fr": "Mise à jour automatique quotidienne." + }, + "version": "1.0~ynh5", + "url": "https://wiki.debian.org/UnattendedUpgrades", + "license": "GPL-2.0-or-later", + "maintainer": { + "name": "Maniack Crudelis", + "email": "maniackc_dev@crudelis.fr" + }, + "requirements": { + "yunohost": ">= 3.6.0" + }, + "multi_instance": false, + "services": [], + "arguments": { + "install" : [ + { + "name": "upgrade_level", + "type": "string", + "ask": { + "en": "Choose the sources of packages to automatically upgrade", + "fr": "Choisissez les sources des paquets à mettre à jour automatiquement" + }, + "choices": ["Security only", "Security and updates"], + "default": "Security only" + }, + { + "name": "ynh_update", + "type": "boolean", + "ask": { + "en": "Would you like to update YunoHost packages automatically ?", + "fr": "Souhaitez-vous mettre à jour les paquets YunoHost automatiquement ?" + }, + "default": true + }, + { + "name": "previous_apticron", + "type": "boolean", + "ask": { + "en": "Would you like to receive an email to inform which upgrades need to be done ?", + "fr": "Souhaitez-vous recevoir un email pour vous informer des mises à jour nécessaires ?" + }, + "default": true + }, + { + "name": "after_apticron", + "type": "boolean", + "ask": { + "en": "Would you like to receive an email to verify if there any upgrades left after each auto upgrade ?", + "fr": "Souhaitez-vous recevoir un email pour vérifier s'il reste des mises à jour après chaque mise à niveau automatique ?" + }, + "default": true + }, + { + "name": "unattended_mail", + "type": "string", + "ask": { + "en": "Would you like to receive an email from Unattended-Upgrades ?", + "fr": "Souhaitez-vous recevoir un email de Unattended-Upgrades ?" + }, + "choices": ["If an upgrade has been done", "Only if there was an error", "Never"], + "default": "If an upgrade has been done" + }, + { + "name": "unattended_verbosity", + "type": "string", + "ask": { + "en": "Choose the level of verbosity of Unattended-Upgrades mail", + "fr": "Choisir le niveau de verbosité du mail de Unattended-Upgrades" + }, + "help": { + "en": "1: Progress report only.
2: Progress report and command outputs.
3: Progress report and command outputs and trace.
", + "fr": "1: Rapport d'avancement seulement.
2: Rapport d'avancement et sortie de commandes.
3: Rapport d'avancement, sortie de commandes et trace." + }, + "choices": ["1", "2", "3"], + "default": "1" + } + ] + } } diff --git a/scripts/backup b/scripts/backup index ae4a7fe..bfc9b77 100644 --- a/scripts/backup +++ b/scripts/backup @@ -19,7 +19,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Load settings" +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -28,35 +28,35 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # BACKUP UNATTENDED-UPGRADES CONFIG #================================================= -ynh_script_progression --message="Backup unattended-upgrades config" +ynh_script_progression --message="Backing up unattended-upgrades config..." -ynh_backup "/etc/apt/apt.conf.d/50unattended-upgrades" +ynh_backup --src_path="/etc/apt/apt.conf.d/50unattended-upgrades" # Backup also the backup of the config file -ynh_backup "/etc/apt/50unattended-upgrades.backup" +ynh_backup --src_path="/etc/apt/50unattended-upgrades.backup" #================================================= # BACKUP APT PERIODIC #================================================= -ynh_script_progression --message="Backup APT periodic" +ynh_script_progression --message="Backing up APT periodic..." -ynh_backup "/etc/apt/apt.conf.d/02periodic" +ynh_backup --src_path="/etc/apt/apt.conf.d/02periodic" #================================================= # BACKUP APTICRON CONFIG #================================================= -ynh_script_progression --message="Backup Apticron config" +ynh_script_progression --message="Backing up Apticron config..." -ynh_backup "/etc/apticron/apticron.conf" +ynh_backup --src_path="/etc/apticron/apticron.conf" #================================================= # BACKUP THE CRON FILE #================================================= -ynh_script_progression --message="Backup cron file" +ynh_script_progression --message="Backing up cron file..." -ynh_backup "/etc/cron.d/apticron" +ynh_backup --src_path="/etc/cron.d/apticron" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Backup completed" --last +ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last diff --git a/scripts/install b/scripts/install index de498c4..104adbb 100644 --- a/scripts/install +++ b/scripts/install @@ -6,11 +6,12 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh -source /usr/share/yunohost/helpers # Load common variables for all scripts. source _variables +source _common.sh +source /usr/share/yunohost/helpers + #================================================= # MANAGE FAILURE OF THE SCRIPT #================================================= @@ -21,38 +22,37 @@ ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -ynh_script_progression --message="Retrieve arguments from the manifest" upgrade_level="$YNH_APP_ARG_UPGRADE_LEVEL" -ynh_update="$YNH_APP_ARG_YNH_UPDATE" -previous_apticron="$YNH_APP_ARG_PREVIOUS_APTICRON" -after_apticron="$YNH_APP_ARG_AFTER_APTICRON" +ynh_update=$YNH_APP_ARG_YNH_UPDATE +previous_apticron=$YNH_APP_ARG_PREVIOUS_APTICRON +after_apticron=$YNH_APP_ARG_AFTER_APTICRON unattended_mail="$YNH_APP_ARG_UNATTENDED_MAIL" -unattended_verbosity="$YNH_APP_ARG_UNATTENDED_VERBOSITY" +unattended_verbosity=$YNH_APP_ARG_UNATTENDED_VERBOSITY app=$YNH_APP_INSTANCE_NAME #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Store settings from manifest" --weight=3 +ynh_script_progression --message="Storing installation settings..." --weight=3 -ynh_app_setting_set $app upgrade_level "$upgrade_level" -ynh_app_setting_set $app ynh_update $ynh_update -ynh_app_setting_set $app previous_apticron $previous_apticron -ynh_app_setting_set $app after_apticron $after_apticron -ynh_app_setting_set $app unattended_mail "$unattended_mail" -ynh_app_setting_set $app unattended_verbosity $unattended_verbosity +ynh_app_setting_set --app=$app --key=upgrade_level --value="$upgrade_level" +ynh_app_setting_set --app=$app --key=ynh_update --value=$ynh_update +ynh_app_setting_set --app=$app --key=previous_apticron --value=$previous_apticron +ynh_app_setting_set --app=$app --key=after_apticron --value=$after_apticron +ynh_app_setting_set --app=$app --key=unattended_mail --value="$unattended_mail" +ynh_app_setting_set --app=$app --key=unattended_verbosity --value=$unattended_verbosity -ynh_app_setting_set $app overwrite_periodic "1" -ynh_app_setting_set $app admin_mail_html "1" +ynh_app_setting_set --app=$app --key=overwrite_periodic --value=1 +ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 #================================================= # STANDARD MODIFICATIONS #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Install dependencies" --weight=10 +ynh_script_progression --message="Installing dependencies..." --weight=10 ynh_install_app_dependencies $app_depencencies @@ -61,62 +61,65 @@ ynh_install_app_dependencies $app_depencencies #================================================= # CONFIGURE APTICRON #================================================= -ynh_script_progression --message="Configure Apticron" +ynh_script_progression --message="Configuring Apticron..." apticron_config="/etc/apticron/apticron.conf" -ynh_replace_string "# CUSTOM_SUBJECT=.*" \ - "&\nCUSTOM_SUBJECT=\'[apticron] \$SYSTEM: \$NUM_PACKAGES package update(s)\'" "$apticron_config" -ynh_replace_string "# CUSTOM_NO_UPDATES_SUBJECT=.*" \ - "&\nCUSTOM_NO_UPDATES_SUBJECT=\'[apticron] \$SYSTEM: Up to date \\\\o/\'" "$apticron_config" +# Create a backup of the config file for the reset action +cp "$apticron_config" "/etc/yunohost/apps/$app/conf/apticron.conf.backup" + +ynh_replace_string --match_string="# CUSTOM_SUBJECT=.*" \ + --replace_string="&\nCUSTOM_SUBJECT=\'[apticron] \$SYSTEM: \$NUM_PACKAGES package update(s)\'" --target_file="$apticron_config" +ynh_replace_string --match_string="# CUSTOM_NO_UPDATES_SUBJECT=.*" \ + --replace_string="&\nCUSTOM_NO_UPDATES_SUBJECT=\'[apticron] \$SYSTEM: Up to date \\\\o/\'" --target_file="$apticron_config" #================================================= # CONFIGURE UNATTENDED-UPGRADES #================================================= -ynh_script_progression --message="Configure Unattended-Upgrades" +ynh_script_progression --message="Configuring Unattended-Upgrades..." unattended_upgrades_config="/etc/apt/apt.conf.d/50unattended-upgrades" # Make a backup of 50unattended-upgrades -cp -a "$unattended_upgrades_config" "/etc/apt/50unattended-upgrades.backup" +cp "$unattended_upgrades_config" "/etc/apt/50unattended-upgrades.backup" # Configure upgrade sources # Allow other updates if [ "$upgrade_level" = "Security and updates" ] then - ynh_replace_string "//\(.*\"o=Debian,a=stable\)" "\1" "$unattended_upgrades_config" - ynh_replace_string "//\(.*\"o=Debian,a=stable-updates\)" "\1" "$unattended_upgrades_config" + ynh_replace_string --match_string="//\(.*\"o=Debian,a=stable\)" --replace_string="\1" --target_file="$unattended_upgrades_config" + ynh_replace_string --match_string="//\(.*\"o=Debian,a=stable-updates\)" --replace_string="\1" --target_file="$unattended_upgrades_config" fi # Add YunoHost upgrade source if [ $ynh_update -eq 1 ] then - ynh_replace_string "origin=Debian,codename=\${distro_codename},label=Debian-Security\";" \ - "&\n\n //YunoHost upgrade\n \"o=YunoHost,a=stable\";" "$unattended_upgrades_config" + ynh_replace_string --match_string="origin=Debian,codename=\${distro_codename},label=Debian-Security\";" \ + --replace_string="&\n\n //YunoHost upgrade\n \"o=YunoHost,a=stable\";" --target_file="$unattended_upgrades_config" fi # Allow MinimalSteps upgrading to reduce risk in case of reboot -ynh_replace_string "//\(Unattended-Upgrade::MinimalSteps\).*" "\1 \"true\";" "$unattended_upgrades_config" +ynh_replace_string --match_string="//\(Unattended-Upgrade::MinimalSteps\).*" --replace_string="\1 \"true\";" --target_file="$unattended_upgrades_config" # Configure Unattended Upgrades mailing if [ "$unattended_mail" = "If an upgrade has been done" ] then - # Allow mail to root - ynh_replace_string "//\(Unattended-Upgrade::Mail \)" "\1" "$unattended_upgrades_config" + # Allow mail to root + ynh_replace_string --match_string="//\(Unattended-Upgrade::Mail \)" --replace_string="\1" --target_file="$unattended_upgrades_config" - # Send mail even if there's no errors - ynh_replace_string "//\(Unattended-Upgrade::MailOnlyOnError \).*" "\1\"false\";" "$unattended_upgrades_config" + # Send mail even if there's no errors + ynh_replace_string --match_string="//\(Unattended-Upgrade::MailOnlyOnError \).*" --replace_string="\1\"false\";" --target_file="$unattended_upgrades_config" elif [ "$unattended_mail" = "Only if there was an error" ] then - # Allow mail to root - ynh_replace_string "//\(Unattended-Upgrade::Mail \)" "\1" "$unattended_upgrades_config" + # Allow mail to root + ynh_replace_string --match_string="//\(Unattended-Upgrade::Mail \)" --replace_string="\1" --target_file="$unattended_upgrades_config" - # Send mail only if there's an error - ynh_replace_string "//\(Unattended-Upgrade::MailOnlyOnError \).*" "\1\"true\";" "$unattended_upgrades_config" + # Send mail only if there's an error + ynh_replace_string --match_string="//\(Unattended-Upgrade::MailOnlyOnError \).*" --replace_string="\1\"true\";" --target_file="$unattended_upgrades_config" else # "Never" - # Comment "Unattended-Upgrade::Mail" if it isn't already commented - ynh_replace_string "^\(Unattended-Upgrade::Mail \)" "//\1" "$unattended_upgrades_config" + # Comment "Unattended-Upgrade::Mail" if it isn't already commented + ynh_replace_string --match_string="^\(Unattended-Upgrade::Mail \)" --replace_string="//\1" --target_file="$unattended_upgrades_config" fi #================================================= @@ -125,7 +128,7 @@ fi ynh_script_progression --message="Configure APT Periodic for Unattended" --weight=2 cp "../conf/02periodic" "/etc/apt/apt.conf.d/02periodic" -ynh_replace_string "__VERBOSITY__" "$unattended_verbosity" "/etc/apt/apt.conf.d/02periodic" +ynh_replace_string --match_string="__VERBOSITY__" --replace_string="$unattended_verbosity" --target_file="/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" @@ -136,23 +139,26 @@ ynh_store_file_checksum "/etc/apt/apt.conf.d/02periodic" ynh_script_progression --message="Modify original Apticron cron file" --weight=3 apticron_cron="/etc/cron.d/apticron" +# Create a backup of the cron file for the reset action +cp "$apticron_cron" "/etc/yunohost/apps/$app/conf/apticron.crond.backup" + # Copy and comment the current cron -ynh_replace_string "^.* root if.*" "#&\n&" "$apticron_cron" +ynh_replace_string --match_string="^.* root if.*" --replace_string="#&\n&" --target_file="$apticron_cron" # Modify the time to set at 20:00 every day -ynh_replace_string "^[[:digit:]].*\( root if.*\)" "0 20 * * *\1" "$apticron_cron" +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 "^0 20\(.*\)" "&\n0 2\1" "$apticron_cron" +ynh_replace_string --match_string="^0 20\(.*\)" --replace_string="&\n0 2\1" --target_file="$apticron_cron" if [ $previous_apticron -eq 0 ] then - # Comment the first cron - ynh_replace_string "^0 20 .*" "#&" "$apticron_cron" + # Comment the first cron + ynh_replace_string --match_string="^0 20 .*" --replace_string="#&" --target_file="$apticron_cron" fi if [ $after_apticron -eq 0 ] then - # Comment the second cron - ynh_replace_string "^0 2 .*" "#&" "$apticron_cron" + # Comment the second cron + ynh_replace_string --match_string="^0 2 .*" --replace_string="#&" --target_file="$apticron_cron" fi #================================================= @@ -176,10 +182,10 @@ You can also find some specific actions for this app by using the experimental _ If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/unattended_upgrades_ynh__URL_TAG3__." > mail_to_send -ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type="install" +ynh_send_readme_to_admin --app_message="mail_to_send" --recipients=root --type=install #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation completed" --last +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 2ed188c..ee5abe4 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Load settings" +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -21,7 +21,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Remove dependencies" --weight=5 +ynh_script_progression --message="Removing dependencies..." --weight=5 ynh_remove_app_dependencies @@ -30,14 +30,14 @@ ynh_remove_app_dependencies #================================================= # REMOVE THE APT PERIODIC FILE #================================================= -ynh_script_progression --message="Remove the APT Periodic file" +ynh_script_progression --message="Removing the APT Periodic file..." ynh_secure_remove "/etc/apt/apt.conf.d/02periodic" #================================================= # DECONFIGURE UNATTENDED-UPGRADES #================================================= -ynh_script_progression --message="Deconfigure unattended-upgrades" +ynh_script_progression --message="Deconfiguring unattended-upgrades..." mv "/etc/apt/50unattended-upgrades.backup" "/etc/apt/apt.conf.d/50unattended-upgrades" @@ -45,4 +45,4 @@ mv "/etc/apt/50unattended-upgrades.backup" "/etc/apt/apt.conf.d/50unattended-upg # END OF SCRIPT #================================================= -ynh_script_progression --message="Deletion completed" --last +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 78d3b69..78fc6fc 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,11 +6,12 @@ # IMPORT GENERIC HELPERS #================================================= -source ../settings/scripts/_common.sh -source /usr/share/yunohost/helpers # Load common variables for all scripts. source ../settings/scripts/_variables +source ../settings/scripts/_common.sh +source /usr/share/yunohost/helpers + #================================================= # MANAGE SCRIPT FAILURE #================================================= @@ -21,7 +22,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Load settings" +ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -30,7 +31,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstall dependencies" --weight=10 +ynh_script_progression --message="Reinstalling dependencies..." --weight=10 ynh_install_app_dependencies $app_depencencies @@ -38,27 +39,27 @@ ynh_install_app_dependencies $app_depencencies # RESTORE UNATTENDED-UPGRADES CONFIG #================================================= -ynh_restore_file "/etc/apt/apt.conf.d/50unattended-upgrades" +ynh_restore_file --origin_path="/etc/apt/apt.conf.d/50unattended-upgrades" # Restore also the backup config file -ynh_restore_file "/etc/apt/50unattended-upgrades.backup" +ynh_restore_file --origin_path="/etc/apt/50unattended-upgrades.backup" #================================================= # RESTORE APT PERIODIC #================================================= -ynh_restore_file "/etc/apt/apt.conf.d/02periodic" +ynh_restore_file --origin_path="/etc/apt/apt.conf.d/02periodic" #================================================= # RESTORE APTICRON CONFIG #================================================= -ynh_restore_file "/etc/apticron/apticron.conf" +ynh_restore_file --origin_path="/etc/apticron/apticron.conf" #================================================= # RESTORE CRON FILE #================================================= -ynh_restore_file "/etc/cron.d/apticron" +ynh_restore_file --origin_path="/etc/cron.d/apticron" #================================================= # GENERIC FINALISATION @@ -81,10 +82,10 @@ You can also find some specific actions for this app by using the experimental _ If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/unattended_upgrades_ynh__URL_TAG3__." > mail_to_send -ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type="restore" +ynh_send_readme_to_admin --app_message="mail_to_send" --recipients=root --type=restore #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed" --last +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index 868c1b1..57113ce 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -6,20 +6,21 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh -source /usr/share/yunohost/helpers # Load common variables for all scripts. source _variables +source _common.sh +source /usr/share/yunohost/helpers + #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Load settings" +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -unattended_verbosity=$(ynh_app_setting_get $app unattended_verbosity) -overwrite_periodic=$(ynh_app_setting_get $app overwrite_periodic) +unattended_verbosity=$(ynh_app_setting_get --app=$app --key=unattended_verbosity) +overwrite_periodic=$(ynh_app_setting_get --app=$app --key=overwrite_periodic) #================================================= # CHECK VERSION @@ -30,24 +31,46 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="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 overwrite_periodic $overwrite_periodic + overwrite_periodic=1 + ynh_app_setting_set --app=$app --key=overwrite_periodic --value=$overwrite_periodic +fi + +# If admin_mail_html doesn't exist, create it +if [ -z "$admin_mail_html" ]; then + admin_mail_html=1 + ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html +fi + +# Make a non perfect backup for apticron.conf if non existent +if [ ! -e "../conf/apticron.conf.backup" ]; then + # Create a backup of the config file for the reset action + cp "/etc/apticron/apticron.conf" "../conf/apticron.conf.backup" + sed --in-place '/^CUSTOM_SUBJECT=/d' "../conf/apticron.conf.backup" + sed --in-place '/^CUSTOM_NO_UPDATES_SUBJECT=/d' "../conf/apticron.conf.backup" +fi + +# Make a non perfect backup for apticron cron file if non existent +if [ ! -e "../conf/apticron.crond.backup" ]; then + # Create a backup of the config file for the reset action + cp "/etc/cron.d/apticron" "../conf/apticron.crond.backup" + sed --in-place '/^[[:digit:]]/d' "../conf/apticron.crond.backup" + ynh_replace_string --match_string="^#\([[:digit:]].*\)" --replace_string="\1" --target_file="../conf/apticron.crond.backup" fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backup the app before upgrading" --weight=3 +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --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 + # restore it if the upgrade fails + ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -57,7 +80,7 @@ ynh_abort_if_errors #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrade dependencies" --weight=5 +ynh_script_progression --message="Upgrading dependencies..." --weight=5 ynh_install_app_dependencies $app_depencencies @@ -82,14 +105,14 @@ ynh_install_app_dependencies $app_depencencies # 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" + ynh_script_progression --message="Upgrading APT Periodic for Unattended..." --weight=3 + ynh_backup_if_checksum_is_different --file="/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 + cp "../conf/02periodic" "/etc/apt/apt.conf.d/02periodic" + ynh_replace_string --match_string="__VERBOSITY__" --replace_string="$unattended_verbosity" --target_file="/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" + ynh_store_file_checksum --file="/etc/apt/apt.conf.d/02periodic" fi #================================================= @@ -132,10 +155,10 @@ If you're facing an issue or want to improve this app, please open a new issue i Changelog since your last upgrade: $(cat changelog)" > mail_to_send -ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type="upgrade" +ynh_send_readme_to_admin --app_message="mail_to_send" --recipients=root --type=upgrade #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade completed" --last +ynh_script_progression --message="Upgrade of $app completed" --last