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.
41 lines
855 B
41 lines
855 B
#!/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)" |
|
|
|
python3 - <<PY |
|
from pathlib import Path |
|
import re |
|
|
|
app = Path("backend/app.py") |
|
text = app.read_text(encoding="utf-8") |
|
|
|
header = """$HEADER""" |
|
footer = """$FOOTER""" |
|
|
|
# inject header |
|
if header not in text: |
|
text = text.replace("<body>", "<body>\\n" + header) |
|
|
|
# inject footer |
|
if footer not in text: |
|
text = text.replace("</body>", footer + "\\n</body>") |
|
|
|
app.write_text(text, encoding="utf-8") |
|
print("otb-tracker branding injected") |
|
PY |
|
|
|
echo "==== restarting service ====" |
|
sudo systemctl restart otb_tracker.service || true |
|
|
|
echo "==== done ===="
|
|
|