fix: regenerate ONLYOFFICE app.css.gz so nginx serves patched CSS with logo hidden

This commit is contained in:
root
2026-07-16 19:05:13 +00:00
parent f6c0bb0c5f
commit 7883c46b15

View File

@@ -2,23 +2,22 @@
# ONLYOFFICE init script - runs before the document server starts
# Hides the ONLYOFFICE logo from the editor header
CSS_FILE=/var/www/onlyoffice/documentserver/web-apps/apps/documenteditor/main/resources/css/app.css
if [ -f "$CSS_FILE" ]; then
patch_css() {
local CSS_FILE=$1
if [ -f "$CSS_FILE" ]; then
# Check if already patched
if ! grep -q 'display:none!important' <<< "$(grep '#header-logo{' "$CSS_FILE" | head -1)"; then
sed -i 's/#header-logo{/#header-logo{display:none!important;/g' "$CSS_FILE"
echo "[onlyoffice-init] Patched app.css to hide logo"
echo "[onlyoffice-init] Patched $CSS_FILE to hide logo"
fi
fi
# Always regenerate the .gz file so nginx serves the patched version
# (nginx gzip_static serves .gz files directly, bypassing the patched .css)
gzip -kf "$CSS_FILE"
echo "[onlyoffice-init] Regenerated ${CSS_FILE}.gz"
fi
}
# Also patch the spreadsheet and presentation editors if they exist
for CSS in \
/var/www/onlyoffice/documentserver/web-apps/apps/spreadsheeteditor/main/resources/css/app.css \
/var/www/onlyoffice/documentserver/web-apps/apps/presentationeditor/main/resources/css/app.css; do
if [ -f "$CSS" ]; then
if ! grep -q 'display:none!important' <<< "$(grep '#header-logo{' "$CSS" | head -1)"; then
sed -i 's/#header-logo{/#header-logo{display:none!important;/g' "$CSS"
echo "[onlyoffice-init] Patched $(basename $(dirname $(dirname $(dirname $(dirname $CSS))))) to hide logo"
fi
fi
done
# Patch all editor types
patch_css /var/www/onlyoffice/documentserver/web-apps/apps/documenteditor/main/resources/css/app.css
patch_css /var/www/onlyoffice/documentserver/web-apps/apps/spreadsheeteditor/main/resources/css/app.css
patch_css /var/www/onlyoffice/documentserver/web-apps/apps/presentationeditor/main/resources/css/app.css