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/conf/systemd.service b/conf/systemd.service index 1dd8209..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 '__FINALPATH__/node_modules/.bin/ts-node --project __FINALPATH__/tsconfig.json __FINALPATH__/bin/server.ts >> /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 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": { diff --git a/scripts/install b/scripts/install index 9191b79..eedba30 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 @@ -97,6 +98,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 #================================================= @@ -176,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 @@ -185,12 +187,16 @@ 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=$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 + + #================================================= # SETUP SYSTEMD #================================================= 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..9ff0276 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 #================================================= @@ -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 #=================================================