Creating the postinstall script
The postinstall script runs the WebsenseEndpoint installer, once both files are guaranteed to be in the same folder.
nano. This is recommended over pasting directly into Terminal, to avoid shell quoting issues.Important: Do not
paste multi-line scripts directly into an interactive Terminal or zsh prompt. The zsh history expansion feature can misinterpret characters such as
! (as in the
#!/bin/bash shebang line), producing an event not found error. Always write scripts into a file first, using a text editor such as
nano, or a here-document with a quoted delimiter (<< 'EOF').Steps
Result
The script works as follows:
STAGEpoints to the folder where both files were copied by the payload. The .pkg and the .json files now sit side by side, exactly as the WebsenseEndpoint installer expects.- The script calls the WebsenseEndpoint installer against the staged .pkg using the built-in macOS
/usr/sbin/installercommand. - The exit status of that installer is captured, the staging folder is deleted for cleanliness, and the script exits with the original status code so that Intune or Terminal can tell whether the install genuinely succeeded or failed.