From ee41044ec0eafd3c626d2ae7d20491f09fc0b2aa Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Sat, 17 Apr 2021 21:32:11 -0400 Subject: [PATCH] Minor fixes --- scripts/_common.sh | 20 ++++++++++++++++++++ scripts/install | 16 ++-------------- scripts/restore | 5 +---- scripts/upgrade | 16 ++-------------- 4 files changed, 25 insertions(+), 32 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 78ced19..ba6cc63 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -11,6 +11,26 @@ pkg_dependencies="nodejs npm libpng16-16 libpng-dev pkg-config autoconf libtool # PERSONAL HELPERS #================================================= +function build_node_app { + ynh_exec_warn_less ynh_install_nodejs --nodejs_version=10 + ynh_use_nodejs + node_PATH=$nodejs_path:$(sudo -u $app sh -c 'echo $PATH') + + pushd $final_path || ynh_die + chown -R $app:$app $final_path + sudo -u $app touch $final_path/.yarnrc + sudo -u $app "env PATH=$node_PATH" yarn --cache-folder $final_path/yarn-cache --use-yarnrc $final_path/.yarnrc install 2>&1 + chown -R root:root $final_path + popd || ynh_die +} + +function set_permissions { + 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 +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 69bb320..2c6ea93 100755 --- a/scripts/install +++ b/scripts/install @@ -106,16 +106,7 @@ usermod -d $final_path $app 2>&1 #================================================= ynh_script_progression --message="Installing Node.js packages ..." --weight=45 -ynh_exec_warn_less ynh_install_nodejs --nodejs_version=10 -ynh_use_nodejs -node_PATH=$nodejs_path:$(sudo -u $app sh -c 'echo $PATH') - -pushd $final_path || ynh_die - chown -R $app:$app $final_path - sudo -u $app touch $final_path/.yarnrc - sudo -u $app PATH=$node_PATH yarn --cache-folder $final_path/yarn-cache --use-yarnrc $final_path/.yarnrc install 2>&1 - chown -R root:root $final_path -popd || ynh_die +build_node_app #================================================= # SETUP SYSTEMD @@ -139,10 +130,7 @@ ln -sf $final_path/config.ini $data_path/config.ini #================================================= # Set permissions to 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 +set_permissions #================================================= # INTEGRATE SERVICE IN YUNOHOST diff --git a/scripts/restore b/scripts/restore index 9b1aace..b2e9f93 100755 --- a/scripts/restore +++ b/scripts/restore @@ -79,10 +79,7 @@ usermod -d $final_path $app 2>&1 #================================================= # 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 +set_permissions #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index 22b92ce..f409532 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -98,16 +98,7 @@ usermod -d $final_path $app 2>&1 #================================================= ynh_script_progression --message="Installing Node.js packages ..." --weight=1 -ynh_exec_warn_less ynh_install_nodejs --nodejs_version=10 -ynh_use_nodejs -node_PATH=$nodejs_path:$(sudo -u $app sh -c 'echo $PATH') - -pushd $final_path || ynh_die - chown -R $app:$app $final_path - sudo -u $app touch $final_path/.yarnrc - sudo -u $app PATH=$node_PATH yarn --cache-folder $final_path/yarn-cache --use-yarnrc $final_path/.yarnrc install 2>&1 - chown -R root:root $final_path -popd || ynh_die +build_node_app #================================================= # SETUP SYSTEMD @@ -131,10 +122,7 @@ ln -sf $final_path/config.ini $data_path/config.ini #================================================= # Set 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 +set_permissions #================================================= # INTEGRATE SERVICE IN YUNOHOST