1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/paperless-ngx_ynh.git synced 2024-09-03 19:56:33 +02:00

Convert to packaging v2 (#23) (#24)

* convert to v2

* v2

* Use /opt/yunohost/__APP__

* v2

* v2

* Auto-update README

* fix

* v2

* v2

* v2

* v2

* Auto-update README

* v2

* typo

* set redis_db in restore script

* fix api permissions

* linter please

* Fix api access

---------

Co-authored-by: Tagada <36127788+Tagadda@users.noreply.github.com>
Co-authored-by: yunohost-bot <yunohost@yunohost.org>
This commit is contained in:
Fabian Wilkens 2023-06-16 21:08:15 +02:00 committed by GitHub
parent 8236072fe2
commit 3b6ea4d4e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 214 additions and 629 deletions

View file

@ -33,7 +33,7 @@ Paperless-ngx is a document management system that transforms your physical docu
* [More screenshots are available in the documentation](https://paperless-ngx.readthedocs.io/en/latest/screenshots.html). * [More screenshots are available in the documentation](https://paperless-ngx.readthedocs.io/en/latest/screenshots.html).
**Shipped version:** 1.14.5~ynh1 **Shipped version:** 1.14.5~ynh2
**Demo:** https://demo.paperless-ngx.com/ **Demo:** https://demo.paperless-ngx.com/
@ -41,22 +41,6 @@ Paperless-ngx is a document management system that transforms your physical docu
![Screenshot of Paperless-ngx](./doc/screenshots/documents-wchrome-dark.png) ![Screenshot of Paperless-ngx](./doc/screenshots/documents-wchrome-dark.png)
## Disclaimers / important information
* This app require a dedicated domain.
* There is no LDAP or SSO support.
* Paperless is performing OCR on documents and images. English is installed by default. More languages can be installed:
* Display a list of all Tesseract language packs `apt-cache search tesseract-ocr`
* Install additional language packs
* Example for french `sudo apt-get install tesseract-ocr-fra`
* Example for german `sudo apt-get install tesseract-ocr-deu`
* Modify config to add new languages
* Open the configuration tab under: https://my-domain.tld/yunohost/admin/#/apps/$app_id/
* You can combine multiple languages like this:
* One language: eng
* Two languages: eng+fra
## Documentation and resources ## Documentation and resources
* Official app website: <https://paperless-ngx.com> * Official app website: <https://paperless-ngx.com>

View file

@ -33,7 +33,7 @@ Paperless-ngx is a document management system that transforms your physical docu
* [More screenshots are available in the documentation](https://paperless-ngx.readthedocs.io/en/latest/screenshots.html). * [More screenshots are available in the documentation](https://paperless-ngx.readthedocs.io/en/latest/screenshots.html).
**Version incluse :** 1.14.5~ynh1 **Version incluse :** 1.14.5~ynh2
**Démo :** https://demo.paperless-ngx.com/ **Démo :** https://demo.paperless-ngx.com/
@ -41,22 +41,6 @@ Paperless-ngx is a document management system that transforms your physical docu
![Capture décran de Paperless-ngx](./doc/screenshots/documents-wchrome-dark.png) ![Capture décran de Paperless-ngx](./doc/screenshots/documents-wchrome-dark.png)
## Avertissements / informations importantes
* This app require a dedicated domain.
* There is no LDAP or SSO support.
* Paperless is performing OCR on documents and images. English is installed by default. More languages can be installed:
* Display a list of all Tesseract language packs `apt-cache search tesseract-ocr`
* Install additional language packs
* Example for french `sudo apt-get install tesseract-ocr-fra`
* Example for german `sudo apt-get install tesseract-ocr-deu`
* Modify config to add new languages
* Open the configuration tab under: https://my-domain.tld/yunohost/admin/#/apps/$app_id/
* You can combine multiple languages like this:
* One language: eng
* Two languages: eng+fra
## Documentations et ressources ## Documentations et ressources
* Site officiel de lapp : <https://paperless-ngx.com> * Site officiel de lapp : <https://paperless-ngx.com>

View file

@ -1,29 +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"
admin="john"
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
upgrade=0 from_commit=CommitHash
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&is_public=1&language=fr&admin=USER&password=pass&port=666&

View file

@ -1,6 +0,0 @@
SOURCE_URL=https://github.com/paperless-ngx/paperless-ngx/releases/download/v1.14.5/paperless-ngx-v1.14.5.tar.xz
SOURCE_SUM=355a5760cbc967c2bd6dcaf89f577aefd5acedd908361377976e04e17c95a8f9
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.xz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=

View file

@ -19,13 +19,13 @@ PAPERLESS_DBPASS=__DB_PWD__
# Paths and folders # Paths and folders
PAPERLESS_SCRATCH_DIR=/tmp/__APP__ PAPERLESS_SCRATCH_DIR=/tmp/__APP__
PAPERLESS_CONSUMPTION_DIR=__DATADIR__/consume PAPERLESS_CONSUMPTION_DIR=__DATA_DIR__/consume
PAPERLESS_DATA_DIR=__DATADIR__/data PAPERLESS_DATA_DIR=__DATA_DIR__/data
#PAPERLESS_TRASH_DIR= #PAPERLESS_TRASH_DIR=
PAPERLESS_MEDIA_ROOT=__DATADIR__/media PAPERLESS_MEDIA_ROOT=__DATA_DIR__/media
#PAPERLESS_STATICDIR=../static #PAPERLESS_STATICDIR=../static
#PAPERLESS_FILENAME_FORMAT= #PAPERLESS_FILENAME_FORMAT=
PAPERLESS_NLTK_DIR=__FINALPATH__/nltk_data PAPERLESS_NLTK_DIR=__INSTALL_DIR__/nltk_data
# Security and hosting # Security and hosting

View file

@ -6,8 +6,8 @@ Requires=redis.service
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/src/ WorkingDirectory=__INSTALL_DIR__/src/
ExecStart=__FINALPATH__/venv/bin/python3 manage.py document_consumer ExecStart=__INSTALL_DIR__/venv/bin/python3 manage.py document_consumer
StandardOutput=append:/var/log/__APP__/__APP__-consumer.log StandardOutput=append:/var/log/__APP__/__APP__-consumer.log
StandardError=inherit StandardError=inherit

View file

@ -6,8 +6,8 @@ Requires=redis.service
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/src/ WorkingDirectory=__INSTALL_DIR__/src/
ExecStart=__FINALPATH__/venv/bin/celery --app paperless beat --loglevel INFO ExecStart=__INSTALL_DIR__/venv/bin/celery --app paperless beat --loglevel INFO
StandardOutput=append:/var/log/__APP__/__APP__-scheduler.log StandardOutput=append:/var/log/__APP__/__APP__-scheduler.log
StandardError=inherit StandardError=inherit

View file

@ -6,8 +6,8 @@ Requires=redis.service
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/src/ WorkingDirectory=__INSTALL_DIR__/src/
ExecStart=__FINALPATH__/venv/bin/celery --app paperless worker --loglevel INFO ExecStart=__INSTALL_DIR__/venv/bin/celery --app paperless worker --loglevel INFO
StandardOutput=append:/var/log/__APP__/__APP__-task-queue.log StandardOutput=append:/var/log/__APP__/__APP__-task-queue.log
StandardError=inherit StandardError=inherit

View file

@ -8,8 +8,8 @@ Requires=redis.service
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/src/ WorkingDirectory=__INSTALL_DIR__/src/
ExecStart=__FINALPATH__/venv/bin/uvicorn --port=__PORT__ --log-level=warning paperless.asgi:application ExecStart=__INSTALL_DIR__/venv/bin/uvicorn --port=__PORT__ --log-level=warning paperless.asgi:application
StandardOutput=append:/var/log/__APP__/__APP__.log StandardOutput=append:/var/log/__APP__/__APP__.log
StandardError=inherit StandardError=inherit

View file

@ -13,7 +13,7 @@ name = "Paperless-ngx configuration"
type = "string" type = "string"
default = "eng" default = "eng"
help = """\ help = """\
Read this informations: https://github.com/YunoHost-Apps/paperless-ngx_ynh#disclaimers--important-information\n\ Read this informations: https://github.com/YunoHost-Apps/paperless-ngx_ynh/tree/master/doc/PRE_INSTALL.md\n\
If your language contains a '-' such as chi-sim, you must use chi_sim\n\ If your language contains a '-' such as chi-sim, you must use chi_sim\n\
Examples:\n- eng\n- eng+fra\n- eng+fra+chi_sim""" Examples:\n- eng\n- eng+fra\n- eng+fra+chi_sim"""
bind = "PAPERLESS_OCR_LANGUAGE:/opt/yunohost/__APP__/paperless.conf" bind = "PAPERLESS_OCR_LANGUAGE:__INSTALL_DIR__/paperless.conf"

View file

@ -7,7 +7,7 @@
* Example for french `sudo apt-get install tesseract-ocr-fra` * Example for french `sudo apt-get install tesseract-ocr-fra`
* Example for german `sudo apt-get install tesseract-ocr-deu` * Example for german `sudo apt-get install tesseract-ocr-deu`
* Modify config to add new languages * Modify config to add new languages
* Open the configuration tab under: https://my-domain.tld/yunohost/admin/#/apps/$app_id/ * Open the configuration
* You can combine multiple languages like this: * You can combine multiple languages like this:
* One language: eng * One language: eng
* Two languages: eng+fra * Two languages: eng+fra

View file

@ -1,64 +0,0 @@
{
"name": "Paperless-ngx",
"id": "paperless-ngx",
"packaging_format": 1,
"description": {
"en": "Scan, index and archive all your physical documents",
"fr": "Scannez, triez et archivez tous vos documents papiers"
},
"version": "1.14.5~ynh1",
"url": "https://paperless-ngx.com",
"upstream": {
"license": "GPL-3.0-or-later",
"website": "https://paperless-ngx.com",
"demo": "https://demo.paperless-ngx.com/",
"admindoc": "https://paperless-ngx.readthedocs.io/en/latest/index.html",
"userdoc": "https://paperless-ngx.readthedocs.io/en/latest/usage_overview.html",
"code": "https://github.com/paperless-ngx/paperless-ngx"
},
"license": "GPL-3.0-or-later",
"maintainer": {
"name": "Tagada"
},
"requirements": {
"yunohost": ">= 11.0.0"
},
"multi_instance": true,
"services": [
"nginx",
"redis",
"postgresql"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "admin",
"type": "user"
},
{
"name": "admin_pw",
"type": "password",
"ask": {
"en": "Please chose a password for admin user."
}
},
{
"name": "is_public",
"type": "boolean",
"default": false
},
{
"name": "is_public_api",
"type": "boolean",
"default": false,
"ask": {
"en": "Should Paperless-ngx be accessible for apps."
}
}
]
}
}

86
manifest.toml Normal file
View file

@ -0,0 +1,86 @@
packaging_format = 2
id = "paperless-ngx"
name = "Paperless-ngx"
description.en = "Scan, index and archive all your physical documents"
description.fr = "Scannez, triez et archivez tous vos documents papiers"
version = "1.14.5~ynh2"
maintainers = ["Tagada"]
[upstream]
license = "GPL-3.0-or-later"
website = "https://paperless-ngx.com"
demo = "https://demo.paperless-ngx.com/"
admindoc = "https://paperless-ngx.readthedocs.io/en/latest/index.html"
userdoc = "https://paperless-ngx.readthedocs.io/en/latest/usage_overview.html"
code = "https://github.com/paperless-ngx/paperless-ngx"
cpe = "???" # XXX: No CPE yet... check https://nvd.nist.gov/products/cpe/search/results?namingFormat=2.3&keyword=paperless
[integration]
yunohost = ">= 11.0.0"
architectures = "all"
multi_instance = true
ldap = false
sso = false
disk = "50M"
ram.build = "350M"
ram.runtime = "350M"
[install]
[install.domain]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "domain"
full_domain = true
[install.admin]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "user"
[install.admin_pw]
ask.en = "Please chose a password for admin user."
type = "password"
[install.init_main_permission]
type = "group"
default = "all_users"
[install.init_api_permission]
ask.en = "Paperless-ngx API access list"
type = "group"
default = "visitors"
[resources]
[resources.sources]
[resources.sources.main]
url = "https://github.com/paperless-ngx/paperless-ngx/releases/download/v1.14.5/paperless-ngx-v1.14.5.tar.xz"
sha256 = "355a5760cbc967c2bd6dcaf89f577aefd5acedd908361377976e04e17c95a8f9"
autoupdate.strategy = "latest_github_release"
autoupdate.asset = "paperless-ngx-*.tar.xz"
[resources.system_user]
[resources.install_dir]
[resources.data_dir]
subdirs = ["consume", "data", "media"]
[resources.permissions]
main.url = "/"
main.auth_header = false
api.url = "/api/"
api.show_tile = false
api.auth_header = false
[resources.ports]
main.default = 8095
[resources.apt]
packages = "python3, python3-pip, python3-dev, python3-venv, default-libmysqlclient-dev, fonts-liberation, imagemagick, gnupg, libpq-dev, libmagic-dev, mime-support, libzbar0, poppler-utils, postgresql, postgresql-contrib, unpaper, ghostscript, icc-profiles-free, qpdf, liblept5, libxml2, pngquant, zlib1g, tesseract-ocr, libatlas-base-dev, libxslt1-dev, redis-server"
[resources.database]
type = "postgresql"

View file

@ -4,11 +4,6 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
# dependencies used by the app
pkg_dependencies="python3 python3-pip python3-dev python3-venv default-libmysqlclient-dev fonts-liberation imagemagick gnupg libpq-dev libmagic-dev mime-support libzbar0 poppler-utils postgresql postgresql-contrib "
ocr_pkg_dependencies="unpaper ghostscript icc-profiles-free qpdf liblept5 libxml2 pngquant zlib1g tesseract-ocr"
raspberry_pkg_dependencies="libatlas-base-dev libxslt1-dev"
timezone=$(cat /etc/timezone) timezone=$(cat /etc/timezone)
main_domain=$(cat /etc/yunohost/current_host) main_domain=$(cat /etc/yunohost/current_host)

View file

@ -10,29 +10,6 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================
@ -47,13 +24,13 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP THE DATA DIR # BACKUP THE DATA DIR
#================================================= #=================================================
ynh_backup --src_path="$datadir" --is_big ynh_backup --src_path="$data_dir" --is_big
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION

View file

@ -9,67 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers 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
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
port=$(ynh_app_setting_get --app=$app --key=port)
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)
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
paperless_secret_key=$(ynh_app_setting_get --app=$app --key=paperless_secret_key)
ocr_language=$(ynh_app_setting_get --app=$app --key=ocr_language)
#=================================================
# 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
# 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 # STANDARD MODIFICATIONS
#================================================= #=================================================
@ -87,29 +26,7 @@ ynh_systemd_action --service_name="$app-task-queue" --action="stop" --log_path="
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf ynh_change_url_nginx_config
# 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
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
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
@ -119,12 +36,12 @@ fi
ynh_script_progression --message="Modifying a configuration file..." --weight=1 ynh_script_progression --message="Modifying a configuration file..." --weight=1
domain="$new_domain" domain="$new_domain"
path_url="$new_path" path="$new_path"
ynh_add_config --template="paperless.conf.example" --destination="$final_path/paperless.conf" ynh_add_config --template="paperless.conf.example" --destination="$install_dir/paperless.conf"
chmod 400 "$final_path/paperless.conf" chmod 400 "$install_dir/paperless.conf"
chown $app:$app "$final_path/paperless.conf" chown $app:$app "$install_dir/paperless.conf"
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION
@ -138,13 +55,6 @@ ynh_systemd_action --service_name="$app-consumer" --action="start" --log_path="/
ynh_systemd_action --service_name="$app-scheduler" --action="start" --log_path="/var/log/$app/$app-scheduler.log" ynh_systemd_action --service_name="$app-scheduler" --action="start" --log_path="/var/log/$app/$app-scheduler.log"
ynh_systemd_action --service_name="$app-task-queue" --action="start" --log_path="/var/log/$app/$app-task-queue.log" ynh_systemd_action --service_name="$app-task-queue" --action="start" --log_path="/var/log/$app/$app-task-queue.log"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -10,101 +10,16 @@ source _common.sh
source ynh_redis source ynh_redis
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
is_public=$YNH_APP_ARG_IS_PUBLIC
is_public_api=$YNH_APP_ARG_IS_PUBLIC_API
admin=$YNH_APP_ARG_ADMIN
admin_pw=$YNH_APP_ARG_ADMIN_PW
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/opt/yunohost/$app
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
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=1
# Find an available port
port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=1
# FIXME: Only on a Raspberry Pi (armv6 v7?)
# ynh_add_app_dependencies $raspberry_pkg_dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $ocr_pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# CREATE A POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1
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_psql_setup_db --db_user=$db_user --db_name=$db_name
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=1 ynh_script_progression --message="Setting up source files..." --weight=1
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_setup_source --dest_dir="$install_dir"
ynh_setup_source --dest_dir="$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chmod 750 "$final_path" chown -R $app:$app "$install_dir"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -121,20 +36,20 @@ ynh_add_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Installing Python dependencies..." ynh_script_progression --message="Installing Python dependencies..."
pushd $final_path pushd $install_dir
python3 -m venv venv python3 -m venv venv
chown -R "$app:" "$final_path" chown -R "$app:" "$install_dir"
( (
source "$final_path/venv/bin/activate" source "$install_dir/venv/bin/activate"
ynh_exec_as $app $final_path/venv/bin/pip3 install --upgrade pip setuptools wheel ynh_exec_as $app $install_dir/venv/bin/pip3 install --upgrade pip setuptools wheel
ynh_exec_as $app $final_path/venv/bin/pip3 install -r "$final_path/requirements.txt" ynh_exec_as $app $install_dir/venv/bin/pip3 install -r "$install_dir/requirements.txt"
# Installing NLTK data # Installing NLTK data
mkdir -p "$final_path/nltk_data" mkdir -p "$install_dir/nltk_data"
chown -R "$app:" "$final_path/nltk_data" chown -R "$app:" "$install_dir/nltk_data"
ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/python3 -m nltk.downloader -d "$final_path/nltk_data" snowball_data ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/python3 -m nltk.downloader -d "$install_dir/nltk_data" snowball_data
ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/python3 -m nltk.downloader -d "$final_path/nltk_data" stopwords ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/python3 -m nltk.downloader -d "$install_dir/nltk_data" stopwords
ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/python3 -m nltk.downloader -d "$final_path/nltk_data" punkt ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/python3 -m nltk.downloader -d "$install_dir/nltk_data" punkt
deactivate deactivate
) )
@ -143,24 +58,11 @@ popd
#================================================= #=================================================
# CREATE DATA DIRECTORY # CREATE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Creating a data directory..." --weight=1 ynh_script_progression --message="Setting permissions for the data directory..." --weight=1
datadir=/home/yunohost.app/$app chmod 750 "$data_dir"
ynh_app_setting_set --app=$app --key=datadir --value=$datadir chmod -R o-rwx "$data_dir"
chown -R $app:$app "$data_dir"
mkdir -p "$datadir/consume"
mkdir -p "$datadir/data"
mkdir -p "$datadir/media"
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
#=================================================
# REMOVE TEMP DIRECTORY
#=================================================
ynh_script_progression --message="Cleanup temp directory..." --weight=1
ynh_secure_remove --file="/tmp/$app"
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
@ -176,20 +78,20 @@ ynh_app_setting_set --app=$app --key=paperless_secret_key --value=$paperless_se
ocr_language="eng" ocr_language="eng"
ynh_app_setting_set --app=$app --key=ocr_language --value=$ocr_language ynh_app_setting_set --app=$app --key=ocr_language --value=$ocr_language
ynh_add_config --template="paperless.conf.example" --destination="$final_path/paperless.conf" ynh_add_config --template="paperless.conf.example" --destination="$install_dir/paperless.conf"
chmod 400 "$final_path/paperless.conf" chmod 400 "$install_dir/paperless.conf"
chown $app:$app "$final_path/paperless.conf" chown $app:$app "$install_dir/paperless.conf"
#================================================= #=================================================
# SETUP THE DATABASE # SETUP THE DATABASE
#================================================= #=================================================
ynh_script_progression --message="Setting up the database..." --weight=1 ynh_script_progression --message="Setting up the database..." --weight=1
pushd "$final_path/src" pushd "$install_dir/src"
( (
source "$final_path/venv/bin/activate" source "$install_dir/venv/bin/activate"
ynh_exec_as $app $final_path/venv/bin/python manage.py migrate ynh_exec_as $app $install_dir/venv/bin/python manage.py migrate
deactivate deactivate
) )
popd popd
@ -199,11 +101,11 @@ popd
#================================================= #=================================================
ynh_script_progression --message="Creating the admin user..." --weight=1 ynh_script_progression --message="Creating the admin user..." --weight=1
pushd "$final_path/src" pushd "$install_dir/src"
( (
source "$final_path/venv/bin/activate" source "$install_dir/venv/bin/activate"
email=$(ynh_user_get_info $admin 'mail') email=$(ynh_user_get_info $admin 'mail')
ynh_exec_as $app env "DJANGO_SUPERUSER_PASSWORD=$admin_pw" $final_path/venv/bin/python3 manage.py createsuperuser --noinput --username "$admin" --email "$email" ynh_exec_as $app env "DJANGO_SUPERUSER_PASSWORD=$admin_pw" $install_dir/venv/bin/python3 manage.py createsuperuser --noinput --username "$admin" --email "$email"
deactivate deactivate
) )
popd popd
@ -259,30 +161,6 @@ ynh_systemd_action --service_name="$app-task-queue" --action="start" --log_path=
# FIXME fail2ban # FIXME fail2ban
# ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-access.log" --failregex="<HOST>.* \"POST /api/v1/token/ HTTP/1.1\" 400 68.*$" --max_retry=5 # ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-access.log" --failregex="<HOST>.* \"POST /api/v1/token/ HTTP/1.1\" 400 68.*$" --max_retry=5
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary
if [ $is_public -eq 1 ]
then
ynh_permission_update --permission="main" --add="visitors"
fi
ynh_permission_create --permission="api" --url="/api" --allowed="all_users" --auth_header="false" --label="$app API" --show_tile="false" --protected="false"
if [ $is_public_api -eq 1 ]
then
ynh_permission_update --permission="api" --add="visitors"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -10,21 +10,6 @@ source _common.sh
source ynh_redis source ynh_redis
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
@ -60,33 +45,6 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight=
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_remove_logrotate
#=================================================
# REMOVE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
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..." --weight=1
ynh_secure_remove --file="$datadir"
fi
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
@ -98,11 +56,10 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1 #REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_redis_remove_db "$redis_db" ynh_redis_remove_db "$redis_db"
ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE FAIL2BAN CONFIGURATION # REMOVE FAIL2BAN CONFIGURATION
@ -119,21 +76,14 @@ ynh_remove_app_dependencies
#================================================= #=================================================
ynh_script_progression --message="Removing various files..." --weight=1 ynh_script_progression --message="Removing various files..." --weight=1
# Remove temp directory securely
ynh_secure_remove --file="/tmp/$app"
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# REMOVE DEDICATED USER # ...
#================================================= #=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user
ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -11,97 +11,53 @@ source ../settings/scripts/_common.sh
source ../settings/scripts/ynh_redis source ../settings/scripts/ynh_redis
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 ynh_script_progression --message="Loading additionnal settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_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)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
paperless_secret_key=$(ynh_app_setting_get --app=$app --key=paperless_secret_key)
ocr_language=$(ynh_app_setting_get --app=$app --key=ocr_language)
redis_db=$(ynh_redis_get_free_db) redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app=$app --key=redis_db --value=$redis_db ynh_app_setting_set --app=$app --key=redis_db --value=$redis_db
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#================================================= #=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app:$app "$final_path" chown -R $app:$app "$install_dir"
#================================================= #=================================================
# RESTORE THE DATA DIRECTORY # RESTORE THE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1 ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_restore_file --origin_path="$datadir" --not_mandatory ynh_restore_file --origin_path="$data_dir" --not_mandatory
mkdir -p "$datadir/consume" mkdir -p "$data_dir/consume"
mkdir -p "$datadir/data" mkdir -p "$data_dir/data"
mkdir -p "$datadir/media" mkdir -p "$data_dir/media"
chmod 750 "$datadir" chmod 750 "$data_dir"
chmod -R o-rwx "$datadir" chmod -R o-rwx "$data_dir"
chown -R $app:$app "$datadir" chown -R $app:$app "$data_dir"
#=================================================
# REMOVE TEMP DIRECTORY
#=================================================
ynh_script_progression --message="Cleanup temp directory..." --weight=1
ynh_secure_remove --file="/tmp/$app"
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="../settings/conf/paperless.conf.example" --destination="$final_path/paperless.conf" ynh_add_config --template="../settings/conf/paperless.conf.example" --destination="$install_dir/paperless.conf"
chmod 400 "$final_path/paperless.conf" chmod 400 "$install_dir/paperless.conf"
chown $app:$app "$final_path/paperless.conf" chown $app:$app "$install_dir/paperless.conf"
#================================================= #=================================================
# RESTORE FAIL2BAN CONFIGURATION # RESTORE FAIL2BAN CONFIGURATION
@ -115,26 +71,20 @@ chown $app:$app "$final_path/paperless.conf"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $ocr_pkg_dependencies
#================================================= #=================================================
# INSTALL PYTHON DEPENDENCIES # INSTALL PYTHON DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing Python dependencies..." ynh_script_progression --message="Installing Python dependencies..."
pushd $final_path pushd $install_dir
ynh_secure_remove --file="$final_path/venv" ynh_secure_remove --file="$install_dir/venv"
python3 -m venv venv python3 -m venv venv
chown -R "$app:" "$final_path" chown -R "$app:" "$install_dir"
( (
source "$final_path/venv/bin/activate" source "$install_dir/venv/bin/activate"
ynh_exec_as $app $final_path/venv/bin/pip3 install --upgrade pip setuptools wheel ynh_exec_as $app $install_dir/venv/bin/pip3 install --upgrade pip setuptools wheel
ynh_exec_as $app $final_path/venv/bin/pip3 install -r "$final_path/requirements.txt" ynh_exec_as $app $install_dir/venv/bin/pip3 install -r "$install_dir/requirements.txt"
deactivate deactivate
) )
popd popd
@ -151,8 +101,6 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
ynh_script_progression --message="Restoring the PostgresSQL database..." --weight=1 ynh_script_progression --message="Restoring the PostgresSQL database..." --weight=1
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 ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#================================================= #=================================================

