ao-mud is a spellbook of well-commented atomic bash scripts that each do one thing. we are building semantic building blocks for an autonomously-evolving digital spellcasting language.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.6 KiB

#!/bin/sh
# Function to check if a package is installed in Debian-based distributions
is_deb_package_installed() {
dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed"
}
# Function to check if a package is installed in Redhat-based distributions
is_rpm_package_installed() {
rpm -q "$1" &> /dev/null
}
# Function to check if a package is installed in Arch-based distributions
is_arch_package_installed() {
pacman -Q "$1" &> /dev/null
}
1 year ago
# Uninstall Bitcoin from source
uninstall_bitcoin_from_source() {
1 year ago
echo "Attempting to uninstall Bitcoin Core installed from source..."
make_directory=$(dirname "$(find / -name "Makefile.in" 2>/dev/null | grep "bitcoin")")
if [ -n "$make_directory" ]; then
cd "$make_directory" && sudo make uninstall > /dev/null 2>&1
else
return 1
fi
1 year ago
}
1 year ago
# Remove Bitcoin binaries explicitly
remove_bitcoin_binaries() {
echo "Could not find Makefile. Uninstalling Bitcoin by removing binaries explicitly..."
1 year ago
bitcoin_bins="bitcoind bitcoin-tx bitcoin-wallet test_bitcoin bitcoin-cli bitcoin-qt bitcoin-util"
for bin in $bitcoin_bins; do
1 year ago
bin_path=$(which $bin)
[ -n "$bin_path" ] && sudo rm -f "$bin_path"
done
}
1 year ago
# Uninstall Bitcoin package
uninstall_bitcoin_package() {
1 year ago
echo "Attempting to uninstall Bitcoin Core package..."
# Detect the operating system's package manager
if command -v apt &> /dev/null; then
if is_deb_package_installed bitcoin; then
sudo apt-get remove -y bitcoin
fi
elif command -v dnf &> /dev/null; then
if is_rpm_package_installed bitcoin; then
sudo dnf remove -y bitcoin
fi
elif command -v pacman &> /dev/null; then
if is_arch_package_installed bitcoin; then
sudo pacman -Rns bitcoin --noconfirm
fi
elif command -v brew &> /dev/null; then
if brew list --cask bitcoin-core; then
brew uninstall --cask bitcoin-core
fi
else
1 year ago
echo "Unsupported package manager"
exit 1
fi
}
1 year ago
# Uninstall Bitcoin
uninstall_bitcoin() {
read -p "This will uninstall Bitcoin Core and might delete your wallet data. Are you sure? (Y/n) " yn
case $yn in
[Yy]* )
1 year ago
uninstall_bitcoin_package || uninstall_bitcoin_from_source || remove_bitcoin_binaries
;;
[Nn]* )
1 year ago
echo "Uninstallation cancelled"
;;
* )
1 year ago
echo "Invalid input. Please answer with Y (yes) or N (no)"
uninstall_bitcoin
;;
esac
}
# Start the uninstallation
uninstall_bitcoin