diff --git a/ALL_README.md b/ALL_README.md
new file mode 100644
index 0000000..a01b345
--- /dev/null
+++ b/ALL_README.md
@@ -0,0 +1,7 @@
+# All available README files by language
+
+- [Read the README in English](README.md)
+- [Irakurri README euskaraz](README_eu.md)
+- [Lire le README en français](README_fr.md)
+- [Le o README en galego](README_gl.md)
+- [阅读中文(简体)的 README](README_zh_Hans.md)
diff --git a/README.md b/README.md
index 3c5cc67..d5f1cb8 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
@@ -9,10 +9,10 @@ It shall NOT be edited by hand.
[![Install Borg Server with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=borgserver)
-*[Lire ce readme en français.](./README_fr.md)*
+*[Read this README in other languages.](./ALL_README.md)*
-> *This package allows you to install Borg Server quickly and simply on a YunoHost server.
-If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
+> *This package allows you to install Borg Server quickly and simply on a YunoHost server.*
+> *If you don't have YunoHost, please consult [the guide](https://yunohost.org/install) to learn how to install it.*
## Overview
@@ -21,22 +21,22 @@ Offer backup storage to a friend.
The main goal of Borg is to provide an efficient and secure way to backup data. The data deduplication technique used makes Borg suitable for daily backups since only changes are stored. The authenticated encryption technique makes it suitable for backups to not fully trusted targets.
-**Shipped version:** 1.1.16~ynh10
+**Shipped version:** 1.2.8~ynh1
## Documentation and resources
-* Official app website:
-* Official admin documentation:
-* Upstream app code repository:
-* YunoHost Store:
-* Report a bug:
+- Official app website:
+- Official admin documentation:
+- Upstream app code repository:
+- YunoHost Store:
+- Report a bug:
## Developer info
-Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing).
+Please send your pull request to the [`testing` branch](https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing).
-To try the testing branch, please proceed like that.
+To try the `testing` branch, please proceed like that:
-``` bash
+```bash
sudo yunohost app install https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing --debug
or
sudo yunohost app upgrade borgserver -u https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing --debug
diff --git a/README_eu.md b/README_eu.md
new file mode 100644
index 0000000..43bffaa
--- /dev/null
+++ b/README_eu.md
@@ -0,0 +1,45 @@
+
+
+# Borg Server YunoHost-erako
+
+[![Integrazio maila](https://dash.yunohost.org/integration/borgserver.svg)](https://dash.yunohost.org/appci/app/borgserver) ![Funtzionamendu egoera](https://ci-apps.yunohost.org/ci/badges/borgserver.status.svg) ![Mantentze egoera](https://ci-apps.yunohost.org/ci/badges/borgserver.maintain.svg)
+
+[![Instalatu Borg Server YunoHost-ekin](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=borgserver)
+
+*[Irakurri README hau beste hizkuntzatan.](./ALL_README.md)*
+
+> *Pakete honek Borg Server YunoHost zerbitzari batean azkar eta zailtasunik gabe instalatzea ahalbidetzen dizu.*
+> *YunoHost ez baduzu, kontsultatu [gida](https://yunohost.org/install) nola instalatu ikasteko.*
+
+## Aurreikuspena
+
+Offer backup storage to a friend.
+
+The main goal of Borg is to provide an efficient and secure way to backup data. The data deduplication technique used makes Borg suitable for daily backups since only changes are stored. The authenticated encryption technique makes it suitable for backups to not fully trusted targets.
+
+
+**Paketatutako bertsioa:** 1.2.8~ynh1
+## Dokumentazioa eta baliabideak
+
+- Aplikazioaren webgune ofiziala:
+- Administratzaileen dokumentazio ofiziala:
+- Jatorrizko aplikazioaren kode-gordailua:
+- YunoHost Denda:
+- Eman errore baten berri:
+
+## Garatzaileentzako informazioa
+
+Bidali `pull request`a [`testing` abarrera](https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing).
+
+`testing` abarra probatzeko, ondorengoa egin:
+
+```bash
+sudo yunohost app install https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing --debug
+edo
+sudo yunohost app upgrade borgserver -u https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing --debug
+```
+
+**Informazio gehiago aplikazioaren paketatzeari buruz:**
diff --git a/README_fr.md b/README_fr.md
index 1312230..2ef4cec 100644
--- a/README_fr.md
+++ b/README_fr.md
@@ -1,6 +1,6 @@
# Borg Server pour YunoHost
@@ -9,10 +9,10 @@ It shall NOT be edited by hand.
[![Installer Borg Server avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=borgserver)
-*[Read this readme in english.](./README.md)*
+*[Lire le README dans d'autres langues.](./ALL_README.md)*
-> *Ce package vous permet d’installer Borg Server rapidement et simplement sur un serveur YunoHost.
-Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l’installer et en profiter.*
+> *Ce package vous permet d’installer Borg Server rapidement et simplement sur un serveur YunoHost.*
+> *Si vous n’avez pas YunoHost, consultez [ce guide](https://yunohost.org/install) pour savoir comment l’installer et en profiter.*
## Vue d’ensemble
@@ -21,25 +21,25 @@ Offer backup storage to a friend.
The main goal of Borg is to provide an efficient and secure way to backup data. The data deduplication technique used makes Borg suitable for daily backups since only changes are stored. The authenticated encryption technique makes it suitable for backups to not fully trusted targets.
-**Version incluse :** 1.1.16~ynh10
+**Version incluse :** 1.2.8~ynh1
## Documentations et ressources
-* Site officiel de l’app :
-* Documentation officielle de l’admin :
-* Dépôt de code officiel de l’app :
-* YunoHost Store:
-* Signaler un bug :
+- Site officiel de l’app :
+- Documentation officielle de l’admin :
+- Dépôt de code officiel de l’app :
+- YunoHost Store :
+- Signaler un bug :
## Informations pour les développeurs
-Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing).
+Merci de faire vos pull request sur la [branche `testing`](https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing).
-Pour essayer la branche testing, procédez comme suit.
+Pour essayer la branche `testing`, procédez comme suit :
-``` bash
+```bash
sudo yunohost app install https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing --debug
ou
sudo yunohost app upgrade borgserver -u https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing --debug
```
-**Plus d’infos sur le packaging d’applications :**
\ No newline at end of file
+**Plus d’infos sur le packaging d’applications :**
diff --git a/README_gl.md b/README_gl.md
new file mode 100644
index 0000000..3f1fe14
--- /dev/null
+++ b/README_gl.md
@@ -0,0 +1,45 @@
+
+
+# Borg Server para YunoHost
+
+[![Nivel de integración](https://dash.yunohost.org/integration/borgserver.svg)](https://dash.yunohost.org/appci/app/borgserver) ![Estado de funcionamento](https://ci-apps.yunohost.org/ci/badges/borgserver.status.svg) ![Estado de mantemento](https://ci-apps.yunohost.org/ci/badges/borgserver.maintain.svg)
+
+[![Instalar Borg Server con YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=borgserver)
+
+*[Le este README en outros idiomas.](./ALL_README.md)*
+
+> *Este paquete permíteche instalar Borg Server de xeito rápido e doado nun servidor YunoHost.*
+> *Se non usas YunoHost, le a [documentación](https://yunohost.org/install) para saber como instalalo.*
+
+## Vista xeral
+
+Offer backup storage to a friend.
+
+The main goal of Borg is to provide an efficient and secure way to backup data. The data deduplication technique used makes Borg suitable for daily backups since only changes are stored. The authenticated encryption technique makes it suitable for backups to not fully trusted targets.
+
+
+**Versión proporcionada:** 1.2.8~ynh1
+## Documentación e recursos
+
+- Web oficial da app:
+- Documentación oficial para admin:
+- Repositorio de orixe do código:
+- Tenda YunoHost:
+- Informar dun problema:
+
+## Info de desenvolvemento
+
+Envía a túa colaboración á [rama `testing`](https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing).
+
+Para probar a rama `testing`, procede deste xeito:
+
+```bash
+sudo yunohost app install https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing --debug
+ou
+sudo yunohost app upgrade borgserver -u https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing --debug
+```
+
+**Máis info sobre o empaquetado da app:**
diff --git a/README_zh_Hans.md b/README_zh_Hans.md
new file mode 100644
index 0000000..60bd91d
--- /dev/null
+++ b/README_zh_Hans.md
@@ -0,0 +1,45 @@
+
+
+# YunoHost 的 Borg Server
+
+[![集成程度](https://dash.yunohost.org/integration/borgserver.svg)](https://dash.yunohost.org/appci/app/borgserver) ![工作状态](https://ci-apps.yunohost.org/ci/badges/borgserver.status.svg) ![维护状态](https://ci-apps.yunohost.org/ci/badges/borgserver.maintain.svg)
+
+[![使用 YunoHost 安装 Borg Server](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=borgserver)
+
+*[阅读此 README 的其它语言版本。](./ALL_README.md)*
+
+> *通过此软件包,您可以在 YunoHost 服务器上快速、简单地安装 Borg Server。*
+> *如果您还没有 YunoHost,请参阅[指南](https://yunohost.org/install)了解如何安装它。*
+
+## 概况
+
+Offer backup storage to a friend.
+
+The main goal of Borg is to provide an efficient and secure way to backup data. The data deduplication technique used makes Borg suitable for daily backups since only changes are stored. The authenticated encryption technique makes it suitable for backups to not fully trusted targets.
+
+
+**分发版本:** 1.2.8~ynh1
+## 文档与资源
+
+- 官方应用网站:
+- 官方管理文档:
+- 上游应用代码库:
+- YunoHost 商店:
+- 报告 bug:
+
+## 开发者信息
+
+请向 [`testing` 分支](https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing) 发送拉取请求。
+
+如要尝试 `testing` 分支,请这样操作:
+
+```bash
+sudo yunohost app install https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing --debug
+或
+sudo yunohost app upgrade borgserver -u https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing --debug
+```
+
+**有关应用打包的更多信息:**
diff --git a/check_process b/check_process
deleted file mode 100644
index edbba5a..0000000
--- a/check_process
+++ /dev/null
@@ -1,27 +0,0 @@
-;; Test complet
- ; Manifest
- ssh_user="sam"
- public_key="ssh-ed25519 AAAACCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
- alert_delay=1
- alert_mails="sam@domain.tld"
- quota="1G"
- ; 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=c6ff77fc299c008b83cfe5f849b5d115989d5c49
- backup_restore=1
- multi_instance=1
- port_already_use=0
- change_url=0
-;;; Options
-Email=ljf+borg_ynh@reflexlibre.net
-Notificatio
-;;; Upgrade options
- ; commit=c6ff77fc299c008b83cfe5f849b5d115989d5c49
- name=Merge pull request #26 from YunoHost-Apps/testing
- manifest_arg=ssh_user=sam&public_key=ssh-ed25519 AAAACCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"a=1G
diff --git a/manifest.json b/manifest.json
deleted file mode 100644
index 270f080..0000000
--- a/manifest.json
+++ /dev/null
@@ -1,78 +0,0 @@
-{
- "name": "Borg Server",
- "id": "borgserver",
- "packaging_format": 1,
- "description": {
- "en": "Offer backup storage to a friend.",
- "fr": "Offrez un espace de stockage à un⋅e ami⋅e."
- },
- "upstream": {
- "license": "BSD-3-Clause",
- "website": "https://www.borgbackup.org/",
- "admindoc": "https://borgbackup.readthedocs.io/en/stable/",
- "code": "https://github.com/borgbackup/borg"
- },
- "version": "1.1.16~ynh10",
- "url": "https://borgbackup.readthedocs.io",
- "license": "BSD-3-Clause",
- "maintainer": {
- "name": "ljf",
- "email": "ljf+borg_ynh@reflexlibre.net",
- "url": "https://reflexlibre.net"
- },
- "requirements": {
- "yunohost": ">= 11.2"
- },
- "multi_instance": true,
- "services": [],
- "arguments": {
- "install" : [
- {
- "name": "ssh_user",
- "type": "string",
- "ask": {
- "en": "Indicate the SSH user to create",
- "fr": "Indiquez l'utilisateur SSH à créer"
- },
- "example": "john"
- },
- {
- "name": "public_key",
- "type": "string",
- "ask": {
- "en": "Indicate the public key given by borg_ynh app",
- "fr": "Indiquez la clé publique donnée par l'app borg_ynh"
- }
- },
- {
- "name": "alert_delay",
- "type": "string",
- "ask": {
- "en": "After which delay in days should we alert if there are no changes on repo ?",
- "fr": "Après quel délais en jours devons-nous lancer une alerte si il n'y a pas de changement dans le repo ?"
- },
- "default": "1"
- },
- {
- "name": "alert_mails",
- "type": "string",
- "ask": {
- "en": "Emails to whom send alerts ?",
- "fr": "Emails des personnes à qui envoyer les alertes ?"
- },
- "default": "root",
- "example": "camille@example.com,eden@example.com"
- },
- {
- "name": "quota",
- "type": "string",
- "ask": {
- "en": "Indicate the storage quota",
- "fr": "Indiquez le quota de stockage"
- },
- "optionnal": true,
- "example": "30G"
- }
- ]
- }
-}
diff --git a/manifest.toml b/manifest.toml
new file mode 100644
index 0000000..0f586ae
--- /dev/null
+++ b/manifest.toml
@@ -0,0 +1,76 @@
+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.2.8~ynh1"
+
+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"
+
+[integration]
+yunohost = ">= 11.2"
+architectures = "all"
+multi_instance = true
+ldap = "not_relevant"
+sso = "not_relevant"
+disk = "50M"
+ram.build = "50M"
+ram.runtime = "50M"
+
+[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"
+ optional = true
+ example = "30G"
+
+[resources]
+ [resources.permissions]
+
+ [resources.apt]
+ packages = [
+ "python3-pip",
+ "python3-dev",
+ "libacl1-dev",
+ "libssl-dev",
+ "liblz4-dev",
+ "python3-jinja2",
+ "python3-setuptools",
+ "python3-venv",
+ "virtualenv",
+ "libfuse3-dev",
+ "pkg-config",
+ ]
diff --git a/scripts/_common.sh b/scripts/_common.sh
index 53870b5..7151311 100644
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -1,13 +1,6 @@
#!/bin/bash
-#=================================================
-# COMMON VARIABLES
-#=================================================
-# App package root directory should be the parent folder
-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"
+BORG_VERSION=1.2.8
# Install borg with pip if borg is not here
install_borg_with_pip () {
@@ -16,9 +9,11 @@ install_borg_with_pip () {
fi
if [ ! -d /opt/borg-env ]; then
python3 -m venv /opt/borg-env
- /opt/borg-env/bin/python /opt/borg-env/bin/pip install wheel
+ /opt/borg-env/bin/python /opt/borg-env/bin/pip install pip -U
+ /opt/borg-env/bin/python /opt/borg-env/bin/pip install setuptools -U
+ /opt/borg-env/bin/python /opt/borg-env/bin/pip install wheel -U
ynh_print_info --message="Installing/compiling borg, this may take some time..."
- /opt/borg-env/bin/python /opt/borg-env/bin/pip install borgbackup[fuse]==$BORG_VERSION
+ /opt/borg-env/bin/python /opt/borg-env/bin/pip install borgbackup[pyfuse3]==$BORG_VERSION
echo "#!/bin/bash
/opt/borg-env/bin/python /opt/borg-env/bin/borg \"\$@\"" > /usr/local/bin/borg
touch "/opt/borg-env/$(ynh_get_debian_release)"
@@ -26,31 +21,3 @@ install_borg_with_pip () {
# We need this to be executable by other borg apps
chmod a+x /usr/local/bin/borg
}
-
-#=================================================
-# COMMON HELPERS
-#=================================================
-ynh_export () {
- local ynh_arg=""
- for var in $@;
- do
- ynh_arg=$(echo "$var" | awk '{print toupper($0)}')
- if [ "$var" == "path_url" ]; then
- ynh_arg="PATH"
- fi
- ynh_arg="YNH_APP_ARG_$ynh_arg"
- export $var="${!ynh_arg}"
- done
-}
-# Save listed var in YunoHost app settings
-# usage: ynh_save_args VARNAME1 [VARNAME2 [...]]
-ynh_save_args () {
- for var in $@;
- do
- local setting_var="$var"
- if [ "$var" == "path_url" ]; then
- setting_var="path"
- fi
- ynh_app_setting_set $app $setting_var "${!var}"
- done
-}
diff --git a/scripts/backup b/scripts/backup
index 4263664..5a503fa 100755
--- a/scripts/backup
+++ b/scripts/backup
@@ -1,28 +1,7 @@
#!/bin/bash
-#=================================================
-# GENERIC START
-#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-
source /usr/share/yunohost/helpers
-#=================================================
-# MANAGE SCRIPT FAILURE
-#=================================================
-
-# Exit if an error occurs during the execution of the script
-ynh_abort_if_errors
-
-#=================================================
-# LOAD SETTINGS
-#=================================================
-ynh_print_info --message="Loading installation settings..."
-
-app=$YNH_APP_INSTANCE_NAME
-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..4faa57f 100755
--- a/scripts/install
+++ b/scripts/install
@@ -9,80 +9,50 @@
source _common.sh
source /usr/share/yunohost/helpers
-#=================================================
-# MANAGE SCRIPT FAILURE
-#=================================================
-
-# Exit if an error occurs during the execution of the script
-ynh_abort_if_errors
-
-#=================================================
-# RETRIEVE ARGUMENTS FROM THE MANIFEST
-#=================================================
-
-export app=$YNH_APP_INSTANCE_NAME
-
-# Retrieve arguments
-ynh_export ssh_user public_key quota alert_delay alert_mails
-
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
#=================================================
# Here is a small hack to avoid multi install CI test to fail due
# to same ssh_user provided
-if [[ "${PACKAGE_CHECK_EXEC:-}" = "1" ]] ; then
+if [[ "${PACKAGE_CHECK_EXEC:-}" = "1" ]] && [[ "$YNH_APP_INSTANCE_NUMBER" != "1" ]] ; then
ssh_user+="$YNH_APP_INSTANCE_NUMBER"
fi
+
ynh_system_user_exists --username=$ssh_user && ynh_die --message="This user already exists"
-#=================================================
-# STORE SETTINGS FROM MANIFEST
-#=================================================
-
-ynh_save_args ssh_user public_key quota alert_delay alert_mails
-
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..."
-ynh_install_app_dependencies $pkg_dependencies
install_borg_with_pip
-#=================================================
-# CREATE SSH USER USED BY BORG
-#=================================================
-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
-
#=================================================
# AUTORIZE SSH FOR THIS USER
#=================================================
ynh_script_progression --message="Configuring SSH public key for remote connexion..."
+ynh_system_user_create --username=$ssh_user --home_dir=/home/$ssh_user --use_shell --groups ssh.app
+
home=/home/$ssh_user
-mkdir -p /home/$ssh_user/.ssh
-chmod o=--- /home/$ssh_user
-chown -R $ssh_user:$ssh_user /home/$ssh_user
-touch /home/$ssh_user/.ssh/authorized_keys
+mkdir -p $home/.ssh
+chmod o=--- $home
+chown -R $ssh_user:$ssh_user $home
+touch $home/.ssh/authorized_keys
extra="--storage-quota $quota"
if [ "$quota" = "" ]; then
extra=""
fi
-echo "command=\"borg serve $extra --restrict-to-repository /home/$ssh_user/backup\",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc $public_key" >> /home/$ssh_user/.ssh/authorized_keys
-
-#=================================================
-# AVOID BACKUP OF BACKUP
-#=================================================
-ynh_script_progression --message="Avoiding to backup the backup itself..."
+echo "command=\"borg serve $extra --restrict-to-repository $home/backup\",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc $public_key" >> $home/.ssh/authorized_keys
+# Tweak to prevent the backup of the backup itself
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 bb5bf94..d907141 100755
--- a/scripts/remove
+++ b/scripts/remove
@@ -9,20 +9,11 @@
source _common.sh
source /usr/share/yunohost/helpers
-#=================================================
-# LOAD SETTINGS
-#=================================================
-
-app=$YNH_APP_INSTANCE_NAME
-ssh_user=$(ynh_app_setting_get $app ssh_user)
-
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..."
-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
ynh_secure_remove "/opt/borg-env"
@@ -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
+
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 410547b..c176e72 100755
--- a/scripts/restore
+++ b/scripts/restore
@@ -9,58 +9,35 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
-#=================================================
-# MANAGE SCRIPT FAILURE
-#=================================================
-
-# Exit if an error occurs during the execution of the script
-ynh_abort_if_errors
-
-#=================================================
-# LOAD SETTINGS
-#=================================================
-
-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)
-
#=================================================
# INSTALL DEPENDENCIES
#=================================================
-ynh_script_progression --message="Reinstalling dependencies..."
+ynh_script_progression --message="Reinstalling borg env..."
-ynh_install_app_dependencies $pkg_dependencies
install_borg_with_pip
#=================================================
# CREATE SSH USER USED BY BORG
#=================================================
-ynh_script_progression --message="Creating SSH user used by Borg..."
+ynh_script_progression --message="Making sure SSH user exists with appropriate permissions..."
ynh_system_user_create --username=$ssh_user --home_dir=/home/$ssh_user --use_shell --groups ssh.app
-#=================================================
-# AUTORIZE SSH FOR THIS USER
-#=================================================
-
home=/home/$ssh_user
-mkdir -p /home/$ssh_user/.ssh
-chmod o=--- /home/$ssh_user
-chown -R $ssh_user:$ssh_user /home/$ssh_user
-touch /home/$ssh_user/.ssh/authorized_keys
+mkdir -p $home/.ssh
+chmod o=--- $home
extra="--storage-quota $quota"
if [ "$quota" = "" ]; then
extra=""
fi
-echo "command=\"borg serve $extra --restrict-to-repository /home/$ssh_user/backup\",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc $public_key" >> /home/$ssh_user/.ssh/authorized_keys
-
-#=================================================
-# AVOID BACKUP OF BACKUP
-#=================================================
+echo "command=\"borg serve $extra --restrict-to-repository $home/backup\",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc $public_key" >> $home/.ssh/authorized_keys
+chown -R $ssh_user:$ssh_user $home
+# Tweak to prevent the backup of the backup itself
touch $home/.nobackup
+
+
+# Actual restore of ...?
ynh_restore
#=================================================
diff --git a/scripts/upgrade b/scripts/upgrade
index a55b038..4546a08 100755
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -9,38 +9,12 @@
source _common.sh
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)
-
#=================================================
# 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
-
-#ynh_backup_before_upgrade
-#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
-
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
@@ -56,7 +30,7 @@ if [ -f "/etc/yunohost/hooks.d/backup/17-data_home" ]; then
fi
# Fix broken value ssh_user that mistakenly got replaced by the public key in previous versions...
-[ -n "$ssh_user" ] || ynh_die "Unable to retrieve ssh_user please fix /etc/yunohost/apps/$app/settings.yml manually :( !"
+[ -n "${ssh_user:-}" ] || ynh_die "Unable to retrieve ssh_user please fix /etc/yunohost/apps/$app/settings.yml manually :( !"
if echo "$ssh_user" | grep -q ' '; then
ssh_user=$(grep "$ssh_user" /home/*/.ssh/authorized_keys | grep borg | cut -d/ -f3)
[ -n "$ssh_user" ] || ynh_die "Unable to retrieve ssh_user please fix /etc/yunohost/apps/$app/settings.yml manually :( !"
@@ -68,7 +42,7 @@ if echo "$public_key" | grep -q -v ' '; then
fi
# Alert delay and alert mail missing
-if [ -z "$alert_delay" ]; then
+if [ -z "${alert_delay:-}" ]; then
ynh_app_setting_set --app=$app --key=alert_delay --value=1
ynh_app_setting_set --app=$app --key=alert_mails --value="root"
fi
@@ -78,20 +52,6 @@ if [ ! -f "/opt/borg-env/$(ynh_get_debian_release)" ] ; then
ynh_secure_remove /opt/borg-env
fi
-#=================================================
-# CREATE SSH USER USED BY BORG
-#=================================================
-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
-
-#=================================================
-# UPGRADE DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Upgrading dependencies..."
-
-ynh_install_app_dependencies $pkg_dependencies
-
#=================================================
# SPECIFIC UPGRADE
#=================================================
@@ -104,28 +64,28 @@ install_borg_with_pip
#=================================================
# AUTORIZE SSH FOR THIS USER
#=================================================
-ynh_script_progression --message="Seting good permissions..."
+ynh_script_progression --message="Making sure SSH user exists with appropriate permissions..."
-mkdir -p /home/$ssh_user/.ssh
-chmod o=--- /home/$ssh_user
+ynh_system_user_create --username=$ssh_user --home_dir=/home/$ssh_user --use_shell --groups ssh.app
+
+home=/home/$ssh_user
+mkdir -p $home/.ssh
+chmod o=--- $home
extra="--storage-quota $quota"
if [ "$quota" = "" ]; then
extra=""
fi
-echo "command=\"borg serve $extra --restrict-to-repository /home/$ssh_user/backup\",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc $public_key" >> /home/$ssh_user/.ssh/authorized_keys
-chown -R $ssh_user:$ssh_user /home/$ssh_user
+echo "command=\"borg serve $extra --restrict-to-repository $home/backup\",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc $public_key" >> $home/.ssh/authorized_keys
+chown -R $ssh_user:$ssh_user $home
-#=================================================
-# AVOID BACKUP OF BACKUP
-#=================================================
-ynh_script_progression --message="Avoiding to backup the backup itself..."
-
-touch /home/$ssh_user/.nobackup
+# Tweak to prevent the backup of the backup itself
+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/tests.toml b/tests.toml
new file mode 100644
index 0000000..faaf6c7
--- /dev/null
+++ b/tests.toml
@@ -0,0 +1,9 @@
+test_format = 1.0
+
+[default]
+
+ args.ssh_user = "sam"
+ args.public_key = "ssh-ed25519 AAAACCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
+ args.alert_delay = 1
+ args.alert_mails = "sam@domain.tld"
+ args.quota = "1G"