#!/bin/sh # 10-block-lg-telemetry # # Layer 3 lockout: bind-mount a comprehensive /etc/hosts blocklist on every boot. # # WHY bind-mount? On webOS 10.2.1 /etc is a READ-ONLY overlay — you cannot edit # /etc/hosts in place (the write silently fails or is lost). The webosbrew # startup.sh does exactly the same trick for its own block list: copy /etc/hosts # to /tmp, append entries, `mount --bind` the copy over /etc/hosts. # # This script runs from /var/lib/webosbrew/init.d/ (run-parts, no dots allowed in # the filename, executed as root every boot by the Homebrew Channel startup.sh). # # Safe to re-run: idempotent, never edits anything outside /tmp, never unmounts # anything it did not mount, and self-heals on reboot (the bind mount is not # persistent — a fresh copy is made every boot). # # To opt out of this script's block list without uninstalling: create # /var/luna/preferences/webosbrew_block_updates_extra_off # (the built-in webosbrew_block_updates flag is NOT touched by this script). set -u HOSTS_SRC=/etc/hosts HOSTS_TMP=/tmp/hosts.lg-block HOSTS_PRISTINE=/tmp/hosts.lg-block.pristine MOUNT_POINT=/etc/hosts # --------------------------------------------------------------------------- # Block list. One hostname per line (no wildcards — /etc/hosts has none). # Lines starting with '#' are comments. See BLOCKLIST.md for the full mapping. # --------------------------------------------------------------------------- BLOCK_HOSTS=' # --- OTA / OS updates --- snu.lge.com su.lge.com su-ssl.lge.com nsu.lge.com snu-dev.lge.com su-dev.lge.com # --- SDX telemetry: nextlgsdp.com family --- nextlgsdp.com ibs.nextlgsdp.com ibsstat.nextlgsdp.com rdx2.nextlgsdp.com # --- SDX telemetry: lgtvcommon.com family --- lgtvcommon.com netflixvoice.lgtvcommon.com nudge.lgtvcommon.com homeprv.lgtvcommon.com wiseconfig.lgtvcommon.com pnv.lgtvcommon.com recommend.lgtvcommon.com cdpsvc.lgtvcommon.com cpauth.lgtvcommon.com cdpbeacon.lgtvcommon.com rdl.lgtvcommon.com wiseresource.lgtvcommon.com qcardservice.lgtvcommon.com qt2-kic.lab.lgtvcommon.com # --- SDX telemetry: other --- lggalleryplus.com tv.wiselg.com # --- Ads --- lgsmartad.com info.lgsmartad.com # --- ThinQ / IoT --- lgtviot.com api.lgtviot.com commonpush.lgtviot.com sports.lgtviot.com ocp.lgtviot.com push.lgtviot.com buddy.lgtviot.com lgthinq.com common.lgthinq.com connect-client.lgthinq.com # --- LLM / AI platform --- ngfts.lge.com qt2-ngfts.lge.com kic-ngfts.lge.com kic-qt2-ngfts.lge.com # --- Crash / analytics upload --- # (rdx2.nextlgsdp.com + rdl.lgtvcommon.com already listed above) # --- Voice NLP backend (optional — breaks voice search, see HOWTO caveats) --- # lgsmartweb.com # lgvoice.com # --- Content Store tradeoff (optional — breaks Content Store, see HOWTO) --- # lgtvsdp.com # lgappstv.com # lgshopsvc.lgappstv.com ' log() { echo "[10-block-lg-telemetry] $*" >&2; } # Opt-out check: if the user created this flag, do nothing (but still log). if [ -f /var/luna/preferences/webosbrew_block_updates_extra_off ]; then log "opt-out flag present; skipping extra block list" exit 0 fi # Sanity: only run on a webOS box with a real /etc/hosts. [ -f "$HOSTS_SRC" ] || { log "FATAL: $HOSTS_SRC missing"; exit 1; } # Build the filtered host list (strip comments + blanks). HOSTS_FILTERED=$(printf '%s\n' "$BLOCK_HOSTS" | sed 's/[[:space:]]*#.*$//' | sed '/^[[:space:]]*$/d') # Idempotence: if our bind mount is already in place, just refresh the file. if mount | grep -q " on $MOUNT_POINT "; then log "bind mount already active; refreshing block file" # /etc/hosts currently IS our block list — rebuild from the pristine copy # taken on first run so we never duplicate entries. if [ -f "$HOSTS_PRISTINE" ]; then cp -f "$HOSTS_PRISTINE" "$HOSTS_TMP" else # No pristine copy (e.g. /tmp was cleared): fall back to the current # /etc/hosts and strip any block entries we previously added. The ::1 # strip only matches single-hostname block lines (2 fields), so the # stock "::1 localhost ip6-localhost ..." line survives. sed '/^# LG lockout block list/d; /^0\.0\.0\.0 /d; /^::1[[:space:]][^[:space:]]*[[:space:]]*$/d' "$HOSTS_SRC" > "$HOSTS_TMP" fi printf '\n# LG lockout block list (10-block-lg-telemetry)\n' >> "$HOSTS_TMP" printf '%s\n' "$HOSTS_FILTERED" | while read -r h; do [ -n "$h" ] && printf '0.0.0.0 %s\n' "$h" >> "$HOSTS_TMP" done printf '%s\n' "$HOSTS_FILTERED" | while read -r h; do [ -n "$h" ] && printf '::1 %s\n' "$h" >> "$HOSTS_TMP" done exit 0 fi # First run: copy the stock hosts, append the block list, bind-mount it. cp -f "$HOSTS_SRC" "$HOSTS_TMP" cp -f "$HOSTS_SRC" "$HOSTS_PRISTINE" printf '\n# LG lockout block list (10-block-lg-telemetry)\n' >> "$HOSTS_TMP" printf '%s\n' "$HOSTS_FILTERED" | while read -r h; do [ -n "$h" ] && printf '0.0.0.0 %s\n' "$h" >> "$HOSTS_TMP" done printf '%s\n' "$HOSTS_FILTERED" | while read -r h; do [ -n "$h" ] && printf '::1 %s\n' "$h" >> "$HOSTS_TMP" done mount --bind "$HOSTS_TMP" "$MOUNT_POINT" 2>/dev/null if mount | grep -q " on $MOUNT_POINT "; then log "bind-mounted block list over /etc/hosts ($(grep -c '^0\.0\.0\.0' "$HOSTS_TMP") hosts blocked)" else log "WARNING: bind mount failed; /etc/hosts unchanged" exit 1 fi exit 0