1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/borgserver_ynh.git synced 2024-09-03 20:36:20 +02:00

Merge pull request #61 from YunoHost-Apps/testing

Testing | Packaging v2 + Borg 1.2.8
This commit is contained in:
eric_G 2024-04-25 17:25:13 +02:00 committed by GitHub
commit 554c1a9ceb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 296 additions and 328 deletions

7
ALL_README.md Normal file
View file

@ -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)

View file

@ -1,5 +1,5 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
N.B.: This README was automatically generated by <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>
It shall NOT be edited by hand.
-->
@ -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,20 +21,20 @@ 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: <https://www.borgbackup.org/>
* Official admin documentation: <https://borgbackup.readthedocs.io/en/stable/>
* Upstream app code repository: <https://github.com/borgbackup/borg>
* YunoHost Store: <https://apps.yunohost.org/app/borgserver>
* Report a bug: <https://github.com/YunoHost-Apps/borgserver_ynh/issues>
- Official app website: <https://www.borgbackup.org/>
- Official admin documentation: <https://borgbackup.readthedocs.io/en/stable/>
- Upstream app code repository: <https://github.com/borgbackup/borg>
- YunoHost Store: <https://apps.yunohost.org/app/borgserver>
- Report a bug: <https://github.com/YunoHost-Apps/borgserver_ynh/issues>
## 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
sudo yunohost app install https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing --debug

45
README_eu.md Normal file
View file

@ -0,0 +1,45 @@
<!--
Ohart ongi: README hau automatikoki sortu da <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>ri esker
EZ editatu eskuz.
-->
# 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: <https://www.borgbackup.org/>
- Administratzaileen dokumentazio ofiziala: <https://borgbackup.readthedocs.io/en/stable/>
- Jatorrizko aplikazioaren kode-gordailua: <https://github.com/borgbackup/borg>
- YunoHost Denda: <https://apps.yunohost.org/app/borgserver>
- Eman errore baten berri: <https://github.com/YunoHost-Apps/borgserver_ynh/issues>
## 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:** <https://yunohost.org/packaging_apps>

View file

@ -1,6 +1,6 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
It shall NOT be edited by hand.
Nota bene: ce README est automatiquement généré par <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>
Il NE doit PAS être modifié à la main.
-->
# 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 dinstaller Borg Server rapidement et simplement sur un serveur YunoHost.
Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment linstaller et en profiter.*
> *Ce package vous permet dinstaller Borg Server rapidement et simplement sur un serveur YunoHost.*
> *Si vous navez pas YunoHost, consultez [ce guide](https://yunohost.org/install) pour savoir comment linstaller et en profiter.*
## Vue densemble
@ -21,20 +21,20 @@ 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 lapp : <https://www.borgbackup.org/>
* Documentation officielle de ladmin : <https://borgbackup.readthedocs.io/en/stable/>
* Dépôt de code officiel de lapp : <https://github.com/borgbackup/borg>
* YunoHost Store: <https://apps.yunohost.org/app/borgserver>
* Signaler un bug : <https://github.com/YunoHost-Apps/borgserver_ynh/issues>
- Site officiel de lapp: <https://www.borgbackup.org/>
- Documentation officielle de ladmin: <https://borgbackup.readthedocs.io/en/stable/>
- Dépôt de code officiel de lapp: <https://github.com/borgbackup/borg>
- YunoHost Store: <https://apps.yunohost.org/app/borgserver>
- Signaler un bug: <https://github.com/YunoHost-Apps/borgserver_ynh/issues>
## 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
sudo yunohost app install https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing --debug
@ -42,4 +42,4 @@ ou
sudo yunohost app upgrade borgserver -u https://github.com/YunoHost-Apps/borgserver_ynh/tree/testing --debug
```
**Plus dinfos sur le packaging dapplications :** <https://yunohost.org/packaging_apps>
**Plus dinfos sur le packaging dapplications:** <https://yunohost.org/packaging_apps>

45
README_gl.md Normal file
View file

@ -0,0 +1,45 @@
<!--
NOTA: Este README foi creado automáticamente por <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>
NON debe editarse manualmente.
-->
# 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: <https://www.borgbackup.org/>
- Documentación oficial para admin: <https://borgbackup.readthedocs.io/en/stable/>
- Repositorio de orixe do código: <https://github.com/borgbackup/borg>
- Tenda YunoHost: <https://apps.yunohost.org/app/borgserver>
- Informar dun problema: <https://github.com/YunoHost-Apps/borgserver_ynh/issues>
## 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:** <https://yunohost.org/packaging_apps>

45
README_zh_Hans.md Normal file
View file

@ -0,0 +1,45 @@
<!--
注意:此 README 由 <https://github.com/YunoHost/apps/tree/master/tools/readme_generator> 自动生成
请勿手动编辑。
-->
# 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
## 文档与资源
- 官方应用网站: <https://www.borgbackup.org/>
- 官方管理文档: <https://borgbackup.readthedocs.io/en/stable/>
- 上游应用代码库: <https://github.com/borgbackup/borg>
- YunoHost 商店: <https://apps.yunohost.org/app/borgserver>
- 报告 bug <https://github.com/YunoHost-Apps/borgserver_ynh/issues>
## 开发者信息
请向 [`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
```
**有关应用打包的更多信息:** <https://yunohost.org/packaging_apps>

View file

@ -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&quota=1G

View file

@ -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"
}
]
}
}

76
manifest.toml Normal file
View file

@ -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",
]

View file

@ -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
}

View file

@ -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
#=================================================

View file

@ -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"
#=================================================

View file

@ -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"
#=================================================

View file

@ -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
#=================================================

View file

@ -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"
#=================================================

9
tests.toml Normal file
View file

@ -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"