1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mygpo_ynh.git synced 2024-09-03 19:55:52 +02:00

Merge pull request #18 from YunoHost-Apps/example

Apply example_ynh
This commit is contained in:
yalh76 2022-02-01 21:01:36 +01:00 committed by GitHub
commit a8cc751f7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 199 additions and 167 deletions

2
.gitignore vendored
View file

@ -1,2 +0,0 @@
*~
*.sw[op]

View file

@ -1,8 +0,0 @@
{
"markdownlint.config": {
"MD028": false,
"MD025": {
"front_matter_title": ""
}
}
}

View file

@ -1,57 +1,48 @@
# `mygpo` (gPodder.net) for YunoHost
<!--
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.
-->
# mygpo (gPodder.net) for YunoHost
[![Integration level](https://dash.yunohost.org/integration/mygpo.svg)](https://dash.yunohost.org/appci/app/mygpo) ![](https://ci-apps.yunohost.org/ci/badges/mygpo.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mygpo.maintain.svg)
[![Install mygpo with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mygpo)
[![Install mygpo (gPodder.net) with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mygpo)
*[Lire ce readme en français.](./README_fr.md)*
> *This package allows you to install mygpo 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 mygpo (gPodder.net) 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
This is the webservice powering the https://gpodder.net website. It can be used to sync podcast subscriptions with [supported clients](https://gpoddernet.readthedocs.io/en/latest/user/clients.html).
**Shipped version:** 2021-10-20
## Screenshots
![](https://github.com/YunoHost-Apps/mygpo_ynh/raw/master/screenshot.png)
## Demo
* [Official demo](https://gpodder.net)
## Configuration
Edit files under `/opt/yunohost/APPDIR/envs/prod` to set environment variables. There is an admin interface at `yourdomain.tld/admin` that the admin user can log in to.
## Documentation
* Official documentation: https://gpoddernet.readthedocs.io/
**Shipped version:** 2.11.20211020~ynh1
#### Multi-user support
**Demo:** https://gpodder.net
* Are LDAP and HTTP auth supported? **LDAP only**
* Can the app be used by multiple users? **Yes**
## Screenshots
#### Supported architectures
![](./doc/screenshots/screenshot1.png)
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mygpo%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mygpo/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mygpo%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mygpo/)
## Disclaimers / important information
## Limitations
* The feed-parsing service is not included, https://feeds.gpodder.net is used
## Links
## Documentation and resources
* Official app website: https://gpodder.net
* Official admin documentation: https://gpoddernet.readthedocs.io/
* Upstream app code repository: https://github.com/gpodder/mygpo
* YunoHost documentation for this app: https://yunohost.org/app_mygpo
* Report a bug: https://github.com/YunoHost-Apps/mygpo_ynh/issues
* App website: https://gpodder.net
* Upstream app repository: https://github.com/gpodder/mygpo
* YunoHost website: https://yunohost.org/
---
## Developer info
@ -61,5 +52,7 @@ To try the testing branch, please proceed like that.
```
sudo yunohost app install https://github.com/YunoHost-Apps/mygpo_ynh/tree/testing --debug
or
sudo yunohost app upgrade mygpo -u https://github.com/YunoHost-Apps/mygpo_ynh/tree/testing --debuggit
sudo yunohost app upgrade mygpo -u https://github.com/YunoHost-Apps/mygpo_ynh/tree/testing --debug
```
**More info regarding app packaging:** https://yunohost.org/packaging_apps

View file

@ -1,57 +1,44 @@
# `mygpo` (gPodder.net) pour YunoHost
# mygpo (gPodder.net) pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/mygpo.svg)](https://dash.yunohost.org/appci/app/mygpo) ![](https://ci-apps.yunohost.org/ci/badges/mygpo.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mygpo.maintain.svg)
[![Installer mygpo avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mygpo)
[![Installer mygpo (gPodder.net) avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mygpo)
*[Read this readme in english.](./README.md)*
*[Lire ce readme en français.](./README_fr.md)*
> *Ce package vous permet d'installer mygpo rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.*
> *Ce package vous permet d'installer mygpo (gPodder.net) 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.*
## Vue d'ensemble
Ceci est le service derrière https://gpodder.net. Il peut servir pour synchronizer vos flux balado entre [clients compatibles](https://gpoddernet.readthedocs.io/en/latest/user/clients.html).
**Version incluse :** 2021-10-20
## Captures d'écran
![](https://github.com/YunoHost-Apps/mygpo_ynh/raw/master/screenshot.png)
## Démo
* [Démo officielle](https://gpodder.net)
This is the webservice powering the https://gpodder.net website. It can be used to sync podcast subscriptions with [supported clients](https://gpoddernet.readthedocs.io/en/latest/user/clients.html).
## Configuration
Modifiez les fichiers sous `/opt/yunohost/APPDIR/envs/prod` pour configurer les variables d'environment. Il y a une interface admin a `votre-domaine.tld/admin` (seulement accessible par l'administrateur).
Edit files under `/opt/yunohost/APPDIR/envs/prod` to set environment variables. There is an admin interface at `yourdomain.tld/admin` that the admin user can log in to.
## Documentation
* Documentation officielle : https://gpoddernet.readthedocs.io/
**Version incluse :** 2.11.20211020~ynh1
#### Support multi-utilisateur
**Démo :** https://gpodder.net
* L'authentification LDAP et HTTP est-elle prise en charge ? **Seulement LDAP**
* L'application peut-elle être utilisée par plusieurs utilisateurs ? **Oui**
## Captures d'écran
#### Architectures supportées
![](./doc/screenshots/screenshot1.png)
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mygpo%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mygpo/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mygpo%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mygpo/)
## Avertissements / informations importantes
## Limitations
* Le service d'analyse de flux n'est pas inclu, https://feeds.gpodder.net est utilisé
* The feed-parsing service is not included, https://feeds.gpodder.net is used
## Liens
## Documentations et ressources
* Signaler un bug : https://github.com/YunoHost-Apps/mygpo_ynh/issues
* Site de l'application : https://gpodder.net
* Dépôt de l'application principale : https://github.com/gpodder/mygpo
* Site web YunoHost : https://yunohost.org/
---
* Site officiel de l'app : https://gpodder.net
* Documentation officielle de l'admin : https://gpoddernet.readthedocs.io/
* Dépôt de code officiel de l'app : https://github.com/gpodder/mygpo
* Documentation YunoHost pour cette app : https://yunohost.org/app_mygpo
* Signaler un bug : https://github.com/YunoHost-Apps/mygpo_ynh/issues
## Informations pour les développeurs
@ -63,3 +50,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/mygpo_ynh/tree/testin
ou
sudo yunohost app upgrade mygpo -u https://github.com/YunoHost-Apps/mygpo_ynh/tree/testing --debug
```
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps

View file

@ -1,13 +1,8 @@
# See here for more information
# https://github.com/YunoHost/package_check#syntax-check_process-file
# Move this file from check_process.default to check_process when you have filled it.
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
admin="john" (USER)
is_public=1 (PUBLIC|public=1|private=0)
domain="domain.tld"
admin="john"
is_public=1
; Checks
pkg_linter=1
setup_sub_dir=0
@ -16,7 +11,10 @@
setup_private=1
setup_public=1
upgrade=1
# 2.11.1~ynh3
upgrade=1 from_commit=a50d46ae3a01d8a5b08ca9f9e62bfc9269fdedfa
# 2.11.20210519~ynh1
upgrade=1 from_commit=59b41b65dc33c3da471175002f37576ff460dc46
backup_restore=1
multi_instance=0
port_already_use=0
@ -26,6 +24,5 @@ Email=
Notification=none
;;; Upgrade options
; commit=CommitHash
name= Tweak starting of systemd services (April 1)
name=Tweak starting of systemd services (April 1)
manifest_arg=domain=DOMAIN&admin=USER&is_public=1&

View file

@ -8,7 +8,7 @@ Requires=__APP__.socket
Type=notify
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__
WorkingDirectory=__FINALPATH__/
ExecStart=__FINALPATH__/venv/bin/envdir __FINALPATH__/envs/prod __FINALPATH__/venv/bin/gunicorn -c __FINALPATH__/conf/gunicorn.conf.py mygpo.wsgi:application --bind unix:/run/__APP__.sock
ExecReload=/bin/kill -s HUP $MAINPID
@ -18,4 +18,4 @@ TimeoutStopSec=5
PrivateTmp=true
[Install]
WantedBy=multi-user.target
WantedBy=multi-user.target

0
doc/.gitkeep Normal file
View file

5
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1,5 @@
This is the webservice powering the https://gpodder.net website. It can be used to sync podcast subscriptions with [supported clients](https://gpoddernet.readthedocs.io/en/latest/user/clients.html).
## Configuration
Edit files under `/opt/yunohost/APPDIR/envs/prod` to set environment variables. There is an admin interface at `yourdomain.tld/admin` that the admin user can log in to.

3
doc/DISCLAIMER.md Normal file
View file

@ -0,0 +1,3 @@
## Limitations
* The feed-parsing service is not included, https://feeds.gpodder.net is used

0
doc/screenshots/.gitkeep Normal file
View file

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

View file

@ -10,7 +10,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
env_path=$final_path/envs/prod
pushd $final_path || ynh_die
sudo -u $app $final_path/venv/bin/envdir $env_path $final_path/venv/bin/python $final_path/manage.py shell <<< "
ynh_exec_as $app $final_path/venv/bin/envdir $env_path $final_path/venv/bin/python $final_path/manage.py shell <<< "
from django.contrib.auth import get_user_model
User = get_user_model()
try:

View file

@ -8,13 +8,20 @@
},
"version": "2.11.20211020~ynh1",
"url": "https://github.com/gpodder/mygpo",
"upstream": {
"license": "AGPL-3.0-only",
"website": "https://gpodder.net",
"demo": "https://gpodder.net",
"admindoc": "https://gpoddernet.readthedocs.io/",
"code": "https://github.com/gpodder/mygpo"
},
"license": "AGPL-3.0-only",
"maintainer": {
"name": "Jules Bertholet",
"email": "jules.bertholet@gmail.com"
},
"requirements": {
"yunohost": ">= 4.1.3"
"yunohost": ">= 4.3.0"
},
"multi_instance": false,
"services": [
@ -23,16 +30,14 @@
"redis-server"
],
"arguments": {
"install" : [
"install": [
{
"name": "domain",
"type": "domain",
"example": "example.com"
"type": "domain"
},
{
"name": "admin",
"type": "user",
"example": "johndoe"
"type": "user"
},
{
"name": "is_public",

View file

@ -4,21 +4,21 @@
# COMMON VARIABLES
#=================================================
# dependencies used by the app
pkg_dependencies="acl python3 python3-pip python3-venv postgresql postgresql-contrib libpq-dev redis-server libldap2-dev libsasl2-dev"
pkg_dependencies="acl python3 python3-dev python3-pip python3-venv postgresql postgresql-contrib libpq-dev redis-server libldap2-dev libsasl2-dev"
#=================================================
# PERSONAL HELPERS
#=================================================
function set_permissions {
mkdir -p $data_path
mkdir -p $datadir
env_path=$final_path/envs/prod
mkdir -p $env_path
chown -R $app:$app $data_path
chmod o-rwx $data_path
setfacl -n -R -m u:www-data:rx -m d:u:www-data:rx $data_path
chown -R $app:$app $datadir
chmod o-rwx $datadir
setfacl -n -R -m u:www-data:rx -m d:u:www-data:rx $datadir
chown -R root:$app $final_path
chmod -R g=u,g-w,o-rwx $final_path
@ -32,11 +32,11 @@ function set_up_virtualenv {
pushd $final_path || ynh_die
chown -R $app:$app $final_path
sudo -u $app python3 -m venv $final_path/venv
sudo -u $app $final_path/venv/bin/pip --cache-dir $final_path/.cache/pip install -U wheel pip --cache-dir $final_path/.cache/pip setuptools
sudo -u $app $final_path/venv/bin/pip --cache-dir $final_path/.cache/pip install -U --requirement $final_path/requirements.txt
sudo -u $app $final_path/venv/bin/pip --cache-dir $final_path/.cache/pip install -U --requirement $final_path/requirements-setup.txt
sudo -u $app $final_path/venv/bin/pip --cache-dir $final_path/.cache/pip install -U --requirement $final_path/requirements-ynh.txt
ynh_exec_warn_less ynh_exec_as $app python3 -m venv $final_path/venv
ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/pip --cache-dir $final_path/.cache/pip install -U wheel pip --cache-dir $final_path/.cache/pip setuptools
ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/pip --cache-dir $final_path/.cache/pip install -U --requirement $final_path/requirements.txt
ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/pip --cache-dir $final_path/.cache/pip install -U --requirement $final_path/requirements-setup.txt
ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/pip --cache-dir $final_path/.cache/pip install -U --requirement $final_path/requirements-ynh.txt
set_permissions
popd || ynh_dies
}
@ -45,7 +45,7 @@ function initialize_db {
pushd $final_path || ynh_die
chown -R $app:$app $final_path
perform_db_migrations
sudo -u $app $final_path/venv/bin/envdir $env_path $final_path/venv/bin/python $final_path/manage.py createsuperuser --username "$admin" --email "$admin_email" --noinput -v 0
ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/envdir $env_path $final_path/venv/bin/python $final_path/manage.py createsuperuser --username "$admin" --email "$admin_email" --noinput -v 0
set_permissions
popd || ynh_die
}
@ -59,15 +59,15 @@ function upgrade_db {
}
function perform_db_migrations {
sudo -u $app $final_path/venv/bin/envdir $env_path $final_path/venv/bin/python $final_path/manage.py makemigrations --merge
sudo -u $app $final_path/venv/bin/envdir $env_path $final_path/venv/bin/python $final_path/manage.py migrate
echo "y" | ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/envdir $env_path $final_path/venv/bin/python $final_path/manage.py makemigrations --merge
ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/envdir $env_path $final_path/venv/bin/python $final_path/manage.py migrate
}
function get_app_settings {
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
data_path=$(ynh_app_setting_get --app=$app --key=data_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
admin=$(ynh_app_setting_get --app=$app --key=admin)
secret_key=$(ynh_app_setting_get --app=$app --key=secret_key)
admin_email=$(ynh_user_get_info --username=$admin --key="mail")

View file

@ -5,6 +5,7 @@
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -12,6 +13,7 @@ source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
@ -35,11 +37,19 @@ ynh_print_info --message="Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
#=================================================
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="$datadir" --is_big
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
@ -47,15 +57,12 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup --src_path="/etc/systemd/system/$app-celery.service"
ynh_backup --src_path="/etc/systemd/system/$app-beat.service"
ynh_backup --src_path="/etc/systemd/system/$app.socket"
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --is_big --src_path="/home/yunohost.app/$app"
#=================================================
# BACKUP THE POSTGRESQL DATABASE
@ -67,4 +74,5 @@ ynh_psql_dump_db --database="$db_name" > db.sql
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -5,15 +5,19 @@
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path="/"
app=$YNH_APP_INSTANCE_NAME
@ -25,9 +29,9 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
get_app_settings
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
@ -44,12 +48,19 @@ ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
@ -110,4 +121,5 @@ ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -5,12 +5,14 @@
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
@ -39,9 +41,6 @@ ynh_script_progression --message="Validating installation parameters..." --weigh
final_path=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
data_path=/home/yunohost.app/$app
test ! -e "$data_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
@ -69,8 +68,8 @@ ynh_install_app_dependencies $pkg_dependencies
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a q user
ynh_system_user_create --username=$app
# Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# CREATE A POSTGRESQL DATABASE
@ -90,12 +89,9 @@ ynh_psql_execute_as_root --sql="ALTER ROLE $db_user SET statement_timeout = 5000
ynh_script_progression --message="Setting up source files..." --weight=1
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
ynh_app_setting_set --app=$app --key=data_path --value=$data_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
set_permissions
#=================================================
# NGINX CONFIGURATION
#=================================================
@ -106,6 +102,16 @@ ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
# CREATE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Creating a data directory..."
datadir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
set_permissions
#=================================================
# ENVDIR CONFIGURATION
#=================================================
@ -119,7 +125,7 @@ echo False > $env_path/DEBUG
echo $domain > $env_path/DEFAULT_BASE_URL
echo "$app@$domain" > $env_path/DEFAULT_FROM_EMAIL
echo "django.core.mail.backends.console.EmailBackend" > $env_path/EMAIL_BACKEND
echo "$data_path" > $env_path/MEDIA_ROOT
echo "$datadir" > $env_path/MEDIA_ROOT
echo $secret_key > $env_path/SECRET_KEY
echo "$app@$domain" > $env_path/SERVER_EMAIL
echo $staff_token > $env_path/STAFF_TOKEN
@ -134,6 +140,8 @@ set_up_virtualenv
#=================================================
# INITIALIZE DATABASE
#=================================================
ynh_script_progression --message="Initializing database..."
initialize_db
#=================================================
@ -202,4 +210,5 @@ ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -5,6 +5,7 @@
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -53,14 +54,6 @@ ynh_script_progression --message="Removing the PostgreSQL database..." --weight=
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE APP MAIN DIR
#=================================================
@ -69,6 +62,17 @@ ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE DATA DIR
#=================================================
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing app data directory..."
ynh_secure_remove --file="$datadir"
fi
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
@ -77,18 +81,24 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..."
# Remove the log files
ynh_secure_remove --file="/var/log/$app"
# Remove data dir
ynh_secure_remove --file="$data_path"
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -5,6 +5,7 @@
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -12,6 +13,7 @@ source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
@ -32,19 +34,16 @@ get_app_settings
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
test ! -d $data_path \
|| ynh_die --message="There is already a directory: $data_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
@ -53,7 +52,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# RESTORE THE APP MAIN DIR
@ -63,12 +62,20 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$final_path"
#=================================================
# RESTORE DATA DIR
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the app data directory..."
ynh_script_progression --message="Restoring the data directory..."
ynh_restore_file --origin_path="$data_path" --not_mandatory
ynh_restore_file --origin_path="$datadir" --not_mandatory
mkdir -p $datadir
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
@ -77,14 +84,6 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Restore permissions on app files
set_permissions
#=================================================
# SPECIFIC RESTORATION
#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
@ -95,6 +94,12 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Restore permissions on app files
set_permissions
#=================================================
# RESTORE SYSTEMD
#=================================================
@ -139,4 +144,5 @@ ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -5,6 +5,7 @@
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -20,21 +21,10 @@ get_app_settings
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
if [ -z "$data_path" ]; then
data_path=$(ynh_app_setting_get --app=$app --key=datadir)
ynh_app_setting_set --app=$app --key=data_path --value=$data_path
ynh_app_setting_delete --app=$app --key=datadir
ynh_app_setting_delete --app=$app --key=db_pwd
ynh_app_setting_delete --app=$app --key=admin_email
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
@ -67,15 +57,30 @@ systemctl disable $app-beat --quiet
systemctl disable $app-celery --quiet
#=================================================
# UPGRADE DEPENDENCIES
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
ynh_install_app_dependencies $pkg_dependencies
if [ -z "$datadir" ]; then
datadir=$(ynh_app_setting_get --app=$app --key=data_path)
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
ynh_app_setting_delete --app=$app --key=data_path
ynh_app_setting_delete --app=$app --key=db_pwd
ynh_app_setting_delete --app=$app --key=admin_email
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=1
@ -95,12 +100,11 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
ynh_script_progression --message="Upgrading dependencies..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# SPECIFIC UPGRADE
@ -161,4 +165,5 @@ ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last