From dffe065991ecc77e036ee49585b11608c7c9114c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 9 Feb 2019 00:12:10 +0100 Subject: [PATCH 01/14] 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 02/14] 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 03/14] 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 04/14] 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 05/14] 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 06/14] 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 07/14] 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 08/14] 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 09/14] 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 10/14] 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 11/14] 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 12/14] 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 13/14] 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 14/14] 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": {