Custom scripts

Elliot Jordan edited this page May 8, 2018 · 2 revisions

Running custom scripts when saving

MunkiAdmin supports running custom scripts while saving (from version 1.1.0 onwards).

MunkiAdmin looks for executable files (with any extension) with the following names:

  • pkginfo-presave
  • pkginfo-postsave
  • manifest-presave
  • manifest-postsave
  • repository-presave
  • repository-postsave

Following conditions apply:

  • scripts should be saved in <repository>/MunkiAdmin/scripts/ or ~/Library/Application Support/MunkiAdmin/scripts/.
  • The presave scripts can abort the save by exiting with anything other than 0.
  • The pkginfo and manifest scripts are called with 2 arguments:
    • $1: Full path to the pkginfo or manifest
    • $2: File name of the pkginfo or manifest
  • All of the scripts are called with the working directory set to the current repository root.
# This MunkiAdmin pkg-info postsave script makes a git commit every time
# a file is saved. The commit will be made using the current user's username

# Use the Unofficial Bash Strict Mode
# <>
set -euo pipefail

echo "Path: ${FILE_PATH}"
echo "Name: ${FILE_NAME}"
echo "Current working directory: $(PWD)"
echo "Current user: $USER"
# Create a git commit
git add "${FILE_PATH}"
git commit -m "$USER edited pkginfo ${FILE_NAME} via MunkiAdmin"
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.