#!/bin/sh # decline-tos.sh # # Layer 4: programmatically decline all LG ToS / consent agreements at the source. # # WHY: LG's consent state lives in /var/luna/preferences/eula (eulaStatus booleans, # false = declined, plus per-document eulaInfo/eulaInfoNetwork lists) and in # /var/luna/preferences/option. The eula-service daemon (/usr/sbin/eula-service) # exposes NO public accept/decline API — only start/requestEulaDownload/ # getEulaDownloadStatus/cancelEulaDownload/resetEula. So with root we write the # files directly, then restart the daemons that cache them. # # On this TV (2026-09-05) these were ACCEPTED and are now declined by this script: # S_MKT Marketing, S_PRG Privacy, S_VNG Voice, S_ADG ACR&Viewing, S_TAG IBA ads. # Not accepted (left as-is): S_SVC Terms, S_DDA Diagnostic, S_LGN Legal, S_DSC Overview. # # This script is idempotent and safe to re-run. Every overwrite is preceded by a # timestamped backup. --dry-run prints what would change without writing. # # NOTE: webOS ships python3 (not `python`). We use python3 when present and fall # back to python. If neither exists we refuse to touch the JSON (sed would corrupt). set -u EULA_FILE=/var/luna/preferences/eula OPTION_FILE=/var/luna/preferences/option GENERAL_FILE=/var/luna/preferences/general ACR_STATE_DIR=/mnt/lg/cmn_data/acr/data ACR_OPTOUT_MARKER="$ACR_STATE_DIR/eula_disallowed_rebooted" DRY_RUN=0 if [ "${1:-}" = "--dry-run" ]; then DRY_RUN=1 fi log() { echo "[decline-tos] $*" >&2; } have() { command -v "$1" >/dev/null 2>&1; } # Pick the python interpreter: python3 first, then python. PY=python3 have python3 || PY=python if ! have "$PY"; then log "ERROR: neither python3 nor python found; refusing to edit JSON with sed (would corrupt)" exit 1 fi # --------------------------------------------------------------------------- # 1. eula file — decline every consent # --------------------------------------------------------------------------- if [ -f "$EULA_FILE" ]; then BACKUP="$EULA_FILE.bak.$(date +%Y%m%d%H%M%S)" [ "$DRY_RUN" = 0 ] && cp -f "$EULA_FILE" "$BACKUP" && log "backup: $BACKUP" if [ "$DRY_RUN" = 0 ]; then "$PY" - "$EULA_FILE" <<'PYEOF' import json, sys p = sys.argv[1] with open(p) as f: e = json.load(f) # eulaStatus: every *Allowed key -> false (false = declined). for k in list(e.get("eulaStatus", {})): if k.endswith("Allowed"): e["eulaStatus"][k] = False # Per-document lists: accepted -> false, and mark updated so the UI re-reads. for section in ("eulaInfo", "eulaInfoNetwork"): lst = e.get(section, {}).get("eulaList") if isinstance(lst, list): for d in lst: if isinstance(d, dict) and "accepted" in d: d["accepted"] = False d["updated"] = True with open(p, "w") as f: json.dump(e, f, indent=2) PYEOF log "eula: all consents declined" else log "eula: would decline all consents (dry-run)" fi else log "WARNING: $EULA_FILE not found; skipping" fi # --------------------------------------------------------------------------- # 2. option file — decline the option-level consents # --------------------------------------------------------------------------- if [ -f "$OPTION_FILE" ]; then BACKUP="$OPTION_FILE.bak.$(date +%Y%m%d%H%M%S)" [ "$DRY_RUN" = 0 ] && cp -f "$OPTION_FILE" "$BACKUP" && log "backup: $BACKUP" if [ "$DRY_RUN" = 0 ]; then "$PY" - "$OPTION_FILE" <<'PYEOF' import json, sys p = sys.argv[1] with open(p) as f: o = json.load(f) # Keys that grant LG data collection / usage. false/off = declined. for k, v in { "voiceAllowed": False, # voice data collection "voice2Allowed": False, # voice data collection (2nd-gen) "watchedListCollection": "off", # viewing-history collection "usageCare": False, # usage data collection "dbgLogUpload": False, # debug log upload "faultLogUpload": False, # fault log upload "thirdPartyCookie": "off", # third-party cookies }.items(): if k in o: o[k] = v with open(p, "w") as f: json.dump(o, f, indent=2) PYEOF log "option: data-collection keys declined" else log "option: would decline data-collection keys (dry-run)" fi else log "WARNING: $OPTION_FILE not found; skipping" fi # --------------------------------------------------------------------------- # 3. general file — decline ad/nudge surfaces (best-effort, non-destructive) # --------------------------------------------------------------------------- if [ -f "$GENERAL_FILE" ]; then BACKUP="$GENERAL_FILE.bak.$(date +%Y%m%d%H%M%S)" [ "$DRY_RUN" = 0 ] && cp -f "$GENERAL_FILE" "$BACKUP" && log "backup: $BACKUP" if [ "$DRY_RUN" = 0 ]; then "$PY" - "$GENERAL_FILE" <<'PYEOF' import json, sys p = sys.argv[1] with open(p) as f: g = json.load(f) for k, v in { "aiNudge": "off", # AI nudge notifications "screenSaverAd": "off", # screen-saver ads "homePromotion": "off", # home-screen promotions "launchEulaByHome": False, # don't re-prompt EULA }.items(): if k in g: g[k] = v with open(p, "w") as f: json.dump(g, f, indent=2) PYEOF log "general: ad/nudge keys declined" else log "general: would decline ad/nudge keys (dry-run)" fi else log "WARNING: $GENERAL_FILE not found; skipping" fi # --------------------------------------------------------------------------- # 4. ACR opt-out marker # --------------------------------------------------------------------------- if [ "$DRY_RUN" = 0 ]; then mkdir -p "$ACR_STATE_DIR" if [ -f "$ACR_STATE_DIR/eula_allowed" ]; then mv -f "$ACR_STATE_DIR/eula_allowed" "$ACR_STATE_DIR/eula_allowed.bak.$(date +%Y%m%d%H%M%S)" log "acr: removed eula_allowed marker" fi : > "$ACR_OPTOUT_MARKER" log "acr: wrote opt-out marker $ACR_OPTOUT_MARKER" else log "acr: would write opt-out marker $ACR_OPTOUT_MARKER (dry-run)" fi # --------------------------------------------------------------------------- # 5. Restart the daemons that cache these settings # --------------------------------------------------------------------------- if [ "$DRY_RUN" = 0 ]; then if have systemctl; then systemctl restart eula-service 2>/dev/null && log "restarted eula-service" \ || log "eula-service restart failed (may not be a systemd unit; will pick up on reboot)" systemctl restart acr2 2>/dev/null && log "restarted acr2" \ || log "acr2 restart failed (not running anyway)" else log "systemctl not found; daemons will pick up changes on next reboot" fi else log "would restart eula-service + acr2 (dry-run)" fi log "done." exit 0