Merge pull request #25 from YunoHost-Apps/manifestv2

Manifest v2
This commit is contained in:
Salamandar 2024-03-29 00:48:34 +01:00 committed by GitHub
commit f5cd3cbd67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 490 additions and 1193 deletions

6
ALL_README.md Normal file
View file

@ -0,0 +1,6 @@
# All available README files by language
- [Read the README in English](README.md)
- [Lire le README en français](README_fr.md)
- [Le o README en galego](README_gl.md)
- [Leggi il “README” in italiano](README_it.md)

151
README.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 django-fritzconnection with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=django-fritzconnection)
*[Lire ce readme en français.](./README_fr.md)*
*[Read this README is other languages.](./ALL_README.md)*
> *This package allows you to install django-fritzconnection 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 django-fritzconnection 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
@ -32,154 +32,23 @@ Pull requests welcome ;)
This package for YunoHost used [django-yunohost-integration](https://github.com/YunoHost-Apps/django_yunohost_integration)
**Shipped version:** 0.2.0~ynh2
**Shipped version:** 0.2.0~ynh3
## Screenshots
![Screenshot of django-fritzconnection](./doc/screenshots/screenshot.png)
## Disclaimers / important information
## Settings and upgrades
Almost everything related to django-fritzconnection's configuration is handled in a `"../conf/settings.py"` file.
You can edit the file `/opt/yunohost/django-fritzconnection/local_settings.py` to enable or disable features.
Test sending emails:
```bash
ssh admin@yourdomain.tld
root@yunohost:~# cd /opt/yunohost/django-fritzconnection/
root@yunohost:/opt/yunohost/django-fritzconnection# source venv/bin/activate
(venv) root@yunohost:/opt/yunohost/django-fritzconnection# ./manage.py sendtestemail --admins
```
Background info: Error mails are send to all [settings.ADMINS](https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-ADMINS). By default the YunoHost admin is inserted here.
To check current ADMINS run:
```bash
(venv) root@yunohost:/opt/yunohost/django-fritzconnection# ./manage.py sendtestemail --admins
```
If you prefere to send error emails to a extrnal email address, just do something like this:
```bash
echo "ADMINS = (('Your Name', 'example@domain.tld'),)" >> /opt/yunohost/django-fritzconnection/local_settings.py
```
To check the effective settings, run this:
```bash
(venv) root@yunohost:/opt/yunohost/django-fritzconnection# ./manage.py diffsettings
```
# Miscellaneous
## SSO authentication
[SSOwat](https://github.com/YunoHost/SSOwat) is fully supported via [django-yunohost-integration](https://github.com/YunoHost-Apps/django_yunohost_integration):
* First user (`$YNH_APP_ARG_ADMIN`) will be created as Django's super user
* All new users will be created as normal users
* Login via SSO is fully supported
* User Email, First / Last name will be updated from SSO data
---
# Yunohost developer commands
To remove call e.g.:
```bash
sudo yunohost app remove django-fritzconnection
```
Backup / remove / restore cycle, e.g.:
```bash
yunohost backup create --apps django-fritzconnection
yunohost backup list
archives:
- django-fritzconnection-pre-upgrade1
- 20201223-163434
yunohost app remove django-fritzconnection
yunohost backup restore 20201223-163434 --apps django-fritzconnection
```
Debug installation, e.g.:
```bash
root@yunohost:~# ls -la /var/www/django-fritzconnection/
total 18
drwxr-xr-x 4 root root 4 Dec 8 08:36 .
drwxr-xr-x 6 root root 6 Dec 8 08:36 ..
drwxr-xr-x 2 root root 2 Dec 8 08:36 media
drwxr-xr-x 7 root root 8 Dec 8 08:40 static
root@yunohost:~# ls -la /opt/yunohost/django-fritzconnection/
total 58
drwxr-xr-x 5 django-fritzconnection django-fritzconnection 11 Dec 8 08:39 .
drwxr-xr-x 3 root root 3 Dec 8 08:36 ..
-rw-r--r-- 1 django-fritzconnection django-fritzconnection 460 Dec 8 08:39 gunicorn.conf.py
-rw-r--r-- 1 django-fritzconnection django-fritzconnection 0 Dec 8 08:39 local_settings.py
-rwxr-xr-x 1 django-fritzconnection django-fritzconnection 274 Dec 8 08:39 manage.py
-rw-r--r-- 1 django-fritzconnection django-fritzconnection 171 Dec 8 08:39 secret.txt
drwxr-xr-x 6 django-fritzconnection django-fritzconnection 6 Dec 8 08:37 venv
-rw-r--r-- 1 django-fritzconnection django-fritzconnection 115 Dec 8 08:39 wsgi.py
-rw-r--r-- 1 django-fritzconnection django-fritzconnection 4737 Dec 8 08:39 settings.py
root@yunohost:~# cd /opt/yunohost/django-fritzconnection/
root@yunohost:/opt/yunohost/django-fritzconnection# source venv/bin/activate
(venv) root@yunohost:/opt/yunohost/django-fritzconnection# ./manage.py check
django-fritzconnection v0.8.2 (Django v2.2.17)
DJANGO_SETTINGS_MODULE='settings'
PROJECT_PATH:/opt/yunohost/django-fritzconnection/venv/lib/python3.7/site-packages
BASE_PATH:/opt/yunohost/django-fritzconnection
System check identified no issues (0 silenced).
root@yunohost:~# tail -f /var/log/django-fritzconnection/django-fritzconnection.log
root@yunohost:~# cat /etc/systemd/system/django-fritzconnection.service
root@yunohost:~# systemctl reload-or-restart django-fritzconnection
root@yunohost:~# journalctl --unit=django-fritzconnection --follow
```
## local test
For quicker developing of django-fritzconnection in the context of YunoHost app,
it's possible to run the Django developer server with the settings
and urls made for YunoHost installation.
e.g.:
```bash
~$ git clone https://github.com/YunoHost-Apps/django-fritzconnection_ynh.git
~$ cd django-fritzconnection_ynh/
~/django-fritzconnection_ynh$ make
install-poetry install or update poetry
install install django-fritzconnection via poetry
update update the sources and installation
local-test Run local_test.py to run django-fritzconnection_ynh locally
~/django-fritzconnection_ynh$ make install-poetry
~/django-fritzconnection_ynh$ make install
~/django-fritzconnection_ynh$ make local-test
```
Notes:
* SQlite database will be used
* A super user with username `test` and password `test` is created
* The page is available under `http://127.0.0.1:8000/app_path/`
## Documentation and resources
* Upstream app code repository: <https://github.com/jedie/django-fritzconnection>
* YunoHost Store: <https://apps.yunohost.org/app/django-fritzconnection>
* Report a bug: <https://github.com/YunoHost-Apps/django-fritzconnection_ynh/issues>
- Upstream app code repository: <https://github.com/jedie/django-fritzconnection>
- YunoHost Store: <https://apps.yunohost.org/app/django-fritzconnection>
- Report a bug: <https://github.com/YunoHost-Apps/django-fritzconnection_ynh/issues>
## Developer info
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/django-fritzconnection_ynh/tree/testing).
Please send your pull request to the [`testing` branch](https://github.com/YunoHost-Apps/django-fritzconnection_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/django-fritzconnection_ynh/tree/testing --debug

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.
-->
# django-fritzconnection pour YunoHost
@ -9,10 +9,10 @@ It shall NOT be edited by hand.
[![Installer django-fritzconnection avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=django-fritzconnection)
*[Read this readme in english.](./README.md)*
*[Lire le README dans d'autres langues.](./ALL_README.md)*
> *Ce package vous permet dinstaller django-fritzconnection 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 django-fritzconnection 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
@ -32,154 +32,23 @@ Pull requests welcome ;)
This package for YunoHost used [django-yunohost-integration](https://github.com/YunoHost-Apps/django_yunohost_integration)
**Version incluse :** 0.2.0~ynh2
**Version incluse:** 0.2.0~ynh3
## Captures décran
![Capture décran de django-fritzconnection](./doc/screenshots/screenshot.png)
## Avertissements / informations importantes
## Settings and upgrades
Almost everything related to django-fritzconnection's configuration is handled in a `"../conf/settings.py"` file.
You can edit the file `/opt/yunohost/django-fritzconnection/local_settings.py` to enable or disable features.
Test sending emails:
```bash
ssh admin@yourdomain.tld
root@yunohost:~# cd /opt/yunohost/django-fritzconnection/
root@yunohost:/opt/yunohost/django-fritzconnection# source venv/bin/activate
(venv) root@yunohost:/opt/yunohost/django-fritzconnection# ./manage.py sendtestemail --admins
```
Background info: Error mails are send to all [settings.ADMINS](https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-ADMINS). By default the YunoHost admin is inserted here.
To check current ADMINS run:
```bash
(venv) root@yunohost:/opt/yunohost/django-fritzconnection# ./manage.py sendtestemail --admins
```
If you prefere to send error emails to a extrnal email address, just do something like this:
```bash
echo "ADMINS = (('Your Name', 'example@domain.tld'),)" >> /opt/yunohost/django-fritzconnection/local_settings.py
```
To check the effective settings, run this:
```bash
(venv) root@yunohost:/opt/yunohost/django-fritzconnection# ./manage.py diffsettings
```
# Miscellaneous
## SSO authentication
[SSOwat](https://github.com/YunoHost/SSOwat) is fully supported via [django-yunohost-integration](https://github.com/YunoHost-Apps/django_yunohost_integration):
* First user (`$YNH_APP_ARG_ADMIN`) will be created as Django's super user
* All new users will be created as normal users
* Login via SSO is fully supported
* User Email, First / Last name will be updated from SSO data
---
# Yunohost developer commands
To remove call e.g.:
```bash
sudo yunohost app remove django-fritzconnection
```
Backup / remove / restore cycle, e.g.:
```bash
yunohost backup create --apps django-fritzconnection
yunohost backup list
archives:
- django-fritzconnection-pre-upgrade1
- 20201223-163434
yunohost app remove django-fritzconnection
yunohost backup restore 20201223-163434 --apps django-fritzconnection
```
Debug installation, e.g.:
```bash
root@yunohost:~# ls -la /var/www/django-fritzconnection/
total 18
drwxr-xr-x 4 root root 4 Dec 8 08:36 .
drwxr-xr-x 6 root root 6 Dec 8 08:36 ..
drwxr-xr-x 2 root root 2 Dec 8 08:36 media
drwxr-xr-x 7 root root 8 Dec 8 08:40 static
root@yunohost:~# ls -la /opt/yunohost/django-fritzconnection/
total 58
drwxr-xr-x 5 django-fritzconnection django-fritzconnection 11 Dec 8 08:39 .
drwxr-xr-x 3 root root 3 Dec 8 08:36 ..
-rw-r--r-- 1 django-fritzconnection django-fritzconnection 460 Dec 8 08:39 gunicorn.conf.py
-rw-r--r-- 1 django-fritzconnection django-fritzconnection 0 Dec 8 08:39 local_settings.py
-rwxr-xr-x 1 django-fritzconnection django-fritzconnection 274 Dec 8 08:39 manage.py
-rw-r--r-- 1 django-fritzconnection django-fritzconnection 171 Dec 8 08:39 secret.txt
drwxr-xr-x 6 django-fritzconnection django-fritzconnection 6 Dec 8 08:37 venv
-rw-r--r-- 1 django-fritzconnection django-fritzconnection 115 Dec 8 08:39 wsgi.py
-rw-r--r-- 1 django-fritzconnection django-fritzconnection 4737 Dec 8 08:39 settings.py
root@yunohost:~# cd /opt/yunohost/django-fritzconnection/
root@yunohost:/opt/yunohost/django-fritzconnection# source venv/bin/activate
(venv) root@yunohost:/opt/yunohost/django-fritzconnection# ./manage.py check
django-fritzconnection v0.8.2 (Django v2.2.17)
DJANGO_SETTINGS_MODULE='settings'
PROJECT_PATH:/opt/yunohost/django-fritzconnection/venv/lib/python3.7/site-packages
BASE_PATH:/opt/yunohost/django-fritzconnection
System check identified no issues (0 silenced).
root@yunohost:~# tail -f /var/log/django-fritzconnection/django-fritzconnection.log
root@yunohost:~# cat /etc/systemd/system/django-fritzconnection.service
root@yunohost:~# systemctl reload-or-restart django-fritzconnection
root@yunohost:~# journalctl --unit=django-fritzconnection --follow
```
## local test
For quicker developing of django-fritzconnection in the context of YunoHost app,
it's possible to run the Django developer server with the settings
and urls made for YunoHost installation.
e.g.:
```bash
~$ git clone https://github.com/YunoHost-Apps/django-fritzconnection_ynh.git
~$ cd django-fritzconnection_ynh/
~/django-fritzconnection_ynh$ make
install-poetry install or update poetry
install install django-fritzconnection via poetry
update update the sources and installation
local-test Run local_test.py to run django-fritzconnection_ynh locally
~/django-fritzconnection_ynh$ make install-poetry
~/django-fritzconnection_ynh$ make install
~/django-fritzconnection_ynh$ make local-test
```
Notes:
* SQlite database will be used
* A super user with username `test` and password `test` is created
* The page is available under `http://127.0.0.1:8000/app_path/`
## Documentations et ressources
* Dépôt de code officiel de lapp : <https://github.com/jedie/django-fritzconnection>
* YunoHost Store: <https://apps.yunohost.org/app/django-fritzconnection>
* Signaler un bug : <https://github.com/YunoHost-Apps/django-fritzconnection_ynh/issues>
- Dépôt de code officiel de lapp: <https://github.com/jedie/django-fritzconnection>
- YunoHost Store: <https://apps.yunohost.org/app/django-fritzconnection>
- Signaler un bug: <https://github.com/YunoHost-Apps/django-fritzconnection_ynh/issues>
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/django-fritzconnection_ynh/tree/testing).
Merci de faire vos pull request sur la [branche `testing`](https://github.com/YunoHost-Apps/django-fritzconnection_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/django-fritzconnection_ynh/tree/testing --debug
@ -187,4 +56,4 @@ ou
sudo yunohost app upgrade django-fritzconnection -u https://github.com/YunoHost-Apps/django-fritzconnection_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>

59
README_gl.md Normal file
View file

@ -0,0 +1,59 @@
<!--
NOTA: Este README foi creado automáticamente por <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>
NON debe editarse manualmente.
-->
# django-fritzconnection para YunoHost
[![Nivel de integración](https://dash.yunohost.org/integration/django-fritzconnection.svg)](https://dash.yunohost.org/appci/app/django-fritzconnection) ![Estado de funcionamento](https://ci-apps.yunohost.org/ci/badges/django-fritzconnection.status.svg) ![Estado de mantemento](https://ci-apps.yunohost.org/ci/badges/django-fritzconnection.maintain.svg)
[![Instalar django-fritzconnection con YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=django-fritzconnection)
*[Le este README en outros idiomas.](./ALL_README.md)*
> *Este paquete permíteche instalar django-fritzconnection 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
Web based FritzBox management using Python/Django and the great [fritzconnection](https://github.com/kbr/fritzconnection) library.
The basic idea is to block/unblock Internet access to a group of devices as easily as possible.
[![pytest](https://github.com/YunoHost-Apps/django-fritzconnection_ynh/actions/workflows/pytest.yml/badge.svg?branch=master)](https://github.com/YunoHost-Apps/django-fritzconnection_ynh/actions/workflows/pytest.yml) [![YunoHost apps package linter](https://github.com/YunoHost-Apps/django-fritzconnection_ynh/actions/workflows/package_linter.yml/badge.svg)](https://github.com/YunoHost-Apps/django-fritzconnection_ynh/actions/workflows/package_linter.yml) [![Coverage Status on codecov.io](https://codecov.io/gh/YunoHost-Apps/django-fritzconnection_ynh/branch/master/graph/badge.svg)](https://codecov.io/gh/YunoHost-Apps/django-fritzconnection_ynh)
![django-fritzconnection @ PyPi](https://img.shields.io/pypi/v/django-fritzconnection?label=django-fritzconnection%20%40%20PyPi)
![Python Versions](https://img.shields.io/pypi/pyversions/django-fritzconnection)
![License GPL V3+](https://img.shields.io/pypi/l/django-fritzconnection)
Pull requests welcome ;)
This package for YunoHost used [django-yunohost-integration](https://github.com/YunoHost-Apps/django_yunohost_integration)
**Versión proporcionada:** 0.2.0~ynh3
## Capturas de pantalla
![Captura de pantalla de django-fritzconnection](./doc/screenshots/screenshot.png)
## Documentación e recursos
- Repositorio de orixe do código: <https://github.com/jedie/django-fritzconnection>
- Tenda YunoHost: <https://apps.yunohost.org/app/django-fritzconnection>
- Informar dun problema: <https://github.com/YunoHost-Apps/django-fritzconnection_ynh/issues>
## Info de desenvolvemento
Envía a túa colaboración á [rama `testing`](https://github.com/YunoHost-Apps/django-fritzconnection_ynh/tree/testing).
Para probar a rama `testing`, procede deste xeito:
```bash
sudo yunohost app install https://github.com/YunoHost-Apps/django-fritzconnection_ynh/tree/testing --debug
ou
sudo yunohost app upgrade django-fritzconnection -u https://github.com/YunoHost-Apps/django-fritzconnection_ynh/tree/testing --debug
```
**Máis info sobre o empaquetado da app:** <https://yunohost.org/packaging_apps>

59
README_it.md Normal file
View file

@ -0,0 +1,59 @@
<!--
N.B.: Questo README è stato automaticamente generato da <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>
NON DEVE essere modificato manualmente.
-->
# django-fritzconnection per YunoHost
[![Livello di integrazione](https://dash.yunohost.org/integration/django-fritzconnection.svg)](https://dash.yunohost.org/appci/app/django-fritzconnection) ![Stato di funzionamento](https://ci-apps.yunohost.org/ci/badges/django-fritzconnection.status.svg) ![Stato di manutenzione](https://ci-apps.yunohost.org/ci/badges/django-fritzconnection.maintain.svg)
[![Installa django-fritzconnection con YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=django-fritzconnection)
*[Leggi questo README in altre lingue.](./ALL_README.md)*
> *Questo pacchetto ti permette di installare django-fritzconnection su un server YunoHost in modo semplice e veloce.*
> *Se non hai YunoHost, consulta [la guida](https://yunohost.org/install) per imparare a installarlo.*
## Panoramica
Web based FritzBox management using Python/Django and the great [fritzconnection](https://github.com/kbr/fritzconnection) library.
The basic idea is to block/unblock Internet access to a group of devices as easily as possible.
[![pytest](https://github.com/YunoHost-Apps/django-fritzconnection_ynh/actions/workflows/pytest.yml/badge.svg?branch=master)](https://github.com/YunoHost-Apps/django-fritzconnection_ynh/actions/workflows/pytest.yml) [![YunoHost apps package linter](https://github.com/YunoHost-Apps/django-fritzconnection_ynh/actions/workflows/package_linter.yml/badge.svg)](https://github.com/YunoHost-Apps/django-fritzconnection_ynh/actions/workflows/package_linter.yml) [![Coverage Status on codecov.io](https://codecov.io/gh/YunoHost-Apps/django-fritzconnection_ynh/branch/master/graph/badge.svg)](https://codecov.io/gh/YunoHost-Apps/django-fritzconnection_ynh)
![django-fritzconnection @ PyPi](https://img.shields.io/pypi/v/django-fritzconnection?label=django-fritzconnection%20%40%20PyPi)
![Python Versions](https://img.shields.io/pypi/pyversions/django-fritzconnection)
![License GPL V3+](https://img.shields.io/pypi/l/django-fritzconnection)
Pull requests welcome ;)
This package for YunoHost used [django-yunohost-integration](https://github.com/YunoHost-Apps/django_yunohost_integration)
**Versione pubblicata:** 0.2.0~ynh3
## Screenshot
![Screenshot di django-fritzconnection](./doc/screenshots/screenshot.png)
## Documentazione e risorse
- Repository upstream del codice dellapp: <https://github.com/jedie/django-fritzconnection>
- Store di YunoHost: <https://apps.yunohost.org/app/django-fritzconnection>
- Segnala un problema: <https://github.com/YunoHost-Apps/django-fritzconnection_ynh/issues>
## Informazioni per sviluppatori
Si prega di inviare la tua pull request alla [branch di `testing`](https://github.com/YunoHost-Apps/django-fritzconnection_ynh/tree/testing).
Per provare la branch di `testing`, si prega di procedere in questo modo:
```bash
sudo yunohost app install https://github.com/YunoHost-Apps/django-fritzconnection_ynh/tree/testing --debug
o
sudo yunohost app upgrade django-fritzconnection -u https://github.com/YunoHost-Apps/django-fritzconnection_ynh/tree/testing --debug
```
**Maggiori informazioni riguardo il pacchetto di questapp:** <https://yunohost.org/packaging_apps>

View file

@ -1,33 +0,0 @@
# 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)
path="/path" (PATH)
admin="john" (USER)
is_public=1 (PUBLIC|public=1|private=0)
password="pass"
port="666" (PORT)
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=0
setup_public=1
upgrade=1
backup_restore=1
multi_instance=1
port_already_use=0
change_url=1
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=CommitHash
name=Name and date of the commit.
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&

View file

@ -13,8 +13,8 @@ workers = multiprocessing.cpu_count() * 2 + 1
loglevel = 'info'
# https://docs.gunicorn.org/en/latest/settings.html#logging
accesslog = '__LOG_FILE__'
errorlog = '__LOG_FILE__'
accesslog = '/var/log/__APP__/__APP__.log'
errorlog = '/var/log/__APP__/__APP__.log'
# https://docs.gunicorn.org/en/latest/settings.html#pidfile
pidfile = '__FINALPATH__/gunicorn.pid'
pidfile = '__INSTALL_DIR__/app/gunicorn.pid'

View file

@ -1,4 +1,4 @@
#!__FINALPATH__/venv/bin/python
#!__INSTALL_DIR__/venv/bin/python
import os
import sys

View file

@ -2,7 +2,7 @@
location __PATH__/static/ {
# Service static files by nginx
# e.g.: /var/www/$app/static
alias __PUBLIC_PATH__/static/;
alias __INSTALL_DIR__/public/static/;
expires 30d;
}

View file

@ -2,7 +2,7 @@
################################################################################
# Please do not modify this file, it will be reset at the next update.
# You can edit the file __FINALPATH__/local_settings.py and add/modify the settings you need.
# You can edit the file __INSTALL_DIR__/local_settings.py and add/modify the settings you need.
# The parameters you add in local_settings.py will overwrite these,
# but you can use the options and documentation in this file to find out what can be done.
@ -20,17 +20,17 @@ from djfritz_project.settings.base import * # noqa:F401,F403
from django_yunohost_integration.base_settings import LOGGING # noqa:F401 isort:skip
FINALPATH = __Path('__FINALPATH__') # /opt/yunohost/$app
assert FINALPATH.is_dir(), f'Directory not exists: {FINALPATH}'
INSTALL_DIR = __Path('__INSTALL_DIR__/app') # /var/www/$app/app
assert INSTALL_DIR.is_dir(), f'Directory not exists: {INSTALL_DIR}'
PUBLIC_PATH = __Path('__PUBLIC_PATH__') # /var/www/$app
PUBLIC_PATH = __Path('__INSTALL_DIR__/public') # /var/www/$app/public
assert PUBLIC_PATH.is_dir(), f'Directory not exists: {PUBLIC_PATH}'
LOG_FILE = __Path('__LOG_FILE__') # /var/log/$app/django_example_ynh.log
LOG_FILE = __Path('/var/log/__APP__/__APP__.log') # /var/log/$app/$app.log
assert LOG_FILE.is_file(), f'File not exists: {LOG_FILE}'
PATH_URL = '__PATH_URL__' # $YNH_APP_ARG_PATH
PATH_URL = PATH_URL.strip('/')
PATH = '__PATH__' # $YNH_APP_ARG_PATH
PATH = PATH.strip('/')
# -----------------------------------------------------------------------------
# config_panel.toml settings:
@ -48,7 +48,7 @@ DEFAULT_FROM_EMAIL = '__DEFAULT_FROM_EMAIL__'
# Function that will be called to finalize a user profile:
YNH_SETUP_USER = 'setup_user.setup_project_user'
SECRET_KEY = __get_or_create_secret(FINALPATH / 'secret.txt') # /opt/yunohost/$app/secret.txt
SECRET_KEY = __get_or_create_secret(INSTALL_DIR / 'secret.txt') # /opt/yunohost/$app/secret.txt
INSTALLED_APPS += [
'axes', # https://github.com/jazzband/django-axes
@ -136,9 +136,9 @@ CACHES = {
# _____________________________________________________________________________
# Static files (CSS, JavaScript, Images)
if PATH_URL:
STATIC_URL = f'/{PATH_URL}/static/'
MEDIA_URL = f'/{PATH_URL}/media/'
if PATH:
STATIC_URL = f'/{PATH}/static/'
MEDIA_URL = f'/{PATH}/media/'
else:
# Installed to domain root, without a path prefix?
STATIC_URL = '/static/'

View file

@ -5,9 +5,9 @@ After=redis.service postgresql.service
[Service]
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__/
WorkingDirectory=__INSTALL_DIR__/app
ExecStart=__FINALPATH__/venv/bin/gunicorn --config __FINALPATH__/gunicorn.conf.py wsgi
ExecStart=__INSTALL_DIR__/venv/bin/gunicorn --config __INSTALL_DIR__/app/gunicorn.conf.py wsgi
StandardOutput=syslog
StandardError=syslog

View file

@ -8,11 +8,11 @@ from django.conf import settings
from django.urls import include, path
if settings.PATH_URL:
# settings.PATH_URL is the $YNH_APP_ARG_PATH
# Prefix all urls with "PATH_URL":
if settings.PATH:
# settings.PATH is the $YNH_APP_ARG_PATH
# Prefix all urls with "PATH":
urlpatterns = [
path(f'{settings.PATH_URL}/', include('djfritz_project.urls')),
path(f'{settings.PATH}/', include('djfritz_project.urls')),
]
else:
# Installed to domain root, without a path prefix

View file

@ -14,13 +14,13 @@ services = ["__APP__"]
ask = "from email"
type = "email"
help = "Default email address to use for various automated emails."
bind = "default_from_email:__FINALPATH__/settings.py"
bind = "default_from_email:__INSTALL_DIR__/app/settings.py"
[main.config.admin_email]
ask = "ADMIN email"
type = "email"
help = "EMail address for error emails."
bind = "admin_email:__FINALPATH__/settings.py"
bind = "admin_email:__INSTALL_DIR__/app/settings.py"
[main.config.debug_enabled]
ask = "DEBUG mode"
@ -28,11 +28,11 @@ services = ["__APP__"]
yes = "1"
no = "0"
help = "Should be never enabled in production!"
bind = "debug_enabled:__FINALPATH__/settings.py"
bind = "debug_enabled:__INSTALL_DIR__/app/settings.py"
[main.config.log_level]
type = "string"
ask = "Log Level"
choices = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
default = "WARNING"
bind = "log_level:__FINALPATH__/settings.py"
bind = "log_level:__INSTALL_DIR__/app/settings.py"

View file

@ -1,39 +1,38 @@
## Settings and upgrades
Almost everything related to django-fritzconnection's configuration is handled in a `"../conf/settings.py"` file.
You can edit the file `/opt/yunohost/django-fritzconnection/local_settings.py` to enable or disable features.
You can edit the file `/var/www/django-fritzconnection/app/local_settings.py` to enable or disable features.
Test sending emails:
```bash
ssh admin@yourdomain.tld
root@yunohost:~# cd /opt/yunohost/django-fritzconnection/
root@yunohost:/opt/yunohost/django-fritzconnection# source venv/bin/activate
(venv) root@yunohost:/opt/yunohost/django-fritzconnection# ./manage.py sendtestemail --admins
root@yunohost:~# cd /var/www/django-fritzconnection/
root@yunohost:/var/www/django-fritzconnection# source venv/bin/activate
(venv) root@yunohost:/var/www/django-fritzconnection# ./app/manage.py sendtestemail --admins
```
Background info: Error mails are send to all [settings.ADMINS](https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-ADMINS). By default the YunoHost admin is inserted here.
To check current ADMINS run:
```bash
(venv) root@yunohost:/opt/yunohost/django-fritzconnection# ./manage.py sendtestemail --admins
(venv) root@yunohost:/var/www/django-fritzconnection# ./app/manage.py sendtestemail --admins
```
If you prefere to send error emails to a extrnal email address, just do something like this:
```bash
echo "ADMINS = (('Your Name', 'example@domain.tld'),)" >> /opt/yunohost/django-fritzconnection/local_settings.py
echo "ADMINS = (('Your Name', 'example@domain.tld'),)" >> /var/www/django-fritzconnection/app/local_settings.py
```
To check the effective settings, run this:
```bash
(venv) root@yunohost:/opt/yunohost/django-fritzconnection# ./manage.py diffsettings
(venv) root@yunohost:/var/www/django-fritzconnection# ./app/manage.py diffsettings
```
# Miscellaneous
## SSO authentication
[SSOwat](https://github.com/YunoHost/SSOwat) is fully supported via [django-yunohost-integration](https://github.com/YunoHost-Apps/django_yunohost_integration):
@ -43,17 +42,18 @@ To check the effective settings, run this:
* Login via SSO is fully supported
* User Email, First / Last name will be updated from SSO data
---
# Yunohost developer commands
To remove call e.g.:
```bash
sudo yunohost app remove django-fritzconnection
```
Backup / remove / restore cycle, e.g.:
```bash
yunohost backup create --apps django-fritzconnection
yunohost backup list
@ -65,6 +65,7 @@ yunohost backup restore 20201223-163434 --apps django-fritzconnection
```
Debug installation, e.g.:
```bash
root@yunohost:~# ls -la /var/www/django-fritzconnection/
total 18
@ -73,7 +74,7 @@ drwxr-xr-x 6 root root 6 Dec 8 08:36 ..
drwxr-xr-x 2 root root 2 Dec 8 08:36 media
drwxr-xr-x 7 root root 8 Dec 8 08:40 static
root@yunohost:~# ls -la /opt/yunohost/django-fritzconnection/
root@yunohost:~# ls -la /var/www/django-fritzconnection/
total 58
drwxr-xr-x 5 django-fritzconnection django-fritzconnection 11 Dec 8 08:39 .
drwxr-xr-x 3 root root 3 Dec 8 08:36 ..
@ -85,13 +86,13 @@ drwxr-xr-x 6 django-fritzconnection django-fritzconnection 6 Dec 8 08:37 ven
-rw-r--r-- 1 django-fritzconnection django-fritzconnection 115 Dec 8 08:39 wsgi.py
-rw-r--r-- 1 django-fritzconnection django-fritzconnection 4737 Dec 8 08:39 settings.py
root@yunohost:~# cd /opt/yunohost/django-fritzconnection/
root@yunohost:/opt/yunohost/django-fritzconnection# source venv/bin/activate
(venv) root@yunohost:/opt/yunohost/django-fritzconnection# ./manage.py check
root@yunohost:~# cd /var/www/django-fritzconnection/
root@yunohost:/var/www/django-fritzconnection# source venv/bin/activate
(venv) root@yunohost:/var/www/django-fritzconnection# ./manage.py check
django-fritzconnection v0.8.2 (Django v2.2.17)
DJANGO_SETTINGS_MODULE='settings'
PROJECT_PATH:/opt/yunohost/django-fritzconnection/venv/lib/python3.7/site-packages
BASE_PATH:/opt/yunohost/django-fritzconnection
PROJECT_PATH:/var/www/django-fritzconnection/venv/lib/python3.7/site-packages
BASE_PATH:/var/www/django-fritzconnection
System check identified no issues (0 silenced).
root@yunohost:~# tail -f /var/log/django-fritzconnection/django-fritzconnection.log
@ -108,6 +109,7 @@ it's possible to run the Django developer server with the settings
and urls made for YunoHost installation.
e.g.:
```bash
~$ git clone https://github.com/YunoHost-Apps/django-fritzconnection_ynh.git
~$ cd django-fritzconnection_ynh/

View file

@ -1,45 +0,0 @@
{
"name": "django-fritzconnection",
"id": "django-fritzconnection",
"packaging_format": 1,
"description": {
"en": "Web based FritzBox management using Python/Django."
},
"version": "0.2.0~ynh2",
"url": "https://github.com/YunoHost-Apps/django-fritzconnection_ynh",
"upstream": {
"license": "GPL-3.0",
"code": "https://github.com/jedie/django-fritzconnection"
},
"license": "GPL-3.0",
"maintainer": {
"name": "Jens Diemer",
"email": "django-fritzconnection_ynh@jensdiemer.de"
},
"previous_maintainers": [],
"requirements": {
"yunohost": ">= 4.4"
},
"multi_instance": true,
"services": [
"nginx", "postgresql", "redis"
],
"arguments": {
"install" : [
{
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/django-fritzconnection",
"default": "/django-fritzconnection"
},
{
"name": "admin",
"type": "user"
}
]
}
}

65
manifest.toml Normal file
View file

@ -0,0 +1,65 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "django-fritzconnection"
name = "django-fritzconnection"
description.en = "Web based FritzBox management using Python/Django."
version = "0.2.0~ynh3"
maintainers = ["Jens Diemer"]
[upstream]
license = "GPL-3.0"
code = "https://github.com/jedie/django-fritzconnection"
[integration]
yunohost = ">= 11.2"
architectures = "all"
multi_instance = true
ldap = true
sso = true
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
[install]
[install.domain]
type = "domain"
[install.path]
type = "path"
default = "/django-fritzconnection"
[install.init_main_permission]
type = "group"
default = "visitors"
[install.admin]
type = "user"
[resources]
[resources.system_user]
[resources.install_dir]
[resources.permissions]
main.url = "/"
[resources.ports]
[resources.apt]
packages = [
"build-essential",
"python3-dev",
"python3-pip",
"python3-venv",
"git",
"libpq-dev",
"postgresql",
"postgresql-contrib",
]
[resources.database]
type = "postgresql"

View file

@ -1,47 +1,39 @@
#!/bin/bash
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
app=$YNH_APP_INSTANCE_NAME
#=================================================
# ARGUMENTS FROM CONFIG PANEL
#=================================================
# 'debug_enabled' -> '__DEBUG_ENABLED__' -> settings.DEBUG
debug_enabled="0"
# 'log_level' -> '__LOG_LEVEL__' -> settings.LOG_LEVEL
log_level="WARNING"
# 'admin_email' -> '__ADMIN_EMAIL__' add in settings.ADMINS
admin_email="${admin}@${domain}"
# 'default_from_email' -> '__DEFAULT_FROM_EMAIL__' -> settings.DEFAULT_FROM_EMAIL
default_from_email="${app}@${domain}"
#=================================================
# SET CONSTANTS
#=================================================
public_path=/var/www/$app
final_path=/opt/yunohost/$app
log_path=/var/log/$app
log_file="${log_path}/${app}.log"
#=================================================
# COMMON VARIABLES
#=================================================
# dependencies used by the app
pkg_dependencies="build-essential python3-dev python3-pip python3-venv git libpq-dev postgresql postgresql-contrib"
log_path=/var/log/$app
log_file="${log_path}/${app}.log"
#=================================================
# PERSONAL HELPERS
#=================================================
_venv_install() {
ynh_exec_as "$app" python3 -m venv --upgrade "$install_dir/venv"
venvpy="$install_dir/venv/bin/python3"
ynh_exec_as "$app" "$venvpy" -m pip install --upgrade --no-cache-dir pip
ynh_exec_as "$app" "$venvpy" -m pip install setuptools wheel pyyaml
}
_build_app() {
ynh_exec_as "$app" "$venvpy" -m ensurepip
ynh_exec_as "$app" "$venvpy" -m pip install --upgrade wheel pip setuptools
ynh_exec_as "$app" "$venvpy" -m pip install --no-deps -r "$install_dir/app/requirements.txt"
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================
#=================================================
# Redis HELPERS
@ -60,10 +52,8 @@ ynh_redis_get_free_db() {
db=0
# default Debian setting is 15 databases
for i in $(seq 0 "$max")
do
if ! echo "$result" | grep -q "db$i"
then
for i in $(seq 0 "$max"); do
if ! echo "$result" | grep -q "db$i"; then
db=$i
break 1
fi
@ -84,4 +74,3 @@ ynh_redis_remove_db() {
local db=$1
redis-cli -n "$db" flushall
}

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -9,21 +7,6 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
public_path=$(ynh_app_setting_get --app="$app" --key=public_path)
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
domain=$(ynh_app_setting_get --app="$app" --key=domain)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
@ -33,35 +16,33 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
ynh_backup --src_path="$public_path"
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION
# SYSTEM CONFIGURATION
#=================================================
# Backup the nginx configuration
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
# Backup the systemd service unit
ynh_backup --src_path="/etc/systemd/system/$app.service"
# Backup the logrotate configuration
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/var/log/$app/"
#=================================================
# BACKUP THE PostgreSQL DATABASE
#=================================================
ynh_psql_dump_db --database="$db_name" > db.sql
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -1,88 +1,12 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
YNH_APP_ARG_DOMAIN=$YNH_APP_NEW_DOMAIN
YNH_APP_ARG_PATH=$YNH_APP_NEW_PATH
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=$YNH_APP_NEW_PATH
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
admin=$(ynh_app_setting_get --app="$app" --key=admin)
public_path=$(ynh_app_setting_get --app="$app" --key=public_path)
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
log_path=$(ynh_app_setting_get --app="$app" --key=log_path)
port=$(ynh_app_setting_get --app="$app" --key=port)
db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd)
db_name=$(ynh_sanitize_dbid --db_name="$app")
db_user=$db_name
redis_db=$(ynh_app_setting_get --app="$app" --key=redis_db)
#-------------------------------------------------
# config_panel.toml settings:
debug_enabled=$(ynh_app_setting_get --app="$app" --key=debug_enabled)
log_level=$(ynh_app_setting_get --app="$app" --key=log_level)
admin_email=$(ynh_app_setting_get --app="$app" --key=admin_email)
default_from_email=$(ynh_app_setting_get --app="$app" --key=default_from_email)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=40
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
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
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
@ -90,64 +14,26 @@ ynh_script_progression --message="Stopping systemd service '$app'..."
ynh_systemd_action --service_name="$app" --action="stop"
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating nginx web server configuration..."
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the nginx config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original nginx config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for nginx helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated nginx config
ynh_add_nginx_config "public_path" "port"
fi
# Change the domain for nginx
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
ynh_change_url_nginx_config
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# MODIFY SETTINGS
#=================================================
ynh_script_progression --message="Modify $app config file..."
domain=$YNH_APP_NEW_DOMAIN
path_url=$YNH_APP_NEW_PATH
ynh_add_config --template="settings.py" --destination="$install_dir/app/settings.py"
ynh_add_config --template="settings.py" --destination="$final_path/settings.py"
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting systemd service '$app'..." --weight=5
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
ynh_systemd_action --service_name="$app" --action="start"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..."
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT

View file

@ -8,53 +8,11 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
# INITIALIZE AND STORE SETTINGS
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..."
# Path for e.g. "static" files, served by nginx:
test ! -e "$public_path" || ynh_die --message="This path already contains a folder"
# Path for own config files, e.g.: Django's settings.py:
test ! -e "$final_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"
mkdir -p "$public_path/media" "$public_path/static"
mkdir -p "$final_path"
mkdir -p "$log_path"
touch "${log_file}"
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app="$app" --key=admin --value="$admin"
ynh_app_setting_set --app="$app" --key=public_path --value="$public_path"
ynh_app_setting_set --app="$app" --key=final_path --value="$final_path"
ynh_app_setting_set --app="$app" --key=log_path --value="$log_file"
ynh_app_setting_set --app="$app" --key=domain --value="$domain"
ynh_app_setting_set --app="$app" --key=path --value="$path_url"
# Find a free port
port=$(ynh_find_port --port=8000)
# Set port as application setting
# https://yunohost.org/en/contribute/packaging_apps/helpers
# https://github.com/YunoHost/yunohost/blob/dev/helpers/setting
ynh_app_setting_set --app="$app" --key=port --value="$port"
db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd)
admin_email="$(ynh_user_get_info "$admin" mail)"
ynh_app_setting_set --app="$app" --key=admin_email --value="$admin_email"
redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
@ -62,184 +20,86 @@ ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
#-------------------------------------------------
# config_panel.toml settings:
debug_enabled="0"
ynh_app_setting_set --app="$app" --key=debug_enabled --value="$debug_enabled"
log_level="WARNING"
ynh_app_setting_set --app="$app" --key=log_level --value="$log_level"
ynh_app_setting_set --app="$app" --key=admin_email --value="$admin_email"
default_from_email="${app}@${domain}"
ynh_app_setting_set --app="$app" --key=default_from_email --value="$default_from_email"
#=================================================
# STANDARD MODIFICATIONS
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing $app dependencies..." --weight=20
ynh_script_progression --message="Setting up source files..." --weight=1
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
mkdir -p "$install_dir/"{app,public/media,public/static}
#=================================================
# CREATE A PostgreSQL DATABASE
#=================================================
ynh_script_progression --message="Creating a PostgreSQL database..."
ynh_add_config --template="requirements.txt" --destination="$install_dir/app/requirements.txt"
db_name=$(ynh_sanitize_dbid --db_name="$app")
db_user=$db_name
ynh_app_setting_set --app="$app" --key=db_name --value="$db_name"
ynh_add_config --template="gunicorn.conf.py" --destination="$install_dir/app/gunicorn.conf.py"
ynh_psql_test_if_first_run
ynh_add_config --template="manage.py" --destination="$install_dir/app/manage.py"
chmod +x "$install_dir/app/manage.py"
# Initialize database and store postgres password for upgrade
ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name"
ynh_add_config --template="settings.py" --destination="$install_dir/app/settings.py"
ynh_add_config --template="setup_user.py" --destination="$install_dir/app/setup_user.py"
ynh_add_config --template="urls.py" --destination="$install_dir/app/urls.py"
ynh_add_config --template="wsgi.py" --destination="$install_dir/app/wsgi.py"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring nginx web server..."
touch "$install_dir/app/local_settings.py"
# Create a dedicated nginx config
# https://yunohost.org/en/contribute/packaging_apps/helpers
# https://github.com/YunoHost/yunohost/blob/dev/helpers/nginx
ynh_add_nginx_config "public_path" "port"
chown -R "$app:www-data" "$install_dir"
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user '$app'..."
# A home directory for venv and settings etc.
ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell
mkdir -p "/var/log/$app"
touch "/var/log/$app/$app.log"
chown -R "$app:$app" "/var/log/$app"
#=================================================
# PYTHON VIRTUALENV
#=================================================
ynh_script_progression --message="Create Python virtualenv..." --weight=5
ynh_script_progression --message="Installing $app..." --weight=10
# Always recreate everything fresh with current python version
ynh_secure_remove "${final_path}/venv"
_venv_install
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
python3 -m venv --without-pip "${final_path}/venv"
cp ../conf/requirements.txt "$final_path/requirements.txt"
chown -R "$app:" "$final_path"
#=================================================
# PIP INSTALLATION
#=================================================
ynh_script_progression --message="Install project via pip..." --weight=45
#run source in a 'sub shell'
(
set +o nounset
source "${final_path}/venv/bin/activate"
set -o nounset
ynh_exec_as $app $final_path/venv/bin/python3 -m ensurepip
ynh_exec_as $app $final_path/venv/bin/pip3 install --upgrade wheel pip setuptools
ynh_exec_as $app $final_path/venv/bin/pip3 install --no-deps -r "$final_path/requirements.txt"
)
#=================================================
# copy config files
# ================================================
ynh_script_progression --message="Create $app configuration files..."
ynh_add_config --template="gunicorn.conf.py" --destination="$final_path/gunicorn.conf.py"
ynh_add_config --template="manage.py" --destination="$final_path/manage.py"
chmod +x "$final_path/manage.py"
ynh_add_config --template="settings.py" --destination="$final_path/settings.py"
ynh_add_config --template="setup_user.py" --destination="$final_path/setup_user.py"
ynh_add_config --template="urls.py" --destination="$final_path/urls.py"
ynh_add_config --template="wsgi.py" --destination="$final_path/wsgi.py"
touch "$final_path/local_settings.py"
#=================================================
# MIGRATE / COLLECTSTATIC / CREATEADMIN
#=================================================
ynh_script_progression --message="migrate/collectstatic/createadmin..." --weight=10
cd "$final_path" || exit
_build_app
pushd "$install_dir/app"
# Just for debugging:
./manage.py diffsettings
ynh_exec_as "$app" "$venvpy" ./manage.py diffsettings
./manage.py migrate --no-input
./manage.py collectstatic --no-input
ynh_exec_as "$app" "$venvpy" ./manage.py migrate --no-input
ynh_exec_as "$app" "$venvpy" ./manage.py collectstatic --no-input
# Create/update Django superuser (set unusable password, because auth done via SSOwat):
./manage.py create_superuser --username="$admin" --email="$(ynh_user_get_info "$admin" mail)"
ynh_exec_as "$app" "$venvpy" ./manage.py create_superuser --username="$admin" --email="$(ynh_user_get_info "$admin" mail)"
# Check the configuration
# This may fail in some cases with errors, etc., but the app works and the user can fix issues later.
./manage.py check --deploy || true
ynh_exec_as "$app" "$venvpy" ./manage.py check --deploy || true
popd
#=================================================
# SETUP LOGROTATE
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring log rotation..."
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated NGINX config using the conf/nginx.conf template
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
yunohost service add "$app" --description="Django-fritzconnection server" --log="/var/log/$app/$app.log"
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate "$log_file"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
yunohost service add $app --log="${log_file}"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files
chown -R "$app:" "$log_path"
chown -R "$app:www-data" "$public_path"
chown -R "$app:" "$final_path"
chmod o-rwx "$log_path"
chmod o-rwx "$public_path"
chmod o-rwx "$final_path"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring systemd service '$app'..." --weight=5
# https://yunohost.org/en/contribute/packaging_apps/helpers
# https://github.com/YunoHost/yunohost/blob/dev/helpers/systemd
ynh_add_systemd_config --service="$app" --template="systemd.service"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring SSOwat..."
# Make app public if necessary or protect it
if [ $is_public -eq 1 ]
then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission "main" --add "visitors"
fi
#=================================================
# Start the app server via systemd
#=================================================
ynh_script_progression --message="Starting systemd service '$app'..." --weight=5
ynh_systemd_action --service_name="$app" --action="start"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..."
ynh_systemd_action --service_name="nginx" --action="reload"
# Start a systemd service
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -10,92 +8,22 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Loading installation settings..."
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
domain=$(ynh_app_setting_get --app="$app" --key=domain)
db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
db_user=$db_name
public_path=$(ynh_app_setting_get --app="$app" --key=public_path)
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
#=================================================
# Remove a service from the admin panel, added by `yunohost service add`
if yunohost service status "$app" >/dev/null 2>&1
then
ynh_script_progression --message="Removing $app service integration..."
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
yunohost service remove "$app"
fi
#=================================================
# STOP PYINVENTORY'S SERVICES
#=================================================
ynh_script_progression --message="Stopping and removing systemd service '$app'..." --weight=5
ynh_remove_systemd_config
ynh_remove_systemd_config --service="$app"
#=================================================
# REMOVE THE PostgreSQL DATABASE
#=================================================
ynh_script_progression --message="Removing the PostgreSQL database..."
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
##=================================================
## REMOVE REDIS DB
##=================================================
ynh_redis_remove_db
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=10
# Remove metapackage and its dependencies
ynh_exec_warn_less ynh_remove_app_dependencies
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely
ynh_secure_remove --file="$public_path"
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing nginx web server configuration..."
# Remove the dedicated nginx config
ynh_remove_nginx_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user
ynh_system_user_delete --username="$app"
ynh_secure_remove --file="/var/log/$app"
#=================================================
# END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -9,165 +7,62 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading settings..."
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
public_path=$(ynh_app_setting_get --app="$app" --key=public_path)
db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd)
domain=$(ynh_app_setting_get --app="$app" --key=domain)
path_url=$(ynh_app_setting_get --app="$app" --key=path)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..."
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring $app main directory..."
ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path"
ynh_restore_file --origin_path="$public_path"
ynh_restore_file --origin_path="$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
#=================================================
# RECREATE THE DEDICATED USER
# RESTORE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..."
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Restore permissions on app files
chown -R "$app:www-data" "$public_path"
chown -R "$app:" "$final_path"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=20
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
#=================================================
# PYTHON VIRTUALENV
# Maybe the backup contains a other Python version
# Maybe the backup contains another Python version
#=================================================
ynh_script_progression --message="Recreate Python virtualenv..." --weight=5
ynh_script_progression --message="Updating Python virtualenv and rebuilding $app..." --weight=5
# Always recreate everything fresh with current python version
ynh_secure_remove "${final_path}/venv"
ynh_secure_remove "$install_dir/venv"
_venv_install
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
python3 -m venv --without-pip "${final_path}/venv"
chown -R "$app:" "$final_path"
_build_app
#=================================================
# PIP INSTALLATION
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Install project via pip..." --weight=45
#run source in a 'sub shell'
(
set +o nounset
source "${final_path}/venv/bin/activate"
set -o nounset
ynh_exec_as $app $final_path/venv/bin/python3 -m ensurepip
ynh_exec_as $app $final_path/venv/bin/pip3 install --upgrade wheel pip setuptools
ynh_exec_as $app $final_path/venv/bin/pip3 install --no-deps -r "$final_path/requirements.txt"
)
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
#=================================================
# RESTORE THE PostgreSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=5
ynh_psql_test_if_first_run
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 SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
systemctl enable "$app.service" --quiet
yunohost service add "$app" --description="Django-fritzconnection server" --log="/var/log/$app/$app.log"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --log="${log_file}"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
mkdir -p "$log_path"
touch "${log_file}"
chown -R "$app:" "$log_path"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
# RESTORE VARIOUS FILES
#=================================================
# Set permissions to app files
chown -R "$app:" "$log_path"
chown -R "$app:www-data" "$public_path"
chown -R "$app:" "$final_path"
chmod o-rwx "$log_path"
chmod o-rwx "$public_path"
chmod o-rwx "$final_path"
ynh_restore_file --origin_path="/var/log/$app/"
#=================================================
# GENERIC FINALIZATION
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#=================================================
# START PYINVENTORY
#=================================================
ynh_script_progression --message="Starting systemd service '$app'..." --weight=5
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
ynh_systemd_action --service_name="$app" --action="start"
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..."
ynh_systemd_action --service_name="nginx" --action="reload"
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT

View file

@ -8,217 +8,113 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Loading installation settings..."
ynh_script_progression --message="Stopping $app's systemd service..." --weight=1
admin=$(ynh_app_setting_get --app="$app" --key=admin)
public_path=$(ynh_app_setting_get --app="$app" --key=public_path)
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
log_path=$(ynh_app_setting_get --app="$app" --key=log_path)
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
domain=$(ynh_app_setting_get --app="$app" --key=domain)
path_url=$(ynh_app_setting_get --app="$app" --key=path)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
port=$(ynh_app_setting_get --app="$app" --key=port)
db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd)
db_name=$(ynh_sanitize_dbid --db_name="$app")
db_user=$db_name
redis_db=$(ynh_app_setting_get --app="$app" --key=redis_db)
#-------------------------------------------------
# config_panel.toml settings:
debug_enabled=$(ynh_app_setting_get --app="$app" --key=debug_enabled)
if [ -z "$debug_enabled" ]; then
if [ -z "${debug_enabled:-}" ]; then
debug_enabled="0"
ynh_app_setting_set --app="$app" --key=debug_enabled --value="$debug_enabled"
fi
log_level=$(ynh_app_setting_get --app="$app" --key=log_level)
if [ -z "$log_level" ]; then
if [ -z "${log_level:-}" ]; then
log_level="WARNING"
ynh_app_setting_set --app="$app" --key=log_level --value="$log_level"
fi
admin_email=$(ynh_app_setting_get --app="$app" --key=admin_email)
if [ -z "$admin_email" ]; then
if [ -z "${admin_email:-}" ]; then
admin_email="${admin}@${domain}"
ynh_app_setting_set --app="$app" --key=admin_email --value="$admin_email"
fi
default_from_email=$(ynh_app_setting_get --app="$app" --key=default_from_email)
if [ -z "$default_from_email" ]; then
if [ -z "${default_from_email:-}" ]; then
default_from_email="${app}@${domain}"
ynh_app_setting_set --app="$app" --key=default_from_email --value="$default_from_email"
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up $app before upgrading (may take a while)..." --weight=40
# Backup the current version of the app
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
if [ -d "/opt/yunohost/$app" ]; then
if [ -d "$install_dir/app" ]; then
ynh_secure_remove --file="/opt/yunohost/$app"
else
mv "/opt/yunohost/$app" "$install_dir/app"
fi
fi
#=================================================
# STANDARD UPGRADE STEPS
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping systemd service '$app'..." --weight=5
ynh_script_progression --message="Upgrading source files..." --weight=1
ynh_systemd_action --service_name="$app" --action="stop"
mkdir -p "$install_dir/"{app,public/media,public/static}
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading nginx web server configuration..."
ynh_add_config --template="requirements.txt" --destination="$install_dir/app/requirements.txt"
# Create a dedicated nginx config
# https://yunohost.org/en/contribute/packaging_apps/helpers
# https://github.com/YunoHost/yunohost/blob/dev/helpers/nginx
ynh_add_nginx_config "public_path" "port"
ynh_add_config --template="gunicorn.conf.py" --destination="$install_dir/app/gunicorn.conf.py"
#=================================================
# SPECIFIC UPGRADE
#=================================================
# Update dependencies
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=20
ynh_add_config --template="manage.py" --destination="$install_dir/app/manage.py"
chmod +x "$install_dir/app/manage.py"
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
ynh_add_config --template="settings.py" --destination="$install_dir/app/settings.py"
ynh_add_config --template="setup_user.py" --destination="$install_dir/app/setup_user.py"
ynh_add_config --template="urls.py" --destination="$install_dir/app/urls.py"
ynh_add_config --template="wsgi.py" --destination="$install_dir/app/wsgi.py"
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
chown -R "$app:www-data" "$install_dir"
# Create a system user
ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell
chown -R "$app:www-data" "$install_dir"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring systemd service '$app'..." --weight=5
ynh_add_systemd_config --service="$app" --template="systemd.service"
mkdir -p "/var/log/$app"
touch "/var/log/$app/$app.log"
chown -R "$app:$app" "/var/log/$app"
#=================================================
# PYTHON VIRTUALENV
#=================================================
ynh_script_progression --message="Recreate Python virtualenv..." --weight=5
ynh_script_progression --message="Upgrading $app..." --weight=10
# Always recreate everything fresh with current python version
ynh_secure_remove "${final_path}/venv"
_venv_install
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
python3 -m venv --without-pip "${final_path}/venv"
cp ../conf/requirements.txt "$final_path/requirements.txt"
chown -R "$app:" "$final_path"
#=================================================
# PIP INSTALLATION
#=================================================
ynh_script_progression --message="Install project via pip..." --weight=45
#run source in a 'sub shell'
(
set +o nounset
source "${final_path}/venv/bin/activate"
set -o nounset
ynh_exec_as $app $final_path/venv/bin/python3 -m ensurepip
ynh_exec_as $app $final_path/venv/bin/pip3 install --upgrade wheel pip setuptools
ynh_exec_as $app $final_path/venv/bin/pip3 install --no-deps -r "$final_path/requirements.txt"
)
#=================================================
# copy config files
# ================================================
ynh_script_progression --message="Create project configuration files..."
ynh_add_config --template="gunicorn.conf.py" --destination="$final_path/gunicorn.conf.py"
ynh_add_config --template="manage.py" --destination="$final_path/manage.py"
chmod +x "$final_path/manage.py"
ynh_add_config --template="settings.py" --destination="$final_path/settings.py"
ynh_add_config --template="setup_user.py" --destination="$final_path/setup_user.py"
ynh_add_config --template="urls.py" --destination="$final_path/urls.py"
ynh_add_config --template="wsgi.py" --destination="$final_path/wsgi.py"
#=================================================
# MIGRATE PYINVENTORY
#=================================================
ynh_script_progression --message="migrate/collectstatic/createadmin..." --weight=10
cd "$final_path" || exit
_build_app
pushd "$install_dir/app"
# Just for debugging:
./manage.py diffsettings
ynh_exec_as "$app" "$venvpy" ./manage.py diffsettings
./manage.py migrate --no-input
./manage.py collectstatic --no-input
ynh_exec_as "$app" "$venvpy" ./manage.py migrate --no-input
ynh_exec_as "$app" "$venvpy" ./manage.py collectstatic --no-input
# Create/update Django superuser (set unusable password, because auth done via SSOwat):
./manage.py create_superuser --username="$admin" --email="$(ynh_user_get_info "$admin" mail)"
ynh_exec_as "$app" "$venvpy" ./manage.py create_superuser --username="$admin" --email="$(ynh_user_get_info "$admin" mail)"
# Check the configuration
# This may fail in some cases with errors, etc., but the app works and the user can fix issues later.
./manage.py check --deploy || true
ynh_exec_as "$app" "$venvpy" ./manage.py check --deploy || true
popd
#=================================================
# SETUP LOGROTATE
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..."
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
ynh_add_nginx_config
ynh_add_systemd_config
yunohost service add "$app" --description="Django-fritzconnection server" --log="/var/log/$app/$app.log"
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
yunohost service add $app --log="${log_file}"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files
chown -R "$app:" "$log_path"
chown -R "$app:www-data" "$public_path"
chown -R "$app:" "$final_path"
chmod o-rwx "$log_path"
chmod o-rwx "$public_path"
chmod o-rwx "$final_path"
#=================================================
# Start the app server via systemd
#=================================================
ynh_script_progression --message="Starting systemd service '$app'..." --weight=5
ynh_systemd_action --service_name="$app" --action="start"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..."
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT

11
tests.toml Normal file
View file

@ -0,0 +1,11 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
test_format = 1.0
[default]
# ------------
# Tests to run
# ------------
test_upgrade_from.4b0799f31dfbde3884f88aed8ebb5a42c4dc4a69.name = "Packaging v1"