mirror of
https://github.com/YunoHost-Apps/borgserver_ynh.git
synced 2024-09-03 20:36:20 +02:00
Upgrade to V.1.1.14 (#29)
* Upgrade to v. 1.1.14 * Fix linter warnings * Small typos Co-authored-by: ljf (zamentur) <zamentur@users.noreply.github.com>
This commit is contained in:
parent
fbd67e8d93
commit
daf24c8ec3
8 changed files with 116 additions and 91 deletions
59
README.md
59
README.md
|
@ -1,3 +1,58 @@
|
|||
# borgserver_ynh
|
||||
Offer backup storage to a friend
|
||||
# Borg Server for YunoHost
|
||||
|
||||
[![Integration level](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)
|
||||
[![Install Borg Server with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=borgserver)
|
||||
|
||||
> *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
|
||||
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.14
|
||||
|
||||
## Documentation
|
||||
|
||||
* Official documentation: https://borgbackup.readthedocs.io/en/stable/
|
||||
* YunoHost documentation: If specific documentation is needed, feel free to contribute.
|
||||
|
||||
## YunoHost specific features
|
||||
|
||||
#### Multi-user support
|
||||
|
||||
* Are LDAP and HTTP auth supported?
|
||||
* Can the app be used by multiple users?
|
||||
|
||||
#### Supported architectures
|
||||
|
||||
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/borgserver%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/borgserver/)
|
||||
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/borgserver%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/borgserver/)
|
||||
|
||||
## Limitations
|
||||
|
||||
* Any known limitations.
|
||||
|
||||
## Additional information
|
||||
|
||||
* Other info you would like to add about this app.
|
||||
|
||||
## Links
|
||||
|
||||
* Report a bug: https://github.com/YunoHost-Apps/borgserver_ynh/issues
|
||||
* App website: https://www.borgbackup.org/
|
||||
* Upstream app repository: https://github.com/borgbackup/borg
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
||||
---
|
||||
|
||||
## Developer info
|
||||
|
||||
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.
|
||||
```
|
||||
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
|
||||
```
|
||||
|
|
|
@ -14,20 +14,8 @@
|
|||
upgrade=1
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
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+borgserver_ynh@reflexlibre.net
|
||||
Notification=down
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"en": "Offer backup storage to a friend.",
|
||||
"fr": "Offrez un espace de stockage à un⋅e ami⋅e."
|
||||
},
|
||||
"version": "1.1.10~ynh5",
|
||||
"version": "1.1.14~ynh1",
|
||||
"url": "https://borgbackup.readthedocs.io",
|
||||
"license": "BSD-3-Clause",
|
||||
"maintainer": {
|
||||
|
@ -15,22 +15,24 @@
|
|||
"url": "https://reflexlibre.net"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.6"
|
||||
"yunohost": ">= 3.8.1"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"multi_instance": false,
|
||||
"services": [],
|
||||
"arguments": {
|
||||
"install" : [
|
||||
{
|
||||
"name": "ssh_user",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Indicate the ssh user to create",
|
||||
"fr": "Indiquez l'utilisateur ssh à créer"
|
||||
"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"
|
||||
|
@ -38,6 +40,7 @@
|
|||
},
|
||||
{
|
||||
"name": "quota",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Indicate the storage quota",
|
||||
"fr": "Indiquez le quota de stockage"
|
||||
|
|
|
@ -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
|
||||
python3 -m venv /opt/borg-env
|
||||
/opt/borg-env/bin/python /opt/borg-env/bin/pip install borgbackup==1.1.10
|
||||
/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 a+x /usr/local/bin/borg
|
||||
|
@ -47,22 +47,7 @@ ynh_save_args () {
|
|||
done
|
||||
}
|
||||
|
||||
# Render templates with Jinja2
|
||||
#
|
||||
# Attention : Variables should be exported before calling this helper to be
|
||||
# accessible inside templates.
|
||||
#
|
||||
# usage: ynh_render_template some_template output_path
|
||||
# | arg: some_template - Template file to be rendered
|
||||
# | arg: output_path - The path where the output will be redirected to
|
||||
ynh_render_template() {
|
||||
local template_path=$1
|
||||
local output_path=$2
|
||||
# Taken from https://stackoverflow.com/a/35009576
|
||||
python2.7 -c 'import os, sys, jinja2; sys.stdout.write(
|
||||
jinja2.Template(sys.stdin.read()
|
||||
).render(os.environ));' < $template_path > $output_path
|
||||
}
|
||||
|
||||
|
||||
ynh_configure () {
|
||||
ynh_backup_if_checksum_is_different $2
|
||||
|
@ -71,57 +56,5 @@ ynh_configure () {
|
|||
}
|
||||
|
||||
ynh_read_json () {
|
||||
sudo python3 -c "import sys, json;print(json.load(open('$1'))['$2'])"
|
||||
}
|
||||
|
||||
ynh_read_manifest () {
|
||||
if [ -f '../manifest.json' ] ; then
|
||||
ynh_read_json '../manifest.json' "$1"
|
||||
else
|
||||
ynh_read_json '../settings/manifest.json' "$1"
|
||||
fi
|
||||
}
|
||||
# Checks the app version to upgrade with the existing app version and returns:
|
||||
# - UPGRADE_APP if the upstream app version has changed
|
||||
# - UPGRADE_PACKAGE if only the YunoHost package has changed
|
||||
#
|
||||
## It stops the current script without error if the package is up-to-date
|
||||
#
|
||||
# This helper should be used to avoid an upgrade of an app, or the upstream part
|
||||
# of it, when it's not needed
|
||||
#
|
||||
# To force an upgrade, even if the package is up to date,
|
||||
# you have to set the variable YNH_FORCE_UPGRADE before.
|
||||
# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp
|
||||
|
||||
# usage: ynh_check_app_version_changed
|
||||
ynh_check_app_version_changed () {
|
||||
local force_upgrade=${YNH_FORCE_UPGRADE:-0}
|
||||
local package_check=${PACKAGE_CHECK_EXEC:-0}
|
||||
|
||||
# By default, upstream app version has changed
|
||||
local return_value="UPGRADE_APP"
|
||||
|
||||
local current_version=$(ynh_read_manifest "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" "version" || echo 1.0)
|
||||
local current_upstream_version="${current_version/~ynh*/}"
|
||||
local update_version=$(ynh_read_manifest "../manifest.json" "version" || echo 1.0)
|
||||
local update_upstream_version="${update_version/~ynh*/}"
|
||||
|
||||
if [ "$current_version" == "$update_version" ] ; then
|
||||
# Complete versions are the same
|
||||
if [ "$force_upgrade" != "0" ]
|
||||
then
|
||||
echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2
|
||||
unset YNH_FORCE_UPGRADE
|
||||
elif [ "$package_check" != "0" ]
|
||||
then
|
||||
echo "Upgrade forced for package check." >&2
|
||||
else
|
||||
ynh_die "Up-to-date, nothing to do" 0
|
||||
fi
|
||||
elif [ "$current_upstream_version" == "$update_upstream_version" ] ; then
|
||||
# Upstream versions are the same, only YunoHost package versions differ
|
||||
return_value="UPGRADE_PACKAGE"
|
||||
fi
|
||||
echo $return_value
|
||||
python3 -c "import sys, json;print(json.load(open('$1'))['$2'])"
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
export app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
export app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve arguments
|
||||
ynh_export ssh_user public_key quota
|
||||
|
@ -28,27 +28,34 @@ ynh_export ssh_user public_key quota
|
|||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
||||
#=================================================
|
||||
|
||||
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
|
||||
|
||||
#=================================================
|
||||
# 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="Creat SSH user used by Borg..."
|
||||
|
||||
adduser $ssh_user --quiet --gecos ",,," --shell /bin/bash --disabled-password
|
||||
|
||||
#=================================================
|
||||
# AUTORIZE SSH FOR THIS USER
|
||||
#=================================================
|
||||
|
||||
home=/home/$ssh_user
|
||||
mkdir -p /home/$ssh_user/.ssh
|
||||
touch /home/$ssh_user/.ssh/authorized_keys
|
||||
|
@ -61,5 +68,11 @@ echo "command=\"borg serve $extra --restrict-to-repository /home/$ssh_user/backu
|
|||
#=================================================
|
||||
# AVOID BACKUP OF BACKUP
|
||||
#=================================================
|
||||
|
||||
touch $home/.nobackup
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
|
|
|
@ -19,9 +19,18 @@ ssh_user=$(ynh_app_setting_get $app ssh_user)
|
|||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..."
|
||||
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# REMOVE FILES
|
||||
#=================================================
|
||||
|
||||
userdel $ssh_user
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
|
|
|
@ -29,17 +29,21 @@ export quota=$(ynh_app_setting_get $app quota)
|
|||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..."
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
install_borg_with_pip
|
||||
|
||||
#=================================================
|
||||
# CREATE SSH USER USED BY BORG
|
||||
#=================================================
|
||||
|
||||
adduser $ssh_user --quiet --gecos ",,," --shell /bin/bash --disabled-password
|
||||
|
||||
#=================================================
|
||||
# AUTORIZE SSH FOR THIS USER
|
||||
#=================================================
|
||||
|
||||
home=/home/$ssh_user
|
||||
mkdir -p /home/$ssh_user/.ssh
|
||||
touch /home/$ssh_user/.ssh/authorized_keys
|
||||
|
@ -52,6 +56,12 @@ echo "command=\"borg serve $extra --restrict-to-repository /home/$ssh_user/backu
|
|||
#=================================================
|
||||
# AVOID BACKUP OF BACKUP
|
||||
#=================================================
|
||||
|
||||
touch $home/.nobackup
|
||||
ynh_restore
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
|
|
|
@ -19,6 +19,7 @@ ssh_user=$(ynh_app_setting_get --app=$app --key=ssh_user)
|
|||
#=================================================
|
||||
# CHECK IF AN UPGRADE IS NEEDED
|
||||
#=================================================
|
||||
|
||||
ynh_check_app_version_changed
|
||||
|
||||
#=================================================
|
||||
|
@ -34,7 +35,6 @@ ynh_clean_setup () {
|
|||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
|
@ -52,3 +52,17 @@ fi
|
|||
if echo "$ssh_user" | grep -v ' '; then
|
||||
ynh_app_setting_set --app=$app --key=ssh_user --value="$(grep -Po 'no-user-rc \K.*$' /home/$ssh_user/.ssh/authorized_keys)"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..."
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
install_borg_with_pip
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
|
|
Loading…
Reference in a new issue