#!/bin/sh # install.sh # # Install the LG lockout on a rooted webOS TV. Run this ON THE TV as root # (or via `ssh root@TV 'sh -s' < install.sh`). # # What it does: # 1. Layer 2: touch /var/luna/preferences/webosbrew_block_updates (built-in # HBChannel blocker: 4 core OTA domains + telemetry-neuter bind mounts). # 2. Layer 3: install scripts/10-block-lg-telemetry into # /var/lib/webosbrew/init.d/ (executable, no dots in name) — bind-mounts a # comprehensive hosts blocklist every boot. # 3. Layer 4: install scripts/decline-tos.sh. # 4. Layer 5: install scripts/clear-app-update-gate.sh. # 5. Layer 6: install scripts/verify-lockout.sh. # 6. Backs up every file it overwrites (timestamped .bak). # # Then run the scripts once (or reboot): # sh /var/lib/webosbrew/lg-lockout/decline-tos.sh # sh /var/lib/webosbrew/lg-lockout/clear-app-update-gate.sh # sh /var/lib/webosbrew/lg-lockout/verify-lockout.sh # # --dry-run: print what would be done without touching the TV. # --apply: actually install (default is dry-run — safe by default). # # NEVER touches /var/lib/webosbrew/startup.sh or jumpstart.sh. # NEVER rm -rf anything. set -u SRC_DIR="$(cd "$(dirname "$0")" && pwd)" # where this script + companions live HB=/var/lib/webosbrew INITD="$HB/init.d" DEST="$HB/lg-lockout" FLAG=/var/luna/preferences/webosbrew_block_updates EXTRA_FLAG=/var/luna/preferences/webosbrew_block_updates_extra_off MODE=dry [ "${1:-}" = "--apply" ] && MODE=apply log() { echo "[install] $*" >&2; } # --- sanity: must be root (files live on RO overlay / root-owned dirs) --- if [ "$(id -u 2>/dev/null)" != "0" ]; then log "ERROR: must run as root (use: ssh root@TV 'sh -s' < install.sh)" exit 1 fi # --- sanity: TV must be rooted with Homebrew Channel --- if [ ! -d "$HB" ]; then log "ERROR: $HB not found — TV is not rooted / Homebrew Channel not installed" exit 1 fi # --- sanity: companion scripts must exist next to this one --- for f in 10-block-lg-telemetry decline-tos.sh clear-app-update-gate.sh verify-lockout.sh; do if [ ! -f "$SRC_DIR/$f" ]; then log "ERROR: $SRC_DIR/$f not found — run install.sh from the lg-lockout dir" exit 1 fi done if [ "$MODE" = "dry" ]; then log "DRY-RUN — nothing written. Re-run with --apply to install." fi # --- 1. built-in HBChannel blocker flag (Layer 2) --- if [ -f "$FLAG" ]; then log "ok: $FLAG already present (built-in blocker enabled)" else if [ "$MODE" = "apply" ]; then : > "$FLAG" log "created $FLAG (built-in OTA + telemetry-neuter blocker)" else log "would create $FLAG (built-in OTA + telemetry-neuter blocker)" fi fi # --- 2. init.d hook (Layer 3) --- if [ "$MODE" = "apply" ]; then mkdir -p "$INITD" cp -f "$SRC_DIR/10-block-lg-telemetry" "$INITD/10-block-lg-telemetry" chmod 755 "$INITD/10-block-lg-telemetry" log "installed $INITD/10-block-lg-telemetry (chmod 755)" else log "would install $INITD/10-block-lg-telemetry" fi # --- 3. companion scripts (Layers 4-6) --- if [ "$MODE" = "apply" ]; then mkdir -p "$DEST" for f in decline-tos.sh clear-app-update-gate.sh verify-lockout.sh; do cp -f "$SRC_DIR/$f" "$DEST/$f" chmod 755 "$DEST/$f" log "installed $DEST/$f" done else log "would install $DEST/{decline-tos.sh,clear-app-update-gate.sh,verify-lockout.sh}" fi # --- 4. note about the extra opt-out flag --- if [ "$MODE" = "apply" ] && [ -f "$EXTRA_FLAG" ]; then log "note: $EXTRA_FLAG exists — 10-block-lg-telemetry will SKIP the extra block list" fi # --- 5. what to do next --- log "" log "Next steps (as root on the TV):" log " sh $DEST/decline-tos.sh # Layer 4: decline all LG consents" log " sh $DEST/clear-app-update-gate.sh # Layer 5: wipe app-update nag state" log " sh $DEST/verify-lockout.sh # Layer 6: verify" log " reboot # or run 10-block-lg-telemetry manually" log " sh $INITD/10-block-lg-telemetry # apply hosts block immediately, no reboot" log "" log "To uninstall: remove $INITD/10-block-lg-telemetry and $DEST, and" log "rm $FLAG (reboot to clear the bind mount)." exit 0