diff --git a/onlyoffice-init.sh b/onlyoffice-init.sh index 7691c04..446ae2f 100644 --- a/onlyoffice-init.sh +++ b/onlyoffice-init.sh @@ -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 - # 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" - fi -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" +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 $CSS_FILE to hide logo" 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 -done \ No newline at end of file +} + +# 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 \ No newline at end of file