diff --git a/README.md b/README.md index 3f8dcee..2d80262 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,34 @@ # CodiMD for YunoHost [![Integration level](https://dash.yunohost.org/integration/codimd.svg)](https://dash.yunohost.org/appci/app/codimd) ![](https://ci-apps.yunohost.org/ci/badges/codimd.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/codimd.maintain.svg) -[![Install CodiMD with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=codimd) +[![Install CodiMD with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=codimd) *[Lire ce readme en français.](./README_fr.md)* > *This package allows you to install CodiMD 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.* +If you don't have YunoHost, please consult [the guide](https://yunohost.org/install) to learn how to install it.* ## Overview CodiMD is a real-time collaborative word processing web service. It uses Markdown language. -**Shipped version:** 1.6.0 +**Shipped version:** 2.3.2 ## Screenshots -![](https://demo.codimd.org/screenshot.png) +![](https://raw.githubusercontent.com/hackmdio/codimd/develop/public/screenshot.png) ## Demo -* [Official demo](https://demo.codimd.org/) +* [Official demo]() ## Configuration -You can configure CodiMD by editing this file `/var/www/codimd/config.json` using the [documentation](https://github.com/codimd/server/blob/master/docs/configuration.md) +You can configure CodiMD by editing this file `/var/www/codimd/config.json` using the [documentation](https://hackmd.io/c/codimd-documentation/%2Fs%2Fcodimd-configuration) ## Documentation - * Official documentation: https://github.com/codimd/server/tree/master/docs/ - * YunoHost documentation: https://yunohost.org/#/app_codimd + * Official documentation: https://hackmd.io/c/codimd-documentation + * YunoHost documentation: https://yunohost.org/en/app_codimd ## YunoHost specific features @@ -39,13 +39,13 @@ You can configure CodiMD by editing this file `/var/www/codimd/config.json` usin #### Supported architectures -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/codimd/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/codimd/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/codimd.svg)](https://ci-apps.yunohost.org/ci/apps/codimd/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/codimd.svg)](https://ci-apps-arm.yunohost.org/ci/apps/codimd/) ## Links * Report a bug: https://github.com/YunoHost-Apps/codimd_ynh/issues - * Upstream app repository: https://github.com/codimd/server/ + * Upstream app repository: https://github.com/hackmdio/codimd * YunoHost website: https://yunohost.org/ --- diff --git a/README_fr.md b/README_fr.md index 80b2e8c..5a3d7dd 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,34 +1,34 @@ # CodiMD pour YunoHost [![Niveau d'intégration](https://dash.yunohost.org/integration/codimd.svg)](https://dash.yunohost.org/appci/app/codimd) ![](https://ci-apps.yunohost.org/ci/badges/codimd.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/codimd.maintain.svg) -[![Installer CodiMD avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=codimd) +[![Installer CodiMD avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=codimd) *[Read this readme in english.](./README.md)* > *Ce package vous permet d'installer CodiMD rapidement et simplement sur un serveur YunoHost. -Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.* +Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/install) pour apprendre comment l'installer.* ## Vue d'ensemble CodiMD est un service web de traitement de texte collaboratif en temps réel. Il utilise le langage Markdown. -**Version incluse :** 1.6.0 +**Version incluse :** 2.3.2 ## Captures d'écran -![](https://demo.codimd.org/screenshot.png) +![](https://raw.githubusercontent.com/hackmdio/codimd/develop/public/screenshot.png) ## Démo -* [Démo officielle](https://demo.codimd.org/) +* [Démo officielle]() ## Configuration -Vous pouvez configurer CodiMD en modifiant le fichier `/var/www/codimd/config.json` et en vous aidant de la [documentation](https://github.com/codimd/server/blob/master/docs/configuration.md) +Vous pouvez configurer CodiMD en modifiant le fichier `/var/www/codimd/config.json` et en vous aidant de la [documentation](https://hackmd.io/c/codimd-documentation/%2Fs%2Fcodimd-configuration) ## Documentation - * Documentation officielle : https://github.com/codimd/server/tree/master/docs/ - * Documentation YunoHost : https://yunohost.org/#/app_codimd_fr + * Documentation officielle : https://hackmd.io/c/codimd-documentation + * Documentation YunoHost : https://yunohost.org/fr/app_codimd ## Caractéristiques spécifiques YunoHost @@ -39,13 +39,13 @@ Vous pouvez configurer CodiMD en modifiant le fichier `/var/www/codimd/config.js #### Architectures supportées -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/codimd/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/codimd%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/codimd/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/codimd.svg)](https://ci-apps.yunohost.org/ci/apps/codimd/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/codimd.svg)](https://ci-apps-arm.yunohost.org/ci/apps/codimd/) ## Liens * Signaler un bug : https://github.com/YunoHost-Apps/codimd_ynh/issues - * Dépôt de l'application principale : https://github.com/codimd/server/ + * Dépôt de l'application principale : https://github.com/hackmdio/codimd * Site web YunoHost : https://yunohost.org/ --- @@ -60,3 +60,9 @@ sudo yunohost app install https://github.com/YunoHost-Apps/codimd_ynh/tree/testi ou sudo yunohost app upgrade codimd -u https://github.com/YunoHost-Apps/codimd_ynh/tree/testing --debug ``` +it. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/codimd_ynh/tree/testing --debug +ou +sudo yunohost app upgrade codimd -u https://github.com/YunoHost-Apps/codimd_ynh/tree/testing --debug +``` diff --git a/conf/.sequelizerc.example b/conf/.sequelizerc.example index 45ef120..9b42bbf 100644 --- a/conf/.sequelizerc.example +++ b/conf/.sequelizerc.example @@ -1,8 +1,10 @@ -var path = require('path'); +const path = require('path') +const config = require('./lib/config') module.exports = { - 'config': path.resolve('config.json'), - 'migrations-path': path.resolve('lib', 'migrations'), - 'models-path': path.resolve('lib', 'models'), - 'url': 'postgres://__DB_USER__:__DB_PASS__@localhost:5432/__DB_NAME__' + config: path.resolve('config.js'), + 'migrations-path': path.resolve('lib', 'migrations'), + 'models-path': path.resolve('lib', 'models'), + url: 'postgres://__DB_NAME__:__DB_PWD__@localhost:5432/__DB_NAME__' } + diff --git a/conf/app.src b/conf/app.src index 07c73b1..a30ec83 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/codimd/server/archive/1.6.0.tar.gz -SOURCE_SUM=5cb53b9441817f2e17f998057174f89213c96924d55b444bdaac35d0e48fab03 +SOURCE_URL=https://github.com/hackmdio/codimd/archive/refs/tags/2.3.2.tar.gz +SOURCE_SUM=aa1134ed283aec23e99ae3557541e183f342031e6728d1045ec5c3b2d32b2e5f SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/config.json.example b/conf/config.json.example index 9986ac3..d361583 100644 --- a/conf/config.json.example +++ b/conf/config.json.example @@ -30,8 +30,8 @@ "addGoogleAnalytics": false }, "db": { - "username": "__DB_USER__", - "password": "__DB_PASS__", + "username": "__DB_NAME__", + "password": "__DB_PWD__", "database": "__DB_NAME__", "host": "localhost", "port": "5432", diff --git a/conf/nginx.conf b/conf/nginx.conf index 1879457..00198e1 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -17,9 +17,13 @@ location ^~ __PATH__/ { proxy_set_header Upgrade $http_upgrade; # setup for image upload - client_max_body_size 256M; - proxy_max_temp_file_size 1024M; - + client_max_body_size 8192m; + proxy_max_temp_file_size 8192m; + + # adjust proxy buffer setting + proxy_buffers 8 32k; + proxy_buffer_size 32k; + proxy_busy_buffers_size 64k; proxy_read_timeout 300; proxy_connect_timeout 300; diff --git a/conf/systemd.service b/conf/systemd.service index f8c9c59..1348510 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,6 +1,6 @@ [Unit] Description=CodiMD: collaborative Markdown notes -Documentation=https://github.com/codimd/server +Documentation=https://github.com/hackmdio/codimd After=network.target postgresql.service [Service] diff --git a/manifest.json b/manifest.json index 57c47bf..c3677d9 100644 --- a/manifest.json +++ b/manifest.json @@ -6,14 +6,14 @@ "en": "Collaborative editor to work on notes written in Markdown", "fr": "Éditeur collaboratif pour travailler sur des notes en Markdown" }, - "version": "1.6.0~ynh8", - "url": "https://github.com/codimd/server", + "version": "2.3.2~ynh1", + "url": "https://github.com/hackmdio/codimd", "license": "AGPL-3.0-only", "maintainer": { - "name": "liberodark" + "name": "" }, "requirements": { - "yunohost": ">= 3.8.1" + "yunohost": ">= 4.1.8" }, "multi_instance": true, "services": [ @@ -24,29 +24,17 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain name for CodiMD", - "fr": "Choisissez un nom de domaine pour CodiMD" - }, "example": "domain.org" }, { "name": "path", "type": "path", - "ask": { - "en": "Choose a path for CodiMD", - "fr": "Choisissez un chemin pour CodiMD" - }, "example": "/codimd", "default": "/codimd" }, { "name": "is_public", "type": "boolean", - "ask": { - "en": "Is it a public site?", - "fr": "Est-ce un site public ?" - }, "help": { "en": "If enabled, CodiMD will be accessible by people who do not have an account. This can be changed later via the webadmin.", "fr": "Si cette case est cochée, CodiMD sera accessible aux personnes n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." diff --git a/pull_request_template.md b/pull_request_template.md index b16fe61..6c28fc5 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -13,6 +13,4 @@ ## Package_check results --- -*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* - -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/codimd_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/codimd_ynh%20PR-NUM-%20(USERNAME)/) +* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"* diff --git a/scripts/change_url b/scripts/change_url index dadd871..a5b16b6 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -31,7 +31,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name -db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP @@ -113,17 +113,16 @@ fi ynh_backup_if_checksum_is_different --file="$final_path/config.json" domain=$new_domain -path_url=$new_path +path_url=${path_url:1} cp ../conf/config.json.example "$final_path/config.json" -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$final_path/config.json" +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config.json" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/config.json" +ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="$final_path/config.json" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/config.json" +ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/config.json" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$final_path/config.json" ynh_store_file_checksum --file="$final_path/config.json" @@ -135,7 +134,7 @@ ynh_store_file_checksum --file="$final_path/config.json" ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="HTTP Server listening" +ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="HTTP Server listening" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index 3ce09ca..e27059c 100644 --- a/scripts/install +++ b/scripts/install @@ -45,16 +45,15 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= ynh_script_progression --message="Storing installation settings..." --weight=2 -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=is_public --value=$is_public +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url #================================================= # STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Configuring firewall..." --weight=2 +ynh_script_progression --message="Finding an available port..." --weight=2 # Find an available port port=$(ynh_find_port --port=3000) @@ -65,13 +64,18 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= ynh_script_progression --message="Installing dependencies..." --weight=20 -ynh_install_app_dependencies $pkg_dependencies +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies # Install Nodejs ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -# Install Yarn -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=2 + +# Create a system user +ynh_system_user_create --username=$app #================================================= # CREATE A POSTGRESQL DATABASE @@ -79,14 +83,10 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2 db_name=$(ynh_sanitize_dbid --db_name=$app) -db_user=$db_name -db_pwd=$(ynh_string_random --length=30) - +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd - ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_psql_setup_db --db_user=$db_name --db_name=$db_name #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -105,14 +105,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=3 - -# Create a system user -ynh_system_user_create --username=$app --home_dir=$final_path - #================================================= # SPECIFIC SETUP #============================================== @@ -120,50 +112,32 @@ ynh_system_user_create --username=$app --home_dir=$final_path #============================================== ynh_script_progression --message="Building CodiMD... (this will take some time and resources!)" --weight=24 +chown -R $app: $final_path + pushd "$final_path" || ynh_die - ynh_use_nodejs - bin/setup - ynh_exec_warn_less yarn run build - + ynh_exec_warn_less bin/setup + ynh_exec_as $app env $ynh_node_load_PATH npm update + ynh_exec_as $app env $ynh_node_load_PATH npm run build popd || ynh_die -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=1 - -ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service" - -ynh_add_systemd_config - #================================================= # MODIFY A CONFIG FILE #================================================= ynh_script_progression --message="Modifying a config file..." -cp ../conf/config.json.example "$final_path/config.json" +path=${path_url:1} +ynh_add_config --template="../conf/config.json.example" --destination="$final_path/config.json" +ynh_add_config --template="../conf/.sequelizerc.example" --destination="$final_path/.sequelizerc" -# Main config File -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$final_path/config.json" +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Configuring a systemd service..." --weight=1 -ynh_store_file_checksum --file="$final_path/config.json" - -cp ../conf/.sequelizerc.example "$final_path/.sequelizerc" - -# DB Config File -ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$final_path/.sequelizerc" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/.sequelizerc" -ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="$final_path/.sequelizerc" - -ynh_store_file_checksum --file="$final_path/.sequelizerc" +ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service" +ynh_add_systemd_config #================================================= # GENERIC FINALIZATION @@ -173,7 +147,9 @@ ynh_store_file_checksum --file="$final_path/.sequelizerc" ynh_script_progression --message="Securing files and directories..." # Set permissions to app files -chown -R $app:$app $final_path +chown -R $app: $final_path +chmod 600 $final_path/config.json +chmod 600 $final_path/.sequelizerc #================================================= # INTEGRATE SERVICE IN YUNOHOST @@ -188,19 +164,17 @@ yunohost service add $app --description="Collaborative Markdown notes" --log="/v ynh_script_progression --message="Starting a systemd service..." --weight=2 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="HTTP Server listening" +ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="HTTP Server listening" #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --weight=1 +ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary or protect it 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" + ynh_permission_update --permission="main" --add="visitors" fi #================================================= diff --git a/scripts/remove b/scripts/remove index 75d3eea..2dddf1c 100644 --- a/scripts/remove +++ b/scripts/remove @@ -17,10 +17,9 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) -port=$(ynh_app_setting_get --app=$app --key=port) +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 -final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD REMOVE diff --git a/scripts/restore b/scripts/restore index ddcfe18..18a1453 100644 --- a/scripts/restore +++ b/scripts/restore @@ -31,7 +31,7 @@ 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 -db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -83,7 +83,7 @@ chown -R $app:$app $final_path ynh_script_progression --message="Reinstalling dependencies..." --weight=7 # Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies # Install Nodejs ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version @@ -120,7 +120,7 @@ yunohost service add $app --description="Collaborative Markdown notes" --log="/v #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="HTTP Server listening" +ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="HTTP Server listening" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index d7fdc10..33317e0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,13 +18,11 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) - db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name -db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= # CHECK VERSION @@ -33,6 +31,18 @@ ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 + +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -90,7 +100,7 @@ fi #================================================= ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= @@ -98,14 +108,11 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Upgrading dependencies..." --weight=18 -ynh_install_app_dependencies $pkg_dependencies +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies # Install Nodejs ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -# Install Yarn -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" - #================================================= # CREATE DEDICATED USER #================================================= @@ -124,43 +131,19 @@ then ynh_script_progression --message="Building CodiMD... (this will take some time and resources!)" --weight=16 pushd "$final_path" || ynh_die - ynh_use_nodejs - bin/setup - ynh_exec_warn_less yarn run build - + ynh_exec_warn_less bin/setup + ynh_exec_warn_less ynh_npm run build popd || ynh_die fi -#================================================= -# MODIFY A CONFIG FILE -#================================================= -ynh_script_progression --message="Modifying a config file..." --weight=2 - -ynh_backup_if_checksum_is_different --file="$final_path/config.json" - -cp ../conf/config.json.example "$final_path/config.json" - -# Main config File -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$final_path/config.json" - -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$final_path/config.json" - #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=2 -ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service" - +ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service" # Create a dedicated systemd config ynh_add_systemd_config @@ -172,12 +155,12 @@ ynh_add_systemd_config ynh_script_progression --message="Securing files and directories..." --weight=1 # Set permissions on app files -chown -R $app:$app $final_path +chown -R $app: $final_path #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=2 +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --description="Collaborative Markdown notes" --log="/var/log/$app/$app.log" @@ -186,7 +169,7 @@ yunohost service add $app --description="Collaborative Markdown notes" --log="/v #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="HTTP Server listening" +ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="HTTP Server listening" #================================================= # RELOAD NGINX