mirror of
https://github.com/YunoHost-Apps/z-push_ynh.git
synced 2024-09-03 18:05:58 +02:00
Switch to dedicated user
This commit is contained in:
parent
43b5e84a05
commit
97c7ea9e14
4 changed files with 46 additions and 11 deletions
|
@ -20,8 +20,8 @@
|
||||||
; Unix user/group of processes
|
; Unix user/group of processes
|
||||||
; Note: The user is mandatory. If the group is not set, the default user's group
|
; Note: The user is mandatory. If the group is not set, the default user's group
|
||||||
; will be used.
|
; will be used.
|
||||||
user = www-data
|
user = __USER__
|
||||||
group = www-data
|
group = __USER__
|
||||||
|
|
||||||
; The address on which to accept FastCGI requests.
|
; The address on which to accept FastCGI requests.
|
||||||
; Valid syntaxes are:
|
; Valid syntaxes are:
|
||||||
|
|
|
@ -82,6 +82,14 @@ ynh_print_info "Configuring nginx web server..."
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info "Configuring system user..."
|
||||||
|
|
||||||
|
# Create a system user
|
||||||
|
ynh_system_user_create $app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PHP-FPM CONFIGURATION
|
# PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -98,10 +106,10 @@ ynh_add_fpm_config
|
||||||
ynh_print_info "Creating statedir and final_logpath..."
|
ynh_print_info "Creating statedir and final_logpath..."
|
||||||
|
|
||||||
mkdir -p $statedir
|
mkdir -p $statedir
|
||||||
chown -R www-data:www-data $statedir
|
chown -R $app: $statedir
|
||||||
|
|
||||||
mkdir -p $final_logpath
|
mkdir -p $final_logpath
|
||||||
chown -R www-data:www-data $final_logpath
|
chown -R $app: $final_logpath
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY A CONFIG FILE
|
# MODIFY A CONFIG FILE
|
||||||
|
@ -201,7 +209,7 @@ ln -s /usr/share/awl/inc/XML* /var/www/$app/include/
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Set permissions to app files
|
# Set permissions to app files
|
||||||
chown -R www-data: $final_path
|
chown -R $app: $final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
|
|
|
@ -54,15 +54,29 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
ynh_print_info "Restoring the app main directory..."
|
ynh_print_info "Restoring the app main directory..."
|
||||||
|
|
||||||
ynh_restore_file "$final_path"
|
ynh_restore_file "$final_path"
|
||||||
chown -R www-data: $final_path
|
|
||||||
|
|
||||||
# Restore statedir
|
# Restore statedir
|
||||||
ynh_restore_file "$statedir"
|
ynh_restore_file "$statedir"
|
||||||
chown -R www-data:www-data $statedir
|
|
||||||
|
|
||||||
# Restore logs, data & permissions
|
# Restore logs, data & permissions
|
||||||
ynh_restore_file "$final_logpath"
|
ynh_restore_file "$final_logpath"
|
||||||
chown -R www-data:www-data $final_logpath
|
|
||||||
|
#=================================================
|
||||||
|
# RECREATE THE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info "Recreating the dedicated system user..."
|
||||||
|
|
||||||
|
# Create the dedicated user (if not existing)
|
||||||
|
ynh_system_user_create $app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE USER RIGHTS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Restore permissions on app files
|
||||||
|
chown -R $app: $final_path
|
||||||
|
chown -R $app: $statedir
|
||||||
|
chown -R $app: $final_logpath
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE PHP-FPM CONFIGURATION
|
# RESTORE THE PHP-FPM CONFIGURATION
|
||||||
|
|
|
@ -46,16 +46,18 @@ if [ -z "$statedir" ];
|
||||||
then
|
then
|
||||||
statedir="/home/yunohost.app/$app"
|
statedir="/home/yunohost.app/$app"
|
||||||
ynh_app_setting_set "$app" statedir "$statedir"
|
ynh_app_setting_set "$app" statedir "$statedir"
|
||||||
|
mkdir -p $statedir
|
||||||
else
|
else
|
||||||
echo "${statedir} exists, we don't create it."
|
ynh_print_info "${statedir} exists, we don't create it."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$final_logpath" ];
|
if [ -z "$final_logpath" ];
|
||||||
then
|
then
|
||||||
final_logpath="/var/log/$app"
|
final_logpath="/var/log/$app"
|
||||||
ynh_app_setting_set "$app" final_logpath "$final_logpath"
|
ynh_app_setting_set "$app" final_logpath "$final_logpath"
|
||||||
|
mkdir -p $final_logpath
|
||||||
else
|
else
|
||||||
echo "${final_logpath} exists, we don't create it."
|
ynh_print_info "${final_logpath} exists, we don't create it."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -100,6 +102,14 @@ ynh_print_info "Upgrading dependencies..."
|
||||||
|
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info "Making sure dedicated system user exists..."
|
||||||
|
|
||||||
|
# Create a dedicated user (if not existing)
|
||||||
|
ynh_system_user_create $app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PHP-FPM CONFIGURATION
|
# PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -216,7 +226,10 @@ ynh_use_logrotate --non-append
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Set permissions on app files
|
# Set permissions on app files
|
||||||
chown -R www-data: $final_path
|
chown -R $app: $final_path
|
||||||
|
|
||||||
|
chown -R $app: $statedir
|
||||||
|
chown -R $app: $final_logpath
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
|
|
Loading…
Add table
Reference in a new issue