From fc0b155bb4558c8d2dfaf22734073ccaaa05fd18 Mon Sep 17 00:00:00 2001 From: Allen Houchins <32207388+allenhouchins@users.noreply.github.com> Date: Fri, 15 Aug 2025 12:57:36 -0500 Subject: [PATCH] Added postinstall script to nudget-assets (#31976) - Added postinstall script to load the Nudge LaunchAgent automatically --- .../lib/macos/scripts/nudge-postinstall.sh | 42 +++++++++++++++++++ .../lib/macos/software/nudge-assets.yml | 2 + 2 files changed, 44 insertions(+) create mode 100644 it-and-security/lib/macos/scripts/nudge-postinstall.sh diff --git a/it-and-security/lib/macos/scripts/nudge-postinstall.sh b/it-and-security/lib/macos/scripts/nudge-postinstall.sh new file mode 100644 index 0000000000..c2f4659de3 --- /dev/null +++ b/it-and-security/lib/macos/scripts/nudge-postinstall.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# Postinstall script to load Nudge LaunchAgent +# This script runs as root + +PLIST_PATH="/Library/LaunchAgents/com.github.macadmins.Nudge.plist" +LABEL="com.github.macadmins.Nudge" + +# Check if the plist file exists +if [[ ! -f "$PLIST_PATH" ]]; then + echo "Error: LaunchAgent plist not found at $PLIST_PATH" + exit 1 +fi + +# Set proper ownership and permissions +/usr/sbin/chown root:wheel "$PLIST_PATH" +/bin/chmod 644 "$PLIST_PATH" + +echo "Loading LaunchAgent: $PLIST_PATH" + +# Check if already loaded and unload first if necessary +if /bin/launchctl list | /usr/bin/grep -q "$LABEL"; then + echo "LaunchAgent already loaded, unloading first..." + /bin/launchctl unload "$PLIST_PATH" 2>/dev/null +fi + +# Load the LaunchAgent +if /bin/launchctl load "$PLIST_PATH"; then + echo "Successfully loaded LaunchAgent" +else + echo "Failed to load LaunchAgent" + exit 1 +fi + +# Verify it's loaded +if /bin/launchctl list | /usr/bin/grep -q "$LABEL"; then + echo "LaunchAgent is now active" +else + echo "Warning: LaunchAgent may not be properly loaded" +fi + +exit 0 diff --git a/it-and-security/lib/macos/software/nudge-assets.yml b/it-and-security/lib/macos/software/nudge-assets.yml index 7e55fb88fd..eaaf9eacfb 100644 --- a/it-and-security/lib/macos/software/nudge-assets.yml +++ b/it-and-security/lib/macos/software/nudge-assets.yml @@ -1,5 +1,7 @@ hash_sha256: 492d47824a94702a1ca68d29286d0b4bc92a6f2e2f485523de6be9c092d45269 self_service: false categories: +post_install_script: + path: ../scripts/nudge-postinstall.sh labels_include_any: - "Nudge test devices"