1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/nodered_ynh.git synced 2024-09-03 19:46:25 +02:00

[enh] proper ownership

This commit is contained in:
tituspijean 2019-10-13 19:50:59 +02:00
parent fbf65c2ee8
commit 5a246be7e3
3 changed files with 38 additions and 18 deletions

View file

@ -7,6 +7,7 @@
#================================================= #=================================================
source _common.sh source _common.sh
source ynh_exec_as
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -94,14 +95,24 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path"
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --time --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# Install through npm # Install through npm
#================================================= #=================================================
ynh_script_progression --message="Installing node-red..." --time --weight=2 ynh_script_progression --message="Installing node-red..." --time --weight=2
chown -R $app: $final_path
pushd $final_path pushd $final_path
ynh_use_nodejs ynh_use_nodejs
npm install --production exec_as $app env PATH=$PATH npm install --production
popd popd
#================================================= #=================================================
@ -114,14 +125,6 @@ ynh_script_progression --message="Configuring nginx web server..." --time --weig
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --time --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================

View file

@ -7,6 +7,7 @@
#================================================= #=================================================
source _common.sh source _common.sh
source ynh_exec_as
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -115,14 +116,24 @@ then
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path"
fi fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# Install through npm # Install through npm
#================================================= #=================================================
ynh_script_progression --message="Installing node-red..." --time --weight=2 ynh_script_progression --message="Installing node-red..." --time --weight=2
chown -R $app: $final_path
pushd $final_path pushd $final_path
ynh_use_nodejs ynh_use_nodejs
npm install --production exec_as $app env PATH=$PATH npm install --production
popd popd
#================================================= #=================================================
@ -133,14 +144,6 @@ ynh_script_progression --message="Upgrading nginx web server configuration..." -
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================

14
scripts/ynh_exec_as Normal file
View file

@ -0,0 +1,14 @@
#!/bin/bash
# Execute a command as another user
# usage: exec_as USER COMMAND [ARG ...]
exec_as() {
local USER=$1
shift 1
if [[ $USER = $(whoami) ]]; then
eval "$@"
else
sudo -u "$USER" "$@"
fi
}