#!/bin/sh
# Firefox enterprise policy + kiosk-chrome plumbing (project-plan Phase 11, follow-up:
# minimal browser chrome + preinstalled uBlock Origin/SponsorBlock).
#
# policies.json is installed to /etc/firefox/policies/policies.json by includes.chroot
# (the documented Linux location), and linked here into firefox-esr's own
# distribution/ directory too — an older location some builds read instead of the
# system one. Whichever the installed firefox-esr honours wins; the other is inert.
set -eu

FIREFOX_LIB_DIR="/usr/lib/firefox-esr"

if [ -d "$FIREFOX_LIB_DIR" ]; then
  mkdir -p "$FIREFOX_LIB_DIR/distribution"
  ln -sf /etc/firefox/policies/policies.json "$FIREFOX_LIB_DIR/distribution/policies.json"
  echo "0900-firefox: linked policies.json into $FIREFOX_LIB_DIR/distribution/"
else
  echo "0900-firefox: $FIREFOX_LIB_DIR not found (firefox-esr not installed yet, or a"
  echo "  different path in this Debian release) — /etc/firefox/policies/policies.json"
  echo "  still applies if the package's install order runs after this hook; verify"
  echo "  about:policies shows uBlock Origin/SponsorBlock as force-installed on first boot."
fi
