#!/bin/sh

set -e
USER_ID=`id -u "$USER"`
/bin/launchctl bootout gui/501 /Library/LaunchAgents/com.shortstorybox.SmartcardIdentifier.plist || true
/bin/launchctl bootstrap gui/$USER_ID /Library/LaunchAgents/com.shortstorybox.SmartcardIdentifier.plist
/bin/launchctl remove SmartcardIdentifierPermissions || true
/bin/launchctl submit -l SmartcardIdentifierPermissions -- bash -c '/usr/local/bin/smartcard-identifier --test-permissions; /bin/launchctl remove SmartcardIdentifierPermissions'

echo postinstall completed successfully > /dev/stderr

