From 585aea1d63910c014a948d187ea6834b137ffbe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Fri, 6 Oct 2023 19:20:15 +0200 Subject: [PATCH] cleaning --- scripts/change_url | 2 +- scripts/install | 10 ------- scripts/restore | 13 -------- scripts/upgrade | 75 +++------------------------------------------- 4 files changed, 5 insertions(+), 95 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 414cc1c..eb922bb 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 4d37886..ac7cbfc 100644 --- a/scripts/install +++ b/scripts/install @@ -46,16 +46,6 @@ ynh_add_config --template="../conf/config.local.php" --destination="$install_dir chmod 650 "$install_dir/config.local.php" chown $app:$app "$install_dir/config.local.php" -# Permissions on files and directories - -#find "$install_dir" -type d -exec chmod 550 {} + -#find "$install_dir" -type f -exec chmod 440 {} + -#find "$install_dir/data" -type d -exec chmod 770 {} + -#find "$install_dir/data" -type f -exec chmod 660 {} + -#chmod 440 "$install_dir/config.local.php" -#chmod 440 "$install_dir/config.local.yunohost.php" -#chmod 660 "$install_dir/data/config.local.user.php" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 9879a3d..2102651 100644 --- a/scripts/restore +++ b/scripts/restore @@ -21,7 +21,6 @@ ynh_restore_file --origin_path="$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" - #================================================= # RESTORE THE DATA DIRECTORY #================================================= @@ -29,18 +28,6 @@ ynh_script_progression --message="Restoring the data directory..." --weight=1 ynh_restore_file --origin_path="$data_dir" --not_mandatory -# (Same as for install dir) -# chown -R $app:www-data "$data_dir" -# find "$install_dir" -type d -exec chmod 550 {} + -# find "$install_dir" -type f -exec chmod 440 {} + -# find "$install_dir/data" -type d -exec chmod 770 {} + -# find "$install_dir/data" -type f -exec chmod 660 {} + -# chmod 440 "$install_dir/config.local.php" -# chmod 440 "$install_dir/config.local.yunohost.php" -# if [[ -f "$install_dir/config.local.user.php" ]]; then -# chmod 660 "$install_dir/config.local.user.php" -# fi - #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index e2f7aea..75db7bc 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -29,23 +29,6 @@ if [[ -z "${secret_key:-}" ]]; then ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key fi -#================================================= -# BACKUP SQLITE DATABASE AND DATAS -#================================================= -ynh_script_progression --message="Backup of the DB in temporary file...." --weight=5 - -# copy data directory backup -tmp_data_backup=$(mktemp -d) -rsync -a $install_dir/data/ $tmp_data_backup/ - -if [[ -f "$install_dir/config.local.user.php" ]]; then - cp -a $install_dir/config.local.user.php $tmp_data_backup/ -fi - -if [[ $(grep "Garradin" "$tmp_data_backup/config.local.user.php") ]] ; then - ynh_replace_string --match_string="namespace Garradin;" --replace_string="namespace Paheko;" --target_file="$tmp_data_backup/config.local.user.php" -fi - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -78,61 +61,11 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Updating a configuration file..." --weight=5 -if ynh_compare_current_package_version --comparison lt --version 1.1.15~ynh1; then - chmod 750 "$install_dir/data/config.local.user.php" - ynh_add_config --template="config.local.user.php" --destination="$install_dir/data/config.local.user.php" -fi +# Install configuration files +ynh_add_config --template="../conf/config.local.php" --destination="$install_dir/config.local.php" -# NOTE: Don't overwrite config.local.user.php -ynh_add_config --template="config.local.php" --destination="$install_dir/config.local.php" -ynh_add_config --template="config.local.yunohost.php" --destination="$install_dir/config.local.yunohost.php" - -#================================================= -# RESTORE BACKUP SQLITE DATABASE AND DATAS -#================================================= -ynh_script_progression --message="Restore datas..." --weight=5 - -# Sync data directory backup -rsync -a $tmp_data_backup/ $install_dir/data/ - -#================================================= -# FIX PERMISSIONS -#================================================= -ynh_script_progression --message="Fix permissions..." --weight=2 - -# Permissions on files and directories -chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" -find "$install_dir" -type d -exec chmod 550 {} + -find "$install_dir" -type f -exec chmod 440 {} + -find "$install_dir/data" -type d -exec chmod 770 {} + -find "$install_dir/data" -type f -exec chmod 660 {} + -chmod 440 "$install_dir/config.local.php" -chmod 440 "$install_dir/config.local.yunohost.php" -chmod 660 "$install_dir/data/config.local.user.php" - -#================================================= -# FINALISE UPGRADE -#================================================= -ynh_script_progression --message="Finalise upgrade" --weight=1 - -ynh_local_curl "/admin/index.php" -sleep 5 -ynh_local_curl "/index.php" -sleep 5 - -# remove data directory backup -ynh_secure_remove --file="$tmp_data_backup" - -# clean duplicate folder if exist -if [[ -d "$install_dir/data/data" ]]; then - ynh_secure_remove --file="$install_dir/data/data" -fi - -# clean unused file if exist -if [[ -f "$install_dir/config.local.user.php" ]]; then - ynh_secure_remove --file="$install_dir/config.local.user.php" -fi +chmod 650 "$install_dir/config.local.php" +chown $app:$app "$install_dir/config.local.php" #================================================= # END OF SCRIPT