@@ -23,6 +23,19 @@ chown -R "$PUID:$PGID" /etc/nginx/nginx
2323chown -R " $PUID :$PGID " 
2424chown -R " $PUID :$PGID " 
2525
26- #  Prevents errors when installing python certbot plugins when non-root
27- chown " $PUID :$PGID " 
28- find /opt/certbot/lib/python* /site-packages -not -user " $PUID " " $PUID :$PGID " \+ 
26+ #  Certbot directories - optimized approach
27+ CERT_INIT_FLAG=" /opt/certbot/.ownership_initialized" 
28+ 29+ if  [ !  -f  " $CERT_INIT_FLAG " ;  then 
30+  #  Prevents errors when installing python certbot plugins when non-root
31+  chown " $PUID :$PGID " 
32+ 33+  #  Handle all site-packages directories efficiently
34+  find /opt/certbot/lib -type d -name " site-packages" |  while  read  -r SITE_PACKAGES_DIR;  do 
35+  chown -R " $PUID :$PGID " " $SITE_PACKAGES_DIR " 
36+  done 
37+ 38+  #  Create a flag file to skip this step on subsequent runs
39+  touch " $CERT_INIT_FLAG " 
40+  chown " $PUID :$PGID " " $CERT_INIT_FLAG " 
41+ fi 
0 commit comments