08-08-2023 11:54 AM - edited 08-08-2023 11:55 AM
I am experiencing installation errors when installing my Xcreds package with the following pre & post install scripts. The app installation does actually succeed, but the installer still throws the "Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance." error. Any idea why these scripts would fail when added to the package?
The preinstall script just terminates any running instances of XCreds and removes any existing installation of XCreds.app from the /Applications directory, and the postinstall script creates a backup of the system.login.console authorization right, installs a login plugin for Xcreds, and runs a login script for the application.
#!/bin/sh
killall XCreds
if [ -d "/Applications/XCreds.app" ] ; then
rm -rf "/Applications/XCreds.app"
fi
#!/bin/bash
set -e
set -x
script_path="${0}"
echo "script_path: ${script_path}"
package_path="${1}"
echo "package_path: ${package_path}"
target_path="${2}"
echo "target_path: {target_path}"
target_volume="${3}"
echo "target_volume: {target_volume}"
xcreds_login_script="${target_path}"/Applications/XCreds.app/Contents/Resources/xcreds_login.sh
plugin_path="${target_path}"/Applications/XCreds.app/Contents/Resources/XCredsLoginPlugin.bundle
auth_backup_folder="${target_path}"/Users/jadah.stone/Library/Application\ Support/xcreds
rights_backup_path="${auth_backup_folder}"/rights.bak
if [ ! -e "${auth_backup_folder}" ]; then
mkdir -p "${auth_backup_folder}"
echo "Creating auth_backup_folder"
fi
if [ ! -e "${rights_backup_path}" ]; then
security authorizationdb read system.login.console > "${rights_backup_path}"
echo "Backing up system.login.console"
fi
if [ -e "${plugin_path}" ]; then
if [ -e "${target_volume}"/Library/Security/SecurityAgentPlugins/XCredsLoginPlugin.bundle ]; then
rm -rf "${target_volume}"/Library/Security/SecurityAgentPlugins/XCredsLoginPlugin.bundle
echo "Removing existing Xcreds Login Plugin"
fi
cp -R "${plugin_path}" "${target_volume}"/Library/Security/SecurityAgentPlugins/
echo "Copying the Xcreds Login Plugin to {target_volume}"/Library/Security/SecurityAgentPlugins/"
chown -R root:wheel "${target_volume}"/Library/Security/SecurityAgentPlugins/XCredsLoginPlugin.bundle
echo "Setting permissions to root:wheel"
fi
if [ -e ${xcreds_login_script} ]; then
echo "Running Xcreds Login Script"
"${xcreds_login_script}" -i
else
echo "could not find xcreds_login_script tool"
exit -1
fi
exit 0