Skip to content

Instantly share code, notes, and snippets.

@bryanheinz
Created October 13, 2021 20:02
Show Gist options
  • Save bryanheinz/a635bc10ae9874014b191b68d52b3c58 to your computer and use it in GitHub Desktop.
Save bryanheinz/a635bc10ae9874014b191b68d52b3c58 to your computer and use it in GitHub Desktop.
pre and post-install scripts for 1Password; and their respective pkginfo.
#!/bin/sh
# get the console user, root if it's at the login window
theUser=$(/usr/bin/stat -f "%Su" /dev/console)
# check for and exit if root
[[ $theUser == "root" ]] && exit 0
# should be a logged in user, reopen 1Password
/usr/bin/su - $theUser -c "open -b com.agilebits.onepassword7"
#!/bin/sh
killall "1Password 7"
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>blocking_applications</key>
<array/>
<key>postinstall_script</key>
<string>#!/bin/sh
theUser=$(/usr/bin/stat -f "%Su" /dev/console)
[[ $theUser == “root” ]] &amp;&amp; exit 0
/usr/bin/su - $theUser -c "open -b com.agilebits.onepassword7"
</string>
<key>preinstall_script</key>
<string>#!/bin/sh
killall "1Password 7"
</string>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment