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

Manifest v2

This commit is contained in:
Salamandar 2024-03-15 23:27:46 +01:00
parent f8040aa656
commit 7dfe48267c
28 changed files with 344 additions and 587 deletions

View file

@ -1,22 +0,0 @@
;; Test complet
; Manifest
domain="domain.tld"
path="/path"
is_public=1
admin="john"
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
#upgrade=1 from_commit=CommitHash
backup_restore=1
multi_instance=0
port_already_use=0
change_url=1
;;; Options
Email=
Notification=none

View file

@ -2,7 +2,7 @@
[alembic] [alembic]
# path to migration scripts # path to migration scripts
script_location = __FINALPATH__/alembic script_location = __INSTALL_DIR__/alembic
# template used to generate migration files # template used to generate migration files
# file_template = %%(rev)s_%%(slug)s # file_template = %%(rev)s_%%(slug)s

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://releases.pagure.org/pagure/pagure-5.13.3.tar.gz
SOURCE_SUM=f684d8193d4c4cf637b465c80cbfece6eb2b1646df3ec4f993adf75ea78d5a1a
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,12 +1,12 @@
location __PATH__/ { location __PATH__/ {
#Source: https://docs.weblate.org/en/latest/admin/install.html#sample-configuration-for-nginx-and-uwsgi #Source: https://docs.weblate.org/en/latest/admin/install.html#sample-configuration-for-nginx-and-uwsgi
# Path to source # Path to source
alias __FINALPATH__/ ; alias __INSTALL_DIR__/ ;
include uwsgi_params; include uwsgi_params;
# Needed for long running operations in admin interface # Needed for long running operations in admin interface
uwsgi_read_timeout 3600; uwsgi_read_timeout 3600;
uwsgi_pass unix://__FINALPATH__/__NAME__.socket; uwsgi_pass unix://__INSTALL_DIR__/__NAME__.socket;
# Include SSOWAT user panel. # Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc; include conf.d/yunohost_panel.conf.inc;

View file

@ -75,12 +75,12 @@ GIT_URL_SSH = 'ssh://git@__DOMAIN____PATH__'
GIT_URL_GIT = 'git://__DOMAIN____PATH__' GIT_URL_GIT = 'git://__DOMAIN____PATH__'
### Folder containing to the git repos ### Folder containing to the git repos
GIT_FOLDER = '__DATADIR__/repos' GIT_FOLDER = '__DATA_DIR__/repos'
REPOSPANNER_PSEUDO_FOLDER = '__DATADIR__/pseudo' REPOSPANNER_PSEUDO_FOLDER = '__DATA_DIR__/pseudo'
### Folder containing the clones for the remote pull-requests ### Folder containing the clones for the remote pull-requests
REMOTE_GIT_FOLDER = '__DATADIR__/remotes' REMOTE_GIT_FOLDER = '__DATA_DIR__/remotes'
### Whether to enable scanning for viruses in attachments ### Whether to enable scanning for viruses in attachments
VIRUS_SCAN_ATTACHMENTS = False VIRUS_SCAN_ATTACHMENTS = False

View file

@ -9,7 +9,7 @@ import pkg_resources
# Set the environment variable pointing to the configuration file # Set the environment variable pointing to the configuration file
import os import os
os.environ['PAGURE_CONFIG'] = '__FINALPATH__/pagure.cfg' os.environ['PAGURE_CONFIG'] = '__INSTALL_DIR__/pagure.cfg'
# Set the environment variable if the tmp folder needs to be moved # Set the environment variable if the tmp folder needs to be moved
# Might be necessary to work around bug in libgit2: # Might be necessary to work around bug in libgit2:
@ -20,7 +20,7 @@ os.environ['TEMP'] = '/var/tmp/'
# The following is only needed if you did not install pagure # The following is only needed if you did not install pagure
# as a python module (for example if you run it from a git clone). # as a python module (for example if you run it from a git clone).
#import sys #import sys
#sys.path.insert(0, '__FINALPATH__/') #sys.path.insert(0, '__INSTALL_DIR__/')
# The most important line to make the wsgi working # The most important line to make the wsgi working

View file

@ -7,9 +7,9 @@ Documentation=https://pagure.io/pagure
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
ExecStart=__FINALPATH__/venv/bin/celery -A pagure.lib.tasks worker --loglevel=info -c 1 -Q authorized_keys_queue ExecStart=__INSTALL_DIR__/venv/bin/celery -A pagure.lib.tasks worker --loglevel=info -c 1 -Q authorized_keys_queue
Environment="PAGURE_CONFIG=__FINALPATH__/pagure.cfg" Environment="PAGURE_CONFIG=__INSTALL_DIR__/pagure.cfg"
Restart=on-failure Restart=on-failure
[Install] [Install]

View file

@ -7,9 +7,9 @@ Documentation=https://pagure.io/pagure
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
ExecStart=__FINALPATH__/venv/bin/celery -A pagure.lib.tasks_services worker --loglevel=info -Q pagure_ci ExecStart=__INSTALL_DIR__/venv/bin/celery -A pagure.lib.tasks_services worker --loglevel=info -Q pagure_ci
Environment="PAGURE_CONFIG=__FINALPATH__/pagure.cfg" Environment="PAGURE_CONFIG=__INSTALL_DIR__/pagure.cfg"
Restart=on-failure Restart=on-failure
[Install] [Install]

View file

@ -7,8 +7,8 @@ Documentation=https://pagure.io/pagure
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
ExecStart=__FINALPATH__/venv/bin/python3 __FINALPATH__/pagure-ev/pagure_stream_server.py ExecStart=__INSTALL_DIR__/venv/bin/python3 __INSTALL_DIR__/pagure-ev/pagure_stream_server.py
Restart=on-failure Restart=on-failure
[Install] [Install]

View file

@ -7,9 +7,9 @@ Documentation=https://pagure.io/pagure
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
ExecStart=__FINALPATH__/venv/bin/celery -A pagure.lib.tasks worker --loglevel=info -c 1 -Q gitolite_queue ExecStart=__INSTALL_DIR__/venv/bin/celery -A pagure.lib.tasks worker --loglevel=info -c 1 -Q gitolite_queue
Environment="PAGURE_CONFIG=__FINALPATH__/pagure.cfg" Environment="PAGURE_CONFIG=__INSTALL_DIR__/pagure.cfg"
Restart=on-failure Restart=on-failure
[Install] [Install]

View file

@ -7,9 +7,9 @@ Documentation=https://pagure.io/pagure
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
ExecStart=__FINALPATH__/venv/bin/celery -A pagure.lib.tasks_services worker --loglevel=info -Q pagure_loadjson ExecStart=__INSTALL_DIR__/venv/bin/celery -A pagure.lib.tasks_services worker --loglevel=info -Q pagure_loadjson
Environment="PAGURE_CONFIG=__FINALPATH__/pagure.cfg" Environment="PAGURE_CONFIG=__INSTALL_DIR__/pagure.cfg"
Restart=on-failure Restart=on-failure
[Install] [Install]

View file

@ -7,9 +7,9 @@ Documentation=https://pagure.io/pagure
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
ExecStart=__FINALPATH__/venv/bin/celery -A pagure.lib.tasks_services worker --loglevel=info -Q pagure_logcom ExecStart=__INSTALL_DIR__/venv/bin/celery -A pagure.lib.tasks_services worker --loglevel=info -Q pagure_logcom
Environment="PAGURE_CONFIG=__FINALPATH__/pagure.cfg" Environment="PAGURE_CONFIG=__INSTALL_DIR__/pagure.cfg"
Restart=on-failure Restart=on-failure
[Install] [Install]

View file

@ -7,8 +7,8 @@ Documentation=https://pagure.io/pagure
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
ExecStart=__FINALPATH__/venv/bin/python3 __FINALPATH__/pagure-milters/comment_email_milter.py ExecStart=__INSTALL_DIR__/venv/bin/python3 __INSTALL_DIR__/pagure-milters/comment_email_milter.py
Restart=on-failure Restart=on-failure
[Install] [Install]

View file

@ -7,9 +7,9 @@ Documentation=https://pagure.io/pagure
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
ExecStart=__FINALPATH__/venv/bin/celery -A pagure.lib.tasks_mirror worker --loglevel=info -Q pagure_mirror ExecStart=__INSTALL_DIR__/venv/bin/celery -A pagure.lib.tasks_mirror worker --loglevel=info -Q pagure_mirror
Environment="PAGURE_CONFIG=__FINALPATH__/pagure.cfg" Environment="PAGURE_CONFIG=__INSTALL_DIR__/pagure.cfg"
Restart=on-failure Restart=on-failure
[Install] [Install]

View file

@ -7,9 +7,9 @@ Documentation=https://pagure.io/pagure
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
ExecStart=__FINALPATH__/venv/bin/celery -A pagure.lib.tasks_services worker --loglevel=info -Q pagure_webhook ExecStart=__INSTALL_DIR__/venv/bin/celery -A pagure.lib.tasks_services worker --loglevel=info -Q pagure_webhook
Environment="PAGURE_CONFIG=__FINALPATH__/pagure.cfg" Environment="PAGURE_CONFIG=__INSTALL_DIR__/pagure.cfg"
Restart=on-failure Restart=on-failure
[Install] [Install]

View file

@ -7,9 +7,9 @@ Documentation=https://pagure.io/pagure
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
ExecStart=__FINALPATH__/venv/bin/celery -A pagure.lib.tasks worker --loglevel=info ExecStart=__INSTALL_DIR__/venv/bin/celery -A pagure.lib.tasks worker --loglevel=info
Environment="PAGURE_CONFIG=__FINALPATH__/pagure.cfg" Environment="PAGURE_CONFIG=__INSTALL_DIR__/pagure.cfg"
Restart=on-failure Restart=on-failure
[Install] [Install]

View file

@ -4,14 +4,14 @@ gid = __APP__
plugins = python3 plugins = python3
master = true master = true
protocol = uwsgi protocol = uwsgi
socket = __FINALPATH__/__APP__.socket socket = __INSTALL_DIR__/__APP__.socket
chmod-socket = 660 chmod-socket = 660
virtualenv = __FINALPATH__/venv virtualenv = __INSTALL_DIR__/venv
mount = __PATH__=__FINALPATH__/pagure.wsgi mount = __PATH__=__INSTALL_DIR__/pagure.wsgi
manage-script-name = true manage-script-name = true
# Python related settings # Python related settings
# the base directory (full path) # the base directory (full path)
chdir = __FINALPATH__/ chdir = __INSTALL_DIR__/
enable-threads = true enable-threads = true
close-on-exec = true close-on-exec = true

View file

@ -1,52 +0,0 @@
{
"name": "Pagure",
"id": "pagure",
"packaging_format": 1,
"description": {
"en": "A git-centered forge, python based using pygit2."
},
"version": "5.13.3~ynh2",
"url": "https://pagure.io/pagure",
"upstream": {
"license": "AGPL-3.0",
"website": "https://pagure.io/pagure",
"demo": "https://pagure.io",
"admindoc": "https://docs.pagure.org/pagure/",
"code": "https://pagure.io/pagure"
},
"license": "AGPL-3.0",
"maintainer": {
"name": "Jean-Baptiste Holcroft",
"email": "jean-baptiste@holcroft.fr"
},
"requirements": {
"yunohost": ">= 4.3.0"
},
"multi_instance": false,
"services": [
"nginx"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/pagure",
"default": "/pagure"
},
{
"name": "is_public",
"type": "boolean",
"default": true
},
{
"name": "admin",
"type": "user"
}
]
}
}

