mirror of
https://github.com/YunoHost-Apps/unattended_upgrades_ynh.git
synced 2024-10-01 13:35:00 +02:00
Global upgrade
This commit is contained in:
parent
02e6b338b1
commit
74210eea81
7 changed files with 275 additions and 229 deletions
117
check_process
117
check_process
|
@ -1,58 +1,71 @@
|
||||||
;; Test complet 1/3
|
;; Test complet 1/3
|
||||||
; Manifest
|
; Manifest
|
||||||
upgrade_level="Security only"
|
upgrade_level="Security only"
|
||||||
ynh_update=1
|
ynh_update=1
|
||||||
previous_apticron=1
|
previous_apticron=1
|
||||||
after_apticron=1
|
after_apticron=1
|
||||||
unattended_mail="If an upgrade has been done"
|
unattended_mail="If an upgrade has been done"
|
||||||
unattended_verbosity="1"
|
unattended_verbosity="1"
|
||||||
; Checks
|
; Actions
|
||||||
pkg_linter=1
|
; Config_panel
|
||||||
setup_sub_dir=0
|
main.unattended_configuration.upgrade_level=Security only|Security and updates
|
||||||
setup_root=0
|
main.unattended_configuration.ynh_update=0|1
|
||||||
setup_nourl=1
|
main.unattended_configuration.unattended_mail=If an upgrade has been done|Only if there was an error|Never
|
||||||
setup_private=0
|
main.apticron_configuration.previous_apticron=0|1
|
||||||
setup_public=0
|
main.apticron_configuration.previous_apticron_hour=21
|
||||||
upgrade=1
|
main.apticron_configuration.after_apticron=0|1
|
||||||
backup_restore=1
|
main.apticron_configuration.after_apticron_hour=5
|
||||||
multi_instance=0
|
main.periodic_configuration.unattended_verbosity=1|2|3
|
||||||
port_already_use=0
|
main.overwrite_files.overwrite_periodic=0|1
|
||||||
change_url=0
|
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
|
;; Test complet 2/3
|
||||||
; Manifest
|
; Manifest
|
||||||
upgrade_level="Security and updates"
|
upgrade_level="Security and updates"
|
||||||
ynh_update=0
|
ynh_update=0
|
||||||
previous_apticron=0
|
previous_apticron=0
|
||||||
after_apticron=1
|
after_apticron=1
|
||||||
unattended_mail="Only if there was an error"
|
unattended_mail="Only if there was an error"
|
||||||
unattended_verbosity="2"
|
unattended_verbosity="2"
|
||||||
; Checks
|
; Checks
|
||||||
setup_nourl=1
|
setup_sub_dir=0
|
||||||
upgrade=1
|
setup_root=0
|
||||||
backup_restore=1
|
setup_nourl=1
|
||||||
|
upgrade=1
|
||||||
|
backup_restore=1
|
||||||
;; Test complet 3/3
|
;; Test complet 3/3
|
||||||
; Manifest
|
; Manifest
|
||||||
upgrade_level="Security only"
|
upgrade_level="Security only"
|
||||||
ynh_update=0
|
ynh_update=0
|
||||||
previous_apticron=1
|
previous_apticron=1
|
||||||
after_apticron=0
|
after_apticron=0
|
||||||
unattended_mail="Never"
|
unattended_mail="Never"
|
||||||
unattended_verbosity="3"
|
unattended_verbosity="3"
|
||||||
; Checks
|
; Checks
|
||||||
setup_nourl=1
|
setup_sub_dir=0
|
||||||
upgrade=1
|
setup_root=0
|
||||||
backup_restore=1
|
setup_nourl=1
|
||||||
|
upgrade=1
|
||||||
|
backup_restore=1
|
||||||
;;; Levels
|
;;; Levels
|
||||||
Level 1=auto
|
Level 5=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
|
|
||||||
;;; Options
|
;;; Options
|
||||||
Email=
|
Email=
|
||||||
Notification=down
|
Notification=change
|
||||||
|
;;; Upgrade options
|
||||||
|
; commit=b86b9d09ed97bf04b7e1afad72376d8d695b418b
|
||||||
|
name=Mar 14, 2018 Update helpers
|
||||||
|
|
165
manifest.json
165
manifest.json
|
@ -1,83 +1,86 @@
|
||||||
{
|
{
|
||||||
"name": "Unattended-upgrades",
|
"name": "Unattended-upgrades",
|
||||||
"id": "unattended_upgrades",
|
"id": "unattended_upgrades",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"description": {
|
"description": {
|
||||||
"en": "Daily automatic upgrades",
|
"en": "Daily automatic upgrades",
|
||||||
"fr": "Mise à jour automatique quotidienne."
|
"fr": "Mise à jour automatique quotidienne."
|
||||||
},
|
},
|
||||||
"version": "1.0~ynh4",
|
"version": "1.0~ynh5",
|
||||||
"url": "https://wiki.debian.org/UnattendedUpgrades",
|
"url": "https://wiki.debian.org/UnattendedUpgrades",
|
||||||
"license": "GPL-2.0-or-later",
|
"license": "GPL-2.0-or-later",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "Maniack Crudelis",
|
"name": "Maniack Crudelis",
|
||||||
"email": "maniackc_dev@crudelis.fr"
|
"email": "maniackc_dev@crudelis.fr"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 3.4"
|
"yunohost": ">= 3.6.0"
|
||||||
},
|
},
|
||||||
"multi_instance": false,
|
"multi_instance": false,
|
||||||
"services": [],
|
"services": [],
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"install" : [
|
"install" : [
|
||||||
{
|
{
|
||||||
"name": "upgrade_level",
|
"name": "upgrade_level",
|
||||||
"ask": {
|
"type": "string",
|
||||||
"en": "Choose the sources of packages to automatically upgrade",
|
"ask": {
|
||||||
"fr": "Choisissez les sources des paquets à mettre à jour automatiquement"
|
"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"
|
"choices": ["Security only", "Security and updates"],
|
||||||
},
|
"default": "Security only"
|
||||||
{
|
},
|
||||||
"name": "ynh_update",
|
{
|
||||||
"type": "boolean",
|
"name": "ynh_update",
|
||||||
"ask": {
|
"type": "boolean",
|
||||||
"en": "Would you like to update YunoHost packages automatically ?",
|
"ask": {
|
||||||
"fr": "Souhaitez-vous mettre à jour les paquets YunoHost automatiquement ?"
|
"en": "Would you like to update YunoHost packages automatically ?",
|
||||||
},
|
"fr": "Souhaitez-vous mettre à jour les paquets YunoHost automatiquement ?"
|
||||||
"default": true
|
},
|
||||||
},
|
"default": true
|
||||||
{
|
},
|
||||||
"name": "previous_apticron",
|
{
|
||||||
"type": "boolean",
|
"name": "previous_apticron",
|
||||||
"ask": {
|
"type": "boolean",
|
||||||
"en": "Would you like to receive an email to inform which upgrades need to be done ?",
|
"ask": {
|
||||||
"fr": "Souhaitez-vous recevoir un email pour vous informer des mises à jour nécessaires ?"
|
"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
|
},
|
||||||
},
|
"default": true
|
||||||
{
|
},
|
||||||
"name": "after_apticron",
|
{
|
||||||
"type": "boolean",
|
"name": "after_apticron",
|
||||||
"ask": {
|
"type": "boolean",
|
||||||
"en": "Would you like to receive an email to verify if there any upgrades left after each auto upgrade ?",
|
"ask": {
|
||||||
"fr": "Souhaitez-vous recevoir un email pour vérifier s'il reste des mises à jour après chaque mise à niveau automatique ?"
|
"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
|
},
|
||||||
},
|
"default": true
|
||||||
{
|
},
|
||||||
"name": "unattended_mail",
|
{
|
||||||
"ask": {
|
"name": "unattended_mail",
|
||||||
"en": "Would you like to receive an email from Unattended-Upgrades ?",
|
"type": "string",
|
||||||
"fr": "Souhaitez-vous recevoir un email de Unattended-Upgrades ?"
|
"ask": {
|
||||||
},
|
"en": "Would you like to receive an email from Unattended-Upgrades ?",
|
||||||
"choices": ["If an upgrade has been done", "Only if there was an error", "Never"],
|
"fr": "Souhaitez-vous recevoir un email de Unattended-Upgrades ?"
|
||||||
"default": "If an upgrade has been done"
|
},
|
||||||
},
|
"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",
|
"name": "unattended_verbosity",
|
||||||
"fr": "Choisir le niveau de verbosité du mail de Unattended-Upgrades"
|
"type": "string",
|
||||||
},
|
"ask": {
|
||||||
"help": {
|
"en": "Choose the level of verbosity of Unattended-Upgrades mail",
|
||||||
"en": "1: Progress report only.<br>2: Progress report and command outputs.<br>3: Progress report and command outputs and trace.<br>",
|
"fr": "Choisir le niveau de verbosité du mail de Unattended-Upgrades"
|
||||||
"fr": "1: Rapport d'avancement seulement.<br>2: Rapport d'avancement et sortie de commandes.<br>3: Rapport d'avancement, sortie de commandes et trace."
|
},
|
||||||
},
|
"help": {
|
||||||
"choices": ["1", "2", "3"],
|
"en": "1: Progress report only.<br>2: Progress report and command outputs.<br>3: Progress report and command outputs and trace.<br>",
|
||||||
"default": "1"
|
"fr": "1: Rapport d'avancement seulement.<br>2: Rapport d'avancement et sortie de commandes.<br>3: Rapport d'avancement, sortie de commandes et trace."
|
||||||
}
|
},
|
||||||
]
|
"choices": ["1", "2", "3"],
|
||||||
}
|
"default": "1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Load settings"
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -28,35 +28,35 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP UNATTENDED-UPGRADES CONFIG
|
# 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
|
# 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
|
# 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
|
# 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
|
# 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
|
# 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
|
||||||
|
|
104
scripts/install
104
scripts/install
|
@ -6,11 +6,12 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
|
||||||
source /usr/share/yunohost/helpers
|
|
||||||
# Load common variables for all scripts.
|
# Load common variables for all scripts.
|
||||||
source _variables
|
source _variables
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE FAILURE OF THE SCRIPT
|
# MANAGE FAILURE OF THE SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -21,38 +22,37 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Retrieve arguments from the manifest"
|
|
||||||
|
|
||||||
upgrade_level="$YNH_APP_ARG_UPGRADE_LEVEL"
|
upgrade_level="$YNH_APP_ARG_UPGRADE_LEVEL"
|
||||||
ynh_update="$YNH_APP_ARG_YNH_UPDATE"
|
ynh_update=$YNH_APP_ARG_YNH_UPDATE
|
||||||
previous_apticron="$YNH_APP_ARG_PREVIOUS_APTICRON"
|
previous_apticron=$YNH_APP_ARG_PREVIOUS_APTICRON
|
||||||
after_apticron="$YNH_APP_ARG_AFTER_APTICRON"
|
after_apticron=$YNH_APP_ARG_AFTER_APTICRON
|
||||||
unattended_mail="$YNH_APP_ARG_UNATTENDED_MAIL"
|
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
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# 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=$app --key=upgrade_level --value="$upgrade_level"
|
||||||
ynh_app_setting_set $app ynh_update $ynh_update
|
ynh_app_setting_set --app=$app --key=ynh_update --value=$ynh_update
|
||||||
ynh_app_setting_set $app previous_apticron $previous_apticron
|
ynh_app_setting_set --app=$app --key=previous_apticron --value=$previous_apticron
|
||||||
ynh_app_setting_set $app after_apticron $after_apticron
|
ynh_app_setting_set --app=$app --key=after_apticron --value=$after_apticron
|
||||||
ynh_app_setting_set $app unattended_mail "$unattended_mail"
|
ynh_app_setting_set --app=$app --key=unattended_mail --value="$unattended_mail"
|
||||||
ynh_app_setting_set $app unattended_verbosity $unattended_verbosity
|
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=$app --key=overwrite_periodic --value=1
|
||||||
ynh_app_setting_set $app admin_mail_html "1"
|
ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Install dependencies" --weight=10
|
ynh_script_progression --message="Installing dependencies..." --weight=10
|
||||||
|
|
||||||
ynh_install_app_dependencies $app_depencencies
|
ynh_install_app_dependencies $app_depencencies
|
||||||
|
|
||||||
|
@ -61,62 +61,65 @@ ynh_install_app_dependencies $app_depencencies
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURE APTICRON
|
# CONFIGURE APTICRON
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configure Apticron"
|
ynh_script_progression --message="Configuring Apticron..."
|
||||||
|
|
||||||
apticron_config="/etc/apticron/apticron.conf"
|
apticron_config="/etc/apticron/apticron.conf"
|
||||||
ynh_replace_string "# CUSTOM_SUBJECT=.*" \
|
# Create a backup of the config file for the reset action
|
||||||
"&\nCUSTOM_SUBJECT=\'[apticron] \$SYSTEM: \$NUM_PACKAGES package update(s)\'" "$apticron_config"
|
cp "$apticron_config" "/etc/yunohost/apps/$app/conf/apticron.conf.backup"
|
||||||
ynh_replace_string "# CUSTOM_NO_UPDATES_SUBJECT=.*" \
|
|
||||||
"&\nCUSTOM_NO_UPDATES_SUBJECT=\'[apticron] \$SYSTEM: Up to date \\\\o/\'" "$apticron_config"
|
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
|
# 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"
|
unattended_upgrades_config="/etc/apt/apt.conf.d/50unattended-upgrades"
|
||||||
|
|
||||||
# Make a backup of 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
|
# Configure upgrade sources
|
||||||
# Allow other updates
|
# Allow other updates
|
||||||
if [ "$upgrade_level" = "Security and updates" ]
|
if [ "$upgrade_level" = "Security and updates" ]
|
||||||
then
|
then
|
||||||
ynh_replace_string "//\(.*\"o=Debian,a=stable\)" "\1" "$unattended_upgrades_config"
|
ynh_replace_string --match_string="//\(.*\"o=Debian,a=stable\)" --replace_string="\1" --target_file="$unattended_upgrades_config"
|
||||||
ynh_replace_string "//\(.*\"o=Debian,a=stable-updates\)" "\1" "$unattended_upgrades_config"
|
ynh_replace_string --match_string="//\(.*\"o=Debian,a=stable-updates\)" --replace_string="\1" --target_file="$unattended_upgrades_config"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add YunoHost upgrade source
|
# Add YunoHost upgrade source
|
||||||
if [ $ynh_update -eq 1 ]
|
if [ $ynh_update -eq 1 ]
|
||||||
then
|
then
|
||||||
ynh_replace_string "origin=Debian,codename=\${distro_codename},label=Debian-Security\";" \
|
ynh_replace_string --match_string="origin=Debian,codename=\${distro_codename},label=Debian-Security\";" \
|
||||||
"&\n\n //YunoHost upgrade\n \"o=YunoHost,a=stable\";" "$unattended_upgrades_config"
|
--replace_string="&\n\n //YunoHost upgrade\n \"o=YunoHost,a=stable\";" --target_file="$unattended_upgrades_config"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Allow MinimalSteps upgrading to reduce risk in case of reboot
|
# 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
|
# Configure Unattended Upgrades mailing
|
||||||
if [ "$unattended_mail" = "If an upgrade has been done" ]
|
if [ "$unattended_mail" = "If an upgrade has been done" ]
|
||||||
then
|
then
|
||||||
# Allow mail to root
|
# Allow mail to root
|
||||||
ynh_replace_string "//\(Unattended-Upgrade::Mail \)" "\1" "$unattended_upgrades_config"
|
ynh_replace_string --match_string="//\(Unattended-Upgrade::Mail \)" --replace_string="\1" --target_file="$unattended_upgrades_config"
|
||||||
|
|
||||||
# Send mail even if there's no errors
|
# Send mail even if there's no errors
|
||||||
ynh_replace_string "//\(Unattended-Upgrade::MailOnlyOnError \).*" "\1\"false\";" "$unattended_upgrades_config"
|
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" ]
|
elif [ "$unattended_mail" = "Only if there was an error" ]
|
||||||
then
|
then
|
||||||
# Allow mail to root
|
# Allow mail to root
|
||||||
ynh_replace_string "//\(Unattended-Upgrade::Mail \)" "\1" "$unattended_upgrades_config"
|
ynh_replace_string --match_string="//\(Unattended-Upgrade::Mail \)" --replace_string="\1" --target_file="$unattended_upgrades_config"
|
||||||
|
|
||||||
# Send mail only if there's an error
|
# Send mail only if there's an error
|
||||||
ynh_replace_string "//\(Unattended-Upgrade::MailOnlyOnError \).*" "\1\"true\";" "$unattended_upgrades_config"
|
ynh_replace_string --match_string="//\(Unattended-Upgrade::MailOnlyOnError \).*" --replace_string="\1\"true\";" --target_file="$unattended_upgrades_config"
|
||||||
|
|
||||||
else # "Never"
|
else # "Never"
|
||||||
# Comment "Unattended-Upgrade::Mail" if it isn't already commented
|
# Comment "Unattended-Upgrade::Mail" if it isn't already commented
|
||||||
ynh_replace_string "^\(Unattended-Upgrade::Mail \)" "//\1" "$unattended_upgrades_config"
|
ynh_replace_string --match_string="^\(Unattended-Upgrade::Mail \)" --replace_string="//\1" --target_file="$unattended_upgrades_config"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -125,7 +128,7 @@ fi
|
||||||
ynh_script_progression --message="Configure APT Periodic for Unattended" --weight=2
|
ynh_script_progression --message="Configure APT Periodic for Unattended" --weight=2
|
||||||
|
|
||||||
cp "../conf/02periodic" "/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"
|
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
|
# This config file is used by /etc/cron.daily/apt
|
||||||
|
|
||||||
ynh_store_file_checksum "/etc/apt/apt.conf.d/02periodic"
|
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
|
ynh_script_progression --message="Modify original Apticron cron file" --weight=3
|
||||||
|
|
||||||
apticron_cron="/etc/cron.d/apticron"
|
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
|
# 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
|
# 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
|
# 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 ]
|
if [ $previous_apticron -eq 0 ]
|
||||||
then
|
then
|
||||||
# Comment the first cron
|
# Comment the first cron
|
||||||
ynh_replace_string "^0 20 .*" "#&" "$apticron_cron"
|
ynh_replace_string --match_string="^0 20 .*" --replace_string="#&" --target_file="$apticron_cron"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $after_apticron -eq 0 ]
|
if [ $after_apticron -eq 0 ]
|
||||||
then
|
then
|
||||||
# Comment the second cron
|
# Comment the second cron
|
||||||
ynh_replace_string "^0 2 .*" "#&" "$apticron_cron"
|
ynh_replace_string --match_string="^0 2 .*" --replace_string="#&" --target_file="$apticron_cron"
|
||||||
fi
|
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
|
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
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Installation completed" --last
|
ynh_script_progression --message="Installation of $app completed" --last
|
||||||
|
|
|
@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Load settings"
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEPENDENCIES
|
# REMOVE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Remove dependencies" --weight=5
|
ynh_script_progression --message="Removing dependencies..." --weight=5
|
||||||
|
|
||||||
ynh_remove_app_dependencies
|
ynh_remove_app_dependencies
|
||||||
|
|
||||||
|
@ -30,14 +30,14 @@ ynh_remove_app_dependencies
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE APT PERIODIC FILE
|
# 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"
|
ynh_secure_remove "/etc/apt/apt.conf.d/02periodic"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DECONFIGURE UNATTENDED-UPGRADES
|
# 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"
|
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
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Deletion completed" --last
|
ynh_script_progression --message="Removal of $app completed" --last
|
||||||
|
|
|
@ -6,11 +6,12 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source ../settings/scripts/_common.sh
|
|
||||||
source /usr/share/yunohost/helpers
|
|
||||||
# Load common variables for all scripts.
|
# Load common variables for all scripts.
|
||||||
source ../settings/scripts/_variables
|
source ../settings/scripts/_variables
|
||||||
|
|
||||||
|
source ../settings/scripts/_common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -21,7 +22,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Load settings"
|
ynh_script_progression --message="Loading settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
# REINSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reinstall dependencies" --weight=10
|
ynh_script_progression --message="Reinstalling dependencies..." --weight=10
|
||||||
|
|
||||||
ynh_install_app_dependencies $app_depencencies
|
ynh_install_app_dependencies $app_depencencies
|
||||||
|
|
||||||
|
@ -38,27 +39,27 @@ ynh_install_app_dependencies $app_depencencies
|
||||||
# RESTORE UNATTENDED-UPGRADES CONFIG
|
# 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
|
# 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
|
# 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
|
# RESTORE APTICRON CONFIG
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_restore_file "/etc/apticron/apticron.conf"
|
ynh_restore_file --origin_path="/etc/apticron/apticron.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE CRON FILE
|
# RESTORE CRON FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_restore_file "/etc/cron.d/apticron"
|
ynh_restore_file --origin_path="/etc/cron.d/apticron"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# 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
|
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
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Restoration completed" --last
|
ynh_script_progression --message="Restoration completed for $app" --last
|
||||||
|
|
|
@ -6,20 +6,21 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
|
||||||
source /usr/share/yunohost/helpers
|
|
||||||
# Load common variables for all scripts.
|
# Load common variables for all scripts.
|
||||||
source _variables
|
source _variables
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Load settings"
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
unattended_verbosity=$(ynh_app_setting_get $app unattended_verbosity)
|
unattended_verbosity=$(ynh_app_setting_get --app=$app --key=unattended_verbosity)
|
||||||
overwrite_periodic=$(ynh_app_setting_get $app overwrite_periodic)
|
overwrite_periodic=$(ynh_app_setting_get --app=$app --key=overwrite_periodic)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
|
@ -30,24 +31,46 @@ upgrade_type=$(ynh_check_app_version_changed)
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# 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 overwrite_periodic doesn't exist, create it
|
||||||
if [ -z "$overwrite_periodic" ]; then
|
if [ -z "$overwrite_periodic" ]; then
|
||||||
overwrite_periodic=1
|
overwrite_periodic=1
|
||||||
ynh_app_setting_set $app overwrite_periodic $overwrite_periodic
|
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
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# 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
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
# restore it if the upgrade fails
|
# restore it if the upgrade fails
|
||||||
ynh_restore_upgradebackup
|
ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
@ -57,7 +80,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrade dependencies" --weight=5
|
ynh_script_progression --message="Upgrading dependencies..." --weight=5
|
||||||
|
|
||||||
ynh_install_app_dependencies $app_depencencies
|
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
|
# Overwrite 02periodic config file only if it's allowed
|
||||||
if [ $overwrite_periodic -eq 1 ]
|
if [ $overwrite_periodic -eq 1 ]
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Upgrade APT Periodic for Unattended" --weight=3
|
ynh_script_progression --message="Upgrading APT Periodic for Unattended..." --weight=3
|
||||||
ynh_backup_if_checksum_is_different "/etc/apt/apt.conf.d/02periodic"
|
ynh_backup_if_checksum_is_different --file="/etc/apt/apt.conf.d/02periodic"
|
||||||
|
|
||||||
cp "../conf/02periodic" "/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"
|
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
|
# 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
|
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:
|
Changelog since your last upgrade:
|
||||||
$(cat changelog)" > mail_to_send
|
$(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
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Upgrade completed" --last
|
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||||
|
|
Loading…
Add table
Reference in a new issue