Change permissions with a dedicated function

This commit is contained in:
Miraty 2022-03-06 02:54:51 +01:00
parent 3a594c167e
commit 2e680284a4
4 changed files with 22 additions and 15 deletions

14
scripts/_common.sh Normal file
View File

@ -0,0 +1,14 @@
libreqr_apply_filesystem_permissions() {
find "$final_path" -type f -exec chmod 400 "{}" +
find "$final_path" -type f -exec chown www-data:www-data "{}" +
find "$final_path" -type d -exec chmod 110 "{}" +
find "$final_path" -type d -exec chown $app:www-data "{}" +
find "$final_path" -type f -name "*.php" -exec chmod 400 "{}" +
find "$final_path" -type f -name "*.php" -exec chown $app:$app "{}" +
find "$final_path" -type f -name "*.css" -exec chmod 440 "{}" +
find "$final_path" -type f -name "*.css" -exec chown $app:www-data "{}" +
find "$final_path" -type f -name "*.less" -exec chmod 440 "{}" +
find "$final_path" -type f -name "*.less" -exec chown $app:www-data "{}" +
chmod 350 "$final_path"/css
chown $app:www-data "$final_path"/css
}

View File

@ -1,4 +1,5 @@
#!/bin/bash
source _common.sh
source /usr/share/yunohost/helpers
ynh_abort_if_errors
@ -23,10 +24,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
ynh_script_progression --message="Setting up source files..."
ynh_setup_source --dest_dir="$final_path"
chmod -R 440 "$final_path"
find "$final_path" -type d | xargs chmod 110
chmod 750 "$final_path"/css
chown -R $app:www-data "$final_path"
libreqr_apply_filesystem_permissions
ynh_script_progression --message="Configuring NGINX web server..."
ynh_add_nginx_config

View File

@ -1,9 +1,10 @@
#!/bin/bash
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
ynh_abort_if_errors
ynh_script_progression --message="Loading installation settings..." --weight=1
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
@ -15,16 +16,13 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path"
chmod -R 440 "$final_path"
find "$final_path" -type d | xargs chmod 110
chmod 750 "$final_path"/css
chown -R $app:www-data "$final_path"
libreqr_apply_filesystem_permissions
ynh_script_progression --message="Restoring the PHP-FPM configuration..."
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
ynh_script_progression --message="Restoring the NGINX configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_systemd_action --service_name=nginx --action=reload

View File

@ -1,4 +1,5 @@
#!/bin/bash
source _common.sh
source /usr/share/yunohost/helpers
ynh_script_progression --message="Loading installation settings..."
@ -31,11 +32,7 @@ then
ynh_secure_remove --file="$final_path"
ynh_setup_source --dest_dir="$final_path"
fi
chmod -R 440 "$final_path"
find "$final_path" -type d | xargs chmod 110
chmod 750 "$final_path"/css
chown -R $app:www-data "$final_path"
libreqr_apply_filesystem_permissions
ynh_script_progression --message="Upgrading NGINX web server configuration..."
ynh_add_nginx_config