From 33684addd3a37e8eb292c03939f65c2a785f0e86 Mon Sep 17 00:00:00 2001 From: ewilly Date: Thu, 6 Jul 2017 22:00:10 +0200 Subject: [PATCH 1/6] test --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index d74b573..22ef625 100644 --- a/scripts/restore +++ b/scripts/restore @@ -28,7 +28,7 @@ nginx_conf="/etc/nginx/conf.d/$domain.d/$app.conf" phpfpm_conf="/etc/php5/fpm/pool.d/$app}.conf" # check domain/path availability -ynh_webpath_available "$domain" "$path_url" +#ynh_webpath_available "$domain" "$path_url" ynh_webpath_register "$app" "$domain" "$path_url" myynh_check_path "$final_path" From 2843a2d5e91cf1c73a5245a12851d2c09b91325b Mon Sep 17 00:00:00 2001 From: ewilly Date: Thu, 6 Jul 2017 22:49:51 +0200 Subject: [PATCH 2/6] test --- scripts/restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/restore b/scripts/restore index 22ef625..87473d1 100644 --- a/scripts/restore +++ b/scripts/restore @@ -28,8 +28,8 @@ nginx_conf="/etc/nginx/conf.d/$domain.d/$app.conf" phpfpm_conf="/etc/php5/fpm/pool.d/$app}.conf" # check domain/path availability -#ynh_webpath_available "$domain" "$path_url" -ynh_webpath_register "$app" "$domain" "$path_url" +ynh_webpath_available "$domain" "$path_url" +#ynh_webpath_register "$app" "$domain" "$path_url" myynh_check_path "$final_path" # add required packages From c2e4d0da47b42d43b3a4d93a21d966fa62705d51 Mon Sep 17 00:00:00 2001 From: ewilly Date: Fri, 7 Jul 2017 06:15:32 +0200 Subject: [PATCH 3/6] test --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 87473d1..50615ea 100644 --- a/scripts/restore +++ b/scripts/restore @@ -25,7 +25,7 @@ backup_core_only=$(ynh_app_setting_get "$app" backup_core_only) final_path="/var/www/$app" data_path="/home/yunohost.app/$app" nginx_conf="/etc/nginx/conf.d/$domain.d/$app.conf" -phpfpm_conf="/etc/php5/fpm/pool.d/$app}.conf" +phpfpm_conf="/etc/php5/fpm/pool.d/$app.conf" # check domain/path availability ynh_webpath_available "$domain" "$path_url" From 59f0b23ffbc12ee501fd7742ac803e8b908b2709 Mon Sep 17 00:00:00 2001 From: ewilly Date: Fri, 7 Jul 2017 06:51:15 +0200 Subject: [PATCH 4/6] Fix restore --- scripts/_common.sh | 10 ++++++++++ scripts/install | 8 +------- scripts/restore | 13 +++++-------- scripts/upgrade | 9 +-------- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 9747461..22c41ea 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -72,6 +72,16 @@ myynh_add_fpm_config () { sudo systemctl reload php5-fpm } +myynh_set_permissions () { + [ -z $(sudo find "$final_path" -type f) ] && sudo find "$final_path" -type f | xargs sudo chmod 0644 + [ -z $(sudo find "$final_path" -type d) ] && sudo find "$final_path" -type d | xargs sudo chmod 0755 + [ -z $(sudo find "$data_path" -type f) ] && sudo find "$data_path" -type f | xargs sudo chmod 0644 + [ -z $(sudo find "$data_path" -type d) ] && sudo find "$data_path" -type d | xargs sudo chmod 0755 + sudo chown -R root:"$app" "$final_path" + sudo chown -R "$app": "$final_path/private" + sudo chown -R "$app": "$data_path/*" +} + # Remove the dedicated php-fpm config myynh_remove_fpm_config () { ynh_secure_remove "$phpfpm_conf" diff --git a/scripts/install b/scripts/install index 943ae70..adbeb9b 100644 --- a/scripts/install +++ b/scripts/install @@ -74,13 +74,7 @@ sudo ln -s "$data_path/uploads" "$final_path/uploads" sudo ln -s "$data_path/thumbs" "$final_path/thumbs" # set permissions -sudo find "$final_path" -type f | xargs sudo chmod 0644 -sudo find "$final_path" -type d | xargs sudo chmod 0755 -sudo find "$data_path" -type d | xargs sudo chmod 0755 -sudo chown -R root:"$app" "$final_path" -sudo chown -R "$app": "$final_path/private" -sudo chown -R "$app": "$data_path/uploads" -sudo chown -R "$app": "$data_path/thumbs" +myynh_set_permissions # configure nginx settings myynh_add_nginx_config diff --git a/scripts/restore b/scripts/restore index 50615ea..2055b36 100644 --- a/scripts/restore +++ b/scripts/restore @@ -29,7 +29,6 @@ phpfpm_conf="/etc/php5/fpm/pool.d/$app.conf" # check domain/path availability ynh_webpath_available "$domain" "$path_url" -#ynh_webpath_register "$app" "$domain" "$path_url" myynh_check_path "$final_path" # add required packages @@ -42,26 +41,24 @@ ynh_system_user_create "$app" ynh_restore_file "$nginx_conf" ynh_restore_file "$phpfpm_conf" -# restore source & their permissions +# restore source ynh_restore_file "$final_path" -sudo chown -R "$app": "$final_path" -sudo chmod 755 "$final_path" -# restore data & their permissions only if there is no data +# restore data only if there is no data if [ ! -d "$data_path" ]; then if [ $backup_core_only -eq 0 ]; then ynh_restore_file "$data_path" - sudo chown -R "$app": "$data_path" else myynh_create_dir "$data_path/uploads" - sudo chown -R "$app": "$data_path/uploads" myynh_create_dir "$data_path/thumbs" - sudo chown -R "$app": "$data_path/thumbs" fi else echo "$data_path already exists and will not be overwritten" >&2 fi +# set permissions +myynh_set_permissions + # restart services sudo systemctl reload php5-fpm sudo systemctl reload nginx diff --git a/scripts/upgrade b/scripts/upgrade index 871179c..916176d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -74,14 +74,7 @@ sudo cp -a "$TMPDIR/." "$final_path" sudo rm -R "$TMPDIR" # set permissions -sudo find "$final_path" -type f | xargs sudo chmod 0644 -sudo find "$final_path" -type d | xargs sudo chmod 0755 -sudo find "$data_path" -type f | xargs sudo chmod 0644 -sudo find "$data_path" -type d | xargs sudo chmod 0755 -sudo chown -R root:"$app" "$final_path" -sudo chown -R "$app": "$final_path/private" -sudo chown -R "$app": "$data_path/uploads" -sudo chown -R "$app": "$data_path/thumbs" +myynh_set_permissions # configure nginx settings myynh_add_nginx_config From c90c8a9aa6b2831a415482f5b11e01ff8811e93f Mon Sep 17 00:00:00 2001 From: ewilly Date: Fri, 7 Jul 2017 07:06:08 +0200 Subject: [PATCH 5/6] Update --- scripts/_common.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 22c41ea..207ca3f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -73,10 +73,10 @@ myynh_add_fpm_config () { } myynh_set_permissions () { - [ -z $(sudo find "$final_path" -type f) ] && sudo find "$final_path" -type f | xargs sudo chmod 0644 - [ -z $(sudo find "$final_path" -type d) ] && sudo find "$final_path" -type d | xargs sudo chmod 0755 - [ -z $(sudo find "$data_path" -type f) ] && sudo find "$data_path" -type f | xargs sudo chmod 0644 - [ -z $(sudo find "$data_path" -type d) ] && sudo find "$data_path" -type d | xargs sudo chmod 0755 + [ $(sudo find "$final_path" -type f | wc -l) -gt 0 ] && sudo find "$final_path" -type f | xargs sudo chmod 0644 + [ $(sudo find "$final_path" -type d | wc -l) -gt 0 ] && sudo find "$final_path" -type d | xargs sudo chmod 0755 + [ $(sudo find "$data_path" -type f | wc -l) -gt 0 ] && sudo find "$data_path" -type f | xargs sudo chmod 0644 + [ $(sudo find "$data_path" -type d | wc -l) -gt 0 ] && sudo find "$data_path" -type d | xargs sudo chmod 0755 sudo chown -R root:"$app" "$final_path" sudo chown -R "$app": "$final_path/private" sudo chown -R "$app": "$data_path/*" From f4e500a940170f00280478f322de962fbebaa699 Mon Sep 17 00:00:00 2001 From: ewilly Date: Fri, 7 Jul 2017 07:11:17 +0200 Subject: [PATCH 6/6] Update --- scripts/_common.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 207ca3f..bfde399 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -79,7 +79,8 @@ myynh_set_permissions () { [ $(sudo find "$data_path" -type d | wc -l) -gt 0 ] && sudo find "$data_path" -type d | xargs sudo chmod 0755 sudo chown -R root:"$app" "$final_path" sudo chown -R "$app": "$final_path/private" - sudo chown -R "$app": "$data_path/*" + sudo chown -R "$app": "$data_path" + sudo chown root: "$data_path" } # Remove the dedicated php-fpm config