From 98f9b630ec0d93a2ffb7a29e2fe87d8f69371754 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 8 May 2021 14:45:46 +0200 Subject: [PATCH 1/6] Update change_url --- scripts/change_url | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 569d127..a5b16b6 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -117,13 +117,12 @@ 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" From 546d52b2bacdc086146270d273d4de2c267bff58 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 8 May 2021 15:31:11 +0200 Subject: [PATCH 2/6] Fix --- scripts/install | 25 ++++++++++--------------- scripts/upgrade | 14 +------------- 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/scripts/install b/scripts/install index b57a9e5..62dd788 100644 --- a/scripts/install +++ b/scripts/install @@ -69,9 +69,6 @@ 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 #================================================= @@ -118,29 +115,27 @@ ynh_script_progression --message="Building CodiMD... (this will take some time a pushd "$final_path" || ynh_die ynh_use_nodejs ynh_exec_warn_less bin/setup - ynh_exec_warn_less yarn run build + ynh_exec_warn_less ynh_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..." 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" +#================================================= +# 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_add_systemd_config + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 202d339..c6493a7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -113,9 +113,6 @@ 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 #================================================= @@ -136,25 +133,16 @@ then pushd "$final_path" || ynh_die ynh_use_nodejs ynh_exec_warn_less bin/setup - ynh_exec_warn_less yarn run build + 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 - -#path=${path_url:1} -#ynh_add_config --template="../conf/config.json.example" --destination="$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" # Create a dedicated systemd config ynh_add_systemd_config From a489492a4985329bdb328dadc56f6e821401cadf Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 8 May 2021 15:44:58 +0200 Subject: [PATCH 3/6] fix --- conf/.sequelizerc.example | 12 +++++++----- scripts/install | 4 +++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/conf/.sequelizerc.example b/conf/.sequelizerc.example index ddb5cba..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_NAME__:__DB_PWD__@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/scripts/install b/scripts/install index 62dd788..88d047d 100644 --- a/scripts/install +++ b/scripts/install @@ -112,10 +112,12 @@ ynh_add_nginx_config #============================================== 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 ynh_exec_warn_less bin/setup - ynh_exec_warn_less ynh_npm run build + ynh_exec_as $app env $ynh_node_load_PATH npm run build popd || ynh_die #================================================= From c7d926727b56e788cbca78feb82d03729c3e70f9 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 8 May 2021 15:55:21 +0200 Subject: [PATCH 4/6] Fix --- scripts/install | 5 +++-- scripts/upgrade | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 88d047d..0247e8c 100644 --- a/scripts/install +++ b/scripts/install @@ -116,7 +116,8 @@ chown -R $app: $final_path pushd "$final_path" || ynh_die ynh_use_nodejs - ynh_exec_warn_less bin/setup + 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 @@ -135,7 +136,7 @@ ynh_add_config --template="../conf/.sequelizerc.example" --destination="$final_p 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 #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index c6493a7..361555d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -143,7 +143,7 @@ fi 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" # Create a dedicated systemd config ynh_add_systemd_config From e7fca508890ca046bdd315be1973603e85a16060 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 8 May 2021 16:21:31 +0200 Subject: [PATCH 5/6] Update install --- scripts/install | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install b/scripts/install index 0247e8c..377bc6e 100644 --- a/scripts/install +++ b/scripts/install @@ -117,6 +117,7 @@ chown -R $app: $final_path pushd "$final_path" || ynh_die ynh_use_nodejs ynh_exec_warn_less bin/setup + npm install -g phantomjs@2.1.1 --unsafe-perm 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 From 461cc626cbdee785fbc7d8d2d96dc353039566a3 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 8 May 2021 16:26:09 +0200 Subject: [PATCH 6/6] Update install --- scripts/install | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/install b/scripts/install index 377bc6e..0247e8c 100644 --- a/scripts/install +++ b/scripts/install @@ -117,7 +117,6 @@ chown -R $app: $final_path pushd "$final_path" || ynh_die ynh_use_nodejs ynh_exec_warn_less bin/setup - npm install -g phantomjs@2.1.1 --unsafe-perm 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