1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/backdrop_ynh.git synced 2024-09-03 20:36:14 +02:00

Protect config file

This commit is contained in:
ericgaspar 2021-03-23 08:37:54 +01:00
parent e379dc87bb
commit ab71f3fa45
No known key found for this signature in database
GPG key ID: 574F281483054D44
3 changed files with 41 additions and 31 deletions

View file

@ -55,6 +55,14 @@ db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=2
# Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -72,14 +80,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=2
# Create a system user
ynh_system_user_create --username=$app
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
@ -96,15 +96,19 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
ynh_script_progression --message="Configuring Backdrop..." --weight=1
cp ../conf/settings.example.php "$final_path/settings.php"
salt=$(ynh_string_random --length=30)
# Change variables in ttrss configuration
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/settings.php"
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/settings.php"
ynh_replace_string --match_string="__SALT__" --replace_string="$(ynh_string_random --length=30)" --target_file="$final_path/settings.php"
ynh_add_config --template="../conf/settings.example.php" --destination="$final_path/settings.php"
# Recalculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$final_path/settings.php"
# cp ../conf/settings.example.php "$final_path/settings.php"
# # Change variables in ttrss configuration
# ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/settings.php"
# ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/settings.php"
# ynh_replace_string --match_string="__SALT__" --replace_string="$(ynh_string_random --length=30)" --target_file="$final_path/settings.php"
# # Recalculate and store the config file checksum into the app settings
# ynh_store_file_checksum --file="$final_path/settings.php"
#=================================================
# SECURE FILES AND DIRECTORIES
@ -115,6 +119,8 @@ chown -R root: $final_path
chown -R $app:www-data $final_path/files
chmod -R 770 $final_path/files
chmod 600 $final_path/settings.php
#=================================================
# SETUP SSOWAT
#=================================================

View file

@ -46,20 +46,20 @@ test ! -d $final_path \
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring Backdrop main directory..." --weight=2
ynh_restore_file --origin_path="$final_path"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=3
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring Backdrop main directory..." --weight=2
ynh_restore_file --origin_path="$final_path"
#=================================================
# RESTORE USER RIGHTS
@ -70,6 +70,8 @@ chown -R root: $final_path
chown -R $app:www-data $final_path/files
chmod -R 770 $final_path/files
chmod 600 $final_path/settings.php
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================

View file

@ -67,6 +67,14 @@ ynh_clean_setup () {
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
@ -88,14 +96,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
@ -144,6 +144,8 @@ chown -R root: $final_path
chown -R $app:www-data $final_path/files
chmod -R 770 $final_path/files
chmod 600 $final_path/settings.php
#=================================================
# GENERIC FINALIZATION
#=================================================