@@ -275,10 +275,10 @@ issue_certificates() {
275275 if certbot_output=$( " ${certbot_cmd[@]} " 2>&1 ) ; then
276276 log_info " Certificates issued successfully"
277277 log_verbose " Certbot output: $certbot_output "
278-
278+
279279 # Fix permissions after Docker operations
280280 fix_letsencrypt_permissions
281-
281+
282282 copy_certificates
283283 return 0
284284 else
@@ -352,10 +352,10 @@ renew_certificates() {
352352 if $VERBOSE ; then
353353 log_verbose " Renewal output: $renew_output "
354354 fi
355-
355+
356356 # Fix permissions after Docker operations
357357 fix_letsencrypt_permissions
358-
358+
359359 copy_certificates
360360 restart_services
361361 return 0
@@ -390,28 +390,28 @@ renew_certificates() {
390390# This is needed because Docker creates files with different ownership
391391fix_letsencrypt_permissions () {
392392 log_debug " Fixing Let's Encrypt directory permissions..."
393-
393+
394394 # Check if Let's Encrypt directory exists
395395 if [[ ! -d $LETSENCRYPT_DIR ]]; then
396396 log_verbose " Let's Encrypt directory doesn't exist yet, skipping permission fix"
397397 return 0
398398 fi
399-
399+
400400 # Get current user and group
401401 local current_user current_group
402402 current_user=$( id -u)
403403 current_group=$( id -g)
404-
404+
405405 log_debug " Setting ownership to user $current_user , group $current_group "
406-
406+
407407 # Fix ownership recursively
408- if ! chown -R " $current_user :$current_group " " $LETSENCRYPT_DIR " 2> /dev/null; then
408+ if ! chown -R " $current_user :$current_group " " $LETSENCRYPT_DIR " 2> /dev/null; then
409409 log_verbose " Permission fix attempted (may require sudo for existing files)"
410-
410+
411411 # Try with sudo if available
412412 if command -v sudo > /dev/null 2>&1 ; then
413413 log_debug " Attempting permission fix with sudo..."
414- if sudo chown -R " $current_user :$current_group " " $LETSENCRYPT_DIR " 2> /dev/null; then
414+ if sudo chown -R " $current_user :$current_group " " $LETSENCRYPT_DIR " 2> /dev/null; then
415415 log_verbose " Permission fix successful with sudo"
416416 else
417417 log_warn " Could not fix permissions with sudo - some operations may fail"
@@ -424,15 +424,15 @@ fix_letsencrypt_permissions() {
424424 else
425425 log_verbose " Permission fix successful"
426426 fi
427-
427+
428428 # Ensure proper directory permissions
429429 if [[ -d $LETSENCRYPT_DIR ]]; then
430- chmod 755 " $LETSENCRYPT_DIR " 2> /dev/null || true
430+ chmod 755 " $LETSENCRYPT_DIR " 2> /dev/null || true
431431 if [[ -d " $LETSENCRYPT_DIR /live" ]]; then
432- chmod 755 " $LETSENCRYPT_DIR /live" 2> /dev/null || true
432+ chmod 755 " $LETSENCRYPT_DIR /live" 2> /dev/null || true
433433 fi
434434 if [[ -d " $LETSENCRYPT_DIR /archive" ]]; then
435- chmod 755 " $LETSENCRYPT_DIR /archive" 2> /dev/null || true
435+ chmod 755 " $LETSENCRYPT_DIR /archive" 2> /dev/null || true
436436 fi
437437 fi
438438}
0 commit comments