1 changed files with 41 additions and 0 deletions
@ -0,0 +1,41 @@ |
|||||||
|
#!/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 ====" |
||||||
Loading…
Reference in new issue