From cad879fb567b057eac20b9b9b80d846c508d066c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Wed, 25 Oct 2023 21:57:09 +0200 Subject: [PATCH] v2 --- manifest.toml | 24 +++++++++++++----------- scripts/_common.sh | 4 +--- scripts/install | 15 +++------------ scripts/remove | 15 ++++----------- scripts/restore | 20 +------------------- scripts/upgrade | 36 ++---------------------------------- tests.toml | 21 +++++++++++++++++++++ 7 files changed, 45 insertions(+), 90 deletions(-) create mode 100644 tests.toml diff --git a/manifest.toml b/manifest.toml index 5e8fbbf..9c8b28f 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "Borg Server" description.en = "Offer backup storage to a friend" description.fr = "Offrez un espace de stockage à un⋅e ami⋅e" -version = "1.1.16~ynh9" +version = "1.2.6~ynh1" maintainers = ["ljf"] @@ -14,18 +14,16 @@ license = "BSD-3-Clause" website = "https://www.borgbackup.org/" admindoc = "https://borgbackup.readthedocs.io/en/stable/" code = "https://github.com/borgbackup/borg" -cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) -fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. [integration] -yunohost = ">= 4.2.3" -architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +yunohost = ">= 11.2" +architectures = "all" multi_instance = true -ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. -sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. -disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... -ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... -ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ldap = "not_relevant" +sso = "not_relevant" +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" [install] [install.ssh_user] @@ -62,6 +60,10 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen [resources] [resources.system_user] - [resources.install_dir] + #[resources.install_dir] [resources.permissions] + + [resources.apt] + packages = "python3-pip, python3-dev, libacl1-dev, libssl-dev, liblz4-dev, python3-jinja2, python3-setuptools, python3-venv, virtualenv, libfuse-dev, pkg-config" + diff --git a/scripts/_common.sh b/scripts/_common.sh index ea74774..a2eafc1 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,9 +5,7 @@ #================================================= # App package root directory should be the parent folder PKG_DIR=$(cd ../; pwd) -BORG_VERSION=1.1.16 - -#REMOVEME? pkg_dependencies="python3-pip python3-dev libacl1-dev libssl-dev liblz4-dev python3-jinja2 python3-setuptools python3-venv virtualenv libfuse-dev pkg-config" +BORG_VERSION=1.2.6 # Install borg with pip if borg is not here install_borg_with_pip () { diff --git a/scripts/install b/scripts/install index d2813c2..d77d07d 100755 --- a/scripts/install +++ b/scripts/install @@ -9,19 +9,10 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -#REMOVEME? export app=$YNH_APP_INSTANCE_NAME - # Retrieve arguments ynh_export ssh_user public_key quota alert_delay alert_mails @@ -44,9 +35,8 @@ ynh_save_args ssh_user public_key quota alert_delay alert_mails #================================================= # INSTALL DEPENDENCIES #================================================= -#REMOVEME? ynh_script_progression --message="Installing dependencies..." +ynh_script_progression --message="Installing dependencies..." -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies install_borg_with_pip #================================================= @@ -54,7 +44,7 @@ install_borg_with_pip #================================================= ynh_script_progression --message="Creating SSH user used by Borg..." -#REMOVEME? ynh_system_user_create --username=$ssh_user --home_dir=/home/$ssh_user --use_shell --groups ssh.app +ynh_system_user_create --username=$ssh_user --home_dir=/home/$ssh_user --use_shell --groups ssh.app #================================================= # AUTORIZE SSH FOR THIS USER @@ -83,6 +73,7 @@ touch $home/.nobackup # SETUP CRON #================================================= ynh_script_progression --message="Configuring cron to monitor backup..." + ynh_add_config --template="monitor-backup" --destination="/etc/cron.d/$app" #================================================= diff --git a/scripts/remove b/scripts/remove index 9d85f73..d907141 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,19 +9,10 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME -#REMOVEME? ssh_user=$(ynh_app_setting_get $app ssh_user) - #================================================= # REMOVE DEPENDENCIES #================================================= -#REMOVEME? ynh_script_progression --message="Removing dependencies..." - -#REMOVEME? ynh_remove_app_dependencies +ynh_script_progression --message="Removing dependencies..." # Remove borg if we are removing the last borg app on the system if [ "$(yunohost app list | grep "id: borg" | wc -l)" == "1" ] ; then @@ -34,11 +25,13 @@ fi #================================================= # We keep files cause we don't know what the user want to do about # backups stored in the home directory -#REMOVEME? ynh_system_user_delete --username=$ssh_user + +ynh_system_user_delete --username=$ssh_user #================================================= # REMOVE CRON FILES #================================================= + ynh_secure_remove "/etc/cron.d/$app" #================================================= diff --git a/scripts/restore b/scripts/restore index 5904c69..12bc819 100755 --- a/scripts/restore +++ b/scripts/restore @@ -9,29 +9,11 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? export ssh_user=$(ynh_app_setting_get $app ssh_user) -#REMOVEME? export public_key=$(ynh_app_setting_get $app public_key) -#REMOVEME? export quota=$(ynh_app_setting_get $app quota) - #================================================= # INSTALL DEPENDENCIES #================================================= #REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies install_borg_with_pip #================================================= @@ -39,7 +21,7 @@ install_borg_with_pip #================================================= ynh_script_progression --message="Creating SSH user used by Borg..." -#REMOVEME? ynh_system_user_create --username=$ssh_user --home_dir=/home/$ssh_user --use_shell --groups ssh.app +ynh_system_user_create --username=$ssh_user --home_dir=/home/$ssh_user --use_shell --groups ssh.app #================================================= # AUTORIZE SSH FOR THIS USER diff --git a/scripts/upgrade b/scripts/upgrade index 13f2c8c..d6b2f3a 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,38 +9,12 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME -#REMOVEME? ssh_user=$(ynh_app_setting_get --app=$app --key=ssh_user) -#REMOVEME? public_key=$(ynh_app_setting_get --app=$app --key=public_key) -#REMOVEME? alert_delay=$(ynh_app_setting_get --app=$app --key=alert_delay) -#REMOVEME? alert_mails=$(ynh_app_setting_get --app=$app --key=alert_mails) -#REMOVEME? quota=$(ynh_app_setting_get --app=$app --key=quota) - #================================================= # CHECK IF AN UPGRADE IS NEEDED #================================================= ynh_check_app_version_changed -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= - -# We don't backup before upgrade cause we don't want accidental -# remove of repo if upgrade failed - -#REMOVEME? #ynh_backup_before_upgrade -#REMOVEME? #ynh_clean_setup () { -# # restore it if the upgrade fails -#REMOVEME? # ynh_restore_upgradebackup -#} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -83,14 +57,7 @@ fi #================================================= ynh_script_progression --message="Creating SSH user used by Borg..." -#REMOVEME? ynh_system_user_create --username=$ssh_user --home_dir=/home/$ssh_user --use_shell --groups ssh.app - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." - -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies +ynh_system_user_create --username=$ssh_user --home_dir=/home/$ssh_user --use_shell --groups ssh.app #================================================= # SPECIFIC UPGRADE @@ -126,6 +93,7 @@ touch /home/$ssh_user/.nobackup # SETUP CRON #================================================= ynh_script_progression --message="Configuring cron to monitor backup..." + ynh_add_config --template="monitor-backup" --destination="/etc/cron.d/$app" #================================================= diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..c61c0a2 --- /dev/null +++ b/tests.toml @@ -0,0 +1,21 @@ +test_format = 1.0 + +[default] + + # ------------ + # Tests to run + # ------------ + + exclude = ["install.root", "install.subdir", "change_url"] # The test IDs to be used in only/exclude statements are: install.root, install.subdir, install.nourl, install.multi, backup_restore, upgrade, upgrade.someCommitId change_url + # NB: you should NOT need this except if you really have a good reason... + + + # ------------ + # Tests to run + # ------------ + + args.ssh_user="sam" + args.public_key="ssh-ed25519 AAAACCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC" + args.alert_delay=1 + args.alert_mails="sam@domain.tld" + args.quota="1G" \ No newline at end of file