Created
April 3, 2017 12:31
-
-
Save Nappp/358eb472a916c72de2db33b9ce602ffa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/sh | |
if [ "$#" -ne 1 ]; then | |
echo | |
echo "Usage: \`./pkg-uninstall PKGNAME\`" | |
echo "Please use \`pkgutil --pkgs\` to find the package you want to remove" | |
echo | |
exit 1 | |
fi | |
confirm_again(){ | |
if [ ! -f "$1" ] && [ ! -d "$1" ]; then | |
echo "Skipping $1" | |
return; | |
fi | |
echo "\n" $1 | |
read -p "Is This file safe to delete ? [ y/N ]" -n 1 -s choice < /dev/tty | |
if [ -z $choice ] || [ 'n' == $choice ];then | |
echo "\n\nAborted" | |
elif [[ 'y' == $choice ]]; then | |
echo "\n\nConfirmed\n" | |
sudo rm -rf "$1" | |
else | |
echo "\n\nInvalid input" | |
fi | |
} | |
execute() { | |
pkgutil --pkg-info $1 | |
volumn=`pkgutil --pkg-info $1 | grep volume | sed 's/^volume: //g'` | |
location=$volumn`pkgutil --pkg-info $1 | grep location | sed 's/^location: //g'` | |
pkgutil --only-dirs --files $1 > $TMPDIR/_pkg_files | |
pkgutil --only-files --files $1 >> $TMPDIR/_pkg_files | |
while read -r file; | |
do | |
confirm_again "$location/$file" | |
done < $TMPDIR/_pkg_files; | |
rm $TMPDIR/_pkg_files | |
read -p "Ready to Forget ? [ y/N ]" -n 1 -s choice < /dev/tty | |
if [ -z $choice ] || [ 'n' == $choice ];then | |
echo "\n\nAborted" | |
elif [[ 'y' == $choice ]]; then | |
echo "\n\nConfirmed\n" | |
sudo pkgutil --forget $1 | |
else | |
echo "\n\nInvalid input" | |
fi | |
} | |
read -p "$1 will be uninstalled, continue? [ y/N ]" -n 1 -s choice | |
if [ -z $choice ] || [ 'n' == $choice ];then | |
echo "\n\nAborted" | |
elif [[ 'y' == $choice ]]; then | |
echo "\n\nConfirmed\n" | |
execute $1 | |
else | |
echo "\n\nInvalid input" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment