mirror of
https://github.com/YunoHost-Apps/paperless-ngx_ynh.git
synced 2024-09-03 19:56:33 +02:00
convert to v2
This commit is contained in:
parent
dae998bbd3
commit
c95c56eb98
14 changed files with 340 additions and 256 deletions
|
@ -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=
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
88
manifest.toml
Normal file
88
manifest.toml
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
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~ynh1"
|
||||||
|
|
||||||
|
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 = "???" # FIXME: 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" # 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]
|
||||||
|
# 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 = false
|
||||||
|
|
||||||
|
[install.is_public_api]
|
||||||
|
ask.en = "Should Paperless-ngx be accessible for apps."
|
||||||
|
type = "boolean"
|
||||||
|
default = false
|
||||||
|
|
||||||
|
[resources]
|
||||||
|
[resources.sources]
|
||||||
|
|
||||||
|
[resources.sources.main]
|
||||||
|
# This will pre-fetch the asset which can then be deployed during the install/upgrade scripts with :
|
||||||
|
# ynh_setup_source --dest_dir="$install_dir"
|
||||||
|
# You can also define other assets than "main" and add --source_id="foobar" in the previous command
|
||||||
|
url = "https://github.com/paperless-ngx/paperless-ngx/releases/download/v1.14.5/paperless-ngx-v1.14.5.tar.xz"
|
||||||
|
sha256 = "355a5760cbc967c2bd6dcaf89f577aefd5acedd908361377976e04e17c95a8f9"
|
||||||
|
|
||||||
|
# These infos are used by https://github.com/YunoHost/apps/blob/master/tools/autoupdate_app_sources/autoupdate_app_sources.py
|
||||||
|
# to auto-update the previous asset urls and sha256sum + manifest version
|
||||||
|
# assuming the upstream's code repo is on github and relies on tags or releases
|
||||||
|
# See the 'sources' resource documentation for more details
|
||||||
|
|
||||||
|
autoupdate.strategy = "latest_github_release"
|
||||||
|
autoupdate.asset = "paperless-ngx-*.tar.xz"
|
||||||
|
|
||||||
|
[resources.system_user]
|
||||||
|
|
||||||
|
[resources.install_dir]
|
||||||
|
|
||||||
|
[resources.data_dir]
|
||||||
|
|
||||||
|
[resources.permissions]
|
||||||
|
main.url = "/"
|
||||||
|
|
||||||
|
[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"
|
||||||
|
|
||||||
|
[resources.database]
|
||||||
|
type = "postgresql"
|
|
@ -5,9 +5,9 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# dependencies used by the app
|
# 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 "
|
#REMOVEME? 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"
|
#REMOVEME? ocr_pkg_dependencies="unpaper ghostscript icc-profiles-free qpdf liblept5 libxml2 pngquant zlib1g tesseract-ocr"
|
||||||
raspberry_pkg_dependencies="libatlas-base-dev libxslt1-dev"
|
#REMOVEME? 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)
|
||||||
|
|
|
@ -14,24 +14,24 @@ source /usr/share/yunohost/helpers
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_clean_setup () {
|
#REMOVEME? ynh_clean_setup () {
|
||||||
### Remove this function if there's nothing to clean before calling the remove script.
|
### Remove this function if there's nothing to clean before calling the remove script.
|
||||||
true
|
# true
|
||||||
}
|
#}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Loading installation settings..."
|
#REMOVEME? ynh_print_info --message="Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
|
@ -47,13 +47,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
|
||||||
|
|
|
@ -13,61 +13,61 @@ source /usr/share/yunohost/helpers
|
||||||
# RETRIEVE ARGUMENTS
|
# RETRIEVE ARGUMENTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
old_domain=$YNH_APP_OLD_DOMAIN
|
#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN
|
||||||
old_path=$YNH_APP_OLD_PATH
|
#REMOVEME? old_path=$YNH_APP_OLD_PATH
|
||||||
|
|
||||||
new_domain=$YNH_APP_NEW_DOMAIN
|
#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN
|
||||||
new_path="/"
|
#REMOVEME? new_path="/"
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
# Needed for helper "ynh_add_nginx_config"
|
#REMOVEME? # Needed for helper "ynh_add_nginx_config"
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
#REMOVEME? db_user=$db_name
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||||
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
#REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
||||||
paperless_secret_key=$(ynh_app_setting_get --app=$app --key=paperless_secret_key)
|
#REMOVEME? paperless_secret_key=$(ynh_app_setting_get --app=$app --key=paperless_secret_key)
|
||||||
ocr_language=$(ynh_app_setting_get --app=$app --key=ocr_language)
|
#REMOVEME? ocr_language=$(ynh_app_setting_get --app=$app --key=ocr_language)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
|
#REMOVEME? 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
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
#REMOVEME? ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
#REMOVEME? ynh_clean_setup () {
|
||||||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
# 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"
|
#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
|
|
||||||
# Restore it if the upgrade fails
|
# Restore it if the upgrade fails
|
||||||
ynh_restore_upgradebackup
|
#REMOVEME? ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
change_domain=0
|
#REMOVEME? change_domain=0
|
||||||
if [ "$old_domain" != "$new_domain" ]
|
#REMOVEME? if [ "$old_domain" != "$new_domain" ]
|
||||||
then
|
then
|
||||||
change_domain=1
|
#REMOVEME? change_domain=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
change_path=0
|
#REMOVEME? change_path=0
|
||||||
if [ "$old_path" != "$new_path" ]
|
#REMOVEME? if [ "$old_path" != "$new_path" ]
|
||||||
then
|
then
|
||||||
change_path=1
|
#REMOVEME? change_path=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -87,28 +87,30 @@ 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
|
||||||
|
|
||||||
|
#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||||
|
|
||||||
# Change the path in the NGINX config file
|
# Change the path in the NGINX config file
|
||||||
if [ $change_path -eq 1 ]
|
if [ $change_path -eq 1 ]
|
||||||
then
|
then
|
||||||
# Make a backup of the original NGINX config file if modified
|
# Make a backup of the original NGINX config file if modified
|
||||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||||
# Set global variables for NGINX helper
|
# Set global variables for NGINX helper
|
||||||
domain="$old_domain"
|
#REMOVEME? domain="$old_domain"
|
||||||
path_url="$new_path"
|
#REMOVEME? path="$new_path"
|
||||||
# Create a dedicated NGINX config
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
#REMOVEME? ynh_add_nginx_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change the domain for NGINX
|
# Change the domain for NGINX
|
||||||
if [ $change_domain -eq 1 ]
|
if [ $change_domain -eq 1 ]
|
||||||
then
|
then
|
||||||
# Delete file checksum for the old conf file location
|
# Delete file checksum for the old conf file location
|
||||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||||
# Store file checksum for the new config file location
|
# Store file checksum for the new config file location
|
||||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -117,14 +119,14 @@ fi
|
||||||
# MODIFY A CONFIGURATION
|
# MODIFY A CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Modifying a configuration file..." --weight=1
|
ynh_script_progression --message="Modifying a configuration file..." --weight=1
|
||||||
|
#REMOVEME?
|
||||||
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
|
||||||
|
@ -141,9 +143,9 @@ ynh_systemd_action --service_name="$app-task-queue" --action="start" --log_path=
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
140
scripts/install
140
scripts/install
|
@ -14,97 +14,97 @@ source /usr/share/yunohost/helpers
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_clean_setup () {
|
#REMOVEME? ynh_clean_setup () {
|
||||||
### Remove this function if there's nothing to clean before calling the remove script.
|
### Remove this function if there's nothing to clean before calling the remove script.
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
#REMOVEME? domain=$YNH_APP_ARG_DOMAIN
|
||||||
path_url="/"
|
path="/"
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
is_public_api=$YNH_APP_ARG_IS_PUBLIC_API
|
#REMOVEME? is_public_api=$YNH_APP_ARG_IS_PUBLIC_API
|
||||||
admin=$YNH_APP_ARG_ADMIN
|
#REMOVEME? admin=$YNH_APP_ARG_ADMIN
|
||||||
admin_pw=$YNH_APP_ARG_ADMIN_PW
|
#REMOVEME? admin_pw=$YNH_APP_ARG_ADMIN_PW
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||||
|
|
||||||
final_path=/opt/yunohost/$app
|
#REMOVEME? install_dir=/opt/yunohost/$app
|
||||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
|
||||||
|
|
||||||
# Register (book) web path
|
# Register (book) web path
|
||||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Storing installation settings..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path
|
||||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# FIND AND OPEN A PORT
|
# FIND AND OPEN A PORT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Finding an available port..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Finding an available port..." --weight=1
|
||||||
|
|
||||||
# Find an available port
|
# Find an available port
|
||||||
port=$(ynh_find_port --port=8095)
|
#REMOVEME? port=$(ynh_find_port --port=8095)
|
||||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing dependencies..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1
|
||||||
|
|
||||||
# FIXME: Only on a Raspberry Pi (armv6 v7?)
|
# FIXME: Only on a Raspberry Pi (armv6 v7?)
|
||||||
# ynh_add_app_dependencies $raspberry_pkg_dependencies
|
# ynh_add_app_dependencies $raspberry_pkg_dependencies
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $ocr_pkg_dependencies
|
#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $ocr_pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring system user..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1
|
||||||
|
|
||||||
# Create a system user
|
# Create a system user
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A POSTGRESQL DATABASE
|
# CREATE A POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1
|
||||||
|
|
||||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||||
db_user=$db_name
|
#REMOVEME? db_user=$db_name
|
||||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||||
|
|
||||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
|
#REMOVEME? 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
|
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
|
||||||
|
|
||||||
ynh_setup_source --dest_dir="$final_path"
|
ynh_setup_source --dest_dir="$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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
@ -119,22 +119,22 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL PYTHON DEPENDENCIES
|
# INSTALL PYTHON DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing Python dependencies..."
|
#REMOVEME? 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
|
||||||
)
|
)
|
||||||
|
@ -145,16 +145,16 @@ popd
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Creating a data directory..." --weight=1
|
ynh_script_progression --message="Creating a data directory..." --weight=1
|
||||||
|
|
||||||
datadir=/home/yunohost.app/$app
|
#REMOVEME? data_dir=/home/yunohost.app/$app
|
||||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir
|
||||||
|
|
||||||
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:www-data "$datadir"
|
chown -R $app:www-data "$data_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE TEMP DIRECTORY
|
# REMOVE TEMP DIRECTORY
|
||||||
|
@ -176,20 +176,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 +199,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
|
||||||
|
@ -262,26 +262,26 @@ ynh_systemd_action --service_name="$app-task-queue" --action="start" --log_path=
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring permissions..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1
|
||||||
|
|
||||||
# Make app public if necessary
|
# Make app public if necessary
|
||||||
if [ $is_public -eq 1 ]
|
#REMOVEME? if [ $is_public -eq 1 ]
|
||||||
then
|
then
|
||||||
ynh_permission_update --permission="main" --add="visitors"
|
#REMOVEME? ynh_permission_update --permission="main" --add="visitors"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_permission_create --permission="api" --url="/api" --allowed="all_users" --auth_header="false" --label="$app API" --show_tile="false" --protected="false"
|
#REMOVEME? 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 ]
|
#REMOVEME? if [ $is_public_api -eq 1 ]
|
||||||
then
|
then
|
||||||
ynh_permission_update --permission="api" --add="visitors"
|
#REMOVEME? ynh_permission_update --permission="api" --add="visitors"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
|
@ -13,17 +13,17 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
#REMOVEME? db_user=$db_name
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
|
||||||
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
#REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
|
@ -63,18 +63,18 @@ ynh_remove_logrotate
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE POSTGRESQL DATABASE
|
# REMOVE THE POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1
|
||||||
|
|
||||||
# Remove a database if it exists, along with the associated user
|
# Remove a database if it exists, along with the associated user
|
||||||
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
#REMOVEME? ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing app main directory..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||||
|
|
||||||
# Remove the app directory securely
|
# Remove the app directory securely
|
||||||
ynh_secure_remove --file="$final_path"
|
#REMOVEME? ynh_secure_remove --file="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DATA DIR
|
# REMOVE DATA DIR
|
||||||
|
@ -84,7 +84,7 @@ ynh_secure_remove --file="$final_path"
|
||||||
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
|
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Removing app data directory..." --weight=1
|
ynh_script_progression --message="Removing app data directory..." --weight=1
|
||||||
ynh_secure_remove --file="$datadir"
|
#REMOVEME? ynh_secure_remove --file="$data_dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -98,11 +98,11 @@ 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
|
#REMOVEME? ynh_remove_app_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE FAIL2BAN CONFIGURATION
|
# REMOVE FAIL2BAN CONFIGURATION
|
||||||
|
@ -130,10 +130,10 @@ ynh_secure_remove --file="/var/log/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEDICATED USER
|
# REMOVE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||||
|
|
||||||
# Delete a system user
|
# Delete a system user
|
||||||
ynh_system_user_delete --username=$app
|
#REMOVEME? ynh_system_user_delete --username=$app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
|
@ -15,30 +15,30 @@ source /usr/share/yunohost/helpers
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_clean_setup () {
|
#REMOVEME? ynh_clean_setup () {
|
||||||
#### Remove this function if there's nothing to clean before calling the remove script.
|
#### Remove this function if there's nothing to clean before calling the remove script.
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
#REMOVEME? db_user=$db_name
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
|
||||||
paperless_secret_key=$(ynh_app_setting_get --app=$app --key=paperless_secret_key)
|
#REMOVEME? paperless_secret_key=$(ynh_app_setting_get --app=$app --key=paperless_secret_key)
|
||||||
ocr_language=$(ynh_app_setting_get --app=$app --key=ocr_language)
|
#REMOVEME? 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
|
||||||
|
@ -46,46 +46,46 @@ ynh_app_setting_set --app=$app --key=redis_db --value=$redis_db
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||||
|
|
||||||
test ! -d $final_path \
|
#REMOVEME? test ! -d $install_dir \
|
||||||
|| ynh_die --message="There is already a directory: $final_path "
|
|| ynh_die --message="There is already a directory: $install_dir "
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD RESTORATION STEPS
|
# STANDARD RESTORATION STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECREATE THE DEDICATED USER
|
# RECREATE THE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
# Create the dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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
|
# REMOVE TEMP DIRECTORY
|
||||||
|
@ -98,10 +98,10 @@ ynh_secure_remove --file="/tmp/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
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
|
||||||
|
@ -117,24 +117,24 @@ chown $app:$app "$final_path/paperless.conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
# REINSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
||||||
|
|
||||||
# Define and install dependencies
|
# Define and install dependencies
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $ocr_pkg_dependencies
|
#REMOVEME? 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..."
|
#REMOVEME? ynh_script_progression --message="Installing Python dependencies..."
|
||||||
|
|
||||||
pushd $final_path
|
pushd $install_dir
|
||||||
ynh_secure_remove --file="$final_path/venv"
|
#REMOVEME? 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
|
||||||
|
@ -149,10 +149,10 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE POSTGRESQL DATABASE
|
# RESTORE THE POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the PostgresSQL database..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Restoring the PostgresSQL database..." --weight=1
|
||||||
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
#REMOVEME? 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
|
#REMOVEME? 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
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -13,22 +13,22 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
#REMOVEME? db_user=$db_name
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||||
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
#REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
||||||
paperless_secret_key=$(ynh_app_setting_get --app=$app --key=paperless_secret_key)
|
#REMOVEME? paperless_secret_key=$(ynh_app_setting_get --app=$app --key=paperless_secret_key)
|
||||||
ocr_language=$(ynh_app_setting_get --app=$app --key=ocr_language)
|
#REMOVEME? ocr_language=$(ynh_app_setting_get --app=$app --key=ocr_language)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
|
@ -38,16 +38,16 @@ upgrade_type=$(ynh_check_app_version_changed)
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
|
||||||
|
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
#REMOVEME? ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
#REMOVEME? ynh_clean_setup () {
|
||||||
# Restore it if the upgrade fails
|
# Restore it if the upgrade fails
|
||||||
ynh_restore_upgradebackup
|
#REMOVEME? ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
|
@ -75,10 +75,10 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
||||||
|
|
||||||
# Create a dedicated user (if not existing)
|
# Create a dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
@ -88,19 +88,19 @@ 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
|
# UPGRADE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $ocr_pkg_dependencies
|
#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $ocr_pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
@ -115,23 +115,23 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL PYTHON DEPENDENCIES
|
# INSTALL PYTHON DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing Python dependencies..."
|
#REMOVEME? 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"
|
#REMOVEME? 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,10 +142,10 @@ 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
|
# REMOVE TEMP DIRECTORY
|
||||||
|
@ -158,10 +158,10 @@ ynh_secure_remove --file="/tmp/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
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
|
||||||
|
@ -221,9 +221,9 @@ ynh_systemd_action --service_name="$app-task-queue" --action="start" --log_path=
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
Loading…
Add table
Reference in a new issue