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 #1 from YunoHost-Apps/testing

Testing
This commit is contained in:
ljf (zamentur) 2018-09-01 17:34:03 +02:00 committed by GitHub
commit 0638806244
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 115 additions and 7 deletions

33
check_process Normal file
View file

@ -0,0 +1,33 @@
;; Test complet
; Manifest
server="domain.tld:22"
ssh_user="sam"
public_key="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILM5TaFx9x9gXAkdRqEw39tpBLW/jXFzcBe9diuPlEfP"
quota="5G"
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=0
setup_nourl=0
setup_private=0
setup_public=0
upgrade=1
backup_restore=1
multi_instance=1
incorrect_path=0
port_already_use=0
change_url=0
;;; Levels
Level 1=auto
Level 2=auto
Level 3=auto
Level 4=1
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

View file

@ -6,7 +6,7 @@
"en": "Offer backup storage to a friend.",
"fr": "Offrez un espace de stockage à un⋅e ami⋅e."
},
"version": "1.0",
"version": "1.0.1",
"url": "https://borgbackup.readthedocs.io",
"license": "BSD-3-Clause",
"maintainer": {
@ -15,7 +15,7 @@
"url": "https://reflexlibre.net"
},
"requirements": {
"yunohost": ">= 2.7.2"
"yunohost": ">= 3.1"
},
"multi_instance": true,
"services": [],

View file

@ -58,3 +58,57 @@ ynh_configure () {
ynh_render_template "${PKG_DIR}/conf/$1.j2" $2
ynh_store_file_checksum $2
}
# 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
}
ynh_install_backports () {
echo "deb http://httpredir.debian.org/debian stretch-backports main" > /etc/apt/sources.list.d/$app-stretch-backports.list
}
ynh_remove_backports () {
rm /etc/apt/sources.list.d/$app-stretch-backports.list
}

View file

@ -29,12 +29,17 @@ ynh_export ssh_user public_key quota
#=================================================
ynh_save_args ssh_user public_key quota
#=================================================
# CONFIGURE BACKPORTS
#=================================================
# We need borg 1.1+ available only in backports
ynh_install_backports
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_install_app_dependencies $pkg_dependencies
pip3 install setuptools --upgrade
pip3 install borgbackup
ynh_package_install -t stretch-backports borgbackup
#=================================================
# CREATE SSH USER USED BY BORG

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
@ -20,6 +21,11 @@ ssh_user=$(ynh_app_setting_get $app ssh_user)
#=================================================
ynh_remove_app_dependencies
#=================================================
# REMOVE BACKPORTS
#=================================================
ynh_remove_backports
#=================================================
# REMOVE FILES
#=================================================

View file

@ -32,11 +32,16 @@ export public_key=$(ynh_app_setting_get $app public_key)
export quota=$(ynh_app_setting_get $app quota)
#=================================================
# STORE SETTINGS FROM MANIFEST
# CONFIGURE BACKPORTS
#=================================================
# We need borg 1.1+ available only in backports
ynh_install_backports
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_install_app_dependencies $pkg_dependencies
pip3 install setuptools --upgrade
pip3 install borgbackup
ynh_package_install -t stretch-backports borgbackup
#=================================================
# CREATE SSH USER USED BY BORG

View file

@ -15,6 +15,11 @@ source /usr/share/yunohost/helpers
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF AN UPGRADE IS NEEDED
#=================================================
ynh_check_app_version_changed
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================