agenshield 2026.7.23 → 2026.7.24-alpha.30205346
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/install.sh +33 -14
- package/package.json +1 -1
package/bin/install.sh
CHANGED
|
@@ -52,6 +52,15 @@ set -e
|
|
|
52
52
|
GITHUB_REPO="${AGENSHIELD_GITHUB_REPO:-agen-co/agenshield}"
|
|
53
53
|
CLI_BINARY="agenshield"
|
|
54
54
|
|
|
55
|
+
# System log dir + the two files this script touches. MUST stay in sync with
|
|
56
|
+
# SYSTEM_LOG_DIR / INSTALL_LOG_PATH / INSTALLER_LOG_PATH in
|
|
57
|
+
# libs/shield-ipc/src/constants.ts. INSTALL_LOG is the .pkg pre/postinstall's
|
|
58
|
+
# own tee target (we only read + truncate it, to drive the live progress tail);
|
|
59
|
+
# INSTALLER_LOG is this script's capture of `installer(8)` output.
|
|
60
|
+
AGENSHIELD_LOG_DIR="/var/log/agenshield"
|
|
61
|
+
INSTALL_LOG="$AGENSHIELD_LOG_DIR/install.log"
|
|
62
|
+
INSTALLER_LOG="$AGENSHIELD_LOG_DIR/installer.log"
|
|
63
|
+
|
|
55
64
|
# First-party CDN base URL, baked at npm-prepare time by tools/build/npm-prepare.mts
|
|
56
65
|
# from AGENSHIELD_CDN_BASE_URL (e.g. https://assets.frontegg.com/agenshield). When
|
|
57
66
|
# set, this installer resolves + downloads CDN-first with GitHub Releases as the
|
|
@@ -105,6 +114,16 @@ else
|
|
|
105
114
|
fi
|
|
106
115
|
die() { error "$1"; exit 1; }
|
|
107
116
|
step() { printf "\n${BOLD}${CYAN}▸${RESET} ${BOLD}%s${RESET}\n" "$1"; }
|
|
117
|
+
# Create the system log dir before we truncate/tail anything inside it. The
|
|
118
|
+
# .pkg preinstall creates it too, but that runs LATER — this script truncates
|
|
119
|
+
# $INSTALLER_LOG before `installer(8)` is even invoked. 0755 so the desktop's
|
|
120
|
+
# fallback diagnostics collector (host user) can read the results. Best-effort:
|
|
121
|
+
# a failure here must never block an install.
|
|
122
|
+
ensure_log_dir() {
|
|
123
|
+
sudo mkdir -p "$AGENSHIELD_LOG_DIR" 2>/dev/null || return 0
|
|
124
|
+
sudo chown root:wheel "$AGENSHIELD_LOG_DIR" 2>/dev/null || true
|
|
125
|
+
sudo chmod 755 "$AGENSHIELD_LOG_DIR" 2>/dev/null || true
|
|
126
|
+
}
|
|
108
127
|
# Transport/source detail (CDN vs GitHub, per-source retries) stays OUT of the
|
|
109
128
|
# standard output (docs/architecture/install-lifecycle.md#transport-hiding) — opt in with
|
|
110
129
|
# AGENSHIELD_INSTALL_VERBOSE=1. Total-failure errors still name every source.
|
|
@@ -532,17 +551,17 @@ EEOF
|
|
|
532
551
|
else
|
|
533
552
|
step "Installing AgenShield (sudo password may be required)"
|
|
534
553
|
fi
|
|
535
|
-
INSTALLER_LOG=/var/log/agenshield-installer.log
|
|
536
554
|
if ! sudo -v; then
|
|
537
555
|
die "Administrator rights are required to install AgenShield."
|
|
538
556
|
fi
|
|
557
|
+
ensure_log_dir
|
|
539
558
|
INSTALL_RC=0
|
|
540
559
|
if sudo -n true 2>/dev/null; then
|
|
541
560
|
# Truncate BOTH logs up front: installer.log is this run's capture,
|
|
542
561
|
# and install.log (the postinstall's tee target) feeds the live
|
|
543
562
|
# 2-line progress tail below — stale lines from a prior run must
|
|
544
563
|
# not appear under this run's spinner.
|
|
545
|
-
sudo -n sh -c ": > '$INSTALLER_LOG'; : >
|
|
564
|
+
sudo -n sh -c ": > '$INSTALLER_LOG'; : > '$INSTALL_LOG'; installer -verbose -pkg '$TMPDIR_INSTALL/$PKG_NAME' -target / >> '$INSTALLER_LOG' 2>&1" &
|
|
546
565
|
INSTALLER_PID=$!
|
|
547
566
|
# Braille spinner + a rolling 2-line dim tail of the postinstall's
|
|
548
567
|
# own step lines — live progress instead of a dead prompt.
|
|
@@ -556,7 +575,7 @@ EEOF
|
|
|
556
575
|
0) SPIN_CH='⠋';; 1) SPIN_CH='⠙';; 2) SPIN_CH='⠹';; 3) SPIN_CH='⠸';; 4) SPIN_CH='⠼';;
|
|
557
576
|
5) SPIN_CH='⠴';; 6) SPIN_CH='⠦';; 7) SPIN_CH='⠧';; 8) SPIN_CH='⠇';; *) SPIN_CH='⠏';;
|
|
558
577
|
esac
|
|
559
|
-
TAIL_TXT=$(tail -n 2
|
|
578
|
+
TAIL_TXT=$(tail -n 2 "$INSTALL_LOG" 2>/dev/null | tr -d '\r' | cut -c1-"$TAIL_MAXW")
|
|
560
579
|
if [ "$DRAWN" -gt 0 ]; then
|
|
561
580
|
printf '\033[%dA\r\033[0J' "$DRAWN" >/dev/tty 2>/dev/null || true
|
|
562
581
|
fi
|
|
@@ -593,8 +612,8 @@ TAILEOF
|
|
|
593
612
|
sudo tail -n 25 "$INSTALLER_LOG" 2>/dev/null | sed 's/^/ │ /' >&2 || true
|
|
594
613
|
# See the headless branch: the postinstall log's last line is the
|
|
595
614
|
# step that died; the installer log only shows pkg phases.
|
|
596
|
-
error "Postinstall progress — last 15 lines of
|
|
597
|
-
sudo tail -n 15
|
|
615
|
+
error "Postinstall progress — last 15 lines of $INSTALL_LOG:"
|
|
616
|
+
sudo tail -n 15 "$INSTALL_LOG" 2>/dev/null | sed 's/^/ │ /' >&2 || true
|
|
598
617
|
exit 1
|
|
599
618
|
fi
|
|
600
619
|
|
|
@@ -610,16 +629,17 @@ TAILEOF
|
|
|
610
629
|
else
|
|
611
630
|
# Non-interactive (MDM/scripted): use command-line installer
|
|
612
631
|
step "Installing package (headless)"
|
|
632
|
+
ensure_log_dir
|
|
613
633
|
|
|
614
634
|
# Show live postinstall progress by tailing the install log
|
|
615
|
-
sudo pkill -f "tail -F
|
|
616
|
-
sudo truncate -s 0
|
|
617
|
-
sudo sh -c
|
|
618
|
-
sudo tail -F
|
|
635
|
+
sudo pkill -f "tail -F $INSTALL_LOG" 2>/dev/null || true
|
|
636
|
+
sudo truncate -s 0 "$INSTALL_LOG" 2>/dev/null || \
|
|
637
|
+
sudo sh -c "echo -n '' > '$INSTALL_LOG'" 2>/dev/null || true
|
|
638
|
+
sudo tail -F "$INSTALL_LOG" 2>/dev/null | sed 's/^/ │ /' &
|
|
619
639
|
TAIL_PID=$!
|
|
620
640
|
_cleanup_tail() {
|
|
621
641
|
sudo pkill -P $$ 2>/dev/null || true
|
|
622
|
-
sudo pkill -f "tail -F
|
|
642
|
+
sudo pkill -f "tail -F $INSTALL_LOG" 2>/dev/null || true
|
|
623
643
|
}
|
|
624
644
|
trap '_cleanup_tail; rm -rf "$TMPDIR_INSTALL"' EXIT INT TERM
|
|
625
645
|
|
|
@@ -629,7 +649,6 @@ TAILEOF
|
|
|
629
649
|
# via the log-tail above. NB: the installer exit code is now CHECKED —
|
|
630
650
|
# previously a FAILED install fell through and still printed "Package
|
|
631
651
|
# installed", hiding the real error.
|
|
632
|
-
INSTALLER_LOG=/var/log/agenshield-installer.log
|
|
633
652
|
# Run the installer AND its log redirect inside a single ROOT shell. A plain
|
|
634
653
|
# `sudo installer … >> "$INSTALLER_LOG"` would open the root-owned 0644 log
|
|
635
654
|
# for append as the UNPRIVILEGED user → EACCES, failing the redirect (and the
|
|
@@ -648,8 +667,8 @@ TAILEOF
|
|
|
648
667
|
# scripts…"). Script failures live in the POSTINSTALL log — its last
|
|
649
668
|
# line is the step that died (an abrupt end with no error text means
|
|
650
669
|
# a `set -e` abort on the next command after that line).
|
|
651
|
-
error "Postinstall progress — last 15 lines of
|
|
652
|
-
sudo tail -n 15
|
|
670
|
+
error "Postinstall progress — last 15 lines of $INSTALL_LOG:"
|
|
671
|
+
sudo tail -n 15 "$INSTALL_LOG" 2>/dev/null | sed 's/^/ │ /' >&2 || true
|
|
653
672
|
rm -rf "$TMPDIR_INSTALL"
|
|
654
673
|
exit 1
|
|
655
674
|
fi
|
|
@@ -683,7 +702,7 @@ TAILEOF
|
|
|
683
702
|
printf " ${BOLD}If macOS prompts, approve the system extension:${RESET}\n"
|
|
684
703
|
printf " ${DIM}System Settings → General → Login Items & Extensions${RESET}\n"
|
|
685
704
|
printf " Installation directory: ${DIM}/Library/AgenShield/${RESET}\n"
|
|
686
|
-
printf " Install log: ${DIM}
|
|
705
|
+
printf " Install log: ${DIM}$INSTALLER_LOG${RESET}\n"
|
|
687
706
|
printf " Dashboard: ${CYAN}http://localhost:5200${RESET}\n"
|
|
688
707
|
printf " ${BOLD}Sign in${RESET} from the AgenShield menubar to link your account.\n\n"
|
|
689
708
|
exit 0
|