branded header, nav, footer for OTB https://outsidethebox.top
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

42 lines
1.4 KiB

#!/bin/bash
set -e
APP_DIR="/home/def/otb_billing"
cd "$APP_DIR" || exit 1
STAMP="$(date +%Y%m%d-%H%M%S)"
BKDIR="backups/shared-brand-$STAMP"
mkdir -p "$BKDIR"
cp -av templates/includes/site_nav.html static/css/style.css templates/portal_*.html "$BKDIR"/
cp -av /home/def/otb-shared-brand/header.html templates/includes/site_nav.html
cp -av /home/def/otb-shared-brand/brand.js static/brand.js
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)"
python3 - <<PY2
from pathlib import Path
import re
footer = '''$FOOTER'''
brandcss = '''$BRANDCSS'''
for p in Path("templates").glob("portal_*.html"):
text = p.read_text(encoding="utf-8")
if '<div class="otb-statusbar">' in text:
text = re.sub(r'<div class="otb-statusbar">.*?</script>', footer, text, count=1, flags=re.S)
else:
text = text.replace('{% include "footer.html" %}', footer + '\n\n {% include "footer.html" %}')
p.write_text(text, encoding="utf-8")
cssp = Path("static/css/style.css")
css = cssp.read_text(encoding="utf-8")
if "/* ===== OTB shared branding ===== */" in css:
css = re.sub(r'/\* ===== OTB shared branding ===== \*/.*', brandcss, css, flags=re.S)
else:
css += "\n\n" + brandcss
cssp.write_text(css, encoding="utf-8")
print("portal deploy complete")
PY2
sudo systemctl restart otb_billing.service