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.

75 lines
2.5 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
}
# Function to uninstall Bitcoin from source
uninstall_bitcoin_from_source() {
# Find the path to the bitcoin binary
bitcoin_bin=$(which bitcoin)
if [ -z "$bitcoin_bin" ]; then
say "Could not find Bitcoin installed from source"
return 1
fi
# Assume the parent directory of the binary is the source directory
bitcoin_src_dir=$(dirname "$bitcoin_bin")
say "Uninstalling Bitcoin Core installed from source in $bitcoin_src_dir"
cd "$bitcoin_src_dir"
sudo make uninstall
}
# Function to uninstall Bitcoin package
uninstall_bitcoin_package() {
# Detect the operating system's package manager and uninstall
if command -v apt &> /dev/null && is_deb_package_installed bitcoin; then
say "Uninstalling Bitcoin Core package installed with apt"
sudo apt-get remove -y bitcoin
elif command -v dnf &> /dev/null && is_rpm_package_installed bitcoin; then
say "Uninstalling Bitcoin Core package installed with dnf"
sudo dnf remove -y bitcoin
elif command -v pacman &> /dev/null && is_arch_package_installed bitcoin; then
say "Uninstalling Bitcoin Core package installed with pacman"
sudo pacman -Rns bitcoin --noconfirm
elif command -v brew &> /dev/null && brew list --cask bitcoin-core; then
say "Uninstalling Bitcoin Core package installed with brew"
brew uninstall --cask bitcoin-core
else
# If no package manager is found, assume it was installed from source
uninstall_bitcoin_from_source
fi
}
# Function to 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]* )
uninstall_bitcoin_package
;;
[Nn]* )
say "Uninstallation cancelled"
;;
* )
say "Invalid input. Please answer with Y (yes) or N (no)"
uninstall_bitcoin
;;
esac
}
# Start the uninstallation
uninstall_bitcoin