From c74280980be676894123ef23ec571b399f4f526c Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sat, 31 Aug 2024 02:50:19 +0200 Subject: [PATCH] [autopatch] Automatic patch attempt for helpers 2.1 --- .gitignore | 1 + manifest.toml | 3 +- scripts/_common.sh | 14 +--- scripts/backup | 33 +++------ scripts/change_url | 42 +++++------ scripts/install | 97 ++++++++++++------------ scripts/remove | 25 +++---- scripts/restore | 84 ++++++++++----------- scripts/upgrade | 114 +++++++++++++---------------- sources/extra_files/app/.gitignore | 2 - sources/patches/.gitignore | 2 - 11 files changed, 178 insertions(+), 239 deletions(-) delete mode 100644 sources/extra_files/app/.gitignore delete mode 100644 sources/patches/.gitignore diff --git a/.gitignore b/.gitignore index 783a4ae..8f144f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *~ *.sw[op] +.DS_Store diff --git a/manifest.toml b/manifest.toml index d5d2e29..c614bae 100644 --- a/manifest.toml +++ b/manifest.toml @@ -18,7 +18,8 @@ userdoc = "https://paperless-ngx.readthedocs.io/en/latest/usage_overview.html" code = "https://github.com/paperless-ngx/paperless-ngx" [integration] -yunohost = ">= 11.2.12" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = true ldap = false diff --git a/scripts/_common.sh b/scripts/_common.sh index c2c97cc..d4bd3a5 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,20 +1,8 @@ #!/bin/bash #================================================= -# COMMON VARIABLES +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= timezone=$(cat /etc/timezone) main_domain=$(cat /etc/yunohost/current_host) - -#================================================= -# PERSONAL HELPERS -#================================================= - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= diff --git a/scripts/backup b/scripts/backup index c1e87bf..3d9674c 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,54 +1,45 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir" +ynh_backup "$install_dir" #================================================= # BACKUP THE DATA DIR #================================================= -ynh_backup --src_path="$data_dir" --is_big +ynh_backup "$data_dir" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_backup --src_path="/etc/logrotate.d/$app" +ynh_backup "/etc/logrotate.d/$app" -ynh_backup --src_path="/etc/systemd/system/$app.service" -ynh_backup --src_path="/etc/systemd/system/$app-consumer.service" -ynh_backup --src_path="/etc/systemd/system/$app-scheduler.service" -ynh_backup --src_path="/etc/systemd/system/$app-task-queue.service" +ynh_backup "/etc/systemd/system/$app.service" +ynh_backup "/etc/systemd/system/$app-consumer.service" +ynh_backup "/etc/systemd/system/$app-scheduler.service" +ynh_backup "/etc/systemd/system/$app-task-queue.service" #================================================= # BACKUP THE MYSQL DATABASE #================================================= -ynh_print_info --message="Backing up the MySQL database..." +ynh_print_info "Backing up the MySQL database..." -ynh_psql_dump_db --database="$db_name" > db.sql +ynh_psql_dump_db > db.sql #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index 6761282..d4b41a1 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,62 +1,54 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD MODIFICATIONS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app-consumer" --action="stop" --log_path="/var/log/$app/$app-consumer.log" -ynh_systemd_action --service_name="$app-scheduler" --action="stop" --log_path="/var/log/$app/$app-scheduler.log" -ynh_systemd_action --service_name="$app-task-queue" --action="stop" --log_path="/var/log/$app/$app-task-queue.log" +ynh_systemctl --service="$app" --action="stop" + +ynh_systemctl --service="$app-consumer" --action="stop" --log_path="/var/log/$app/$app-consumer.log" +ynh_systemctl --service="$app-scheduler" --action="stop" --log_path="/var/log/$app/$app-scheduler.log" +ynh_systemctl --service="$app-task-queue" --action="stop" --log_path="/var/log/$app/$app-task-queue.log" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx #================================================= # SPECIFIC MODIFICATIONS #================================================= # MODIFY A CONFIGURATION #================================================= -ynh_script_progression --message="Modifying a configuration file..." --weight=1 +ynh_script_progression "Modifying a configuration file..." domain="$new_domain" path="$new_path" -ynh_add_config --template="paperless.conf.example" --destination="$install_dir/paperless.conf" +ynh_config_add --template="paperless.conf.example" --destination="$install_dir/paperless.conf" chmod 400 "$install_dir/paperless.conf" chown $app:$app "$install_dir/paperless.conf" -#================================================= -# GENERIC FINALISATION #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app-consumer" --action="start" --log_path="/var/log/$app/$app-consumer.log" -ynh_systemd_action --service_name="$app-scheduler" --action="start" --log_path="/var/log/$app/$app-scheduler.log" -ynh_systemd_action --service_name="$app-task-queue" --action="start" --log_path="/var/log/$app/$app-task-queue.log" +ynh_systemctl --service="$app" --action="start" + +ynh_systemctl --service="$app-consumer" --action="start" --log_path="/var/log/$app/$app-consumer.log" +ynh_systemctl --service="$app-scheduler" --action="start" --log_path="/var/log/$app/$app-scheduler.log" +ynh_systemctl --service="$app-task-queue" --action="start" --log_path="/var/log/$app/$app-task-queue.log" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index bf57d28..b315d7b 100755 --- a/scripts/install +++ b/scripts/install @@ -1,56 +1,49 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=1 +ynh_script_progression "Setting up source files..." ynh_setup_source --dest_dir="$install_dir" ynh_setup_source --dest_dir="$install_dir/ghostscript" --source_id="gs" -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R $app:$app "$install_dir" - +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "$install_dir" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=1 +ynh_script_progression "Configuring NGINX web server..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx #================================================= # SPECIFIC SETUP #================================================= # INSTALL PYTHON DEPENDENCIES #================================================= -ynh_script_progression --message="Installing Python dependencies..." +ynh_script_progression "Installing Python dependencies..." pushd $install_dir python3 -m venv venv - chown -R "$app:" "$install_dir" + #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:" "$install_dir" ( source "$install_dir/venv/bin/activate" - ynh_exec_as $app $install_dir/venv/bin/pip3 install --upgrade pip setuptools wheel - ynh_exec_as $app $install_dir/venv/bin/pip3 install -r "$install_dir/requirements.txt" + ynh_exec_as_app $install_dir/venv/bin/pip3 install --upgrade pip setuptools wheel + ynh_exec_as_app $install_dir/venv/bin/pip3 install -r "$install_dir/requirements.txt" # Installing NLTK data mkdir -p "$install_dir/nltk_data" chown -R "$app:" "$install_dir/nltk_data" - ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/python3 -m nltk.downloader -d "$install_dir/nltk_data" snowball_data - ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/python3 -m nltk.downloader -d "$install_dir/nltk_data" stopwords - ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/python3 -m nltk.downloader -d "$install_dir/nltk_data" punkt + ynh_hide_warnings ynh_exec_as_app $install_dir/venv/bin/python3 -m nltk.downloader -d "$install_dir/nltk_data" snowball_data + ynh_hide_warnings ynh_exec_as_app $install_dir/venv/bin/python3 -m nltk.downloader -d "$install_dir/nltk_data" stopwords + ynh_hide_warnings ynh_exec_as_app $install_dir/venv/bin/python3 -m nltk.downloader -d "$install_dir/nltk_data" punkt deactivate ) @@ -59,15 +52,15 @@ popd #================================================= # BUILD GHOSTCRIPT SPECIFIC VERSION #================================================= -ynh_script_progression --message="Building Ghostscript dependency... (this will take a long time!)" +ynh_script_progression "Building Ghostscript dependency... (this will take a long time!)" pushd $install_dir/ghostscript - ynh_exec_warn_less ./configure - ynh_exec_warn_less make + ynh_hide_warnings ./configure + ynh_hide_warnings make mv bin/ $install_dir/ popd -ynh_secure_remove --file="$install_dir/ghostscript" +ynh_safe_rm "$install_dir/ghostscript" chmod -R o-rwx "$install_dir/bin" chown -R $app:$app "$install_dir/bin" chmod 550 $install_dir/bin/gs @@ -77,7 +70,7 @@ local_path=$install_dir/bin/:$PATH #================================================= # CREATE DATA DIRECTORY #================================================= -ynh_script_progression --message="Setting permissions for the data directory..." --weight=1 +ynh_script_progression "Setting permissions for the data directory..." chmod 750 "$data_dir" chmod -R o-rwx "$data_dir" @@ -86,37 +79,37 @@ chown -R $app:$app "$data_dir" #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression "Adding $app's configuration..." redis_db=$(ynh_redis_get_free_db) -ynh_app_setting_set --app=$app --key=redis_db --value=$redis_db +ynh_app_setting_set --key=redis_db --value=$redis_db paperless_secret_key=$(ynh_string_random) -ynh_app_setting_set --app=$app --key=paperless_secret_key --value=$paperless_secret_key +ynh_app_setting_set --key=paperless_secret_key --value=$paperless_secret_key ocr_language="eng" -ynh_app_setting_set --app=$app --key=ocr_language --value=$ocr_language +ynh_app_setting_set --key=ocr_language --value=$ocr_language -ynh_add_config --template="paperless.conf.example" --destination="$install_dir/paperless.conf" +ynh_config_add --template="paperless.conf.example" --destination="$install_dir/paperless.conf" chmod 400 "$install_dir/paperless.conf" chown $app:$app "$install_dir/paperless.conf" # ImageMagick configuration mkdir -p "$install_dir/.config/ImageMagick" -ynh_add_config --template="policy.xml" --destination="$install_dir/.config/ImageMagick/policy.xml" -chmod 400 "$install_dir/.config/ImageMagick/policy.xml" +ynh_config_add --template="policy.xml" --destination="$install_dir/.config/ImageMagick/policy.xml" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/.config/ImageMagick/policy.xml" chown -R $app:$app "$install_dir/.config" #================================================= # SETUP THE DATABASE #================================================= -ynh_script_progression --message="Setting up the database..." --weight=1 +ynh_script_progression "Setting up the database..." pushd "$install_dir/src" ( source "$install_dir/venv/bin/activate" - ynh_exec_as $app $install_dir/venv/bin/python manage.py migrate + ynh_exec_as_app $install_dir/venv/bin/python manage.py migrate deactivate ) popd @@ -124,13 +117,13 @@ popd #================================================= # CREATE THE ADMIN USER #================================================= -ynh_script_progression --message="Creating the admin user..." --weight=1 +ynh_script_progression "Creating the admin user..." pushd "$install_dir/src" ( source "$install_dir/venv/bin/activate" email=$(ynh_user_get_info $admin 'mail') - ynh_exec_as $app env "DJANGO_SUPERUSER_PASSWORD=$admin_pw" $install_dir/venv/bin/python3 manage.py createsuperuser --noinput --username "$admin" --email "$email" + ynh_exec_as_app "DJANGO_SUPERUSER_PASSWORD=$admin_pw" $install_dir/venv/bin/python3 manage.py createsuperuser --noinput --username "$admin" --email "$email" deactivate ) popd @@ -138,28 +131,27 @@ popd #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=1 +ynh_script_progression "Configuring $app's systemd service..." # Create a dedicated systemd config -ynh_add_systemd_config --service="$app" --template="systemd.service" -ynh_add_systemd_config --service="$app-consumer" --template="systemd-consumer.service" -ynh_add_systemd_config --service="$app-scheduler" --template="systemd-scheduler.service" -ynh_add_systemd_config --service="$app-task-queue" --template="systemd-task-queue.service" +ynh_config_add_systemd + +ynh_config_add_systemd --service="$app-consumer" --template="systemd-consumer.service" +ynh_config_add_systemd --service="$app-scheduler" --template="systemd-scheduler.service" +ynh_config_add_systemd --service="$app-task-queue" --template="systemd-task-queue.service" -#================================================= -# GENERIC FINALIZATION #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 +ynh_script_progression "Configuring log rotation..." # Use logrotate to manage application logfile(s) -ynh_use_logrotate +ynh_config_add_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression "Integrating service in YunoHost..." yunohost service add "$app" --log="/var/log/$app/$app.log" yunohost service add "$app-consumer" --log="/var/log/$app/$app-consumer.log" @@ -169,15 +161,16 @@ yunohost service add "$app-task-queue" --log="/var/log/$app/$app-task-queue.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app-consumer" --action="start" --log_path="/var/log/$app/$app-consumer.log" -ynh_systemd_action --service_name="$app-scheduler" --action="start" --log_path="/var/log/$app/$app-scheduler.log" -ynh_systemd_action --service_name="$app-task-queue" --action="start" --log_path="/var/log/$app/$app-task-queue.log" +ynh_systemctl --service="$app" --action="start" + +ynh_systemctl --service="$app-consumer" --action="start" --log_path="/var/log/$app/$app-consumer.log" +ynh_systemctl --service="$app-scheduler" --action="start" --log_path="/var/log/$app/$app-scheduler.log" +ynh_systemctl --service="$app-task-queue" --action="start" --log_path="/var/log/$app/$app-task-queue.log" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index f8de052..e3b97d4 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -16,9 +10,9 @@ source /usr/share/yunohost/helpers #================================================= # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status $app >/dev/null +if ynh_hide_warnings yunohost service status $app >/dev/null then - ynh_script_progression --message="Removing $app service integration..." --weight=1 + ynh_script_progression "Removing $app service integration..." yunohost service remove "$app" yunohost service remove "$app-consumer" yunohost service remove "$app-scheduler" @@ -26,16 +20,17 @@ then fi # Remove the dedicated systemd config -ynh_remove_systemd_config --service="$app" -ynh_remove_systemd_config --service="$app-consumer" -ynh_remove_systemd_config --service="$app-scheduler" -ynh_remove_systemd_config --service="$app-task-queue" +ynh_config_remove_systemd + +ynh_config_remove_systemd"$app-consumer" +ynh_config_remove_systemd"$app-scheduler" +ynh_config_remove_systemd"$app-task-queue" # Remove the app-specific logrotate config -ynh_remove_logrotate +ynh_config_remove_logrotate # Remove the dedicated NGINX config -ynh_remove_nginx_config +ynh_config_remove_nginx # Remove metapackage and its dependencies ynh_redis_remove_db "$redis_db" @@ -44,4 +39,4 @@ ynh_redis_remove_db "$redis_db" # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index f58006f..635ad55 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -13,28 +7,27 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading additionnal settings..." --weight=1 +ynh_script_progression "Loading additionnal settings..." redis_db=$(ynh_redis_get_free_db) -ynh_app_setting_set --app=$app --key=redis_db --value=$redis_db +ynh_app_setting_set --key=redis_db --value=$redis_db #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$install_dir" - -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R $app:$app "$install_dir" +ynh_restore "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= -ynh_script_progression --message="Restoring the data directory..." --weight=1 +ynh_script_progression "Restoring the data directory..." -ynh_restore_file --origin_path="$data_dir" --not_mandatory +ynh_restore "$data_dir" mkdir -p "$data_dir/consume" mkdir -p "$data_dir/data" @@ -47,9 +40,9 @@ chown -R $app:$app "$data_dir" #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression "Adding $app's configuration..." -ynh_add_config --template="../settings/conf/paperless.conf.example" --destination="$install_dir/paperless.conf" +ynh_config_add --template="../settings/conf/paperless.conf.example" --destination="$install_dir/paperless.conf" chmod 400 "$install_dir/paperless.conf" chown $app:$app "$install_dir/paperless.conf" @@ -57,16 +50,16 @@ chown $app:$app "$install_dir/paperless.conf" #================================================= # INSTALL PYTHON DEPENDENCIES #================================================= -ynh_script_progression --message="Installing Python dependencies..." +ynh_script_progression "Installing Python dependencies..." pushd $install_dir - ynh_secure_remove --file="$install_dir/venv" + ynh_safe_rm "$install_dir/venv" python3 -m venv venv - chown -R "$app:" "$install_dir" + #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:" "$install_dir" ( source "$install_dir/venv/bin/activate" - ynh_exec_as $app $install_dir/venv/bin/pip3 install --upgrade pip setuptools wheel - ynh_exec_as $app $install_dir/venv/bin/pip3 install -r "$install_dir/requirements.txt" + ynh_exec_as_app $install_dir/venv/bin/pip3 install --upgrade pip setuptools wheel + ynh_exec_as_app $install_dir/venv/bin/pip3 install -r "$install_dir/requirements.txt" deactivate ) popd @@ -74,26 +67,26 @@ popd #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 +ynh_script_progression "Restoring the NGINX web server configuration..." -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgresSQL database..." --weight=1 +ynh_script_progression "Restoring the PostgresSQL database..." -ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +ynh_psql_db_shell < ./db.sql #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 +ynh_script_progression "Restoring $app's systemd service..." -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -ynh_restore_file --origin_path="/etc/systemd/system/$app-consumer.service" -ynh_restore_file --origin_path="/etc/systemd/system/$app-scheduler.service" -ynh_restore_file --origin_path="/etc/systemd/system/$app-task-queue.service" +ynh_restore "/etc/systemd/system/$app.service" +ynh_restore "/etc/systemd/system/$app-consumer.service" +ynh_restore "/etc/systemd/system/$app-scheduler.service" +ynh_restore "/etc/systemd/system/$app-task-queue.service" systemctl enable "$app.service" --quiet systemctl enable "$app-consumer.service" --quiet systemctl enable "$app-scheduler.service" --quiet @@ -102,17 +95,17 @@ systemctl enable "$app-task-queue.service" --quiet #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 +ynh_script_progression "Restoring the logrotate configuration..." mkdir -p "/var/log/$app" -chown -R $app: "/var/log/$app" +#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app: "/var/log/$app" -ynh_restore_file --origin_path="/etc/logrotate.d/$app" +ynh_restore "/etc/logrotate.d/$app" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression "Integrating service in YunoHost..." yunohost service add "$app" --log="/var/log/$app/$app.log" yunohost service add "$app-consumer" --log="/var/log/$app/$app-consumer.log" @@ -122,24 +115,23 @@ yunohost service add "$app-task-queue" --log="/var/log/$app/$app-task-queue.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app-consumer" --action="start" --log_path="/var/log/$app/$app-consumer.log" -ynh_systemd_action --service_name="$app-scheduler" --action="start" --log_path="/var/log/$app/$app-scheduler.log" -ynh_systemd_action --service_name="$app-task-queue" --action="start" --log_path="/var/log/$app/$app-task-queue.log" +ynh_systemctl --service="$app" --action="start" + +ynh_systemctl --service="$app-consumer" --action="start" --log_path="/var/log/$app/$app-consumer.log" +ynh_systemctl --service="$app-scheduler" --action="start" --log_path="/var/log/$app/$app-scheduler.log" +ynh_systemctl --service="$app-task-queue" --action="start" --log_path="/var/log/$app/$app-task-queue.log" -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_script_progression "Reloading NGINX web server..." -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index d7b12d4..e2ca016 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,85 +1,75 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app-consumer" --action="stop" --log_path="/var/log/$app/$app-consumer.log" -ynh_systemd_action --service_name="$app-scheduler" --action="stop" --log_path="/var/log/$app/$app-scheduler.log" -ynh_systemd_action --service_name="$app-task-queue" --action="stop" --log_path="/var/log/$app/$app-task-queue.log" +ynh_systemctl --service="$app" --action="stop" + +ynh_systemctl --service="$app-consumer" --action="stop" --log_path="/var/log/$app/$app-consumer.log" +ynh_systemctl --service="$app-scheduler" --action="stop" --log_path="/var/log/$app/$app-scheduler.log" +ynh_systemctl --service="$app-task-queue" --action="stop" --log_path="/var/log/$app/$app-task-queue.log" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +ynh_script_progression "Ensuring downward compatibility..." # If ocr_language doesn't exist, create it if [ -z "$ocr_language" ]; then ocr_language="eng" - ynh_app_setting_set --app=$app --key=ocr_language --value=$ocr_language + ynh_app_setting_set --key=ocr_language --value=$ocr_language fi if ynh_compare_current_package_version -c le -v "1.14.5~ynh1" then # When upgrading from older version when install_dir was in /var/www, # we need to rebuild the venv entierly - ynh_secure_remove --file="$install_dir/venv" + ynh_safe_rm "$install_dir/venv" fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Upgrading source files..." --weight=1 +ynh_script_progression "Upgrading source files..." ynh_setup_source --dest_dir="$install_dir" --keep="paperless.conf" -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R $app:$app "$install_dir" - +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "$install_dir" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 +ynh_script_progression "Upgrading NGINX web server configuration..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx -#================================================= -# SPECIFIC UPGRADE #================================================= # INSTALL PYTHON DEPENDENCIES #================================================= -ynh_script_progression --message="Installing Python dependencies..." --weight=5 +ynh_script_progression "Installing Python dependencies..." pushd $install_dir python3 -m venv venv - chown -R "$app:" "$install_dir" + #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:" "$install_dir" ( source "$install_dir/venv/bin/activate" - ynh_exec_as $app $install_dir/venv/bin/pip3 install --upgrade pip setuptools wheel - ynh_exec_as $app $install_dir/venv/bin/pip3 install -r "$install_dir/requirements.txt" + ynh_exec_as_app $install_dir/venv/bin/pip3 install --upgrade pip setuptools wheel + ynh_exec_as_app $install_dir/venv/bin/pip3 install -r "$install_dir/requirements.txt" # Installing NLTK data - ynh_secure_remove --file="$install_dir/nltk_data" + ynh_safe_rm "$install_dir/nltk_data" mkdir -p "$install_dir/nltk_data" chown -R "$app:" "$install_dir/nltk_data" - ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/python3 -m nltk.downloader -d "$install_dir/nltk_data" snowball_data - ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/python3 -m nltk.downloader -d "$install_dir/nltk_data" stopwords - ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/python3 -m nltk.downloader -d "$install_dir/nltk_data" punkt + ynh_hide_warnings ynh_exec_as_app $install_dir/venv/bin/python3 -m nltk.downloader -d "$install_dir/nltk_data" snowball_data + ynh_hide_warnings ynh_exec_as_app $install_dir/venv/bin/python3 -m nltk.downloader -d "$install_dir/nltk_data" stopwords + ynh_hide_warnings ynh_exec_as_app $install_dir/venv/bin/python3 -m nltk.downloader -d "$install_dir/nltk_data" punkt deactivate ) @@ -90,17 +80,17 @@ popd #================================================= if ! dpkg --compare-versions "$($install_dir/bin/gs --version 2>/dev/null)" ge "10.02.1" then - ynh_script_progression --message="Building Ghostscript dependency... (this will take a long time!)" + ynh_script_progression "Building Ghostscript dependency... (this will take a long time!)" ynh_setup_source --dest_dir="$install_dir/ghostscript" --source_id="gs" --full_replace pushd $install_dir/ghostscript - ynh_exec_warn_less ./configure - ynh_exec_warn_less make + ynh_hide_warnings ./configure + ynh_hide_warnings make mv bin/ $install_dir/ popd - ynh_secure_remove --file="$install_dir/ghostscript" + ynh_safe_rm "$install_dir/ghostscript" chmod -R o-rwx "$install_dir/bin" chown -R $app:$app "$install_dir/bin" chmod 550 $install_dir/bin/gs @@ -111,28 +101,28 @@ local_path=$install_dir/bin/:$PATH #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." --weight=1 +ynh_script_progression "Updating configuration..." -ynh_add_config --template="paperless.conf.example" --destination="$install_dir/paperless.conf" +ynh_config_add --template="paperless.conf.example" --destination="$install_dir/paperless.conf" chmod 400 "$install_dir/paperless.conf" chown $app:$app "$install_dir/paperless.conf" # ImageMagick configuration mkdir -p "$install_dir/.config/ImageMagick" -ynh_add_config --template="policy.xml" --destination="$install_dir/.config/ImageMagick/policy.xml" -chmod 400 "$install_dir/.config/ImageMagick/policy.xml" +ynh_config_add --template="policy.xml" --destination="$install_dir/.config/ImageMagick/policy.xml" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/.config/ImageMagick/policy.xml" chown -R $app:$app "$install_dir/.config" #================================================= # SETUP THE DATABASE #================================================= -ynh_script_progression --message="Setting up the database..." --weight=1 +ynh_script_progression "Setting up the database..." pushd "$install_dir/src" ( source "$install_dir/venv/bin/activate" - ynh_exec_as $app $install_dir/venv/bin/python manage.py migrate + ynh_exec_as_app $install_dir/venv/bin/python manage.py migrate deactivate ) popd @@ -140,31 +130,30 @@ popd #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 +ynh_script_progression "Upgrading systemd configuration..." # Create a dedicated systemd config -ynh_add_systemd_config --service="$app" --template="systemd.service" -ynh_add_systemd_config --service="$app-consumer" --template="systemd-consumer.service" -ynh_add_systemd_config --service="$app-scheduler" --template="systemd-scheduler.service" -ynh_add_systemd_config --service="$app-task-queue" --template="systemd-task-queue.service" +ynh_config_add_systemd + +ynh_config_add_systemd --service="$app-consumer" --template="systemd-consumer.service" +ynh_config_add_systemd --service="$app-scheduler" --template="systemd-scheduler.service" +ynh_config_add_systemd --service="$app-task-queue" --template="systemd-task-queue.service" -#================================================= -# GENERIC FINALIZATION #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 +ynh_script_progression "Upgrading logrotate configuration..." # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --logfile="/var/log/$app/$app.log" -ynh_use_logrotate --logfile="/var/log/$app/$app-consumer.log" -ynh_use_logrotate --logfile="/var/log/$app/$app-scheduler.log" -ynh_use_logrotate --logfile="/var/log/$app/$app-task-queue.log" +ynh_config_add_logrotate "/var/log/$app/$app.log" +ynh_config_add_logrotate "/var/log/$app/$app-consumer.log" +ynh_config_add_logrotate "/var/log/$app/$app-scheduler.log" +ynh_config_add_logrotate "/var/log/$app/$app-task-queue.log" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression "Integrating service in YunoHost..." yunohost service add "$app" --log="/var/log/$app/$app.log" yunohost service add "$app-consumer" --log="/var/log/$app/$app-consumer.log" @@ -174,15 +163,16 @@ yunohost service add "$app-task-queue" --log="/var/log/$app/$app-task-queue.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="$app-consumer" --action="start" --log_path="/var/log/$app/$app-consumer.log" -ynh_systemd_action --service_name="$app-scheduler" --action="start" --log_path="/var/log/$app/$app-scheduler.log" -ynh_systemd_action --service_name="$app-task-queue" --action="start" --log_path="/var/log/$app/$app-task-queue.log" +ynh_systemctl --service="$app" --action="start" + +ynh_systemctl --service="$app-consumer" --action="start" --log_path="/var/log/$app/$app-consumer.log" +ynh_systemctl --service="$app-scheduler" --action="start" --log_path="/var/log/$app/$app-scheduler.log" +ynh_systemctl --service="$app-task-queue" --action="start" --log_path="/var/log/$app/$app-task-queue.log" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed" diff --git a/sources/extra_files/app/.gitignore b/sources/extra_files/app/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/extra_files/app/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op] diff --git a/sources/patches/.gitignore b/sources/patches/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/patches/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op]