From d5eca08f72e2c8bc145147862791374c154c263f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 7 Feb 2019 21:40:19 +0100 Subject: [PATCH 01/22] Fix External URL --- conf/systemd.service | 2 ++ scripts/install | 1 + scripts/upgrade | 1 + 3 files changed, 4 insertions(+) diff --git a/conf/systemd.service b/conf/systemd.service index 8de39bf..13bdf9f 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -9,6 +9,8 @@ Group=__APP__ Environment="PATH=__NODEJS_PATH__" Environment="PORT=__PORT__" Environment="DB_DIR=__FINALPATH__/db" +Environment="EXTERNAL_URL=https://__DOMAIN_URI__" +Environment="NODE_TLS_REJECT_UNAUTHORIZED=0" Environment="NODE_ENV=production" WorkingDirectory=__FINALPATH__/ ExecStart=/bin/sh -c '__FINALPATH__/node_modules/.bin/ts-node --project __FINALPATH__/tsconfig.json __FINALPATH__/bin/server.ts >> /var/log/__APP__/__APP__.log 2>&1' diff --git a/scripts/install b/scripts/install index eb4a67f..9d4400f 100644 --- a/scripts/install +++ b/scripts/install @@ -209,6 +209,7 @@ popd # Create a dedicated systemd config ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "../conf/systemd.service" ynh_replace_string "__PORT__" "$port" "../conf/systemd.service" +ynh_replace_string "__DOMAIN_URI__" "$domain$path_url" "../conf/systemd.service" ynh_add_systemd_config #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index cbfd5cd..f20e274 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -160,6 +160,7 @@ ynh_use_logrotate --non-append # Create a dedicated systemd config ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "../conf/systemd.service" ynh_replace_string "__PORT__" "$port" "../conf/systemd.service" +ynh_replace_string "__DOMAIN_URI__" "$domain$path_url" "../conf/systemd.service" ynh_add_systemd_config #================================================= From 9467260b76b4c30973b9f3a823596a584c1316e1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 7 Feb 2019 23:44:14 +0100 Subject: [PATCH 02/22] remove not needed: Environment="NODE_TLS_REJECT_UNAUTHORIZED=0" --- conf/systemd.service | 1 - 1 file changed, 1 deletion(-) diff --git a/conf/systemd.service b/conf/systemd.service index 13bdf9f..92ec11a 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -10,7 +10,6 @@ Environment="PATH=__NODEJS_PATH__" Environment="PORT=__PORT__" Environment="DB_DIR=__FINALPATH__/db" Environment="EXTERNAL_URL=https://__DOMAIN_URI__" -Environment="NODE_TLS_REJECT_UNAUTHORIZED=0" Environment="NODE_ENV=production" WorkingDirectory=__FINALPATH__/ ExecStart=/bin/sh -c '__FINALPATH__/node_modules/.bin/ts-node --project __FINALPATH__/tsconfig.json __FINALPATH__/bin/server.ts >> /var/log/__APP__/__APP__.log 2>&1' From 55157454f9ef11a01ba69e5e62cacbe9c3f8b751 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 8 Feb 2019 20:54:06 +0100 Subject: [PATCH 03/22] adding link to LDAP authentication --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 8aeebc6..037e415 100644 --- a/check_process +++ b/check_process @@ -26,7 +26,7 @@ Level 3=auto # Level 4: If the app supports LDAP and SSOwat, turn level 4 to '1' and add a link to an issue or a part of your code to show it. # If the app does not use LDAP nor SSOwat, and can't use them, turn level 4 to 'na' and explain as well. - # no ldap support + # https://github.com/YunoHost-Apps/distbin_ynh/issues/18 Level 4=na Level 5=auto Level 6=auto From b082413f641a4fbe309d319c8ea618f8b66ef55a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 8 Feb 2019 21:40:36 +0100 Subject: [PATCH 04/22] adding change_url steps --- scripts/change_url | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index 4775517..1018e97 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -90,9 +90,25 @@ fi #================================================= # SPECIFIC MODIFICATIONS #================================================= -# ... +# STOP SERVICE #================================================= +ynh_systemd_action --action=stop --service_name=$app + +#================================================= +# MODIFY A CONFIG FILE +#================================================= + +# 9999 TODO : Change the config file or the systemd file +#ynh_replace_string "EXTERNAL_URL=.*" "EXTERNAL_URL=https://$new_domain$new_path" "$final_path/.env" + +#================================================= +# START SERVICE +#================================================= + +ynh_systemd_action --action=start --service_name=$app + + #================================================= # GENERIC FINALISATION #================================================= From 7428ad8313c2fd54b8f811aa11168494dedc7ba7 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 8 Feb 2019 23:10:29 +0100 Subject: [PATCH 05/22] Moving environment variable from systemd to .env file --- conf/.env | 14 ++++++++++++++ conf/systemd.service | 6 +----- scripts/install | 14 ++++++++------ scripts/upgrade | 35 ++++++++++++++++++++++------------- 4 files changed, 45 insertions(+), 24 deletions(-) create mode 100644 conf/.env diff --git a/conf/.env b/conf/.env new file mode 100644 index 0000000..6df3fe4 --- /dev/null +++ b/conf/.env @@ -0,0 +1,14 @@ +# The path to NODEJS +PATH=__NODEJS_PATH__ + +# The port used by the application +PORT=__PORT__ + +# The directory where is store the database +DB_DIR=__FINALPATH__/db + +# The external URL +EXTERNAL_URL=https://__DOMAIN_URI__ + +# The Node Environnement +NODE_ENV=production \ No newline at end of file diff --git a/conf/systemd.service b/conf/systemd.service index 92ec11a..1dd8209 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,11 +6,7 @@ After=network.target Type=simple User=__APP__ Group=__APP__ -Environment="PATH=__NODEJS_PATH__" -Environment="PORT=__PORT__" -Environment="DB_DIR=__FINALPATH__/db" -Environment="EXTERNAL_URL=https://__DOMAIN_URI__" -Environment="NODE_ENV=production" +EnvironmentFile=__FINALPATH__/.env WorkingDirectory=__FINALPATH__/ ExecStart=/bin/sh -c '__FINALPATH__/node_modules/.bin/ts-node --project __FINALPATH__/tsconfig.json __FINALPATH__/bin/server.ts >> /var/log/__APP__/__APP__.log 2>&1' diff --git a/scripts/install b/scripts/install index 9d4400f..f6ba20e 100644 --- a/scripts/install +++ b/scripts/install @@ -207,9 +207,6 @@ popd ### - And the section "SETUP SYSTEMD" in the upgrade script # Create a dedicated systemd config -ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "../conf/systemd.service" -ynh_replace_string "__PORT__" "$port" "../conf/systemd.service" -ynh_replace_string "__DOMAIN_URI__" "$domain$path_url" "../conf/systemd.service" ynh_add_systemd_config #================================================= @@ -248,7 +245,12 @@ ynh_add_systemd_config ### `ynh_replace_string` is used to replace a string in a file. ### (It's compatible with sed regular expressions syntax) -#ynh_replace_string "match_string" "replace_string" "$final_path/CONFIG_FILE" +cp "../conf/.env" "$final_path/.env" + +ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "$final_path/.env" +ynh_replace_string "__PORT__" "$port" "$final_path/.env" +ynh_replace_string "__DOMAIN_URI__" "$domain$path_url" "$final_path/.env" +ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/.env" #================================================= # STORE THE CONFIG FILE CHECKSUM @@ -259,7 +261,7 @@ ynh_add_systemd_config ### you can make a backup of this file before modifying it again if the admin had modified it. # Calculate and store the config file checksum into the app settings -#ynh_store_file_checksum "$final_path/package.json" +ynh_store_file_checksum "$final_path/.env" #================================================= # GENERIC FINALIZATION @@ -272,7 +274,7 @@ ynh_add_systemd_config ### that really need such authorization. # Set permissions to app files -#chown -R root: $final_path +chown -R "$app":"$app" "$final_path" #================================================= # SETUP LOGROTATE diff --git a/scripts/upgrade b/scripts/upgrade index f20e274..578ddde 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -64,12 +64,6 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors -#================================================= -# STOP SERVICE -#================================================= - -ynh_systemd_action --action=stop --service_name=$app - #================================================= # CHECK THE PATH #================================================= @@ -77,6 +71,12 @@ ynh_systemd_action --action=stop --service_name=$app # Normalize the URL path syntax path_url=$(ynh_normalize_url_path $path_url) +#================================================= +# STOP SERVICE +#================================================= + +ynh_systemd_action --action=stop --service_name=$app + #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -120,8 +120,6 @@ ynh_system_user_create "$app" "$final_path" #================================================= # SPECIFIC UPGRADE -#================================================= - #================================================= # CREATE DB FOLDER #================================================= @@ -140,11 +138,25 @@ pushd $final_path sudo -u $app env PATH=$PATH:$nodejs_path npm audit fix popd +#================================================= +# MODIFY A CONFIG FILE +#================================================= + +### `ynh_replace_string` is used to replace a string in a file. +### (It's compatible with sed regular expressions syntax) + +cp "../conf/.env" "$final_path/.env" + +ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "$final_path/.env" +ynh_replace_string "__PORT__" "$port" "$final_path/.env" +ynh_replace_string "__DOMAIN_URI__" "$domain$path_url" "$final_path/.env" +ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/.env" + ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. -#ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE" +ynh_backup_if_checksum_is_different "$final_path/.env" # Recalculate and store the checksum of the file for the next upgrade. -#ynh_store_file_checksum "$final_path/CONFIG_FILE" +ynh_store_file_checksum "$final_path/.env" #================================================= # SETUP LOGROTATE @@ -158,9 +170,6 @@ ynh_use_logrotate --non-append #================================================= # Create a dedicated systemd config -ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "../conf/systemd.service" -ynh_replace_string "__PORT__" "$port" "../conf/systemd.service" -ynh_replace_string "__DOMAIN_URI__" "$domain$path_url" "../conf/systemd.service" ynh_add_systemd_config #================================================= From 388b15a8d243201a41de0e3a973e8fd3d0959596 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 8 Feb 2019 23:29:28 +0100 Subject: [PATCH 06/22] update URL in the .env file --- scripts/change_url | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 1018e97..bcf134d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -99,8 +99,14 @@ ynh_systemd_action --action=stop --service_name=$app # MODIFY A CONFIG FILE #================================================= -# 9999 TODO : Change the config file or the systemd file -#ynh_replace_string "EXTERNAL_URL=.*" "EXTERNAL_URL=https://$new_domain$new_path" "$final_path/.env" +# Change the URL in the configuration file +ynh_replace_string "EXTERNAL_URL=.*" "EXTERNAL_URL=https://$new_domain$new_path" "$final_path/.env" + +### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. +### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. +ynh_backup_if_checksum_is_different "$final_path/.env" +# Recalculate and store the checksum of the file for the next upgrade. +ynh_store_file_checksum "$final_path/.env" #================================================= # START SERVICE From 77c19df3572d8bbee095da35b31bf272fbdcb5d2 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 8 Feb 2019 23:44:30 +0100 Subject: [PATCH 07/22] remove $PATH --- scripts/install | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index f6ba20e..9191b79 100644 --- a/scripts/install +++ b/scripts/install @@ -185,10 +185,10 @@ mkdir -p "$final_path/db" chown -R "$app":"$app" "$final_path" pushd $final_path ynh_use_nodejs - sudo -u $app env PATH=$PATH:$nodejs_path npm add hoek@^4.2.1 --save --production - sudo -u $app env PATH=$PATH:$nodejs_path npm install ts-node - sudo -u $app env PATH=$PATH:$nodejs_path npm install --production - sudo -u $app env PATH=$PATH:$nodejs_path npm audit fix + sudo -u $app env PATH=$nodejs_path npm add hoek@^4.2.1 --save --production + sudo -u $app env PATH=$nodejs_path npm install ts-node + sudo -u $app env PATH=$nodejs_path npm install --production + sudo -u $app env PATH=$nodejs_path npm audit fix popd #================================================= From 03a7bafc74a6aa3641a877ddad85a5f8291749f2 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 8 Feb 2019 23:48:37 +0100 Subject: [PATCH 08/22] remove $PATH in upgrade scripts/upgrade --- scripts/upgrade | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 578ddde..95bea49 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -133,9 +133,9 @@ mkdir -p "$final_path/db" chown -R "$app":"$app" "$final_path" pushd $final_path ynh_use_nodejs - sudo -u $app env PATH=$PATH:$nodejs_path npm update --production - sudo -u $app env PATH=$PATH:$nodejs_path npm install --production - sudo -u $app env PATH=$PATH:$nodejs_path npm audit fix + sudo -u $app env PATH=$nodejs_path npm update --production + sudo -u $app env PATH=$nodejs_path npm install --production + sudo -u $app env PATH=$nodejs_path npm audit fix popd #================================================= From dffe065991ecc77e036ee49585b11608c7c9114c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 9 Feb 2019 00:12:10 +0100 Subject: [PATCH 09/22] Adding dependencies --- conf/.env | 2 +- scripts/install | 1 + scripts/restore | 2 +- scripts/upgrade | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/conf/.env b/conf/.env index 6df3fe4..1453925 100644 --- a/conf/.env +++ b/conf/.env @@ -5,7 +5,7 @@ PATH=__NODEJS_PATH__ PORT=__PORT__ # The directory where is store the database -DB_DIR=__FINALPATH__/db +DB_DIR=__FINALPATH__/distbin-db # The external URL EXTERNAL_URL=https://__DOMAIN_URI__ diff --git a/scripts/install b/scripts/install index 9191b79..f046920 100644 --- a/scripts/install +++ b/scripts/install @@ -97,6 +97,7 @@ ynh_app_setting_set $app port $port ### - As well as the section "REINSTALL DEPENDENCIES" in the restore script ### - And the section "UPGRADE DEPENDENCIES" in the upgrade script +ynh_install_app_dependencies ca-certificates ynh_install_nodejs 8 #================================================= diff --git a/scripts/restore b/scripts/restore index 831ccd5..4aa9169 100644 --- a/scripts/restore +++ b/scripts/restore @@ -93,7 +93,7 @@ chown -R $app:$app /var/log/$app #================================================= # Define and install dependencies -#ynh_install_app_dependencies +ynh_install_app_dependencies ca-certificates ynh_install_nodejs 8 #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 95bea49..9efaa7a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -101,7 +101,7 @@ ynh_add_nginx_config # UPGRADE DEPENDENCIES #================================================= -#ynh_install_app_dependencies deb1 deb2 +ynh_install_app_dependencies ca-certificates ynh_install_nodejs 8 #================================================= From d326e36dea6ee79241c98ad3d0ecd64e497aec4d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 9 Feb 2019 00:19:33 +0100 Subject: [PATCH 10/22] Change installation steps --- conf/systemd.service | 2 +- scripts/install | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index 1dd8209..a79e801 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -8,7 +8,7 @@ User=__APP__ Group=__APP__ EnvironmentFile=__FINALPATH__/.env WorkingDirectory=__FINALPATH__/ -ExecStart=/bin/sh -c '__FINALPATH__/node_modules/.bin/ts-node --project __FINALPATH__/tsconfig.json __FINALPATH__/bin/server.ts >> /var/log/__APP__/__APP__.log 2>&1' +ExecStart=/bin/sh -c 'npm start >> /var/log/__APP__/__APP__.log 2>&1' [Install] WantedBy=multi-user.target diff --git a/scripts/install b/scripts/install index f046920..1bd631e 100644 --- a/scripts/install +++ b/scripts/install @@ -16,6 +16,7 @@ source /usr/share/yunohost/helpers ynh_clean_setup () { ### Remove this function if there's nothing to clean before calling the remove script. + read -p "Press any key..." ynh_clean_check_starting } # Exit if an error occurs during the execution of the script @@ -186,10 +187,8 @@ mkdir -p "$final_path/db" chown -R "$app":"$app" "$final_path" pushd $final_path ynh_use_nodejs - sudo -u $app env PATH=$nodejs_path npm add hoek@^4.2.1 --save --production - sudo -u $app env PATH=$nodejs_path npm install ts-node - sudo -u $app env PATH=$nodejs_path npm install --production - sudo -u $app env PATH=$nodejs_path npm audit fix + sudo -u $app env PATH=$nodejs_path npm install --ignore-scripts + sudo -u $app env PATH=$nodejs_path npm run build popd #================================================= From 4831b7576c5492f2f862b1b27a5035fd6c793e7a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 9 Feb 2019 00:28:20 +0100 Subject: [PATCH 11/22] Add PATH for npm build --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 1bd631e..0f68d13 100644 --- a/scripts/install +++ b/scripts/install @@ -187,8 +187,8 @@ mkdir -p "$final_path/db" chown -R "$app":"$app" "$final_path" pushd $final_path ynh_use_nodejs - sudo -u $app env PATH=$nodejs_path npm install --ignore-scripts - sudo -u $app env PATH=$nodejs_path npm run build + sudo -u $app env PATH=$PATH npm install --ignore-scripts + sudo -u $app env PATH=$PATH npm run build popd #================================================= From 99e2e8e53dae73b78a04c7596c14fcfbc4cb15f8 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 9 Feb 2019 00:42:18 +0100 Subject: [PATCH 12/22] Fix distbin-db --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 0f68d13..3f18d97 100644 --- a/scripts/install +++ b/scripts/install @@ -178,7 +178,7 @@ chown -R "$app":"$app" "/var/log/$app" # CREATE DB FOLDER #================================================= -mkdir -p "$final_path/db" +mkdir -p "$final_path/distbin-db" #================================================= # MAKE SETUP From fc8e667ebc192314e62673b121f97e67aacee2b2 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 9 Feb 2019 00:47:42 +0100 Subject: [PATCH 13/22] Fix working dir path --- conf/systemd.service | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index a79e801..4c9bd16 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,8 +7,8 @@ Type=simple User=__APP__ Group=__APP__ EnvironmentFile=__FINALPATH__/.env -WorkingDirectory=__FINALPATH__/ -ExecStart=/bin/sh -c 'npm start >> /var/log/__APP__/__APP__.log 2>&1' +WorkingDirectory=__FINALPATH__ +ExecStart=/bin/sh -c 'node ./dist/bin/server >> /var/log/__APP__/__APP__.log 2>&1' [Install] WantedBy=multi-user.target From a1272c8cf72a8cfb30db448f386502d29690785d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 9 Feb 2019 00:54:47 +0100 Subject: [PATCH 14/22] add hoek dependencies --- scripts/install | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install b/scripts/install index 3f18d97..f0dc299 100644 --- a/scripts/install +++ b/scripts/install @@ -187,6 +187,7 @@ mkdir -p "$final_path/distbin-db" chown -R "$app":"$app" "$final_path" pushd $final_path ynh_use_nodejs + sudo -u $app env PATH=$PATH npm add hoek@^4.2.1 --save sudo -u $app env PATH=$PATH npm install --ignore-scripts sudo -u $app env PATH=$PATH npm run build popd From 5310877d5dadaa34c95194577a91c66b543772ff Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 9 Feb 2019 01:16:13 +0100 Subject: [PATCH 15/22] fix install steps --- scripts/install | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index f0dc299..eca9834 100644 --- a/scripts/install +++ b/scripts/install @@ -187,11 +187,13 @@ mkdir -p "$final_path/distbin-db" chown -R "$app":"$app" "$final_path" pushd $final_path ynh_use_nodejs - sudo -u $app env PATH=$PATH npm add hoek@^4.2.1 --save - sudo -u $app env PATH=$PATH npm install --ignore-scripts sudo -u $app env PATH=$PATH npm run build popd +pushd $final_path/dist + sudo -u $app env PATH=$PATH npm install --ignore-scripts --production +popd + #================================================= # SETUP SYSTEMD #================================================= From 213be1cdae428e195e5a972e5373f4fa1675f3af Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 9 Feb 2019 01:18:01 +0100 Subject: [PATCH 16/22] remove --production, lack some module --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index eca9834..5a16ea6 100644 --- a/scripts/install +++ b/scripts/install @@ -191,7 +191,7 @@ pushd $final_path popd pushd $final_path/dist - sudo -u $app env PATH=$PATH npm install --ignore-scripts --production + sudo -u $app env PATH=$PATH npm install --ignore-scripts popd #================================================= From 078d1c87cc1b141ced0eb6919e79e4c86798eaab Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 9 Feb 2019 01:20:03 +0100 Subject: [PATCH 17/22] back to original --- scripts/install | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index 5a16ea6..fdf7f62 100644 --- a/scripts/install +++ b/scripts/install @@ -187,13 +187,10 @@ mkdir -p "$final_path/distbin-db" chown -R "$app":"$app" "$final_path" pushd $final_path ynh_use_nodejs + sudo -u $app env PATH=$PATH npm install --ignore-scripts --production sudo -u $app env PATH=$PATH npm run build popd -pushd $final_path/dist - sudo -u $app env PATH=$PATH npm install --ignore-scripts -popd - #================================================= # SETUP SYSTEMD #================================================= From 0351b5038060553544350ac77ec8b3c3232c9c48 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 9 Feb 2019 01:23:03 +0100 Subject: [PATCH 18/22] Fix install path --- scripts/install | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index fdf7f62..0bb879e 100644 --- a/scripts/install +++ b/scripts/install @@ -187,7 +187,8 @@ mkdir -p "$final_path/distbin-db" chown -R "$app":"$app" "$final_path" pushd $final_path ynh_use_nodejs - sudo -u $app env PATH=$PATH npm install --ignore-scripts --production + #sudo -u $app env PATH=$PATH npm add typescript --save # --production + sudo -u $app env PATH=$PATH npm install --ignore-scripts sudo -u $app env PATH=$PATH npm run build popd From 1e70aa1c3592a629bde83c2bc3b5462c030f4b94 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 9 Feb 2019 02:22:57 +0100 Subject: [PATCH 19/22] Fix install --- scripts/install | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 0bb879e..5c67a91 100644 --- a/scripts/install +++ b/scripts/install @@ -187,11 +187,15 @@ mkdir -p "$final_path/distbin-db" chown -R "$app":"$app" "$final_path" pushd $final_path ynh_use_nodejs - #sudo -u $app env PATH=$PATH npm add typescript --save # --production sudo -u $app env PATH=$PATH npm install --ignore-scripts sudo -u $app env PATH=$PATH npm run build popd +pushd $final_path/dist + sudo -u $app env PATH=$PATH npm install --ignore-scripts --production +popd + + #================================================= # SETUP SYSTEMD #================================================= From 388bbfe735bd9540d93e78cffb34439e0d0a7fb6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 9 Feb 2019 02:27:26 +0100 Subject: [PATCH 20/22] Fix install --- scripts/install | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install b/scripts/install index 5c67a91..eedba30 100644 --- a/scripts/install +++ b/scripts/install @@ -189,6 +189,7 @@ pushd $final_path ynh_use_nodejs sudo -u $app env PATH=$PATH npm install --ignore-scripts sudo -u $app env PATH=$PATH npm run build + cp package* dist/ popd pushd $final_path/dist From 9012e8e72225f898c297c89f449219db1b592dcd Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 9 Feb 2019 02:57:23 +0100 Subject: [PATCH 21/22] Fix update --- scripts/upgrade | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 9efaa7a..9ff0276 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -124,7 +124,11 @@ ynh_system_user_create "$app" "$final_path" # CREATE DB FOLDER #================================================= -mkdir -p "$final_path/db" +DIRECTORY="$final_path/db" +#Move old db +if [ -d "$DIRECTORY" ]; then + mv "$final_path/db" "$final_path/distbin-db" +fi #================================================= # MAKE INSTALL @@ -133,9 +137,13 @@ mkdir -p "$final_path/db" chown -R "$app":"$app" "$final_path" pushd $final_path ynh_use_nodejs - sudo -u $app env PATH=$nodejs_path npm update --production - sudo -u $app env PATH=$nodejs_path npm install --production - sudo -u $app env PATH=$nodejs_path npm audit fix + sudo -u $app env PATH=$PATH npm install --ignore-scripts + sudo -u $app env PATH=$PATH npm run build + cp package* dist/ +popd + +pushd $final_path/dist + sudo -u $app env PATH=$PATH npm install --ignore-scripts --production popd #================================================= From 77d55bc8a04af19a63a92474d2a1f9569e92f0b7 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 9 Feb 2019 03:11:06 +0100 Subject: [PATCH 22/22] change the version number --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 78b34d9..a42d123 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Distributed pastebin with ActivityPub.", "fr": "Pastebin distribué utilisant le protocole ActivityPub." }, - "version": "1.0~ynh3", + "version": "1.0~ynh4", "url": "https://example.com", "license": "Apache-2.0", "maintainer": {