#!/bin/bash set -e APP_DIR="/opt/otb_tracker" cd "$APP_DIR" || exit 1 STAMP="$(date +%Y%m%d-%H%M%S)" BKDIR="backups/shared-brand-$STAMP" mkdir -p "$BKDIR" cp -av backend/app.py "$BKDIR"/ HEADER="$(cat /home/def/otb-shared-brand/header.html)" FOOTER="$(cat /home/def/otb-shared-brand/footer.html | sed 's|__OTB_BRAND_JS__|/static/brand.js|g')" BRANDCSS="$(cat /home/def/otb-shared-brand/brand.css)" BRANDJS="$(cat /home/def/otb-shared-brand/brand.js)" mkdir -p static printf '%s ' "$BRANDJS" > static/brand.js python3 - <\n{brandcss}\n" text = re.sub(r'', '', text, flags=re.S) if header not in text: text = text.replace("", "\n" + header) if footer not in text: text = text.replace("", footer + "\n") if style_block not in text: text = text.replace("", style_block + "\n") app.write_text(text, encoding="utf-8") print("otb-tracker branding injected") PY2 sudo systemctl restart otb-tracker.service || true