From 7dfe48267c2cd7ee8f4aa97872ba17e373e4d28a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 15 Mar 2024 23:27:46 +0100 Subject: [PATCH 1/6] Manifest v2 --- check_process | 22 -- conf/alembic.ini | 2 +- conf/app.src | 7 - conf/nginx.conf | 4 +- conf/pagure.cfg.sample | 6 +- conf/pagure.wsgi | 4 +- conf/pagure_authorized_keys_worker.service | 6 +- conf/pagure_ci.service | 6 +- conf/pagure_ev_server.service | 4 +- conf/pagure_gitolite_worker.service | 6 +- conf/pagure_loadjson.service | 6 +- conf/pagure_logcom.service | 6 +- conf/pagure_milters.service | 4 +- conf/pagure_mirror.service | 6 +- conf/pagure_webhook.service | 6 +- conf/pagure_worker.service | 6 +- conf/uwsgi.ini | 8 +- doc/{DISCLAIMER.md => POST_INSTALL.md} | 0 manifest.json | 52 ----- manifest.toml | 85 ++++++++ scripts/_common.sh | 4 - scripts/backup | 20 +- scripts/change_url | 92 ++++---- scripts/install | 232 ++++++--------------- scripts/remove | 182 ++-------------- scripts/restore | 62 +++--- scripts/upgrade | 84 ++++---- tests.toml | 9 + 28 files changed, 344 insertions(+), 587 deletions(-) delete mode 100644 check_process delete mode 100644 conf/app.src rename doc/{DISCLAIMER.md => POST_INSTALL.md} (100%) delete mode 100644 manifest.json create mode 100644 manifest.toml create mode 100644 tests.toml diff --git a/check_process b/check_process deleted file mode 100644 index b05adb8..0000000 --- a/check_process +++ /dev/null @@ -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 diff --git a/conf/alembic.ini b/conf/alembic.ini index 518d2b8..9dc26f8 100644 --- a/conf/alembic.ini +++ b/conf/alembic.ini @@ -2,7 +2,7 @@ [alembic] # path to migration scripts -script_location = __FINALPATH__/alembic +script_location = __INSTALL_DIR__/alembic # template used to generate migration files # file_template = %%(rev)s_%%(slug)s diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index 2ea1bd0..0000000 --- a/conf/app.src +++ /dev/null @@ -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 diff --git a/conf/nginx.conf b/conf/nginx.conf index 52fc331..5c0b15c 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,12 +1,12 @@ location __PATH__/ { #Source: https://docs.weblate.org/en/latest/admin/install.html#sample-configuration-for-nginx-and-uwsgi # Path to source - alias __FINALPATH__/ ; + alias __INSTALL_DIR__/ ; include uwsgi_params; # Needed for long running operations in admin interface uwsgi_read_timeout 3600; - uwsgi_pass unix://__FINALPATH__/__NAME__.socket; + uwsgi_pass unix://__INSTALL_DIR__/__NAME__.socket; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/conf/pagure.cfg.sample b/conf/pagure.cfg.sample index 61bf898..be0bccf 100644 --- a/conf/pagure.cfg.sample +++ b/conf/pagure.cfg.sample @@ -75,12 +75,12 @@ GIT_URL_SSH = 'ssh://git@__DOMAIN____PATH__' GIT_URL_GIT = 'git://__DOMAIN____PATH__' ### 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 -REMOTE_GIT_FOLDER = '__DATADIR__/remotes' +REMOTE_GIT_FOLDER = '__DATA_DIR__/remotes' ### Whether to enable scanning for viruses in attachments VIRUS_SCAN_ATTACHMENTS = False diff --git a/conf/pagure.wsgi b/conf/pagure.wsgi index 023ad9b..78ba97a 100644 --- a/conf/pagure.wsgi +++ b/conf/pagure.wsgi @@ -9,7 +9,7 @@ import pkg_resources # Set the environment variable pointing to the configuration file 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 # 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 # as a python module (for example if you run it from a git clone). #import sys -#sys.path.insert(0, '__FINALPATH__/') +#sys.path.insert(0, '__INSTALL_DIR__/') # The most important line to make the wsgi working diff --git a/conf/pagure_authorized_keys_worker.service b/conf/pagure_authorized_keys_worker.service index 55ee4c7..da67aea 100644 --- a/conf/pagure_authorized_keys_worker.service +++ b/conf/pagure_authorized_keys_worker.service @@ -7,9 +7,9 @@ Documentation=https://pagure.io/pagure Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/venv/bin/celery -A pagure.lib.tasks worker --loglevel=info -c 1 -Q authorized_keys_queue -Environment="PAGURE_CONFIG=__FINALPATH__/pagure.cfg" +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=__INSTALL_DIR__/venv/bin/celery -A pagure.lib.tasks worker --loglevel=info -c 1 -Q authorized_keys_queue +Environment="PAGURE_CONFIG=__INSTALL_DIR__/pagure.cfg" Restart=on-failure [Install] diff --git a/conf/pagure_ci.service b/conf/pagure_ci.service index efdacca..38a6deb 100644 --- a/conf/pagure_ci.service +++ b/conf/pagure_ci.service @@ -7,9 +7,9 @@ Documentation=https://pagure.io/pagure Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/venv/bin/celery -A pagure.lib.tasks_services worker --loglevel=info -Q pagure_ci -Environment="PAGURE_CONFIG=__FINALPATH__/pagure.cfg" +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=__INSTALL_DIR__/venv/bin/celery -A pagure.lib.tasks_services worker --loglevel=info -Q pagure_ci +Environment="PAGURE_CONFIG=__INSTALL_DIR__/pagure.cfg" Restart=on-failure [Install] diff --git a/conf/pagure_ev_server.service b/conf/pagure_ev_server.service index f031e7d..a992d8f 100644 --- a/conf/pagure_ev_server.service +++ b/conf/pagure_ev_server.service @@ -7,8 +7,8 @@ Documentation=https://pagure.io/pagure Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/venv/bin/python3 __FINALPATH__/pagure-ev/pagure_stream_server.py +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=__INSTALL_DIR__/venv/bin/python3 __INSTALL_DIR__/pagure-ev/pagure_stream_server.py Restart=on-failure [Install] diff --git a/conf/pagure_gitolite_worker.service b/conf/pagure_gitolite_worker.service index 84f5b6d..b5881ba 100644 --- a/conf/pagure_gitolite_worker.service +++ b/conf/pagure_gitolite_worker.service @@ -7,9 +7,9 @@ Documentation=https://pagure.io/pagure Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/venv/bin/celery -A pagure.lib.tasks worker --loglevel=info -c 1 -Q gitolite_queue -Environment="PAGURE_CONFIG=__FINALPATH__/pagure.cfg" +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=__INSTALL_DIR__/venv/bin/celery -A pagure.lib.tasks worker --loglevel=info -c 1 -Q gitolite_queue +Environment="PAGURE_CONFIG=__INSTALL_DIR__/pagure.cfg" Restart=on-failure [Install] diff --git a/conf/pagure_loadjson.service b/conf/pagure_loadjson.service index b7209a7..cd96875 100644 --- a/conf/pagure_loadjson.service +++ b/conf/pagure_loadjson.service @@ -7,9 +7,9 @@ Documentation=https://pagure.io/pagure Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/venv/bin/celery -A pagure.lib.tasks_services worker --loglevel=info -Q pagure_loadjson -Environment="PAGURE_CONFIG=__FINALPATH__/pagure.cfg" +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=__INSTALL_DIR__/venv/bin/celery -A pagure.lib.tasks_services worker --loglevel=info -Q pagure_loadjson +Environment="PAGURE_CONFIG=__INSTALL_DIR__/pagure.cfg" Restart=on-failure [Install] diff --git a/conf/pagure_logcom.service b/conf/pagure_logcom.service index 2f3b102..52241d4 100644 --- a/conf/pagure_logcom.service +++ b/conf/pagure_logcom.service @@ -7,9 +7,9 @@ Documentation=https://pagure.io/pagure Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/venv/bin/celery -A pagure.lib.tasks_services worker --loglevel=info -Q pagure_logcom -Environment="PAGURE_CONFIG=__FINALPATH__/pagure.cfg" +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=__INSTALL_DIR__/venv/bin/celery -A pagure.lib.tasks_services worker --loglevel=info -Q pagure_logcom +Environment="PAGURE_CONFIG=__INSTALL_DIR__/pagure.cfg" Restart=on-failure [Install] diff --git a/conf/pagure_milters.service b/conf/pagure_milters.service index d751e2f..f8a5058 100644 --- a/conf/pagure_milters.service +++ b/conf/pagure_milters.service @@ -7,8 +7,8 @@ Documentation=https://pagure.io/pagure Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/venv/bin/python3 __FINALPATH__/pagure-milters/comment_email_milter.py +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=__INSTALL_DIR__/venv/bin/python3 __INSTALL_DIR__/pagure-milters/comment_email_milter.py Restart=on-failure [Install] diff --git a/conf/pagure_mirror.service b/conf/pagure_mirror.service index 332e738..b98eee9 100644 --- a/conf/pagure_mirror.service +++ b/conf/pagure_mirror.service @@ -7,9 +7,9 @@ Documentation=https://pagure.io/pagure Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/venv/bin/celery -A pagure.lib.tasks_mirror worker --loglevel=info -Q pagure_mirror -Environment="PAGURE_CONFIG=__FINALPATH__/pagure.cfg" +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=__INSTALL_DIR__/venv/bin/celery -A pagure.lib.tasks_mirror worker --loglevel=info -Q pagure_mirror +Environment="PAGURE_CONFIG=__INSTALL_DIR__/pagure.cfg" Restart=on-failure [Install] diff --git a/conf/pagure_webhook.service b/conf/pagure_webhook.service index 3a678d3..7fd6436 100644 --- a/conf/pagure_webhook.service +++ b/conf/pagure_webhook.service @@ -7,9 +7,9 @@ Documentation=https://pagure.io/pagure Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/venv/bin/celery -A pagure.lib.tasks_services worker --loglevel=info -Q pagure_webhook -Environment="PAGURE_CONFIG=__FINALPATH__/pagure.cfg" +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=__INSTALL_DIR__/venv/bin/celery -A pagure.lib.tasks_services worker --loglevel=info -Q pagure_webhook +Environment="PAGURE_CONFIG=__INSTALL_DIR__/pagure.cfg" Restart=on-failure [Install] diff --git a/conf/pagure_worker.service b/conf/pagure_worker.service index 89159e3..194bfa5 100644 --- a/conf/pagure_worker.service +++ b/conf/pagure_worker.service @@ -7,9 +7,9 @@ Documentation=https://pagure.io/pagure Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/venv/bin/celery -A pagure.lib.tasks worker --loglevel=info -Environment="PAGURE_CONFIG=__FINALPATH__/pagure.cfg" +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=__INSTALL_DIR__/venv/bin/celery -A pagure.lib.tasks worker --loglevel=info +Environment="PAGURE_CONFIG=__INSTALL_DIR__/pagure.cfg" Restart=on-failure [Install] diff --git a/conf/uwsgi.ini b/conf/uwsgi.ini index 776269c..88bcb40 100644 --- a/conf/uwsgi.ini +++ b/conf/uwsgi.ini @@ -4,14 +4,14 @@ gid = __APP__ plugins = python3 master = true protocol = uwsgi -socket = __FINALPATH__/__APP__.socket +socket = __INSTALL_DIR__/__APP__.socket chmod-socket = 660 -virtualenv = __FINALPATH__/venv -mount = __PATH__=__FINALPATH__/pagure.wsgi +virtualenv = __INSTALL_DIR__/venv +mount = __PATH__=__INSTALL_DIR__/pagure.wsgi manage-script-name = true # Python related settings # the base directory (full path) -chdir = __FINALPATH__/ +chdir = __INSTALL_DIR__/ enable-threads = true close-on-exec = true diff --git a/doc/DISCLAIMER.md b/doc/POST_INSTALL.md similarity index 100% rename from doc/DISCLAIMER.md rename to doc/POST_INSTALL.md diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 863ef68..0000000 --- a/manifest.json +++ /dev/null @@ -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" - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..ec696b0 --- /dev/null +++ b/manifest.toml @@ -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" diff --git a/scripts/_common.sh b/scripts/_common.sh index c5c1ed8..944a65e 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,10 +4,6 @@ # 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 #================================================= diff --git a/scripts/backup b/scripts/backup index 83b1d0d..e084f5b 100644 --- a/scripts/backup +++ b/scripts/backup @@ -14,23 +14,23 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { true } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # 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) -domain=$(ynh_app_setting_get --app=$app --key=domain) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) #================================================= # 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 #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE DATA DIR #================================================= -ynh_backup --src_path="$datadir" --is_big +ynh_backup --src_path="$data_dir" --is_big #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index 0ecc55e..4a50ae2 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -15,64 +15,64 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH +#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN +#REMOVEME? old_path=$YNH_APP_OLD_PATH -new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH +#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN +#REMOVEME? new_path=$YNH_APP_NEW_PATH -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +#REMOVEME? ynh_script_progression --message="Loading installation settings..." -# Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get --app=$app --key=final_path) +#REMOVEME? # Needed for helper "ynh_add_nginx_config" +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) # Add settings here as needed by your application -admin=$(ynh_app_setting_get --app=$app --key=admin) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) -secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) -salt_email=$(ynh_app_setting_get --app=$app --key=salt_email) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) +#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? db_user=$db_name +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +#REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) +#REMOVEME? secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) +#REMOVEME? salt_email=$(ynh_app_setting_get --app=$app --key=salt_email) +#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) #================================================= # 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 -ynh_backup_before_upgrade -ynh_clean_setup () { - ynh_clean_check_starting +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { + #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. - 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 - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # 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 #================================================= -change_domain=0 -if [ "$old_domain" != "$new_domain" ] +#REMOVEME? change_domain=0 +#REMOVEME? if [ "$old_domain" != "$new_domain" ] then - change_domain=1 + #REMOVEME? change_domain=1 fi -change_path=0 -if [ "$old_path" != "$new_path" ] +#REMOVEME? change_path=0 +#REMOVEME? if [ "$old_path" != "$new_path" ] then - change_path=1 + #REMOVEME? change_path=1 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..." -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 if [ $change_path -eq 1 ] then # Make a backup of the original NGINX config file if modified - ynh_backup_if_checksum_is_different --file="$nginx_conf_path" +#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path" # Set global variables for NGINX helper - domain="$old_domain" - path_url="$new_path" +#REMOVEME? domain="$old_domain" +#REMOVEME? path="$new_path" # Create a dedicated NGINX config - ynh_add_nginx_config +#REMOVEME? ynh_add_nginx_config fi # Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location - ynh_delete_file_checksum --file="$nginx_conf_path" - mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf +#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" +#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location - ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= @@ -129,16 +131,16 @@ fi # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating a configuration file..." - +#REMOVEME? 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" -chown $app:$app "$final_path/pagure.cfg" +chmod 400 "$install_dir/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" #================================================= @@ -164,9 +166,9 @@ ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="start" --lo #================================================= # 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 diff --git a/scripts/install b/scripts/install index 154037f..9fc906f 100755 --- a/scripts/install +++ b/scripts/install @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -12,131 +10,40 @@ source ynh_uwsgi_service__2 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) +ynh_app_setting_set --app="$app" --key="secret_key" --value="$secret_key" salt_email=$(ynh_string_random) - -#================================================= -# 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) +ynh_app_setting_set --app="$app" --key="salt_email" --value="$salt_email" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= 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 -ynh_setup_source --dest_dir="$final_path" +ynh_setup_source --dest_dir="$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod -R o-rwx "$install_dir" +chown -R "$app:www-data" "$install_dir" + +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..." - -# 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..." +ynh_script_progression --message="Adding $app's configuration files..." --weight=1 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" -chown $app:$app "$final_path/pagure.cfg" +chmod 400 "$install_dir/pagure.cfg" +chown "$app:$app" "$install_dir/pagure.cfg" #================================================= # SETUP SYSTEMD @@ -146,16 +53,16 @@ ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_systemd_config --service="${app}_authorized_keys_worker" --template="pagure_authorized_keys_worker.service" ynh_add_systemd_config --service="${app}_ci" --template="pagure_ci.service" -#ynh_add_systemd_config --service="${app}_ev_server" --template="pagure_ev_server.service" +# ynh_add_systemd_config --service="${app}_ev_server" --template="pagure_ev_server.service" ynh_add_systemd_config --service="${app}_gitolite_worker" --template="pagure_gitolite_worker.service" ynh_add_systemd_config --service="${app}_loadjson" --template="pagure_loadjson.service" ynh_add_systemd_config --service="${app}_logcom" --template="pagure_logcom.service" -#ynh_add_systemd_config --service="${app}_milters" --template="pagure_milters.service" +# ynh_add_systemd_config --service="${app}_milters" --template="pagure_milters.service" ynh_add_systemd_config --service="${app}_mirror" --template="pagure_mirror.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_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" #================================================= @@ -163,44 +70,44 @@ ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini" #================================================= ynh_script_progression --message="Building app..." -pushd "$final_path" - python3 -m venv venv - source ./venv/bin/activate - pip install --upgrade pip - pip install wheel - pip install cffi - pip install psycopg2 - pip install pyyaml - pip install pygit2 - pip install "jinja2<3.1.0" - pip install -r requirements.txt - ynh_add_config --template="../conf/alembic.ini" --destination="$final_path/alembic.ini" - PAGURE_CONFIG=${final_path}/pagure.cfg python createdb.py --initial alembic.ini 2>&1 +pushd "$install_dir" + python3 -m venv venv + ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install --upgrade pip + ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install wheel + ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install cffi + ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install psycopg2 + ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install pyyaml + ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install pygit2 + ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install "jinja2<3.1.0" + ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install -r requirements.txt + + ynh_add_config --template="alembic.ini" --destination="$install_dir/alembic.ini" + ynh_exec_as "$app" PAGURE_CONFIG="${install_dir}/pagure.cfg" "$install_dir/venv/bin/python3" createdb.py --initial alembic.ini 2>&1 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 "$final_path" -chown -R $app:www-data "$final_path" +chmod -R o-rwx "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= -# GENERIC FINALIZATION +# SYSTEM CONFIGURATION #================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 -yunohost service add ${app}_authorized_keys_worker -yunohost service add ${app}_ci -#yunohost service add ${app}_ev_server -yunohost service add ${app}_gitolite_worker -yunohost service add ${app}_loadjson -yunohost service add ${app}_logcom -#yunohost service add ${app}_milters -yunohost service add ${app}_mirror -yunohost service add ${app}_webhook -yunohost service add ${app}_worker +# Create a dedicated NGINX config +ynh_add_nginx_config + +yunohost service add "${app}_authorized_keys_worker" +yunohost service add "${app}_ci" +#yunohost service add "${app}_ev_server" +yunohost service add "${app}_gitolite_worker" +yunohost service add "${app}_loadjson" +yunohost service add "${app}_logcom" +#yunohost service add "${app}_milters" +yunohost service add "${app}_mirror" +yunohost service add "${app}_webhook" +yunohost service add "${app}_worker" #================================================= # START SYSTEMD SERVICE @@ -208,38 +115,19 @@ yunohost service add ${app}_worker ynh_script_progression --message="Starting 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}_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}_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}_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}_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}_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}_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}_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}_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}_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="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 #================================================= diff --git a/scripts/remove b/scripts/remove index 9fa3329..6fab851 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -12,176 +10,36 @@ source ynh_uwsgi_service__2 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 - -domain=$(ynh_app_setting_get --app=$app --key=domain) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) - -#================================================= -# STANDARD REMOVE -#================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST -#================================================= - -# 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 - -# 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}_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" +services=( + "${app}_authorized_keys_worker" + "${app}_ci" + "${app}_ev_server" + "${app}_gitolite_worker" + "${app}_loadjson" + "${app}_logcom" + "${app}_milters" + "${app}_mirror" + "${app}_webhook" + "${app}_worker" +) +for service in "${services[@]}"; do + if ynh_exec_warn_less yunohost service status "$service" >/dev/null; then + yunohost service remove "$service" + fi + ynh_remove_systemd_config --service="$service" +done 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 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" -#================================================= -# 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 #================================================= diff --git a/scripts/restore b/scripts/restore index 1f67525..c4a1461 100644 --- a/scripts/restore +++ b/scripts/restore @@ -16,33 +16,33 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # 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) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -datadir=$(ynh_app_setting_get --app=$app --key=datadir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? db_user=$db_name +#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) #================================================= # 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 \ - || ynh_die --message="There is already a directory: $final_path " +#REMOVEME? test ! -d $install_dir \ + || ynh_die --message="There is already a directory: $install_dir " #================================================= # STANDARD RESTORATION STEPS @@ -56,54 +56,54 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # 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) -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 #================================================= 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 -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # RESTORE 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 "${datadir}"/{repos,remotes,attachments,releases} +mkdir -p $data_dir +mkdir -p "${data_dir}"/{repos,remotes,attachments,releases} -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:www-data "$datadir" +chmod 750 "$data_dir" +chmod -R o-rwx "$data_dir" +chown -R $app:www-data "$data_dir" #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." +#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies #================================================= # 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) -ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +#REMOVEME? ynh_psql_test_if_first_run +#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 #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b15a845..8934678 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -14,21 +14,21 @@ source /usr/share/yunohost/helpers #================================================= # 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) -path_url=$(ynh_app_setting_get --app=$app --key=path) -admin=$(ynh_app_setting_get --app=$app --key=admin) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) -secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) -salt_email=$(ynh_app_setting_get --app=$app --key=salt_email) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? db_user=$db_name +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) +#REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) +#REMOVEME? secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) +#REMOVEME? salt_email=$(ynh_app_setting_get --app=$app --key=salt_email) #================================================= # CHECK VERSION @@ -40,17 +40,17 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." +#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting # Restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # 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..." # Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all +#REMOVEME? if ynh_legacy_permissions_exists; then +#REMOVEME? ynh_legacy_permissions_delete_all ynh_app_setting_delete --app=$app --key=is_public fi @@ -86,10 +86,10 @@ fi #================================================= # 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) -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 @@ -100,12 +100,12 @@ then ynh_script_progression --message="Upgrading source files..." # 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 -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # NGINX CONFIGURATION @@ -118,9 +118,9 @@ ynh_add_nginx_config #================================================= # 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 @@ -129,10 +129,10 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= 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" -chown $app:$app "$final_path/pagure.cfg" +chmod 400 "$install_dir/pagure.cfg" +chown $app:$app "$install_dir/pagure.cfg" #================================================= # 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}_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" #================================================= @@ -159,8 +159,8 @@ ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini" #================================================= ynh_script_progression --message="Building app..." -pushd "$final_path" - ynh_secure_remove --file="${final_path}/venv" +pushd "$install_dir" + ynh_secure_remove --file="${install_dir}/venv" python3 -m venv venv source ./venv/bin/activate pip install --upgrade pip @@ -171,15 +171,15 @@ pushd "$final_path" pip install pygit2 pip install "jinja2<3.1.0" pip install -r requirements.txt - ynh_add_config --template="../conf/alembic.ini" --destination="$final_path/alembic.ini" - PAGURE_CONFIG=${final_path}/pagure.cfg alembic upgrade head 2>&1 + ynh_add_config --template="../conf/alembic.ini" --destination="$install_dir/alembic.ini" + PAGURE_CONFIG=${install_dir}/pagure.cfg alembic upgrade head 2>&1 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 "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # GENERIC FINALIZATION @@ -219,9 +219,9 @@ ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="start" --lo #================================================= # 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 diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..953b195 --- /dev/null +++ b/tests.toml @@ -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 + # ------------ From 82a5ae0227f1b73afbdcdfb602f46472b963d6fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 15 Mar 2024 23:32:30 +0100 Subject: [PATCH 2/6] Fix dependencies --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index ec696b0..3c00aa7 100644 --- a/manifest.toml +++ b/manifest.toml @@ -74,7 +74,7 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen "python3-venv", "python3", "redis-server", - "uwsgi-plugin-python", + "uwsgi-plugin-python3", "uwsgi", "virtualenv", From cf3cda851a53424432c7471fa5f4800841556808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 15 Mar 2024 23:36:28 +0100 Subject: [PATCH 3/6] fix install --- scripts/_common.sh | 13 ++++ scripts/backup | 45 ++----------- scripts/install | 54 ++++------------ scripts/remove | 18 +----- scripts/restore | 154 +++++++-------------------------------------- 5 files changed, 57 insertions(+), 227 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..5af4c21 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,6 +4,19 @@ # COMMON VARIABLES #================================================= +services=( + "authorized_keys_worker" + "ci" + # "ev_server" + "gitolite_worker" + "loadjson" + "logcom" + # "milters" + "mirror" + "webhook" + "worker" +) + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index e084f5b..281bb3c 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,28 +8,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_print_info --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -50,27 +26,16 @@ ynh_backup --src_path="$install_dir" ynh_backup --src_path="$data_dir" --is_big #================================================= -# BACKUP THE NGINX CONFIGURATION +# BACKUP THE SYSTEM CONFIGURATION #================================================= ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP SYSTEMD -#================================================= +for service in "${services[@]}"; do + ynh_backup --src_path="/etc/systemd/system/${app}_${service}.service" +done -ynh_backup --src_path="/etc/systemd/system/${app}_authorized_keys_worker.service" -ynh_backup --src_path="/etc/systemd/system/${app}_ci.service" -#ynh_backup --src_path="/etc/systemd/system/${app}_ev_server.service" -ynh_backup --src_path="/etc/systemd/system/${app}_gitolite_worker.service" -ynh_backup --src_path="/etc/systemd/system/${app}_loadjson.service" -ynh_backup --src_path="/etc/systemd/system/${app}_logcom.service" -#ynh_backup --src_path="/etc/systemd/system/${app}_milters.service" -ynh_backup --src_path="/etc/systemd/system/${app}_mirror.service" -ynh_backup --src_path="/etc/systemd/system/${app}_webhook.service" -ynh_backup --src_path="/etc/systemd/system/${app}_worker.service" +# ynh_add_config --template="pagure.wsgi" --destination="$install_dir/pagure.wsgi" #================================================= # BACKUP THE POSTGRESQL DATABASE diff --git a/scripts/install b/scripts/install index 9fc906f..6812e5a 100755 --- a/scripts/install +++ b/scripts/install @@ -45,33 +45,13 @@ ynh_add_config --template="pagure.cfg.sample" --destination="$install_dir/pagure chmod 400 "$install_dir/pagure.cfg" chown "$app:$app" "$install_dir/pagure.cfg" -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." - -# Create a dedicated systemd config -ynh_add_systemd_config --service="${app}_authorized_keys_worker" --template="pagure_authorized_keys_worker.service" -ynh_add_systemd_config --service="${app}_ci" --template="pagure_ci.service" -# ynh_add_systemd_config --service="${app}_ev_server" --template="pagure_ev_server.service" -ynh_add_systemd_config --service="${app}_gitolite_worker" --template="pagure_gitolite_worker.service" -ynh_add_systemd_config --service="${app}_loadjson" --template="pagure_loadjson.service" -ynh_add_systemd_config --service="${app}_logcom" --template="pagure_logcom.service" -# ynh_add_systemd_config --service="${app}_milters" --template="pagure_milters.service" -ynh_add_systemd_config --service="${app}_mirror" --template="pagure_mirror.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_config --template="pagure.wsgi" --destination="$install_dir/pagure.wsgi" -ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini" - #================================================= # BUILD APP #================================================= ynh_script_progression --message="Building app..." pushd "$install_dir" - python3 -m venv venv + ynh_exec_as "$app" python3 -m venv venv ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install --upgrade pip ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install wheel ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install cffi @@ -98,16 +78,15 @@ ynh_script_progression --message="Adding system configurations related to $app.. # Create a dedicated NGINX config ynh_add_nginx_config -yunohost service add "${app}_authorized_keys_worker" -yunohost service add "${app}_ci" -#yunohost service add "${app}_ev_server" -yunohost service add "${app}_gitolite_worker" -yunohost service add "${app}_loadjson" -yunohost service add "${app}_logcom" -#yunohost service add "${app}_milters" -yunohost service add "${app}_mirror" -yunohost service add "${app}_webhook" -yunohost service add "${app}_worker" +# Create a dedicated systemd config +for service in "${services[@]}"; do + ynh_add_systemd_config --service="${app}_${service}" --template="pagure_${service}.service" + yunohost service add "${app}_${service}" +done + +ynh_add_config --template="pagure.wsgi" --destination="$install_dir/pagure.wsgi" +ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini" +yunohost service add "uwsgi-app@$app" #================================================= # START SYSTEMD SERVICE @@ -115,16 +94,9 @@ yunohost service add "${app}_worker" ynh_script_progression --message="Starting 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}_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}_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}_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}_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}_worker" --action="start" --log_path="systemd" --line_match="ready" +for service in "${services[@]}"; do + ynh_systemd_action --service_name="${app}_${service}" --action="start" --log_path="systemd" --line_match="ready" +done ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="start" --log_path="systemd" --line_match="Started" diff --git a/scripts/remove b/scripts/remove index 6fab851..ef49fe5 100755 --- a/scripts/remove +++ b/scripts/remove @@ -14,23 +14,11 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 -services=( - "${app}_authorized_keys_worker" - "${app}_ci" - "${app}_ev_server" - "${app}_gitolite_worker" - "${app}_loadjson" - "${app}_logcom" - "${app}_milters" - "${app}_mirror" - "${app}_webhook" - "${app}_worker" -) for service in "${services[@]}"; do - if ynh_exec_warn_less yunohost service status "$service" >/dev/null; then - yunohost service remove "$service" + if ynh_exec_warn_less yunohost service status "${app}_${service}" >/dev/null; then + yunohost service remove "${app}_${service}" fi - ynh_remove_systemd_config --service="$service" + ynh_remove_systemd_config --service="${app}_${service}" done ynh_remove_uwsgi_service --service="$app" diff --git a/scripts/restore b/scripts/restore index c4a1461..1a2d453 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -12,168 +10,62 @@ source ../settings/scripts/ynh_redis source ../settings/scripts/ynh_uwsgi_service__2 source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." - -#REMOVEME? test ! -d $install_dir \ - || ynh_die --message="There is already a directory: $install_dir " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." - -# Create the dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." +ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_restore_file --origin_path="$install_dir" -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= -ynh_script_progression --message="Restoring the data directory..." +ynh_script_progression --message="Restoring the data directory..." --weight=1 ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p $data_dir -mkdir -p "${data_dir}"/{repos,remotes,attachments,releases} - -chmod 750 "$data_dir" -chmod -R o-rwx "$data_dir" -chown -R $app:www-data "$data_dir" - -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." - -# Define and install dependencies -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies +chown -R "$app:www-data" "$data_dir" #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -#REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -#REMOVEME? ynh_psql_test_if_first_run -#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_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql + +#================================================= +# RESTORE SYSTEM CONFIGURATIONS +#================================================= +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE SYSTEMD #================================================= ynh_script_progression --message="Restoring the systemd configuration..." -ynh_restore_file --origin_path="/etc/systemd/system/${app}_authorized_keys_worker.service" -systemctl enable ${app}_authorized_keys_worker.service --quiet -ynh_restore_file --origin_path="/etc/systemd/system/${app}_ci.service" -systemctl enable ${app}_ci.service --quiet -#ynh_restore_file --origin_path="/etc/systemd/system/${app}_ev_server.service" -#systemctl enable ${app}_ev_server.service --quiet -ynh_restore_file --origin_path="/etc/systemd/system/${app}_gitolite_worker.service" -systemctl enable ${app}_gitolite_worker.service --quiet -ynh_restore_file --origin_path="/etc/systemd/system/${app}_loadjson.service" -systemctl enable ${app}_loadjson.service --quiet -ynh_restore_file --origin_path="/etc/systemd/system/${app}_logcom.service" -systemctl enable ${app}_logcom.service --quiet -#ynh_restore_file --origin_path="/etc/systemd/system/${app}_milters.service" -#systemctl enable ${app}_milters.service --quiet -ynh_restore_file --origin_path="/etc/systemd/system/${app}_mirror.service" -systemctl enable ${app}_mirror.service --quiet -ynh_restore_file --origin_path="/etc/systemd/system/${app}_webhook.service" -systemctl enable ${app}_webhook.service --quiet -ynh_restore_file --origin_path="/etc/systemd/system/${app}_worker.service" -systemctl enable ${app}_worker.service --quiet +for service in "${services[@]}"; do + ynh_restore_file --origin_path="/etc/systemd/system/${app}_${service}.service" + systemctl enable "${app}_${service}.service" --quiet + yunohost service add "${app}_${service}" +done ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini" -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - -yunohost service add ${app}_authorized_keys_worker -yunohost service add ${app}_ci -#yunohost service add ${app}_ev_server -yunohost service add ${app}_gitolite_worker -yunohost service add ${app}_loadjson -yunohost service add ${app}_logcom -#yunohost service add ${app}_milters -yunohost service add ${app}_mirror -yunohost service add ${app}_webhook -yunohost service add ${app}_worker - #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 # 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}_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}_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}_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}_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}_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" +for service in "${services[@]}"; do + ynh_systemd_action --service_name="${app}_${service}" --action="start" --log_path="systemd" --line_match="ready" +done -#================================================= -# GENERIC FINALIZATION -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="start" --log_path="systemd" --line_match="Started" ynh_systemd_action --service_name=nginx --action=reload From d9f13f2f02c0af309bf0860256d5f4fc9bcf90ef Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Fri, 15 Mar 2024 22:36:34 +0000 Subject: [PATCH 4/6] Auto-update README --- README.md | 24 +++++++++--------------- README_fr.md | 26 ++++++++++---------------- 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 67d0b24..cce38e8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ @@ -17,27 +17,21 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview A git-centered forge, python based using pygit2. +**Shipped version:** 5.13.3~ynh3 -**Shipped version:** 5.13.3~ynh2 - -**Demo:** https://pagure.io +**Demo:** ## Screenshots ![Screenshot of Pagure](./doc/screenshots/screenshot.png) -## Disclaimers / important information - -* The admin you choose during the installation has been added to the PAGURE_ADMIN_USERS -* After installation, you must create an account with the same username - ## Documentation and resources -* Official app website: -* Official admin documentation: -* Upstream app code repository: -* YunoHost Store: -* Report a bug: +- Official app website: +- Official admin documentation: +- Upstream app code repository: +- YunoHost Store: +- Report a bug: ## Developer info @@ -45,7 +39,7 @@ Please send your pull request to the [testing branch](https://github.com/YunoHos To try the testing branch, please proceed like that. -``` bash +```bash sudo yunohost app install https://github.com/YunoHost-Apps/pagure_ynh/tree/testing --debug or sudo yunohost app upgrade pagure -u https://github.com/YunoHost-Apps/pagure_ynh/tree/testing --debug diff --git a/README_fr.md b/README_fr.md index d0d9fb9..7376f7a 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,5 +1,5 @@ @@ -17,27 +17,21 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po ## Vue d’ensemble +**Version incluse :** 5.13.3~ynh3 -**Version incluse :** 5.13.3~ynh2 - -**Démo :** https://pagure.io +**Démo :** ## Captures d’écran ![Capture d’écran de Pagure](./doc/screenshots/screenshot.png) -## Avertissements / informations importantes - -* The admin you choose during the installation has been added to the PAGURE_ADMIN_USERS -* After installation, you must create an account with the same username - ## Documentations et ressources -* Site officiel de l’app : -* Documentation officielle de l’admin : -* Dépôt de code officiel de l’app : -* YunoHost Store: -* Signaler un bug : +- Site officiel de l’app : +- Documentation officielle de l’admin : +- Dépôt de code officiel de l’app : +- YunoHost Store : +- Signaler un bug : ## Informations pour les développeurs @@ -45,10 +39,10 @@ Merci de faire vos pull request sur la [branche testing](https://github.com/Yuno Pour essayer la branche testing, procédez comme suit. -``` bash +```bash sudo yunohost app install https://github.com/YunoHost-Apps/pagure_ynh/tree/testing --debug ou sudo yunohost app upgrade pagure -u https://github.com/YunoHost-Apps/pagure_ynh/tree/testing --debug ``` -**Plus d’infos sur le packaging d’applications :** \ No newline at end of file +**Plus d’infos sur le packaging d’applications :** From 19d085ad4380550760ddae90a1bde98ccf65c89b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 15 Mar 2024 23:40:31 +0100 Subject: [PATCH 5/6] Update upgrade --- scripts/change_url | 138 ++---------------------------- scripts/install | 2 +- scripts/upgrade | 209 ++++++++++----------------------------------- 3 files changed, 53 insertions(+), 296 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 4a50ae2..c5036c3 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC STARTING #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -11,87 +9,14 @@ source ynh_redis source ynh_uwsgi_service__2 source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN -#REMOVEME? old_path=$YNH_APP_OLD_PATH - -#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN -#REMOVEME? new_path=$YNH_APP_NEW_PATH - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." - -#REMOVEME? # Needed for helper "ynh_add_nginx_config" -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) - -# Add settings here as needed by your application -#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -#REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) -#REMOVEME? secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) -#REMOVEME? salt_email=$(ynh_app_setting_get --app=$app --key=salt_email) -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) - -#================================================= -# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - #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. -#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # Restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -#REMOVEME? change_domain=0 -#REMOVEME? if [ "$old_domain" != "$new_domain" ] -then - #REMOVEME? change_domain=1 -fi - -#REMOVEME? change_path=0 -#REMOVEME? if [ "$old_path" != "$new_path" ] -then - #REMOVEME? change_path=1 -fi - -#================================================= -# STANDARD MODIFICATIONS #================================================= # STOP SYSTEMD SERVICE #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=${app}_authorized_keys_worker --action="stop" --log_path="systemd" -ynh_systemd_action --service_name=${app}_ci --action="stop" --log_path="systemd" -#ynh_systemd_action --service_name=${app}_ev_server --action="stop" --log_path="systemd" -ynh_systemd_action --service_name=${app}_gitolite_worker --action="stop" --log_path="systemd" -ynh_systemd_action --service_name=${app}_loadjson --action="stop" --log_path="systemd" -ynh_systemd_action --service_name=${app}_logcom --action="stop" --log_path="systemd" -#ynh_systemd_action --service_name=${app}_milters --action="stop" --log_path="systemd" -ynh_systemd_action --service_name=${app}_mirror --action="stop" --log_path="systemd" -ynh_systemd_action --service_name=${app}_webhook --action="stop" --log_path="systemd" -ynh_systemd_action --service_name=${app}_worker --action="stop" --log_path="systemd" +for service in "${services[@]}"; do + ynh_systemd_action --service_name="${app}_${service}" --action="stop" --log_path="systemd" +done ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="stop" --log_path="systemd" #================================================= @@ -101,75 +26,30 @@ ynh_script_progression --message="Updating NGINX web server configuration..." 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 -if [ $change_path -eq 1 ] -then - # Make a backup of the original NGINX config file if modified -#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for NGINX helper -#REMOVEME? domain="$old_domain" -#REMOVEME? path="$new_path" - # Create a dedicated NGINX config -#REMOVEME? ynh_add_nginx_config -fi - -# Change the domain for NGINX -if [ $change_domain -eq 1 ] -then - # Delete file checksum for the old conf file location -#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" -#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location -#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi - -#================================================= -# SPECIFIC MODIFICATIONS #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating a configuration file..." -#REMOVEME? -domain=$new_domain -path=$new_path -ynh_add_config --template="../conf/pagure.cfg.sample" --destination="$install_dir/pagure.cfg" +ynh_add_config --template="pagure.cfg.sample" --destination="$install_dir/pagure.cfg" chmod 400 "$install_dir/pagure.cfg" -chown $app:$app "$install_dir/pagure.cfg" +chown "$app:$app" "$install_dir/pagure.cfg" -ynh_add_config --template="../conf/pagure.wsgi" --destination="$install_dir/pagure.wsgi" +ynh_add_config --template="pagure.wsgi" --destination="$install_dir/pagure.wsgi" ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini" -#================================================= -# GENERIC FINALISATION #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting 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}_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}_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}_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}_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}_worker --action="start" --log_path="systemd" --line_match="ready" +for service in "${services[@]}"; do + ynh_systemd_action --service_name="${app}_${service}" --action="start" --log_path="systemd" --line_match="ready" +done ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="start" --log_path="systemd" --line_match="Started" -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." - -#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index 6812e5a..bc27fb2 100755 --- a/scripts/install +++ b/scripts/install @@ -91,7 +91,7 @@ yunohost service add "uwsgi-app@$app" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting $app's systemd services..." # Start a systemd service for service in "${services[@]}"; do diff --git a/scripts/upgrade b/scripts/upgrade index 8934678..64d14ed 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -11,148 +9,41 @@ source ynh_redis source ynh_uwsgi_service__2 source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) -#REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) -#REMOVEME? secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) -#REMOVEME? salt_email=$(ynh_app_setting_get --app=$app --key=salt_email) - -#================================================= -# CHECK VERSION -#================================================= -ynh_script_progression --message="Checking version..." - -upgrade_type=$(ynh_check_app_version_changed) - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting - # Restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=${app}_authorized_keys_worker --action="stop" --log_path="systemd" -ynh_systemd_action --service_name=${app}_ci --action="stop" --log_path="systemd" -#ynh_systemd_action --service_name=${app}_ev_server --action="stop" --log_path="systemd" -ynh_systemd_action --service_name=${app}_gitolite_worker --action="stop" --log_path="systemd" -ynh_systemd_action --service_name=${app}_loadjson --action="stop" --log_path="systemd" -ynh_systemd_action --service_name=${app}_logcom --action="stop" --log_path="systemd" -#ynh_systemd_action --service_name=${app}_milters --action="stop" --log_path="systemd" -ynh_systemd_action --service_name=${app}_mirror --action="stop" --log_path="systemd" -ynh_systemd_action --service_name=${app}_webhook --action="stop" --log_path="systemd" -ynh_systemd_action --service_name=${app}_worker --action="stop" --log_path="systemd" +for service in "${services[@]}"; do + ynh_systemd_action --service_name="${app}_${service}" --action="stop" --log_path="systemd" +done ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="stop" --log_path="systemd" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." - -# Cleaning legacy permissions -#REMOVEME? if ynh_legacy_permissions_exists; then -#REMOVEME? ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" +# ynh_script_progression --message="Ensuring downward compatibility..." #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Upgrading source files..." -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Upgrading source files..." +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source --dest_dir="$install_dir" - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$install_dir" -fi - -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." - -# Create a dedicated NGINX config -ynh_add_nginx_config - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." - -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# SPECIFIC UPGRADE #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating a configuration file..." -ynh_add_config --template="../conf/pagure.cfg.sample" --destination="$install_dir/pagure.cfg" +ynh_add_config --template="pagure.cfg.sample" --destination="$install_dir/pagure.cfg" chmod 400 "$install_dir/pagure.cfg" -chown $app:$app "$install_dir/pagure.cfg" - -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." - -# Create a dedicated systemd config -ynh_add_systemd_config --service="${app}_authorized_keys_worker" --template="pagure_authorized_keys_worker.service" -ynh_add_systemd_config --service="${app}_ci" --template="pagure_ci.service" -#ynh_add_systemd_config --service="${app}_ev_server" --template="pagure_ev_server.service" -ynh_add_systemd_config --service="${app}_gitolite_worker" --template="pagure_gitolite_worker.service" -ynh_add_systemd_config --service="${app}_loadjson" --template="pagure_loadjson.service" -ynh_add_systemd_config --service="${app}_logcom" --template="pagure_logcom.service" -#ynh_add_systemd_config --service="${app}_milters" --template="pagure_milters.service" -ynh_add_systemd_config --service="${app}_mirror" --template="pagure_mirror.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_config --template="../conf/pagure.wsgi" --destination="$install_dir/pagure.wsgi" -ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini" +chown "$app:$app" "$install_dir/pagure.cfg" #================================================= # BUILD APP @@ -160,69 +51,55 @@ ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini" ynh_script_progression --message="Building app..." pushd "$install_dir" - ynh_secure_remove --file="${install_dir}/venv" - python3 -m venv venv - source ./venv/bin/activate - pip install --upgrade pip - pip install wheel - pip install cffi - pip install psycopg2 - pip install pyyaml - pip install pygit2 - pip install "jinja2<3.1.0" - pip install -r requirements.txt - ynh_add_config --template="../conf/alembic.ini" --destination="$install_dir/alembic.ini" - PAGURE_CONFIG=${install_dir}/pagure.cfg alembic upgrade head 2>&1 + ynh_secure_remove --file="${install_dir}/venv" + ynh_exec_as "$app" python3 -m venv venv + ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install --upgrade pip + ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install wheel + ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install cffi + ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install psycopg2 + ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install pyyaml + ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install pygit2 + ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install "jinja2<3.1.0" + ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install -r requirements.txt + + ynh_add_config --template="alembic.ini" --destination="$install_dir/alembic.ini" + ynh_exec_as "$app" PAGURE_CONFIG="${install_dir}/pagure.cfg" "$install_dir/venv/bin/python3" alembic upgrade head 2>&1 popd ynh_replace_string --match_string="validators.Required" --replace_string="validators.DataRequired" --target_file="$install_dir/pagure/forms.py" -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= -# GENERIC FINALIZATION +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 -yunohost service add ${app}_authorized_keys_worker -yunohost service add ${app}_ci -#yunohost service add ${app}_ev_server -yunohost service add ${app}_gitolite_worker -yunohost service add ${app}_loadjson -yunohost service add ${app}_logcom -#yunohost service add ${app}_milters -yunohost service add ${app}_mirror -yunohost service add ${app}_webhook -yunohost service add ${app}_worker +# Create a dedicated NGINX config +ynh_add_nginx_config + +# Create a dedicated systemd config +for service in "${services[@]}"; do + ynh_add_systemd_config --service="${app}_${service}" --template="pagure_${service}.service" + yunohost service add "${app}_${service}" +done + +ynh_add_config --template="pagure.wsgi" --destination="$install_dir/pagure.wsgi" +ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting $app's systemd services..." + +# Start a systemd service +for service in "${services[@]}"; do + ynh_systemd_action --service_name="${app}_${service}" --action="start" --log_path="systemd" --line_match="ready" +done -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}_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}_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}_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}_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="uwsgi-app@$app.service" --action="start" --log_path="systemd" --line_match="Started" -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= From 11ba09c729e039256827b69873ca5d37889e83e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 15 Mar 2024 23:41:16 +0100 Subject: [PATCH 6/6] Cleanup start line_match --- scripts/change_url | 2 +- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index c5036c3..8ea339d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -48,7 +48,7 @@ ynh_script_progression --message="Starting a systemd service..." for service in "${services[@]}"; do ynh_systemd_action --service_name="${app}_${service}" --action="start" --log_path="systemd" --line_match="ready" done -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" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index bc27fb2..f6c493d 100755 --- a/scripts/install +++ b/scripts/install @@ -98,7 +98,7 @@ for service in "${services[@]}"; do ynh_systemd_action --service_name="${app}_${service}" --action="start" --log_path="systemd" --line_match="ready" done -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" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 1a2d453..f74c8d9 100644 --- a/scripts/restore +++ b/scripts/restore @@ -65,7 +65,7 @@ for service in "${services[@]}"; do ynh_systemd_action --service_name="${app}_${service}" --action="start" --log_path="systemd" --line_match="ready" done -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" ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 64d14ed..8018c00 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -98,7 +98,7 @@ for service in "${services[@]}"; do ynh_systemd_action --service_name="${app}_${service}" --action="start" --log_path="systemd" --line_match="ready" done -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" #================================================= # END OF SCRIPT