From 50643e260cfdf07553d5266c2b32a62501e0c8aa Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 19 Dec 2020 10:25:23 +0100 Subject: [PATCH] Upgrade to upstream version --- README.md | 4 ++-- check_process | 12 ------------ manifest.json | 16 ++++++++-------- scripts/_common.sh | 2 +- scripts/backup | 11 +++++++++++ scripts/install | 23 +++++++++++++++++++++-- scripts/remove | 8 ++++++++ scripts/restore | 15 +++++++++++++-- scripts/upgrade | 21 +++++++++++++++++---- 9 files changed, 81 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 853e42a..3f81d8d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Borg Backup App for YunoHost +# Borg Backup for YunoHost -[![Latest Version](https://img.shields.io/badge/version-1.0.3-green.svg?style=flat)](https://github.com/YunoHost-Apps/borg_ynh/releases) +[![Latest Version](https://img.shields.io/badge/version-1.1.14-green.svg?style=flat)](https://github.com/YunoHost-Apps/borg_ynh/releases) [![Status](https://img.shields.io/badge/status-testing-yellow.svg?style=flat)](https://github.com/YunoHost-Apps/borg_ynh/milestones) [![Integration level](https://dash.yunohost.org/integration/borg.svg)](https://dash.yunohost.org/appci/app/borg) [![GitHub license](https://img.shields.io/badge/license-GPLv3-blue.svg?style=flat)](https://raw.githubusercontent.com/YunoHost-Apps/borg_ynh/master/LICENSE) diff --git a/check_process b/check_process index ee3719e..c4d634d 100644 --- a/check_process +++ b/check_process @@ -17,20 +17,8 @@ upgrade=1 backup_restore=1 multi_instance=1 - incorrect_path=0 port_already_use=0 change_url=0 -;;; 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 ;;; Options Email=ljf+borg_ynh@reflexlibre.net Notification=down diff --git a/manifest.json b/manifest.json index af09fb3..701d61a 100644 --- a/manifest.json +++ b/manifest.json @@ -1,12 +1,12 @@ { - "name": "Borg Backup App", + "name": "Borg Backup", "id": "borg", "packaging_format": 1, "description": { "en": "Backup your server on a host server using Borg.", "fr": "Sauvegardez votre serveur sur un serveur distant avec Borg." }, - "version": "1.1.13~ynh2", + "version": "1.1.14~ynh1", "url": "https://borgbackup.readthedocs.io", "license": "BSD-3-Clause", "maintainer": { @@ -15,7 +15,7 @@ "url": "https://reflexlibre.net" }, "requirements": { - "yunohost": ">= 3.5.0" + "yunohost": ">= 3.8.1" }, "multi_instance": true, "services": [], @@ -53,7 +53,7 @@ "fr": "Indiquez une phrase de passe forte pour chiffrer vos sauvegardes. Sans espaces" }, "help":{ - "en": "Keep it safe! ...if you want to be able to restore. Do not communicate it to host Server holder or anyone else. ", + "en": "Keep it safe! ...if you want to be able to restore. Do not communicate it to host Server holder or anyone else.", "fr": "Gardez-la précieusement! ...si vous voulez pouvoir restaurer. Ne donnez pas la clé au possesseur du Serveur distant, ni personne." } }, @@ -61,7 +61,7 @@ "name": "conf", "type": "boolean", "ask": { - "en": "Should Borg backup your YunoHost configuration ?", + "en": "Should Borg backup your YunoHost configuration?", "fr": "Borg doit-il sauvegarder la configuration système YunoHost ?" }, "default": true @@ -70,7 +70,7 @@ "name": "data", "type": "boolean", "ask": { - "en": "Should Borg backup emails and user home directory ?", + "en": "Should Borg backup emails and user home directory?", "fr": "Borg doit-elle sauvegarder les mails et les répertoires des utilisateurs ?" }, "default": true @@ -78,7 +78,7 @@ { "name": "apps", "ask": { - "en": "Which apps should Borg backup (list separated by comma or 'all') ?", + "en": "Which apps should Borg backup (list separated by comma or 'all')?", "fr": "Quelles applications doivent être sauvegardées par Borg (liste séparée par virgule ou 'all' ?" }, "default": "all" @@ -86,7 +86,7 @@ { "name": "on_calendar", "ask": { - "en": "With which regular time schedule should the backups be performed ? (see systemd OnCalendar format)", + "en": "With which regular time schedule should the backups be performed? (see systemd OnCalendar format)", "fr": "À quelle fréquence les sauvegardes doivent-elles être effectuées ? (voir le format OnCalendar de systemd)" }, "example": "Monthly or Weekly or Daily or Hourly or 4:00 or 5,17:00 or Sat --1..7 18:00:00", diff --git a/scripts/_common.sh b/scripts/_common.sh index 59992d6..ccc3f42 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -12,7 +12,7 @@ pkg_dependencies="python3-pip python3-dev libacl1-dev libssl-dev liblz4-dev pyth install_borg_with_pip () { if [ ! -d /opt/borg-env ]; then virtualenv --python=python3 /opt/borg-env - /opt/borg-env/bin/python /opt/borg-env/bin/pip install borgbackup==1.1.13 + /opt/borg-env/bin/python /opt/borg-env/bin/pip install borgbackup==1.1.14 echo "#!/bin/bash /opt/borg-env/bin/python /opt/borg-env/bin/borg \"\$@\"" > /usr/local/bin/borg chmod u+x /usr/local/bin/borg diff --git a/scripts/backup b/scripts/backup index 6775113..9a0f189 100755 --- a/scripts/backup +++ b/scripts/backup @@ -18,9 +18,14 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME +#================================================= +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_print_info --message="Declaring files to be backed up..." ynh_backup "/usr/local/bin/backup-with-$app" ynh_backup "/etc/systemd/system/$app.service" @@ -28,3 +33,9 @@ ynh_backup "/etc/systemd/system/$app.timer" ynh_backup "/etc/yunohost/hooks.d/backup_method/05-${app}_app" ynh_backup "/root/.ssh/id_${app}_ed25519" ynh_backup "/root/.ssh/id_${app}_ed25519.pub" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/install b/scripts/install index b80bca6..fd39233 100755 --- a/scripts/install +++ b/scripts/install @@ -19,6 +19,7 @@ ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= + export app=$YNH_APP_INSTANCE_NAME # Retrieve arguments @@ -27,17 +28,21 @@ ynh_export server ssh_user passphrase on_calendar conf data apps #================================================= # STORE SETTINGS FROM MANIFEST #================================================= + ynh_save_args server ssh_user passphrase on_calendar conf data apps #================================================= # INSTALL DEPENDENCIES #================================================= +ynh_script_progression --message="Installing dependencies..." + ynh_install_app_dependencies $pkg_dependencies install_borg_with_pip #================================================= # ACTIVATE BACKUP METHODS #================================================= + mkdir -p /etc/yunohost/hooks.d/backup_method mkdir -p /usr/share/yunohost/backup_method @@ -49,19 +54,28 @@ ynh_configure backup_method "/etc/yunohost/hooks.d/backup_method/05-${app}_app" #================================================= # CONFIGURE CRON #================================================= + ynh_configure backup-with-borg "/usr/local/bin/backup-with-$app" chmod u+x "/usr/local/bin/backup-with-$app" ynh_add_systemd_config ynh_configure systemd.timer "/etc/systemd/system/$app.timer" -systemctl enable $app.timer +systemctl enable $app.timer --quiet systemctl start $app.timer #yunohost service add $app.timer #yunohost service enable $app.timer #yunohost service start $app.timer +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." + +yunohost service add $app + #================================================= # GENERATE SSH KEY #================================================= + private_key="/root/.ssh/id_${app}_ed25519" test -f $private_key || ssh-keygen -q -t ed25519 -N "" -f $private_key @@ -73,10 +87,10 @@ echo "You should now install the \"Borg Server\" app on $server and fill questio User: ${ssh_user} Public key: $(cat ${private_key}.pub)" - #================================================= # SEND A README FOR THE ADMIN #================================================= + ynh_print_OFF message="You should now install the \"Borg Server\" app on $server and fill questions like this: User: ${ssh_user} @@ -91,3 +105,8 @@ If you facing an issue or want to improve this app, please open a new issue in t ynh_send_readme_to_admin "$message" "root" ynh_print_ON +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 3463708..07a2ab1 100755 --- a/scripts/remove +++ b/scripts/remove @@ -18,6 +18,8 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # REMOVE DEPENDENCIES #================================================= +ynh_script_progression --message="Removing dependencies..." + ynh_remove_app_dependencies #================================================= @@ -29,3 +31,9 @@ ynh_remove_systemd_config ynh_secure_remove "/etc/systemd/system/$app.timer" ynh_secure_remove "/usr/local/bin/backup-with-$app" ynh_secure_remove "/etc/yunohost/hooks.d/backup_method/05-${app}_app" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index df9443e..bc7c282 100755 --- a/scripts/restore +++ b/scripts/restore @@ -19,6 +19,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -28,25 +29,29 @@ ssh_user=$(ynh_app_setting_get $app ssh_user) #================================================= # INSTALL DEPENDENCIES #================================================= +ynh_script_progression --message="Reinstalling dependencies..." + ynh_install_app_dependencies $pkg_dependencies install_borg_with_pip #================================================= # ACTIVATE BACKUP METHODS #================================================= + mkdir -p /etc/yunohost/hooks.d/backup_method mkdir -p /usr/share/yunohost/backup_method #================================================= # RESTORE FILES #================================================= + ynh_restore #================================================= # ADVERTISE SERVICE IN ADMIN PANEL #================================================= yunohost service add $app -systemctl enable $app.timer +systemctl enable $app.timer --quiet systemctl start $app.timer #yunohost service add $app.timer #yunohost service enable $app.timer @@ -55,5 +60,11 @@ systemctl start $app.timer #================================================= # RESTORE SYSTEMD #================================================= -systemctl enable $app.service +systemctl enable $app.service --quiet + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index 139e4ee..02c8408 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -39,6 +39,7 @@ ynh_check_app_version_changed #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -46,13 +47,14 @@ 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 if grep "borg.timer" /etc/yunohost/services.yml > /dev/null ; then yunohost service remove $app.timer - systemctl enable $app.timer + systemctl enable $app.timer --quiet systemctl start $app.timer fi @@ -63,8 +65,7 @@ if is_buster; then ynh_secure_remove /opt/borg-env install_borg_with_pip touch /opt/borg-env/buster - fi - + fi fi #================================================= @@ -79,5 +80,17 @@ ynh_configure backup-with-borg "/usr/local/bin/backup-with-$app" chmod u+x "/usr/local/bin/backup-with-$app" ynh_add_systemd_config ynh_configure systemd.timer "/etc/systemd/system/$app.timer" -systemctl enable $app.timer +systemctl enable $app.timer --quiet systemctl start $app.timer + +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +yunohost service add $app + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" --last