Skip to content

Commit 5f16676

Browse files
cfsmp3claude
authored andcommitted
fix: add log directory ownership check to pre_deploy.sh
Per review feedback: ensure logs directory is owned by www-data during deployment, preventing silent fallback to console-only logging. The pre-deploy script now: - Checks if logs directory has correct ownership - Automatically fixes ownership if possible (when run as root) - Fails deployment if ownership cannot be fixed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent d3238af commit 5f16676

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

install/deploy/pre_deploy.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,32 @@ if ! git diff --quiet 2>/dev/null; then
101101
git status --short
102102
fi
103103

104+
# Check 8: Verify logs directory ownership
105+
LOGS_DIR="$INSTALL_FOLDER/logs"
106+
WEB_USER="${WEB_USER:-www-data}"
107+
if [ -d "$LOGS_DIR" ]; then
108+
LOGS_OWNER=$(stat -c '%U' "$LOGS_DIR" 2>/dev/null || echo "unknown")
109+
if [ "$LOGS_OWNER" != "$WEB_USER" ]; then
110+
echo "WARNING: Logs directory owned by '$LOGS_OWNER', should be '$WEB_USER'"
111+
echo "Fixing ownership..."
112+
chown -R "$WEB_USER:$WEB_USER" "$LOGS_DIR" 2>/dev/null || {
113+
echo "ERROR: Failed to fix logs ownership. Run manually:"
114+
echo " sudo chown -R $WEB_USER:$WEB_USER $LOGS_DIR"
115+
exit 1
116+
}
117+
echo "✓ Logs directory ownership fixed"
118+
else
119+
echo "✓ Logs directory ownership OK ($WEB_USER)"
120+
fi
121+
else
122+
echo "Creating logs directory with correct ownership..."
123+
mkdir -p "$LOGS_DIR"
124+
chown "$WEB_USER:$WEB_USER" "$LOGS_DIR" 2>/dev/null || {
125+
echo "WARNING: Could not set logs ownership (run as root)"
126+
}
127+
echo "✓ Logs directory created"
128+
fi
129+
104130
# Export backup directory for other scripts
105131
echo "$BACKUP_DIR" > /tmp/sp-deploy-backup-dir.txt
106132

0 commit comments

Comments
 (0)