Skip to content

Instantly share code, notes, and snippets.

@timsutton
Created May 27, 2018 19:52
Show Gist options
  • Save timsutton/a539ba1d28cd62ad616d4eeacab44f1a to your computer and use it in GitHub Desktop.
Save timsutton/a539ba1d28cd62ad616d4eeacab44f1a to your computer and use it in GitHub Desktop.
1P 'mv1Password' script
#!/bin/sh
# this script removes the binary before we install it to ensure that we don't end up with a hybrid of what was there and what we're installing
echo "Removing legacy helper startup items"
loggedInUser=$(stat -f%Su /dev/console)
bundleIds=( "2BUA8C4S2C.com.agilebits.onepassword4-helper"
"2BUA8C4S2C.com.agilebits.onepassword-osx-helper"
"com.agilebits.onepassword-osx-helper"
"ws.agile.1PasswordAgent"
)
for i in "${bundleIds[@]}"
do
echo "Killing $i"
launchctl asuser launchctl stop $i
launchctl asuser launchctl remove $i
killall $i
echo "."
done
killall -SIGTERM cfprefsd
echo "Removing older copies of 1Password"
bundlePaths=( "/Applications/1Password 6.app"
"/Applications/1Password.app"
"$2"
)
for i in "${bundlePaths[@]}"
do
if [[ -d "$i" ]]; then
if [[ ! -f "$i.zip" ]]; then
echo "Zipping $i.zip"
ditto -ck --rsrc --sequesterRsrc --keepParent "$i" "$i.zip"
fi
echo "Removing $i"
rm -rf "$i"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment