diff --git a/README.md b/README.md index 5847eac..12dbc06 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,10 @@ *[Lire ce readme en français.](./README_fr.md)* -> *This package allow you to install CodiMD quickly and simply on a YunoHost server. -If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* +> *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.* ## Overview - CodiMD is a real-time collaborative word processing web service. It uses Markdown language. **Shipped version:** 1.6.0 @@ -33,7 +32,7 @@ You can configure CodiMD by editing this file `/var/www/codimd/config.json` usin ## YunoHost specific features -#### Multi-users support +#### Multi-user support * Is LDAP supported? **Yes** * Can the app be used by multiple users? **Yes** @@ -42,11 +41,6 @@ You can configure CodiMD by editing this file `/var/www/codimd/config.json` usin * 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/) -* Buster x86-64 - [![Build Status](https://ci-buster.nohost.me/ci/logs/codimd%20%28Apps%29.svg)](https://ci-buster.nohost.me/ci/apps/codimd/) - -## Limitations - -## Additional information ## Links @@ -56,10 +50,10 @@ You can configure CodiMD by editing this file `/var/www/codimd/config.json` usin --- -Developers info +Developer info ---------------- -Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/codimd_ynh/tree/testing). +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/codimd_ynh/tree/testing). To try the testing branch, please proceed like that. ``` diff --git a/README_fr.md b/README_fr.md index be14170..87ab9ea 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,20 +1,19 @@ # 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) +[![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) *[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.* - -## Vue d’ensemble +> *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.* +## 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 -## Captures d’écran +## Captures d'écran ![](https://demo.codimd.org/screenshot.png) @@ -33,25 +32,20 @@ Vous pouvez configurer CodiMD en modifiant le fichier `/var/www/codimd/config.js ## Caractéristiques spécifiques YunoHost -#### Support multi-utilisateurs +#### Support multi-utilisateur -* L’authentification LDAP est-elle prise en charge ? **Oui** -* L’application peut-elle être utilisée par plusieurs utilisateurs ? **Oui** +* L'authentification LDAP est-elle prise en charge ? **Oui** +* L'application peut-elle être utilisée par plusieurs utilisateurs ? **Oui** #### 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/) +* x86-64b - [![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/) -* Buster x86-64 - [![Build Status](https://ci-buster.nohost.me/ci/logs/codimd%20%28Apps%29.svg)](https://ci-buster.nohost.me/ci/apps/codimd/) - -## Limitations - -## Informations additionnelles ## 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/codimd/server/ * Site web YunoHost : https://yunohost.org/ --- diff --git a/conf/systemd.service b/conf/systemd.service index 6797ec1..53450d9 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -10,7 +10,7 @@ Group=__APP__ WorkingDirectory=__FINALPATH__ Environment="PATH=__ENV_PATH__" Environment="NODE_ENV=production" -ExecStart=/usr/bin/yarn start +ExecStart=__YNH_NPM__ start Restart=always PrivateTmp=true PrivateDevices=true diff --git a/manifest.json b/manifest.json index e6e1b74..0ceb6c1 100644 --- a/manifest.json +++ b/manifest.json @@ -20,7 +20,8 @@ "nginx" ], "arguments": { - "install": [{ + "install" : [ + { "name": "domain", "type": "domain", "ask": { diff --git a/scripts/_common.sh b/scripts/_common.sh index b0b3f5f..4804c27 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,3 +8,15 @@ pkg_dependencies="postgresql apt-transport-https" nodejs_version=10 + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/backup b/scripts/backup index b342a14..7065f73 100644 --- a/scripts/backup +++ b/scripts/backup @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= + ynh_clean_setup () { ynh_clean_check_starting } @@ -31,11 +32,14 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path=$final_path +ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION @@ -43,13 +47,6 @@ ynh_backup --src_path=$final_path ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# BACKUP THE DATABASE -#================================================= -ynh_print_info --message="Backing up the database..." - -ynh_psql_dump_db --database=$db_name > db.sql - #================================================= # SPECIFIC BACKUP #================================================= @@ -64,6 +61,13 @@ ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/systemd/system/$app.service" +#================================================= +# BACKUP THE POSTGRESQL DATABASE +#================================================= +ynh_print_info --message="Backing up the Postgresql database..." + +ynh_psql_dump_db --database="$db_name" > db.sql + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/change_url b/scripts/change_url index 754711f..9b97276 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# GENERIC START +# GENERIC STARTING #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -107,6 +107,7 @@ fi #================================================= 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" #================================================= diff --git a/scripts/install b/scripts/install index a4768b7..60be9fe 100644 --- a/scripts/install +++ b/scripts/install @@ -16,7 +16,6 @@ source /usr/share/yunohost/helpers ynh_clean_setup () { ynh_clean_check_starting } - # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -24,23 +23,34 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -app=$YNH_APP_INSTANCE_NAME - domain=$YNH_APP_ARG_DOMAIN path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC +app=$YNH_APP_INSTANCE_NAME + #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= ynh_script_progression --message="Validating installation parameters..." --weight=1 final_path=/var/www/$app -test ! -e "$final_path" || ynh_die "This path already contains a folder" +test ! -e "$final_path" || ynh_die --message="This path already contains a folder" # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url +#================================================= +# STORE SETTINGS FROM MANIFEST +#================================================= +ynh_script_progression --message="Storing installation settings..." --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 + +#================================================= +# STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= @@ -51,18 +61,8 @@ port=$(ynh_find_port --port=3000) ynh_app_setting_set --app=$app --key=port --value=$port #================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -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=final_path --value=$final_path - -#============================================== # INSTALL DEPENDENCIES -#============================================== +#================================================= ynh_script_progression --message="Installing dependencies..." --weight=20 ynh_install_app_dependencies $pkg_dependencies @@ -73,18 +73,17 @@ 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 DB -#============================================== -ynh_script_progression --message="Creating a database..." --weight=2 +#================================================= +# CREATE A POSTGRESQL DATABASE +#================================================= +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) -ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_app_setting_set --app=$app --key=db_user --value=$db_user +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 @@ -94,6 +93,7 @@ ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd #================================================= ynh_script_progression --message="Setting up source files..." --weight=2 +ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir=$final_path @@ -106,29 +106,15 @@ ynh_script_progression --message="Configuring Nginx web server..." --weight=2 ynh_add_nginx_config #================================================= -# MODIFY A CONFIG FILE +# CREATE DEDICATED USER #================================================= +ynh_script_progression --message="Configuring system user..." --weight=3 -# Main config File -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/config.json.example" - -cp ../conf/config.json.example "$final_path/config.json" - -ynh_store_file_checksum "$final_path/config.json" - -# DB Config File -ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/.sequelizerc.example" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/.sequelizerc.example" -ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/.sequelizerc.example" - -cp ../conf/.sequelizerc.example "$final_path/.sequelizerc" +# Create a system user +ynh_system_user_create --username=$app --home_dir=$final_path +#================================================= +# SPECIFIC SETUP #============================================== # INSTALL CODIMD #============================================== @@ -142,16 +128,54 @@ pushd "$final_path" || ynh_die popd || ynh_die +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Configuring a systemd service..." --weight=1 + +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --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="__NODE__" --replace_string="$nodejs_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..." + +# Main config File +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/config.json.example" + +cp ../conf/config.json.example "$final_path/config.json" + +ynh_store_file_checksum --file="$final_path/config.json" + +# DB Config File +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/.sequelizerc.example" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/.sequelizerc.example" +ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/.sequelizerc.example" + +cp ../conf/.sequelizerc.example "$final_path/.sequelizerc" + +ynh_store_file_checksum --file="$final_path/.sequelizerc" + #================================================= # GENERIC FINALIZATION #================================================= -# CREATE DEDICATED USER +# SECURE FILES AND DIRECTORIES #================================================= -ynh_script_progression --message="Configuring system user..." --weight=3 - -# Create a system user -ynh_system_user_create --username=$app --home_dir=$final_path +ynh_script_progression --message="Securing files and directories..." +# Set permissions to app files chown -R $app:$app $final_path #================================================= @@ -163,24 +187,18 @@ ynh_script_progression --message="Configuring log rotation..." --weight=2 ynh_use_logrotate #================================================= -# SETUP SYSTEMD +# INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=1 - -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --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="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" - -ynh_add_systemd_config +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --description "Collaborative Markdown notes" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting $app..." --weight=2 +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" #================================================= diff --git a/scripts/remove b/scripts/remove index 0d524ee..d9cd71a 100644 --- a/scripts/remove +++ b/scripts/remove @@ -18,9 +18,9 @@ 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=$(ynh_app_setting_get --app=$app --key=db_user) +db_user=$db_name +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD REMOVE @@ -44,9 +44,9 @@ ynh_script_progression --message="Stopping and removing the systemd service..." ynh_remove_systemd_config #================================================= -# REMOVE THE DATABASE +# REMOVE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Removing the database..." --weight=2 +ynh_script_progression --message="Removing the PostgreSQL database..." --weight=2 # Remove a database if it exists, along with the associated user ynh_psql_remove_db --db_user=$db_user --db_name=$db_name @@ -64,10 +64,10 @@ ynh_remove_nodejs #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing $app main directory..." --weight=6 +ynh_script_progression --message="Removing app main directory..." --weight=6 # Remove the app directory securely -ynh_secure_remove --file=$final_path +ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION diff --git a/scripts/restore b/scripts/restore index dc72ab7..cbba363 100644 --- a/scripts/restore +++ b/scripts/restore @@ -29,9 +29,8 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -port=$(ynh_app_setting_get --app=$app --key=port) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$(ynh_app_setting_get --app=$app --key=db_user) +db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #================================================= @@ -49,6 +48,7 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the nginx configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -57,7 +57,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=60 -ynh_restore_file --origin_path=$final_path +ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER @@ -70,6 +70,7 @@ ynh_system_user_create --username=$app #================================================= # RESTORE USER RIGHTS #================================================= +ynh_script_progression --message="Restoring user rights..." # Restore permissions on app files chown -R $app:$app $final_path @@ -84,15 +85,16 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=7 # Define and install dependencies 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" -ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version - #================================================= -# RESTORE THE DATABASE +# RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the database..." --weight=6 +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6 ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd @@ -109,6 +111,7 @@ systemctl enable $app.service #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --description "collaborative Markdown editor" --log "/var/log/$app/$app.log" diff --git a/scripts/upgrade b/scripts/upgrade index b0c4f00..62a91f3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,12 +23,13 @@ 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=$(ynh_app_setting_get --app=$app --key=db_user) +db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -58,6 +59,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= + if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=160 @@ -81,11 +83,55 @@ then # Remove the tmp directory securely ynh_secure_remove --file="$tmpdir" - fi +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading Nginx web server configuration..." --weight=2 + +# Create a dedicated nginx config +ynh_add_nginx_config + +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=18 + +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="Making sure dedicated system user exists..." --weight=1 + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app + #================================================= # SPECIFIC UPGRADE +#============================================== +# INSTALL CODIMD +#============================================== +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=160 + + pushd "$final_path" || ynh_die + + ynh_use_nodejs + yarn install --frozen-lockfile + ynh_exec_warn_less yarn run build + + popd || ynh_die +fi + #================================================= # MODIFY A CONFIG FILE #================================================= @@ -107,52 +153,6 @@ cp ../conf/config.json.example "$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" -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading Nginx web server configuration..." --weight=2 - -# Create a dedicated nginx config -ynh_add_nginx_config - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=18 - -# 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" - -ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version - -ynh_install_app_dependencies $pkg_dependencies - -#============================================== -# INSTALL CODIMD -#============================================== -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=160 - - pushd "$final_path" - - ynh_use_nodejs - yarn install --frozen-lockfile - ynh_exec_warn_less yarn run build - - popd -fi - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - -#================================================= -# SPECIFIC UPGRADE #================================================= # SETUP LOGROTATE #================================================= @@ -170,14 +170,17 @@ ynh_replace_string --match_string="__APP__" --replace_string="$app" ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --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="__NODE__" --replace_string="$nodejs_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 -yunohost service add $app --description "Collaborative Markdown notes" --log="/var/log/$app/$app.log" - +#================================================= +# GENERIC FINALIZATION #================================================= # SECURE FILES AND DIRECTORIES #================================================= +ynh_script_progression --message="Securing files and directories..." # Set permissions on app files chown -R $app:$app $final_path @@ -194,6 +197,13 @@ then ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" fi +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." + +yunohost service add $app --description "Collaborative Markdown notes" --log="/var/log/$app/$app.log" + #================================================= # START SYSTEMD SERVICE #=================================================