From fbeeb6083e6203a13a8980a9557bb14340d356f4 Mon Sep 17 00:00:00 2001 From: Florent Date: Mon, 6 Feb 2023 12:04:29 +0100 Subject: [PATCH] Don't use git anymore --- conf/systemd.service | 3 ++- scripts/_common.sh | 2 +- scripts/install | 15 ++++++--------- scripts/upgrade | 21 +++++++-------------- 4 files changed, 16 insertions(+), 25 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index 3f34b6f..19671ae 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -8,9 +8,10 @@ Requires=elasticsearch8.service Type=simple Environment=NODE_ENV=production Environment=NODE_CONFIG_DIR=__FINALPATH__/config +Environment="__YNH_NODE_LOAD_PATH__" User=__APP__ Group=__APP__ -ExecStart=__YNH_NPM__ start +ExecStart=__YNH_NODE__ __FINALPATH__/dist/server.js WorkingDirectory=__FINALPATH__/ StandardOutput=syslog StandardError=syslog diff --git a/scripts/_common.sh b/scripts/_common.sh index 9660e48..07f4d28 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="git" +pkg_dependencies="" app_dependencies="elasticsearch8" extra_pkg_dependencies="elasticsearch-oss" diff --git a/scripts/install b/scripts/install index c5153e8..eeb4fe7 100644 --- a/scripts/install +++ b/scripts/install @@ -64,9 +64,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= ynh_script_progression --message="Installing dependencies..." - ynh_install_apps --apps="$app_dependencies" -ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" @@ -85,16 +83,12 @@ ynh_script_progression --message="Setting up source files..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -git clone $REPOSITORY $final_path --quiet +ynh_setup_source --dest_dir="$final_path" --keep="config/local.yaml" chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" -pushd "$final_path" - ynh_exec_as $app git checkout $COMMIT --quiet -popd - #================================================= # NGINX CONFIGURATION #================================================= @@ -111,13 +105,16 @@ ynh_add_nginx_config ynh_script_progression --message="Building..." pushd "$final_path" - ynh_exec_as $app git submodule update --init --recursive ynh_use_nodejs yarn install --pure-lockfile - ynh_exec_as $app mkdir "$final_path/dist" $ynh_npm run build popd +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app "$final_path" + + #================================================= # ADD A CONFIGURATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 86f5006..894c7e1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -79,12 +79,7 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." - # Download, check integrity, uncompress and patch the source from app.src - pushd "$final_path" - ynh_exec_as $app git checkout master - ynh_exec_as $app git pull --quiet - ynh_exec_as $app git checkout $COMMIT --quiet - popd + ynh_setup_source --full_replace=1 --dest_dir="$final_path" --keep="config/local.yaml" fi chmod 750 "$final_path" @@ -105,17 +100,11 @@ ynh_add_nginx_config ynh_script_progression --message="Upgrading dependencies..." if ynh_compare_current_package_version --comparison lt --version 0.0.1.2023-01-04~ynh1; then - # Remove elasticsearch from repositories + # Remove elasticsearch and git from dependencies ynh_remove_app_dependencies - - # Fix rights - chmod 750 "$final_path" - chmod -R o-rwx "$final_path" - chown -R $app:$app "$final_path" fi ynh_install_apps --apps="$app_dependencies" -ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" @@ -127,12 +116,16 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st ynh_script_progression --message="Building..." pushd "$final_path" - ynh_exec_as $app git submodule update --init --recursive ynh_use_nodejs yarn install --pure-lockfile $ynh_npm run build + popd +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app "$final_path" + #================================================= # UPDATE A CONFIG FILE #=================================================