Merge pull request #496 from dlynas/feat/fast-entrypoint-permissions
fix: skip recursive chown on startup when UIDs are already correct
This commit is contained in:
commit
7ceeee2715
1 changed files with 13 additions and 5 deletions
|
|
@ -35,9 +35,15 @@ if [ "$CURRENT_UID" != "$PUID" ] || [ "$CURRENT_GID" != "$PGID" ]; then
|
||||||
usermod -o -u "$PUID" soulsync
|
usermod -o -u "$PUID" soulsync
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Fix ownership of app directories
|
# Only do the expensive recursive chown if the data directory ownership
|
||||||
echo "🔒 Fixing permissions on app directories..."
|
# doesn't already match — avoids walking large libraries on every restart.
|
||||||
chown -R soulsync:soulsync /app/config /app/data /app/logs /app/downloads /app/Transfer /app/Staging 2>/dev/null || true
|
DATA_OWNER=$(stat -c '%u:%g' /app/data 2>/dev/null || echo "unknown")
|
||||||
|
if [ "$DATA_OWNER" != "$PUID:$PGID" ]; then
|
||||||
|
echo "🔒 Fixing permissions on app directories..."
|
||||||
|
chown -R soulsync:soulsync /app/config /app/data /app/logs /app/downloads /app/Transfer /app/Staging 2>/dev/null || true
|
||||||
|
else
|
||||||
|
echo "✅ App directory permissions already correct"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "✅ User/Group IDs already correct"
|
echo "✅ User/Group IDs already correct"
|
||||||
fi
|
fi
|
||||||
|
|
@ -63,9 +69,11 @@ echo " 📄 Updating settings.py to current version..."
|
||||||
cp /defaults/settings.py /app/config/settings.py
|
cp /defaults/settings.py /app/config/settings.py
|
||||||
chown soulsync:soulsync /app/config/settings.py 2>/dev/null || true
|
chown soulsync:soulsync /app/config/settings.py 2>/dev/null || true
|
||||||
|
|
||||||
# Ensure all directories exist and have proper permissions
|
# Ensure all directories exist with correct ownership.
|
||||||
|
# Only the directory nodes themselves need chown here — the recursive chown
|
||||||
|
# above already ran if UIDs changed, so avoid walking the whole tree every start.
|
||||||
mkdir -p /app/config /app/data /app/logs /app/downloads /app/Transfer /app/Staging
|
mkdir -p /app/config /app/data /app/logs /app/downloads /app/Transfer /app/Staging
|
||||||
chown -R soulsync:soulsync /app/config /app/data /app/logs /app/downloads /app/Transfer /app/Staging 2>/dev/null || true
|
chown soulsync:soulsync /app/config /app/data /app/logs /app/downloads /app/Transfer /app/Staging 2>/dev/null || true
|
||||||
|
|
||||||
echo "✅ Configuration initialized successfully"
|
echo "✅ Configuration initialized successfully"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue