Browse Source

parses apt output

main
deicidus 2 years ago
parent
commit
b67732fae0
  1. 20
      spells/menu/bitcoin/uninstall-bitcoin

20
spells/menu/bitcoin/uninstall-bitcoin

@ -20,8 +20,9 @@ uninstall_bitcoin_from_source() {
echo "Attempting to uninstall Bitcoin Core installed from source..." echo "Attempting to uninstall Bitcoin Core installed from source..."
make_directory=$(dirname "$(find / -name "Makefile.in" 2>/dev/null | grep "bitcoin")") make_directory=$(dirname "$(find / -name "Makefile.in" 2>/dev/null | grep "bitcoin")")
if [ -n "$make_directory" ]; then if [ -n "$make_directory" ]; then
cd "$make_directory" && sudo make uninstall > /dev/null 2>&1 cd "$make_directory" && sudo make uninstall > /dev/null 2>&1 && return 0
fi fi
return 1
} }
# Remove Bitcoin binaries explicitly # Remove Bitcoin binaries explicitly
@ -41,28 +42,25 @@ uninstall_bitcoin_package() {
# Detect the operating system's package manager # Detect the operating system's package manager
if command -v apt &> /dev/null; then if command -v apt &> /dev/null; then
if is_deb_package_installed bitcoin; then if is_deb_package_installed bitcoin; then
sudo apt remove -y bitcoin sudo apt remove -y bitcoin && return 0
return 0
fi fi
elif command -v dnf &> /dev/null; then elif command -v dnf &> /dev/null; then
if is_rpm_package_installed bitcoin; then if is_rpm_package_installed bitcoin; then
sudo dnf remove -y bitcoin sudo dnf remove -y bitcoin && return 0
return 0
fi fi
elif command -v pacman &> /dev/null; then elif command -v pacman &> /dev/null; then
if is_arch_package_installed bitcoin; then if is_arch_package_installed bitcoin; then
sudo pacman -Rns bitcoin --noconfirm sudo pacman -Rns bitcoin --noconfirm && return 0
return 0
fi fi
elif command -v brew &> /dev/null; then elif command -v brew &> /dev/null; then
if brew list --cask bitcoin-core; then if brew list --cask bitcoin-core; then
brew uninstall --cask bitcoin-core brew uninstall --cask bitcoin-core && return 0
return 0
fi fi
else else
echo "Unsupported package manager" echo "Unsupported package manager"
return 1 return 1
fi fi
return 1
} }
# Uninstall Bitcoin # Uninstall Bitcoin
@ -70,9 +68,11 @@ uninstall_bitcoin() {
read -p "This will uninstall Bitcoin Core and might delete your wallet data. Are you sure? (Y/n) " yn read -p "This will uninstall Bitcoin Core and might delete your wallet data. Are you sure? (Y/n) " yn
case $yn in case $yn in
[Yy]* ) [Yy]* )
if ! uninstall_bitcoin_package && ! uninstall_bitcoin_from_source; then if ! uninstall_bitcoin_package; then
if ! uninstall_bitcoin_from_source; then
remove_bitcoin_binaries remove_bitcoin_binaries
fi fi
fi
;; ;;
[Nn]* ) [Nn]* )
echo "Uninstallation cancelled" echo "Uninstallation cancelled"

Loading…
Cancel
Save