From ad2e5bae89b8b024d05fce3705332e3d5e23d127 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:45:35 +0200 Subject: [PATCH] v2 --- manifest.toml | 67 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/_common.sh | 8 +++--- scripts/backup | 8 +++--- scripts/install | 10 +++---- scripts/remove | 10 +++---- scripts/restore | 16 +++++------ scripts/upgrade | 26 +++++++++--------- 7 files changed, 106 insertions(+), 39 deletions(-) create mode 100644 manifest.toml diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..5e8fbbf --- /dev/null +++ b/manifest.toml @@ -0,0 +1,67 @@ +packaging_format = 2 + +id = "borgserver" +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" + +maintainers = ["ljf"] + +[upstream] +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"] +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, ... + +[install] + [install.ssh_user] + ask.en = "Indicate the SSH user to create" + ask.fr = "Indiquez l'utilisateur SSH à créer" + type = "string" + example = "john" + + [install.public_key] + ask.en = "Indicate the public key given by borg_ynh app" + ask.fr = "Indiquez la clé publique donnée par l'app borg_ynh" + type = "string" + + [install.alert_delay] + ask.en = "After which delay in days should we alert if there are no changes on repo ?" + ask.fr = "Après quel délais en jours devons-nous lancer une alerte si il n'y a pas de changement dans le repo ?" + type = "string" + default = "1" + + [install.alert_mails] + ask.en = "Emails to whom send alerts ?" + ask.fr = "Emails des personnes à qui envoyer les alertes ?" + type = "string" + default = "root" + example = "camille@example.com,eden@example.com" + + [install.quota] + ask.en = "Indicate the storage quota" + ask.fr = "Indiquez le quota de stockage" + type = "string" + optionnal = true + example = "30G" + +[resources] + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] diff --git a/scripts/_common.sh b/scripts/_common.sh index 53870b5..ea74774 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,7 +7,7 @@ PKG_DIR=$(cd ../; pwd) BORG_VERSION=1.1.16 -pkg_dependencies="python3-pip python3-dev libacl1-dev libssl-dev liblz4-dev python3-jinja2 python3-setuptools python3-venv virtualenv libfuse-dev pkg-config" +#REMOVEME? pkg_dependencies="python3-pip python3-dev libacl1-dev libssl-dev liblz4-dev python3-jinja2 python3-setuptools python3-venv virtualenv libfuse-dev pkg-config" # Install borg with pip if borg is not here install_borg_with_pip () { @@ -35,10 +35,10 @@ ynh_export () { for var in $@; do ynh_arg=$(echo "$var" | awk '{print toupper($0)}') - if [ "$var" == "path_url" ]; then + if [ "$var" == "path" ]; then ynh_arg="PATH" fi - ynh_arg="YNH_APP_ARG_$ynh_arg" +#REMOVEME? ynh_arg="YNH_APP_ARG_$ynh_arg" export $var="${!ynh_arg}" done } @@ -48,7 +48,7 @@ ynh_save_args () { for var in $@; do local setting_var="$var" - if [ "$var" == "path_url" ]; then + if [ "$var" == "path" ]; then setting_var="path" fi ynh_app_setting_set $app $setting_var "${!var}" diff --git a/scripts/backup b/scripts/backup index 4263664..2d524e4 100755 --- a/scripts/backup +++ b/scripts/backup @@ -13,15 +13,15 @@ source /usr/share/yunohost/helpers #================================================= # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +#REMOVEME? ynh_print_info --message="Loading installation settings..." -app=$YNH_APP_INSTANCE_NAME -export ssh_user="$(ynh_app_setting_get $app ssh_user)" +#REMOVEME? app=$YNH_APP_INSTANCE_NAME +#REMOVEME? export ssh_user="$(ynh_app_setting_get $app ssh_user)" #================================================= # DECLARE DATA AND CONF FILES TO BACKUP diff --git a/scripts/install b/scripts/install index a7c29c3..d2813c2 100755 --- a/scripts/install +++ b/scripts/install @@ -14,13 +14,13 @@ source /usr/share/yunohost/helpers #================================================= # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -export app=$YNH_APP_INSTANCE_NAME +#REMOVEME? export app=$YNH_APP_INSTANCE_NAME # Retrieve arguments ynh_export ssh_user public_key quota alert_delay alert_mails @@ -44,9 +44,9 @@ ynh_save_args ssh_user public_key quota alert_delay alert_mails #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." +#REMOVEME? ynh_script_progression --message="Installing dependencies..." -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies install_borg_with_pip #================================================= @@ -54,7 +54,7 @@ install_borg_with_pip #================================================= ynh_script_progression --message="Creating SSH user used by Borg..." -ynh_system_user_create --username=$ssh_user --home_dir=/home/$ssh_user --use_shell --groups ssh.app +#REMOVEME? 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/remove b/scripts/remove index bb5bf94..9d85f73 100755 --- a/scripts/remove +++ b/scripts/remove @@ -13,15 +13,15 @@ source /usr/share/yunohost/helpers # LOAD SETTINGS #================================================= -app=$YNH_APP_INSTANCE_NAME -ssh_user=$(ynh_app_setting_get $app ssh_user) +#REMOVEME? app=$YNH_APP_INSTANCE_NAME +#REMOVEME? ssh_user=$(ynh_app_setting_get $app ssh_user) #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." +#REMOVEME? ynh_script_progression --message="Removing dependencies..." -ynh_remove_app_dependencies +#REMOVEME? ynh_remove_app_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,7 +34,7 @@ fi #================================================= # We keep files cause we don't know what the user want to do about # backups stored in the home directory -ynh_system_user_delete --username=$ssh_user +#REMOVEME? ynh_system_user_delete --username=$ssh_user #================================================= # REMOVE CRON FILES diff --git a/scripts/restore b/scripts/restore index 410547b..5904c69 100755 --- a/scripts/restore +++ b/scripts/restore @@ -14,24 +14,24 @@ source /usr/share/yunohost/helpers #================================================= # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -export ssh_user=$(ynh_app_setting_get $app ssh_user) -export public_key=$(ynh_app_setting_get $app public_key) -export quota=$(ynh_app_setting_get $app quota) +#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 #================================================= -ynh_script_progression --message="Reinstalling dependencies..." +#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies install_borg_with_pip #================================================= @@ -39,7 +39,7 @@ install_borg_with_pip #================================================= ynh_script_progression --message="Creating SSH user used by Borg..." -ynh_system_user_create --username=$ssh_user --home_dir=/home/$ssh_user --use_shell --groups ssh.app +#REMOVEME? 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 a55b038..13f2c8c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -13,12 +13,12 @@ source /usr/share/yunohost/helpers # LOAD SETTINGS #================================================= -app=$YNH_APP_INSTANCE_NAME -ssh_user=$(ynh_app_setting_get --app=$app --key=ssh_user) -public_key=$(ynh_app_setting_get --app=$app --key=public_key) -alert_delay=$(ynh_app_setting_get --app=$app --key=alert_delay) -alert_mails=$(ynh_app_setting_get --app=$app --key=alert_mails) -quota=$(ynh_app_setting_get --app=$app --key=quota) +#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 @@ -33,13 +33,13 @@ ynh_check_app_version_changed # We don't backup before upgrade cause we don't want accidental # remove of repo if upgrade failed -#ynh_backup_before_upgrade -#ynh_clean_setup () { +#REMOVEME? #ynh_backup_before_upgrade +#REMOVEME? #ynh_clean_setup () { # # restore it if the upgrade fails -# ynh_restore_upgradebackup +#REMOVEME? # ynh_restore_upgradebackup #} # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -83,14 +83,14 @@ fi #================================================= ynh_script_progression --message="Creating SSH user used by Borg..." -ynh_system_user_create --username=$ssh_user --home_dir=/home/$ssh_user --use_shell --groups ssh.app +#REMOVEME? ynh_system_user_create --username=$ssh_user --home_dir=/home/$ssh_user --use_shell --groups ssh.app #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." +#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies #================================================= # SPECIFIC UPGRADE