1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/teampass_ynh.git synced 2024-09-03 20:26:37 +02:00

Simplification

This commit is contained in:
yalh76 2022-07-04 21:15:54 +02:00
parent 1d775411a8
commit c9e7571703
3 changed files with 17 additions and 27 deletions

View file

@ -12,7 +12,7 @@ $port = 3306;
$encoding = "utf8"; $encoding = "utf8";
@date_default_timezone_set($_SESSION['settings']['timezone']); @date_default_timezone_set($_SESSION['settings']['timezone']);
@define('SECUREPATH', '__PATH_SK_FILE__'); @define('SECUREPATH', '/etc/__APP__/');
if (file_exists("__PATH_SK_FILE__sk.php")) { if (file_exists("/etc/__APP__/sk.php")) {
require_once "__PATH_SK_FILE__sk.php"; require_once "/etc/__APP__/sk.php";
} }

View file

@ -158,9 +158,6 @@ echo ");" >> $tp_config_file
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." ynh_script_progression --message="Adding a configuration file..."
path_sk_file=/etc/$app/
mkdir $path_sk_file
ynh_add_config --template="../conf/settings.php" --destination="$final_path/includes/config/settings.php" ynh_add_config --template="../conf/settings.php" --destination="$final_path/includes/config/settings.php"
#================================================= #=================================================
@ -169,15 +166,15 @@ ynh_add_config --template="../conf/settings.php" --destination="$final_path/incl
ynh_script_progression --message="Creating a saltkey..." ynh_script_progression --message="Creating a saltkey..."
saltkey=$(ynh_string_random --length=32) saltkey=$(ynh_string_random --length=32)
ynh_replace_string "__SALTKEY__" "$saltkey" ../conf/sk.php mkdir /etc/$app/
ynh_add_config --template="../conf/sk.php" --destination="$path_sk_file/sk.php" ynh_add_config --template="../conf/sk.php" --destination="/etc/$app/sk.php"
chown -R $app /etc/$app/
chmod 750 /etc/$app/
#================================================= #=================================================
# COPY THE FILES # CREATE CSRFP
#================================================= #=================================================
ynh_script_progression --message="Creating a csrfp..."
chown -R $app $path_sk_file
chmod 750 $path_sk_file
cp $final_path/includes/libraries/csrfp/libs/csrfp.config.sample.php $final_path/includes/libraries/csrfp/libs/csrfp.config.php # Créer le fichier de config de csrfp cp $final_path/includes/libraries/csrfp/libs/csrfp.config.sample.php $final_path/includes/libraries/csrfp/libs/csrfp.config.php # Créer le fichier de config de csrfp
ynh_replace_string "CSRFP_TOKEN\" => \"" "&$(head -n40 /dev/urandom | tr -c -d 'a-f0-9' | head -c50)" $final_path/includes/libraries/csrfp/libs/csrfp.config.php # Renseigne un token, valide en hexadécimal ynh_replace_string "CSRFP_TOKEN\" => \"" "&$(head -n40 /dev/urandom | tr -c -d 'a-f0-9' | head -c50)" $final_path/includes/libraries/csrfp/libs/csrfp.config.php # Renseigne un token, valide en hexadécimal
@ -213,7 +210,6 @@ ynh_replace_string "jsUrl\" => \"" "&includes/libraries/csrfp/js/csrfprotector.j
ynh_script_progression --message="Creating a cron file for an automatic backup..." ynh_script_progression --message="Creating a cron file for an automatic backup..."
echo "0 0 * * 0 $app cd $final_path/backups && php script.backup.php" > /etc/cron.d/$app echo "0 0 * * 0 $app cd $final_path/backups && php script.backup.php" > /etc/cron.d/$app
# Add also a clean of old backup.
#================================================= #=================================================
# SECURING FILES AND DIRECTORIES # SECURING FILES AND DIRECTORIES

View file

@ -87,9 +87,8 @@ then
# 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"
# Delete the install directory. # Do not delete the install directory. Keep it for the manual upgrade process...
# Keep it for the manual upgrade process... # ynh_secure_remove "$final_path/install"
# ynh_secure_remove "$final_path/install"
fi fi
chmod 750 "$final_path" chmod 750 "$final_path"
@ -103,6 +102,7 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
# Create a dedicated PHP-FPM config # Create a dedicated PHP-FPM config
ynh_add_fpm_config ynh_add_fpm_config
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -133,18 +133,13 @@ do
done <<< "$(ynh_mysql_execute_as_root "SELECT intitule, valeur FROM teampass_misc" $app)" done <<< "$(ynh_mysql_execute_as_root "SELECT intitule, valeur FROM teampass_misc" $app)"
echo ");" >> $tp_config_file echo ");" >> $tp_config_file
#=================================================
# CREATE A CRON FILE FOR AUTOMATIC BACKUP
#=================================================
ynh_script_progression --message="Creating a cron file for an automatic backup..."
echo "0 0 * * 0 $app cd $final_path/backups && php script.backup.php" > /etc/cron.d/$app
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." ynh_script_progression --message="Updating a configuration file..."
ynh_add_config --template="../conf/settings.php" --destination="$final_path/includes/config/settings.php"
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
# Move settings.php from old teampass version # Move settings.php from old teampass version
@ -173,12 +168,11 @@ then
fi fi
#================================================= #=================================================
# UPDATE SETTINGS.PHP # CREATE A CRON FILE FOR AN AUTOMATIC BACKUP
#================================================= #=================================================
ynh_script_progression --message="Creating a cron file for an automatic backup..."
path_sk_file="/etc/$app/" echo "0 0 * * 0 $app cd $final_path/backups && php script.backup.php" > /etc/cron.d/$app
ynh_add_config --template="../conf/settings.php" --destination="$final_path/includes/config/settings.php"
#================================================= #=================================================
# SECURING FILES AND DIRECTORIES # SECURING FILES AND DIRECTORIES