From eee5fa80df452dc243c9886d71be5594c8b0ad27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sun, 23 Jun 2024 13:30:03 +0200 Subject: [PATCH 1/2] Update READMEs --- ALL_README.md | 4 +++- README.md | 6 +++++- README_es.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++ README_eu.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++ README_fr.md | 4 ++++ README_gl.md | 4 ++++ README_zh_Hans.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 181 insertions(+), 2 deletions(-) create mode 100644 README_es.md create mode 100644 README_eu.md create mode 100644 README_zh_Hans.md diff --git a/ALL_README.md b/ALL_README.md index 3d6c579..152f2e7 100644 --- a/ALL_README.md +++ b/ALL_README.md @@ -1,6 +1,8 @@ # All available README files by language - [Read the README in English](README.md) +- [Lea el README en español](README_es.md) +- [Irakurri README euskaraz](README_eu.md) - [Lire le README en français](README_fr.md) - [Le o README en galego](README_gl.md) -- [Leggi il “README” in italiano](README_it.md) +- [阅读中文(简体)的 README](README_zh_Hans.md) diff --git a/README.md b/README.md index 1eafb97..c82133d 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ It shall NOT be edited by hand. [![Install Distbin with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=distbin) -*[Read this README is other languages.](./ALL_README.md)* +*[Read this README in other languages.](./ALL_README.md)* > *This package allows you to install Distbin quickly and simply on a YunoHost server.* > *If you don't have YunoHost, please consult [the guide](https://yunohost.org/install) to learn how to install it.* @@ -29,6 +29,10 @@ A networked place to store posted web documents. This is meant to allow for dist ![Screenshot of Distbin](./doc/screenshots/screenshot.PNG) +## :red_circle: Antifeatures + +- **Upstream not maintained**: This software is not maintained anymore. Expect it to break down over time, be exposed to unfixed security breaches, etc. + ## Documentation and resources - Official app website: diff --git a/README_es.md b/README_es.md new file mode 100644 index 0000000..6cf2a3e --- /dev/null +++ b/README_es.md @@ -0,0 +1,55 @@ + + +# Distbin para Yunohost + +[![Nivel de integración](https://dash.yunohost.org/integration/distbin.svg)](https://dash.yunohost.org/appci/app/distbin) ![Estado funcional](https://ci-apps.yunohost.org/ci/badges/distbin.status.svg) ![Estado En Mantención](https://ci-apps.yunohost.org/ci/badges/distbin.maintain.svg) + +[![Instalar Distbin con Yunhost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=distbin) + +*[Leer este README en otros idiomas.](./ALL_README.md)* + +> *Este paquete le permite instalarDistbin rapidamente y simplement en un servidor YunoHost.* +> *Si no tiene YunoHost, visita [the guide](https://yunohost.org/install) para aprender como instalarla.* + +## Descripción general + +A distributed pastebin. i.e. it is a service where anyone can post things on the web, and others can react by posting anywhere else on the web (including here). + +A networked place to store posted web documents. This is meant to allow for distributed social commentary and reaction around these documents using best practices recommended or noted by the W3C Social Web Working Group. + + +**Versión actual:** 1.3.0~ynh13 + +**Demo:** + +## Capturas + +![Captura de Distbin](./doc/screenshots/screenshot.PNG) + +## :red_circle: Características no deseables + +- **Upstream not maintained**: This software is not maintained anymore. Expect it to break down over time, be exposed to unfixed security breaches, etc. + +## Documentaciones y recursos + +- Sitio web oficial: +- Repositorio del código fuente oficial de la aplicación : +- Catálogo YunoHost: +- Reportar un error: + +## Información para desarrolladores + +Por favor enviar sus correcciones a la [`branch testing`](https://github.com/YunoHost-Apps/distbin_ynh/tree/testing + +Para probar la rama `testing`, sigue asÍ: + +```bash +sudo yunohost app install https://github.com/YunoHost-Apps/distbin_ynh/tree/testing --debug +o +sudo yunohost app upgrade distbin -u https://github.com/YunoHost-Apps/distbin_ynh/tree/testing --debug +``` + +**Mas informaciones sobre el empaquetado de aplicaciones:** diff --git a/README_eu.md b/README_eu.md new file mode 100644 index 0000000..4b900c8 --- /dev/null +++ b/README_eu.md @@ -0,0 +1,55 @@ + + +# Distbin YunoHost-erako + +[![Integrazio maila](https://dash.yunohost.org/integration/distbin.svg)](https://dash.yunohost.org/appci/app/distbin) ![Funtzionamendu egoera](https://ci-apps.yunohost.org/ci/badges/distbin.status.svg) ![Mantentze egoera](https://ci-apps.yunohost.org/ci/badges/distbin.maintain.svg) + +[![Instalatu Distbin YunoHost-ekin](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=distbin) + +*[Irakurri README hau beste hizkuntzatan.](./ALL_README.md)* + +> *Pakete honek Distbin YunoHost zerbitzari batean azkar eta zailtasunik gabe instalatzea ahalbidetzen dizu.* +> *YunoHost ez baduzu, kontsultatu [gida](https://yunohost.org/install) nola instalatu ikasteko.* + +## Aurreikuspena + +A distributed pastebin. i.e. it is a service where anyone can post things on the web, and others can react by posting anywhere else on the web (including here). + +A networked place to store posted web documents. This is meant to allow for distributed social commentary and reaction around these documents using best practices recommended or noted by the W3C Social Web Working Group. + + +**Paketatutako bertsioa:** 1.3.0~ynh13 + +**Demoa:** + +## Pantaila-argazkiak + +![Distbin(r)en pantaila-argazkia](./doc/screenshots/screenshot.PNG) + +## :red_circle: Ezaugarri zalantzagarriak + +- **Jatorrizko garapena utzita**: Software honek ez du arduradunik. Denborak aurrera egin ahala funtzionatzeari utziko dio, konpondu gabeko segurtasun arazoak izango ditu, etab. + +## Dokumentazioa eta baliabideak + +- Aplikazioaren webgune ofiziala: +- Jatorrizko aplikazioaren kode-gordailua: +- YunoHost Denda: +- Eman errore baten berri: + +## Garatzaileentzako informazioa + +Bidali `pull request`a [`testing` abarrera](https://github.com/YunoHost-Apps/distbin_ynh/tree/testing). + +`testing` abarra probatzeko, ondorengoa egin: + +```bash +sudo yunohost app install https://github.com/YunoHost-Apps/distbin_ynh/tree/testing --debug +edo +sudo yunohost app upgrade distbin -u https://github.com/YunoHost-Apps/distbin_ynh/tree/testing --debug +``` + +**Informazio gehiago aplikazioaren paketatzeari buruz:** diff --git a/README_fr.md b/README_fr.md index 104100c..183f820 100644 --- a/README_fr.md +++ b/README_fr.md @@ -29,6 +29,10 @@ A networked place to store posted web documents. This is meant to allow for dist ![Capture d’écran de Distbin](./doc/screenshots/screenshot.PNG) +## :red_circle: Anti-fonctionnalités + +- **Application non maintenue **: Ce logiciel n'est plus maintenu. Attendez-vous à ce qu'il ne fonctionne plus avec le temps, et que l'on découvre des failles de sécurité qui ne seront pas corrigées, etc. + ## Documentations et ressources - Site officiel de l’app : diff --git a/README_gl.md b/README_gl.md index 1dfd30c..f12acc9 100644 --- a/README_gl.md +++ b/README_gl.md @@ -29,6 +29,10 @@ A networked place to store posted web documents. This is meant to allow for dist ![Captura de pantalla de Distbin](./doc/screenshots/screenshot.PNG) +## :red_circle: Debes considerar + +- **Upstream not maintained**: This software is not maintained anymore. Expect it to break down over time, be exposed to unfixed security breaches, etc. + ## Documentación e recursos - Web oficial da app: diff --git a/README_zh_Hans.md b/README_zh_Hans.md new file mode 100644 index 0000000..b04af43 --- /dev/null +++ b/README_zh_Hans.md @@ -0,0 +1,55 @@ + + +# YunoHost 上的 Distbin + +[![集成程度](https://dash.yunohost.org/integration/distbin.svg)](https://dash.yunohost.org/appci/app/distbin) ![工作状态](https://ci-apps.yunohost.org/ci/badges/distbin.status.svg) ![维护状态](https://ci-apps.yunohost.org/ci/badges/distbin.maintain.svg) + +[![使用 YunoHost 安装 Distbin](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=distbin) + +*[阅读此 README 的其它语言版本。](./ALL_README.md)* + +> *通过此软件包,您可以在 YunoHost 服务器上快速、简单地安装 Distbin。* +> *如果您还没有 YunoHost,请参阅[指南](https://yunohost.org/install)了解如何安装它。* + +## 概况 + +A distributed pastebin. i.e. it is a service where anyone can post things on the web, and others can react by posting anywhere else on the web (including here). + +A networked place to store posted web documents. This is meant to allow for distributed social commentary and reaction around these documents using best practices recommended or noted by the W3C Social Web Working Group. + + +**分发版本:** 1.3.0~ynh13 + +**演示:** + +## 截图 + +![Distbin 的截图](./doc/screenshots/screenshot.PNG) + +## :red_circle: 负面特征 + +- **Upstream not maintained**: This software is not maintained anymore. Expect it to break down over time, be exposed to unfixed security breaches, etc. + +## 文档与资源 + +- 官方应用网站: +- 上游应用代码库: +- YunoHost 商店: +- 报告 bug: + +## 开发者信息 + +请向 [`testing` 分支](https://github.com/YunoHost-Apps/distbin_ynh/tree/testing) 发送拉取请求。 + +如要尝试 `testing` 分支,请这样操作: + +```bash +sudo yunohost app install https://github.com/YunoHost-Apps/distbin_ynh/tree/testing --debug +或 +sudo yunohost app upgrade distbin -u https://github.com/YunoHost-Apps/distbin_ynh/tree/testing --debug +``` + +**有关应用打包的更多信息:** From 9c8c7df41f86a3e37f14d2432b8ccedc3f1f59ba Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Fri, 30 Aug 2024 22:49:05 +0200 Subject: [PATCH 2/2] [autopatch] Automatic patch attempt for helpers 2.1 --- conf/.env | 2 +- conf/systemd.service | 2 +- manifest.toml | 3 +- scripts/_common.sh | 16 ++------- scripts/backup | 23 ++++--------- scripts/change_url | 36 ++++++++------------ scripts/install | 60 +++++++++++++++------------------ scripts/remove | 22 +++++------- scripts/restore | 49 +++++++++++---------------- scripts/upgrade | 79 ++++++++++++++++++-------------------------- 10 files changed, 113 insertions(+), 179 deletions(-) diff --git a/conf/.env b/conf/.env index a44c5d0..eaac2b3 100644 --- a/conf/.env +++ b/conf/.env @@ -1,5 +1,5 @@ # The path to NODEJS -PATH=__YNH_NODE_LOAD_PATH__ +PATH=PATH=__PATH_WITH_NODEJS__ # The port used by the application PORT=__PORT__ diff --git a/conf/systemd.service b/conf/systemd.service index 08af0f9..c435e43 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,7 +7,7 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__INSTALL_DIR__/ -ExecStart=__YNH_NODE__ __INSTALL_DIR__/dist/bin/server >> +ExecStart=__NODEJS_DIR__/node __INSTALL_DIR__/dist/bin/server >> StandardOutput=append:/var/log/__APP__/__APP__.log StandardError=inherit Restart=always diff --git a/manifest.toml b/manifest.toml index a6950a5..4c2bb9c 100644 --- a/manifest.toml +++ b/manifest.toml @@ -16,7 +16,8 @@ demo = "https://distbin.com/" code = "https://github.com/gobengo/distbin" [integration] -yunohost = ">= 11.2" +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 3693f10..eaae793 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,19 +1,7 @@ #!/bin/bash #================================================= -# COMMON VARIABLES +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= -NODEJS_VERSION=16 - -#================================================= -# PERSONAL HELPERS -#================================================= - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= +nodejs_version=16 diff --git a/scripts/backup b/scripts/backup index d4006e2..8ff9300 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,37 +1,28 @@ #!/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" #================================================= # SPECIFIC BACKUP @@ -39,16 +30,16 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" # BACKUP LOGROTATE #================================================= -ynh_backup --src_path="/etc/logrotate.d/$app" +ynh_backup "/etc/logrotate.d/$app" #================================================= # BACKUP SYSTEMD #================================================= -ynh_backup --src_path="/etc/systemd/system/$app.service" +ynh_backup "/etc/systemd/system/$app.service" #================================================= # 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 783cb76..0b88d92 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,39 +1,31 @@ #!/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..." +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped" +ynh_systemctl --service=$app --action="stop" --log_path=systemd --wait_until="Stopped" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx #================================================= # SPECIFIC MODIFICATIONS #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_print_info --message="Modifying config file..." +ynh_print_info "Modifying config file..." config="$install_dir/.env" -ynh_backup_if_checksum_is_different --file="$config" +ynh_backup_if_checksum_is_different "$config" # Change the URL in the configuration file @@ -44,27 +36,25 @@ else new_domain_uri="$new_domain$new_path" fi -ynh_replace_string --match_string="EXTERNAL_URL=.*" --replace_string="EXTERNAL_URL=https://$new_domain_uri/" --target_file="$config" +ynh_replace --match="EXTERNAL_URL=.*" --replace="EXTERNAL_URL=https://$new_domain_uri/" --file="$config" #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= -ynh_print_info --message="Storing the config file checksum..." +ynh_print_info "Storing the config file checksum..." # Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$config" +ynh_store_file_checksum "$config" -#================================================= -# GENERIC FINALISATION #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression "Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started" +ynh_systemctl --service=$app --action="start" --log_path=systemd --wait_until="Started" -if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then +if ynh_in_ci_tests; then sleep 60 fi @@ -72,4 +62,4 @@ fi # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index a8830b9..e784de2 100644 --- a/scripts/install +++ b/scripts/install @@ -1,89 +1,83 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." +ynh_script_progression "Installing dependencies..." -ynh_install_nodejs --nodejs_version=$NODEJS_VERSION +ynh_nodejs_install #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." +ynh_script_progression "Setting up source files..." ynh_setup_source --dest_dir="$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 -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" #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." +ynh_script_progression "Configuring $app's systemd service..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated systemd config -ynh_add_systemd_config +ynh_config_add_systemd # Use logrotate to manage application logfile(s) -ynh_use_logrotate +ynh_config_add_logrotate yunohost service add $app --description="Distributed pastebin" --log="/var/log/$app/$app.log" mkdir -p "/var/log/$app" -chmod 750 "/var/log/$app" -chmod -R o-rwx "/var/log/$app" -chown -R $app:$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 | chmod 750 "/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 | chmod -R o-rwx "/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:$app "/var/log/$app" #================================================= # SPECIFIC SETUP #================================================= # INSTALLING DISTBIN #================================================= -ynh_script_progression --message="Installing Distbin..." +ynh_script_progression "Installing Distbin..." pushd $install_dir - ynh_use_nodejs - ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts - ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm run build - ynh_exec_warn_less ynh_exec_as $app cp -af package* dist/ + + ynh_hide_warnings ynh_exec_as_app node_load_PATH npm install --ignore-scripts + ynh_hide_warnings ynh_exec_as_app node_load_PATH npm run build + ynh_hide_warnings ynh_exec_as_app cp -af package* dist/ + popd pushd $install_dir/dist - ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts --production + ynh_hide_warnings ynh_exec_as_app node_load_PATH npm install --ignore-scripts --production popd #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." +ynh_script_progression "Adding $app's configuration..." -ynh_add_config --template="../conf/.env" --destination="$install_dir/.env" +ynh_config_add --template=".env" --destination="$install_dir/.env" -chmod 400 "$install_dir/.env" -chown $app:$app "$install_dir/.env" +#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/.env" +#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 | chown $app:$app "$install_dir/.env" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression "Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started" +ynh_systemctl --service=$app --action="start" --log_path=systemd --wait_until="Started" -if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then +if ynh_in_ci_tests; then sleep 60 fi @@ -91,4 +85,4 @@ fi # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index f0f5cad..4f07ded 100644 --- 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,29 +10,29 @@ 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..." + ynh_script_progression "Removing $app service integration..." yunohost service remove $app fi # Remove the dedicated systemd config -ynh_remove_systemd_config +ynh_config_remove_systemd # 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_remove_nodejs +ynh_nodejs_remove # Remove the log files -ynh_secure_remove --file="/var/log/$app" +#REMOVEME? (Apps should not remove their log dir during remove ... this should only happen if --purge is used, and be handled by the core...) ynh_safe_rm "/var/log/$app" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 6f81649..dbe4bce 100644 --- 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,65 +7,62 @@ source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$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 -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..." +ynh_script_progression "Restoring the data directory..." -ynh_restore_file --origin_path="$data_dir" --not_mandatory +ynh_restore "$data_dir" chown -R $app:www-data "$data_dir" #================================================= # CREATE LOG FOLDER #================================================= -ynh_script_progression --message="Creating log folder..." +ynh_script_progression "Creating log folder..." mkdir -p "/var/log/$app" -chmod 750 "/var/log/$app" -chmod -R o-rwx "/var/log/$app" -chown -R $app:$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 | chmod 750 "/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 | chmod -R o-rwx "/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:$app "/var/log/$app" -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_install_nodejs --nodejs_version=$NODEJS_VERSION +ynh_nodejs_install -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +ynh_restore "/etc/systemd/system/$app.service" systemctl enable $app.service --quiet -ynh_restore_file --origin_path="/etc/logrotate.d/$app" +ynh_restore "/etc/logrotate.d/$app" yunohost service add $app --description="Distributed pastebin" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started" +ynh_systemctl --service=$app --action="start" --log_path=systemd --wait_until="Started" -if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then +if ynh_in_ci_tests; then sleep 60 fi -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +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" +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 511e954..7675b74 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,114 +1,99 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# CHECK VERSION -#================================================= - -upgrade_type=$(ynh_check_app_version_changed) - -#================================================= -# STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped" +ynh_systemctl --service=$app --action="stop" --log_path=systemd --wait_until="Stopped" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -if [ "$upgrade_type" == "UPGRADE_APP" ] +# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed +if ynh_app_upstream_version_changed then - ynh_script_progression --message="Upgrading source files..." + ynh_script_progression "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" fi -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 -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..." +ynh_script_progression "Upgrading NGINX web server configuration..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx -ynh_install_nodejs --nodejs_version=$NODEJS_VERSION +ynh_nodejs_install -#================================================= -# SPECIFIC UPGRADE #================================================= # CREATE LOG FOLDER #================================================= -ynh_script_progression --message="Creating log folder..." +ynh_script_progression "Creating log folder..." mkdir -p "/var/log/$app" -chmod 750 "/var/log/$app" -chmod -R o-rwx "/var/log/$app" -chown -R $app:$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 | chmod 750 "/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 | chmod -R o-rwx "/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:$app "/var/log/$app" #================================================= # MAKE UPGRADE #================================================= -ynh_script_progression --message="Making upgrade..." +ynh_script_progression "Making upgrade..." pushd $install_dir - ynh_use_nodejs - ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts - ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm run build - ynh_exec_warn_less ynh_exec_as $app cp -af package* dist/ + + ynh_hide_warnings ynh_exec_as_app node_load_PATH npm install --ignore-scripts + ynh_hide_warnings ynh_exec_as_app node_load_PATH npm run build + ynh_hide_warnings ynh_exec_as_app cp -af package* dist/ + popd pushd $install_dir/dist - ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts --production + ynh_hide_warnings ynh_exec_as_app node_load_PATH npm install --ignore-scripts --production popd #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a config file..." +ynh_script_progression "Updating a config file..." -ynh_add_config --template="../conf/.env" --destination="$install_dir/.env" +ynh_config_add --template=".env" --destination="$install_dir/.env" -chmod 400 "$install_dir/.env" -chown $app:$app "$install_dir/.env" +#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/.env" +#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 | chown $app:$app "$install_dir/.env" #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." +ynh_script_progression "Upgrading systemd configuration..." # Create a dedicated systemd config -ynh_add_systemd_config +ynh_config_add_systemd # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append +ynh_config_add_logrotate yunohost service add $app --description="Distributed pastebin" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started" +ynh_systemctl --service=$app --action="start" --log_path=systemd --wait_until="Started" -if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then +if ynh_in_ci_tests; then sleep 60 fi @@ -116,4 +101,4 @@ fi # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" +ynh_script_progression "Upgrade of $app completed"