85
manifest.toml Normal file
View file

@ -0,0 +1,85 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "pagure"
name = "Pagure"
description.en = "A git-centered forge, python based using pygit2."
version = "5.13.3~ynh3"
maintainers = ["Jean-Baptiste Holcroft"]
[upstream]
license = "AGPL-3.0"
website = "https://pagure.io/pagure"
demo = "https://pagure.io"
admindoc = "https://docs.pagure.org/pagure/"
code = "https://pagure.io/pagure"
cpe = "cpe:2.3:a:redhat:pagure"
[integration]
yunohost = ">= 11.2"
architectures = "all"
multi_instance = false
ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials.
sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal.
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
[install]
[install.domain]
type = "domain"
[install.path]
type = "path"
default = "/pagure"
[install.init_main_permission]
type = "group"
default = "visitors"
[install.admin]
type = "user"
[resources]
[resources.sources.main]
url = "https://releases.pagure.org/pagure/pagure-5.13.3.tar.gz"
sha256 = "f684d8193d4c4cf637b465c80cbfece6eb2b1646df3ec4f993adf75ea78d5a1a"
[resources.system_user]
[resources.install_dir]
[resources.data_dir]
subdirs = ["repos", "remotes", "attachments", "releases"]
[resources.permissions]
main.url = "/"
[resources.apt]
packages = [
"gcc",
"git",
"libffi-dev",
"libgit2-dev",
"libjpeg-dev",
"libpq-dev",
"python3-cffi",
"python3-dev",
"python3-gdbm",
"python3-psycopg2",
"python3-venv",
"python3",
"redis-server",
"uwsgi-plugin-python",
"uwsgi",
"virtualenv",
"postgresql",
]
[resources.database]
type = "postgresql"

