From 057297c0a6af7fc302755bfad5a8d31340154511 Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Sat, 17 Apr 2021 21:27:09 -0400 Subject: [PATCH] Various minor fixes --- conf/librephotos.env | 2 +- scripts/_common.sh | 11 +++++++---- scripts/restore | 17 ++++++++--------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/conf/librephotos.env b/conf/librephotos.env index ddac611..9f12ab2 100644 --- a/conf/librephotos.env +++ b/conf/librephotos.env @@ -26,4 +26,4 @@ httpPort=__PORT__ BACKEND_PORT=__BACKEND_PORT__ IMAGE_SIMILARITY_SERVER_PORT=__SIMILARITY_PORT__ MPLCONFIGDIR=__DATA_PATH__/matplotlib -NODEJS_PATH=__NODEJS_PATH__ \ No newline at end of file +NODEJS_PATH=__NODEJS_PATH__ diff --git a/scripts/_common.sh b/scripts/_common.sh index 6179262..e8cb5be 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -50,18 +50,21 @@ function set_up_virtualenv { popd || ynh_die } -function set_up_frontend { +function set_node_vars { ynh_exec_warn_less ynh_install_nodejs --nodejs_version=10 ynh_use_nodejs node_PATH=$nodejs_path:$(sudo -u $app sh -c 'echo $PATH') +} + +function set_up_frontend { frontend_path=$final_path/frontend pushd $final_path/frontend || ynh_die chown -R $app:$app $frontend_path sudo -u $app touch $frontend_path/.yarnrc - sudo -u $app PATH=$node_PATH yarn --cache-folder $frontend_path/yarn-cache --use-yarnrc $frontend_path/.yarnrc install 2>&1 - sudo -u $app PATH=$node_PATH yarn --cache-folder $frontend_path/yarn-cache --use-yarnrc $frontend_path/.yarnrc run build 2>&1 - sudo -u $app PATH=$node_PATH yarn --cache-folder $frontend_path/yarn-cache --use-yarnrc $frontend_path/.yarnrc add serve 2>&1 + sudo -u $app env "PATH=$node_PATH" yarn --cache-folder $frontend_path/yarn-cache --use-yarnrc $frontend_path/.yarnrc install 2>&1 + sudo -u $app env "PATH=$node_PATH" yarn --cache-folder $frontend_path/yarn-cache --use-yarnrc $frontend_path/.yarnrc run build 2>&1 + sudo -u $app env "PATH=$node_PATH" yarn --cache-folder $frontend_path/yarn-cache --use-yarnrc $frontend_path/.yarnrc add serve 2>&1 chown -R root:root $frontend_path popd || ynh_die } diff --git a/scripts/restore b/scripts/restore index f1f28a9..6c6e656 100755 --- a/scripts/restore +++ b/scripts/restore @@ -113,15 +113,7 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= # Restore permissions on app files -chown -R root:$app $final_path -chmod -R g=u,g-w,o-rwx $final_path -chown -R $app:$app $data_path -chmod -R g=u,g-w,o-rwx $data_path -chown -R $app:$app $final_path/data_models -chown -R $app:$app /var/log/$app -chmod -R g-w,o-rwx /var/log/$app -setfacl -n -m user:www-data:rx $data_path -setfacl -n -R -m user:www-data:rx -m default:user:www-data:rx $data_path/protected_media $data_path/data $data_path/data/nextcloud_media +set_permissions #================================================= # SPECIFIC RESTORATION @@ -134,6 +126,13 @@ ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +#================================================= +# RESTORE NODE.JS +#================================================= +ynh_script_progression --message="Restoring Node.js..." --weight=1 + +set_node_vars + #================================================= # RESTORE SYSTEMD #=================================================