#!/usr/bin/env python3 """Inject a trucking-appropriate trust strip into the trucking source-template campaigns in the trucking Listmonk DB (the ones the nightly builder clones). Idempotent: skips campaigns that already have the strip. Run on the host. """ import subprocess, sys SOURCE_IDS = [271, 272, 273, 274, 309, 310] MARKER = "pw-trust-strip-v1" # Trucking trust strip — data-safety + guarantee + social proof. Matches site. STRIP = ( '' '' '' '
' '🛡️ SOC 2 Type II hosting' '🔒 256-bit TLS encrypted' '💳 Secure payment by Stripe' '✅ SSL Labs A+ rated' '
' '100% satisfaction guarantee · fixed pricing, no billable hours · trusted by thousands of carriers nationwide' '
' ) def psql(sql, fetch=False): cmd = ["docker", "exec", "-i", "performancewest-api-postgres-1", "psql", "-U", "pw", "-d", "listmonk", "-tAc", sql] r = subprocess.run(["sudo"] + cmd, capture_output=True, text=True) if r.returncode != 0: print("PSQL ERR:", r.stderr[:200]); sys.exit(1) return r.stdout.strip() def set_body(cid, body): # write body via a file to avoid shell-escaping a huge HTML blob import tempfile, os with tempfile.NamedTemporaryFile("w", suffix=".sql", delete=False) as f: # use dollar-quoting f.write(f"UPDATE campaigns SET body = $PWBODY${body}$PWBODY$ WHERE id = {cid};") path = f.name subprocess.run(["sudo", "docker", "cp", path, "performancewest-api-postgres-1:/tmp/u.sql"], check=True) r = subprocess.run(["sudo", "docker", "exec", "performancewest-api-postgres-1", "psql", "-U", "pw", "-d", "listmonk", "-f", "/tmp/u.sql"], capture_output=True, text=True) os.unlink(path) return "UPDATE 1" in r.stdout def main(): for cid in SOURCE_IDS: body = psql(f"select body from campaigns where id={cid};") if not body: print(f" {cid}: NOT FOUND, skip"); continue if MARKER in body: print(f" {cid}: already has trust strip, skip"); continue # Inject right before the final footer block. Anchor: the # '
idx = body.rfind("
") new = body[:idx] + STRIP + body[idx:] if idx != -1 else body + STRIP if set_body(cid, new): print(f" {cid}: trust strip injected") else: print(f" {cid}: UPDATE failed") if __name__ == "__main__": main()