1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/paheko_ynh.git synced 2024-09-03 19:56:22 +02:00

keep backup if exist of config.local.php

This commit is contained in:
Robles Rodolphe 2020-08-28 16:40:06 +02:00
parent 649a74f3e2
commit 3423f57188

View file

@ -71,6 +71,7 @@ ynh_script_progression --message="Backing up the data before upgrading (may take
bdd=$final_path/association.sqlite bdd=$final_path/association.sqlite
squelettes=$final_path/www/squelettes squelettes=$final_path/www/squelettes
config=$final_path/config.local.php
if [ -d "$squelettes" ]; then if [ -d "$squelettes" ]; then
cp -ar $squelettes /tmp/squelettes cp -ar $squelettes /tmp/squelettes
@ -80,6 +81,10 @@ if [ -e "$bdd" ]; then
cp -a $bdd /tmp/association.sqlite cp -a $bdd /tmp/association.sqlite
fi fi
if [ -e "$config" ]; then
cp -a $config /tmp/config
fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
@ -153,17 +158,17 @@ ynh_add_fpm_config
# Change options in file config.dist.php # Change options in file config.dist.php
# and copy in local.dist.php # and copy in local.dist.php
#================================================= #=================================================
ynh_script_progression --message="final configuration needed..." --time --weight=1 # ynh_script_progression --message="final configuration needed..." --time --weight=1
# key=$(ynh_string_random --length=50) # key=$(ynh_string_random --length=50)
cp -a $final_path/config.dist.php $final_path/config.local.php # cp -a $final_path/config.dist.php $final_path/config.local.php
# ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" # ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php"
if [ "$path_url" == "/" ] # if [ "$path_url" == "/" ]
then # then
ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" # ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php"
else # else
ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" # ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php"
fi # fi
#======================================================= #=======================================================
# backup bdd, squelettes directory and config.local.php # backup bdd, squelettes directory and config.local.php
#======================================================= #=======================================================
@ -171,6 +176,7 @@ ynh_script_progression --message="restore data..." --time --weight=1
backup_bdd=/tmp/association.sqlite backup_bdd=/tmp/association.sqlite
backup_squelettes=/tmp/squelettes backup_squelettes=/tmp/squelettes
backup_config=/tmp/config
if [ -d "$backup_squelettes" ] if [ -d "$backup_squelettes" ]
then then
@ -182,6 +188,21 @@ then
cp -a $backup_bdd $final_path/association.sqlite cp -a $backup_bdd $final_path/association.sqlite
fi fi
if [ -e "$backup_config" ]
then
cp -a $backup_config $final_path/config.local.php
else
key=$(ynh_string_random --length=50)
cp -a $final_path/config.dist.php $final_path/config.local.php
ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php"
if [ "$path_url" == "/" ]
then
ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php"
else
ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php"
fi
fi
#================================================= #=================================================
# Files owned by user app # Files owned by user app
#================================================= #=================================================