View file

@ -4,10 +4,6 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
# dependencies used by the app
#pkg_dependencies="git python-dev libgit2-dev redis-server libjpeg-dev gcc libffi-dev virtualenv python-virtualenv python-cffi python-gdbm python-psycopg2 postgresql uwsgi uwsgi-plugin-python"
pkg_dependencies="git python3 python3-dev libgit2-dev redis-server libjpeg-dev gcc libffi-dev python3-venv python3-cffi python3-gdbm python3-psycopg2 libpq-dev postgresql"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================

View file

@ -14,23 +14,23 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
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
@ -41,13 +41,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

@ -15,64 +15,64 @@ 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=$YNH_APP_NEW_PATH #REMOVEME? new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." #REMOVEME? ynh_script_progression --message="Loading installation settings..."
# 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)
# Add settings here as needed by your application # Add settings here as needed by your application
admin=$(ynh_app_setting_get --app=$app --key=admin) #REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin)
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)
secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) #REMOVEME? secret_key=$(ynh_app_setting_get --app=$app --key=secret_key)
salt_email=$(ynh_app_setting_get --app=$app --key=salt_email) #REMOVEME? salt_email=$(ynh_app_setting_get --app=$app --key=salt_email)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) #REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
#================================================= #=================================================
# 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)..." #REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
# 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 () {
ynh_clean_check_starting #REMOVEME? ynh_clean_check_starting
# 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
#================================================= #=================================================
@ -99,28 +99,30 @@ ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="stop" --log
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." ynh_script_progression --message="Updating NGINX web server configuration..."
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
#================================================= #=================================================
@ -129,16 +131,16 @@ fi
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." ynh_script_progression --message="Updating a configuration file..."
#REMOVEME?
domain=$new_domain domain=$new_domain
path_url=$new_path path=$new_path
ynh_add_config --template="../conf/pagure.cfg.sample" --destination="$final_path/pagure.cfg" ynh_add_config --template="../conf/pagure.cfg.sample" --destination="$install_dir/pagure.cfg"
chmod 400 "$final_path/pagure.cfg" chmod 400 "$install_dir/pagure.cfg"
chown $app:$app "$final_path/pagure.cfg" chown $app:$app "$install_dir/pagure.cfg"
ynh_add_config --template="../conf/pagure.wsgi" --destination="$final_path/pagure.wsgi" ynh_add_config --template="../conf/pagure.wsgi" --destination="$install_dir/pagure.wsgi"
ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini" ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini"
#================================================= #=================================================
@ -164,9 +166,9 @@ ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="start" --lo
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload #REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -12,131 +10,40 @@ source ynh_uwsgi_service__2
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # INITIALIZE AND STORE SETTINGS
#================================================= #=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# 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=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
admin=$YNH_APP_ARG_ADMIN
app=$YNH_APP_INSTANCE_NAME
secret_key=$(ynh_string_random) secret_key=$(ynh_string_random)
ynh_app_setting_set --app="$app" --key="secret_key" --value="$secret_key"
salt_email=$(ynh_string_random) salt_email=$(ynh_string_random)
ynh_app_setting_set --app="$app" --key="salt_email" --value="$salt_email"
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..."
final_path=/var/www/$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..."
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
ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key
ynh_app_setting_set --app=$app --key=salt_email --value=$salt_email
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..."
# 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..."
ynh_psql_test_if_first_run
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
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." ynh_script_progression --message="Setting up source files..."
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$install_dir"
chmod 750 "$final_path" chmod -R o-rwx "$install_dir"
chmod -R o-rwx "$final_path" chown -R "$app:www-data" "$install_dir"
chown -R $app:www-data "$final_path"
chmod -R o-rwx "$data_dir"
chown -R "$app:www-data" "$data_dir"
#================================================= #=================================================
# NGINX CONFIGURATION # APP INITIAL CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring NGINX web server..." ynh_script_progression --message="Adding $app's configuration files..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
# CREATE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Creating a data directory..."
datadir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
mkdir -p $datadir
mkdir -p "${datadir}"/{repos,remotes,attachments,releases}
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
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"
ynh_add_config --template="../conf/pagure.cfg.sample" --destination="$final_path/pagure.cfg" ynh_add_config --template="pagure.cfg.sample" --destination="$install_dir/pagure.cfg"
chmod 400 "$final_path/pagure.cfg" chmod 400 "$install_dir/pagure.cfg"
chown $app:$app "$final_path/pagure.cfg" chown "$app:$app" "$install_dir/pagure.cfg"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -155,7 +62,7 @@ ynh_add_systemd_config --service="${app}_mirror" --template="pagure_mirror.servi
ynh_add_systemd_config --service="${app}_webhook" --template="pagure_webhook.service" ynh_add_systemd_config --service="${app}_webhook" --template="pagure_webhook.service"
ynh_add_systemd_config --service="${app}_worker" --template="pagure_worker.service" ynh_add_systemd_config --service="${app}_worker" --template="pagure_worker.service"
ynh_add_config --template="../conf/pagure.wsgi" --destination="$final_path/pagure.wsgi" ynh_add_config --template="pagure.wsgi" --destination="$install_dir/pagure.wsgi"
ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini" ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini"
#================================================= #=================================================
@ -163,44 +70,44 @@ ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini"
#================================================= #=================================================
ynh_script_progression --message="Building app..." ynh_script_progression --message="Building app..."
pushd "$final_path" pushd "$install_dir"
python3 -m venv venv python3 -m venv venv
source ./venv/bin/activate ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install --upgrade pip
pip install --upgrade pip ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install wheel
pip install wheel ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install cffi
pip install cffi ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install psycopg2
pip install psycopg2 ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install pyyaml
pip install pyyaml ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install pygit2
pip install pygit2 ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install "jinja2<3.1.0"
pip install "jinja2<3.1.0" ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install -r requirements.txt
pip install -r requirements.txt
ynh_add_config --template="../conf/alembic.ini" --destination="$final_path/alembic.ini" ynh_add_config --template="alembic.ini" --destination="$install_dir/alembic.ini"
PAGURE_CONFIG=${final_path}/pagure.cfg python createdb.py --initial alembic.ini 2>&1 ynh_exec_as "$app" PAGURE_CONFIG="${install_dir}/pagure.cfg" "$install_dir/venv/bin/python3" createdb.py --initial alembic.ini 2>&1
popd popd
ynh_replace_string --match_string="validators.Required" --replace_string="validators.DataRequired" --target_file="$final_path/pagure/forms.py" ynh_replace_string --match_string="validators.Required" --replace_string="validators.DataRequired" --target_file="$install_dir/pagure/forms.py"
chmod 750 "$final_path" chmod -R o-rwx "$install_dir"
chmod -R o-rwx "$final_path" chown -R "$app:www-data" "$install_dir"
chown -R $app:www-data "$final_path"
#================================================= #=================================================
# GENERIC FINALIZATION # SYSTEM CONFIGURATION
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add ${app}_authorized_keys_worker # Create a dedicated NGINX config
yunohost service add ${app}_ci ynh_add_nginx_config
#yunohost service add ${app}_ev_server
yunohost service add ${app}_gitolite_worker yunohost service add "${app}_authorized_keys_worker"
yunohost service add ${app}_loadjson yunohost service add "${app}_ci"
yunohost service add ${app}_logcom #yunohost service add "${app}_ev_server"
#yunohost service add ${app}_milters yunohost service add "${app}_gitolite_worker"
yunohost service add ${app}_mirror yunohost service add "${app}_loadjson"
yunohost service add ${app}_webhook yunohost service add "${app}_logcom"
yunohost service add ${app}_worker #yunohost service add "${app}_milters"
yunohost service add "${app}_mirror"
yunohost service add "${app}_webhook"
yunohost service add "${app}_worker"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -208,38 +115,19 @@ yunohost service add ${app}_worker
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=${app}_authorized_keys_worker --action="start" --log_path="systemd" --line_match="ready" ynh_systemd_action --service_name="${app}_authorized_keys_worker" --action="start" --log_path="systemd" --line_match="ready"
ynh_systemd_action --service_name=${app}_ci --action="start" --log_path="systemd" --line_match="ready" ynh_systemd_action --service_name="${app}_ci" --action="start" --log_path="systemd" --line_match="ready"
#ynh_systemd_action --service_name=${app}_ev_server --action="start" --log_path="systemd" --line_match="ready" #ynh_systemd_action --service_name="${app}_ev_server" --action="start" --log_path="systemd" --line_match="ready"
ynh_systemd_action --service_name=${app}_gitolite_worker --action="start" --log_path="systemd" --line_match="ready" ynh_systemd_action --service_name="${app}_gitolite_worker" --action="start" --log_path="systemd" --line_match="ready"
ynh_systemd_action --service_name=${app}_loadjson --action="start" --log_path="systemd" --line_match="ready" ynh_systemd_action --service_name="${app}_loadjson" --action="start" --log_path="systemd" --line_match="ready"
ynh_systemd_action --service_name=${app}_logcom --action="start" --log_path="systemd" --line_match="ready" ynh_systemd_action --service_name="${app}_logcom" --action="start" --log_path="systemd" --line_match="ready"
#ynh_systemd_action --service_name=${app}_milters --action="start" --log_path="systemd" --line_match="ready" #ynh_systemd_action --service_name="${app}_milters" --action="start" --log_path="systemd" --line_match="ready"
ynh_systemd_action --service_name=${app}_mirror --action="start" --log_path="systemd" --line_match="ready" ynh_systemd_action --service_name="${app}_mirror" --action="start" --log_path="systemd" --line_match="ready"
ynh_systemd_action --service_name=${app}_webhook --action="start" --log_path="systemd" --line_match="ready" ynh_systemd_action --service_name="${app}_webhook" --action="start" --log_path="systemd" --line_match="ready"
ynh_systemd_action --service_name=${app}_worker --action="start" --log_path="systemd" --line_match="ready" ynh_systemd_action --service_name="${app}_worker" --action="start" --log_path="systemd" --line_match="ready"
ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="start" --log_path="systemd" --line_match="Started" ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="start" --log_path="systemd" --line_match="Started"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..."
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -12,176 +10,36 @@ source ynh_uwsgi_service__2
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # REMOVE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
app=$YNH_APP_INSTANCE_NAME services=(
"${app}_authorized_keys_worker"
domain=$(ynh_app_setting_get --app=$app --key=domain) "${app}_ci"
db_name=$(ynh_app_setting_get --app=$app --key=db_name) "${app}_ev_server"
db_user=$db_name "${app}_gitolite_worker"
final_path=$(ynh_app_setting_get --app=$app --key=final_path) "${app}_loadjson"
datadir=$(ynh_app_setting_get --app=$app --key=datadir) "${app}_logcom"
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) "${app}_milters"
"${app}_mirror"
#================================================= "${app}_webhook"
# STANDARD REMOVE "${app}_worker"
#================================================= )
# REMOVE SERVICE INTEGRATION IN YUNOHOST for service in "${services[@]}"; do
#================================================= if ynh_exec_warn_less yunohost service status "$service" >/dev/null; then
yunohost service remove "$service"
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status ${app}_authorized_keys_worker >/dev/null
then
ynh_script_progression --message="Removing ${app}_authorized_keys_worker service integration..."
yunohost service remove ${app}_authorized_keys_worker
fi fi
ynh_remove_systemd_config --service="$service"
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) done
if ynh_exec_warn_less yunohost service status ${app}_ci >/dev/null
then
ynh_script_progression --message="Removing ${app}_ci service integration..."
yunohost service remove ${app}_ci
fi
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status ${app}_ev_server >/dev/null
then
ynh_script_progression --message="Removing ${app}_ev_server service integration..."
yunohost service remove ${app}_ev_server
fi
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status ${app}_gitolite_worker >/dev/null
then
ynh_script_progression --message="Removing ${app}_gitolite_worker service integration..."
yunohost service remove ${app}_gitolite_worker
fi
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status ${app}_loadjson >/dev/null
then
ynh_script_progression --message="Removing ${app}_loadjson service integration..."
yunohost service remove ${app}_loadjson
fi
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status ${app}_logcom >/dev/null
then
ynh_script_progression --message="Removing ${app}_logcom service integration..."
yunohost service remove ${app}_logcom
fi
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status ${app}_milters >/dev/null
then
ynh_script_progression --message="Removing ${app}_milters service integration..."
yunohost service remove ${app}_milters
fi
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status ${app}_mirror >/dev/null
then
ynh_script_progression --message="Removing ${app}_mirror service integration..."
yunohost service remove ${app}_mirror
fi
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status ${app}_webhook >/dev/null
then
ynh_script_progression --message="Removing ${app}_webhook service integration..."
yunohost service remove ${app}_webhook
fi
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status ${app}_worker >/dev/null
then
ynh_script_progression --message="Removing ${app}_worker service integration..."
yunohost service remove ${app}_worker
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_remove_systemd_config --service="${app}_authorized_keys_worker"
ynh_remove_systemd_config --service="${app}_ci"
#ynh_remove_systemd_config --service="${app}_ev_server"
ynh_remove_systemd_config --service="${app}_gitolite_worker"
ynh_remove_systemd_config --service="${app}_loadjson"
ynh_remove_systemd_config --service="${app}_logcom"
#ynh_remove_systemd_config --service="${app}_milters"
ynh_remove_systemd_config --service="${app}_mirror"
ynh_remove_systemd_config --service="${app}_webhook"
ynh_remove_systemd_config --service="${app}_worker"
ynh_remove_uwsgi_service --service="$app" ynh_remove_uwsgi_service --service="$app"
#=================================================
# REMOVE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Removing the PostgreSQL database..."
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE DATA DIR
#=================================================
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing app data directory..."
ynh_secure_remove --file="$datadir"
fi
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..."
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE THE REDIS DATABASE
#=================================================
ynh_script_progression --message="Removing the redis database..."
ynh_redis_remove_db "$redis_db" ynh_redis_remove_db "$redis_db"
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user
ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -16,33 +16,33 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
} }
# 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..." #REMOVEME? ynh_script_progression --message="Loading installation settings..."
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)
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
datadir=$(ynh_app_setting_get --app=$app --key=datadir) #REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." #REMOVEME? ynh_script_progression --message="Validating restoration parameters..."
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
@ -56,54 +56,54 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." #REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..."
# 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..." ynh_script_progression --message="Restoring the app main directory..."
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:www-data "$final_path" chown -R $app:www-data "$install_dir"
#================================================= #=================================================
# RESTORE THE DATA DIRECTORY # RESTORE THE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Restoring the data directory..." ynh_script_progression --message="Restoring the data directory..."
ynh_restore_file --origin_path="$datadir" --not_mandatory ynh_restore_file --origin_path="$data_dir" --not_mandatory
mkdir -p $datadir mkdir -p $data_dir
mkdir -p "${datadir}"/{repos,remotes,attachments,releases} mkdir -p "${data_dir}"/{repos,remotes,attachments,releases}
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"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." #REMOVEME? ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies #REMOVEME? ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." #REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..."
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_psql_test_if_first_run #REMOVEME? ynh_psql_test_if_first_run
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_execute_file_as_root --file="./db.sql" --database=$db_name ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
#================================================= #=================================================