View file

@ -10,45 +10,11 @@ source _common.sh
source ynh_redis source ynh_redis
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
port=$(ynh_app_setting_get --app=$app --key=port)
admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
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)
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
paperless_secret_key=$(ynh_app_setting_get --app=$app --key=paperless_secret_key)
ocr_language=$(ynh_app_setting_get --app=$app --key=ocr_language)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# 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
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -72,13 +38,12 @@ if [ -z "$ocr_language" ]; then
ynh_app_setting_set --app=$app --key=ocr_language --value=$ocr_language ynh_app_setting_set --app=$app --key=ocr_language --value=$ocr_language
fi fi
#================================================= if ynh_compare_current_package_version -c le -v "1.14.5~ynh1"
# CREATE DEDICATED USER then
#================================================= # When upgrading from older version when install_dir was in /var/www,
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 # we need to rebuild the venv entierly
ynh_secure_remove --file="$install_dir/venv"
# Create a dedicated user (if not existing) fi
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -88,19 +53,12 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_script_progression --message="Upgrading source files..." --weight=1
ynh_setup_source --dest_dir="$final_path" --keep="paperless.conf" ynh_setup_source --dest_dir="$install_dir" --keep="paperless.conf"
fi fi
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app:$app "$final_path" chown -R $app:$app "$install_dir"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $ocr_pkg_dependencies
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -117,21 +75,21 @@ ynh_add_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Installing Python dependencies..." ynh_script_progression --message="Installing Python dependencies..."
pushd $final_path pushd $install_dir
python3 -m venv venv python3 -m venv venv
chown -R "$app:" "$final_path" chown -R "$app:" "$install_dir"
( (
source "$final_path/venv/bin/activate" source "$install_dir/venv/bin/activate"
ynh_exec_as $app $final_path/venv/bin/pip3 install --upgrade pip setuptools wheel ynh_exec_as $app $install_dir/venv/bin/pip3 install --upgrade pip setuptools wheel
ynh_exec_as $app $final_path/venv/bin/pip3 install -r "$final_path/requirements.txt" ynh_exec_as $app $install_dir/venv/bin/pip3 install -r "$install_dir/requirements.txt"
# Installing NLTK data # Installing NLTK data
ynh_secure_remove --file="$final_path/nltk_data" ynh_secure_remove --file="$install_dir/nltk_data"
mkdir -p "$final_path/nltk_data" mkdir -p "$install_dir/nltk_data"
chown -R "$app:" "$final_path/nltk_data" chown -R "$app:" "$install_dir/nltk_data"
ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/python3 -m nltk.downloader -d "$final_path/nltk_data" snowball_data ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/python3 -m nltk.downloader -d "$install_dir/nltk_data" snowball_data
ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/python3 -m nltk.downloader -d "$final_path/nltk_data" stopwords ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/python3 -m nltk.downloader -d "$install_dir/nltk_data" stopwords
ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/python3 -m nltk.downloader -d "$final_path/nltk_data" punkt ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/python3 -m nltk.downloader -d "$install_dir/nltk_data" punkt
deactivate deactivate
) )
@ -142,26 +100,20 @@ popd
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1 ynh_script_progression --message="Updating a configuration file..." --weight=1
ynh_add_config --template="paperless.conf.example" --destination="$final_path/paperless.conf" ynh_add_config --template="paperless.conf.example" --destination="$install_dir/paperless.conf"
chmod 400 "$final_path/paperless.conf" chmod 400 "$install_dir/paperless.conf"
chown $app:$app "$final_path/paperless.conf" chown $app:$app "$install_dir/paperless.conf"
#=================================================
# REMOVE TEMP DIRECTORY
#=================================================
ynh_script_progression --message="Cleanup temp directory..." --weight=1
ynh_secure_remove --file="/tmp/$app"
#================================================= #=================================================
# SETUP THE DATABASE # SETUP THE DATABASE
#================================================= #=================================================
ynh_script_progression --message="Setting up the database..." --weight=1 ynh_script_progression --message="Setting up the database..." --weight=1
pushd "$final_path/src" pushd "$install_dir/src"
( (
source "$final_path/venv/bin/activate" source "$install_dir/venv/bin/activate"
ynh_exec_as $app $final_path/venv/bin/python manage.py migrate ynh_exec_as $app $install_dir/venv/bin/python manage.py migrate
deactivate deactivate
) )
popd popd
@ -218,13 +170,6 @@ ynh_systemd_action --service_name="$app-task-queue" --action="start" --log_path=
# Create a dedicated Fail2Ban config # Create a dedicated Fail2Ban config
#ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" #ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

27
tests.toml Normal file
View file

@ -0,0 +1,27 @@
test_format = 1.0
[default]
# ------------
# Tests to run
# ------------
exclude = ["install.subdir"]
# -------------------------------
# Default args to use for install
# -------------------------------
# By default, the CI will automagically fill the 'standard' args
# such as domain, path, admin, is_public and password with relevant values
# and also install args with a "default" provided in the manifest..
# It should only make sense to declare custom args here for args with no default values
args.admin_pw = "acab"
args.init_main_permission = "all_users"
# -------------------------------
# Commits to test upgrade from
# -------------------------------
test_upgrade_from.8236072.name = "Upgrade from 1.14.5~ynh1 (v1)"