Reset the Navicat trial time on Mac.
#!/bin/bash
set -e
file=$(defaults read /Applications/Navicat\ Premium.app/Contents/Info.plist)
regex="CFBundleShortVersionString = \"([0-9]+)"
if [[ $file =~ $regex ]]; then
version=${BASH_REMATCH[1]}
else
echo "Unable to detect Navicat Premium version."
exit 1
fi
echo "Detected Navicat Premium version $version"
case $version in
"17"|"16")
plist_file=~/Library/Preferences/com.navicat.NavicatPremium.plist
;;
"15")
plist_file=~/Library/Preferences/com.prect.NavicatPremium15.plist
;;
*)
echo "Version '$version' not handled"
exit 1
;;
esac
echo -n "Resetting trial time..."
regex="([0-9A-Z]{32}) = "
if [[ $(defaults read "$plist_file") =~ $regex ]]; then
hash=${BASH_REMATCH[1]}
if [ -n "$hash" ]; then
defaults delete "$plist_file" "$hash"
fi
fi
regex="\.([0-9A-Z]{32})"
if [[ $(ls -a ~/Library/Application\ Support/PremiumSoft\ CyberTech/Navicat\ CC/Navicat\ Premium/ | grep '^\.') =~ $regex ]]; then
hash2=${BASH_REMATCH[1]}
if [ -n "$hash2" ]; then
rm ~/Library/Application\ Support/PremiumSoft\ CyberTech/Navicat\ CC/Navicat\ Premium/."$hash2"
fi
fi
echo " Done"