View file

@ -14,21 +14,21 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." #REMOVEME? ynh_script_progression --message="Loading installation settings..."
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)
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) #REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) #REMOVEME? secret_key=$(ynh_app_setting_get --app=$app --key=secret_key)
salt_email=$(ynh_app_setting_get --app=$app --key=salt_email) #REMOVEME? salt_email=$(ynh_app_setting_get --app=$app --key=salt_email)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -40,17 +40,17 @@ 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)..." #REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# 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 () {
ynh_clean_check_starting ynh_clean_check_starting
# 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
@ -77,8 +77,8 @@ ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="stop" --log
ynh_script_progression --message="Ensuring downward compatibility..." ynh_script_progression --message="Ensuring downward compatibility..."
# Cleaning legacy permissions # Cleaning legacy permissions
if ynh_legacy_permissions_exists; then #REMOVEME? if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all #REMOVEME? ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public ynh_app_setting_delete --app=$app --key=is_public
fi fi
@ -86,10 +86,10 @@ fi
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." #REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..."
# 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
@ -100,12 +100,12 @@ then
ynh_script_progression --message="Upgrading source files..." ynh_script_progression --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$install_dir"
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:www-data "$final_path" chown -R $app:www-data "$install_dir"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -118,9 +118,9 @@ ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." #REMOVEME? ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies #REMOVEME? ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
@ -129,10 +129,10 @@ ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." ynh_script_progression --message="Updating a configuration file..."
ynh_add_config --template="../conf/pagure.cfg.sample" --destination="$final_path/pagure.cfg" ynh_add_config --template="../conf/pagure.cfg.sample" --destination="$install_dir/pagure.cfg"
chmod 400 "$final_path/pagure.cfg" chmod 400 "$install_dir/pagure.cfg"
chown $app:$app "$final_path/pagure.cfg" chown $app:$app "$install_dir/pagure.cfg"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -151,7 +151,7 @@ ynh_add_systemd_config --service="${app}_mirror" --template="pagure_mirror.servi
ynh_add_systemd_config --service="${app}_webhook" --template="pagure_webhook.service" ynh_add_systemd_config --service="${app}_webhook" --template="pagure_webhook.service"
ynh_add_systemd_config --service="${app}_worker" --template="pagure_worker.service" ynh_add_systemd_config --service="${app}_worker" --template="pagure_worker.service"
ynh_add_config --template="../conf/pagure.wsgi" --destination="$final_path/pagure.wsgi" ynh_add_config --template="../conf/pagure.wsgi" --destination="$install_dir/pagure.wsgi"
ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini" ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini"
#================================================= #=================================================
@ -159,8 +159,8 @@ ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini"
#================================================= #=================================================
ynh_script_progression --message="Building app..." ynh_script_progression --message="Building app..."
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
source ./venv/bin/activate source ./venv/bin/activate
pip install --upgrade pip pip install --upgrade pip
@ -171,15 +171,15 @@ pushd "$final_path"
pip install pygit2 pip install pygit2
pip install "jinja2<3.1.0" pip install "jinja2<3.1.0"
pip install -r requirements.txt pip install -r requirements.txt
ynh_add_config --template="../conf/alembic.ini" --destination="$final_path/alembic.ini" ynh_add_config --template="../conf/alembic.ini" --destination="$install_dir/alembic.ini"
PAGURE_CONFIG=${final_path}/pagure.cfg alembic upgrade head 2>&1 PAGURE_CONFIG=${install_dir}/pagure.cfg alembic upgrade head 2>&1
popd popd
ynh_replace_string --match_string="validators.Required" --replace_string="validators.DataRequired" --target_file="$final_path/pagure/forms.py" ynh_replace_string --match_string="validators.Required" --replace_string="validators.DataRequired" --target_file="$install_dir/pagure/forms.py"
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$install_dir"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
@ -219,9 +219,9 @@ ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="start" --lo
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

9
tests.toml Normal file
View file

@ -0,0 +1,9 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
test_format = 1.0
[default]
# ------------
# Tests to run
# ------------