|
|
@ -15,45 +15,50 @@ is_arch_package_installed() { |
|
|
|
pacman -Q "$1" &> /dev/null |
|
|
|
pacman -Q "$1" &> /dev/null |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Uninstall Bitcoin from source |
|
|
|
# Function to uninstall Bitcoin from source |
|
|
|
uninstall_bitcoin_from_source() { |
|
|
|
uninstall_bitcoin_from_source() { |
|
|
|
say "Uninstalling Bitcoin Core installed 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 |
|
|
|
sudo make uninstall |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Uninstall Bitcoin package |
|
|
|
# Function to uninstall Bitcoin package |
|
|
|
uninstall_bitcoin_package() { |
|
|
|
uninstall_bitcoin_package() { |
|
|
|
say "Uninstalling Bitcoin Core package" |
|
|
|
# Detect the operating system's package manager and uninstall |
|
|
|
|
|
|
|
if command -v apt &> /dev/null && is_deb_package_installed bitcoin; then |
|
|
|
# Detect the operating system's package manager |
|
|
|
say "Uninstalling Bitcoin Core package installed with apt" |
|
|
|
if command -v apt &> /dev/null; then |
|
|
|
sudo apt-get remove -y bitcoin |
|
|
|
if is_deb_package_installed bitcoin; then |
|
|
|
elif command -v dnf &> /dev/null && is_rpm_package_installed bitcoin; then |
|
|
|
sudo apt-get remove -y bitcoin |
|
|
|
say "Uninstalling Bitcoin Core package installed with dnf" |
|
|
|
fi |
|
|
|
sudo dnf remove -y bitcoin |
|
|
|
elif command -v dnf &> /dev/null; then |
|
|
|
elif command -v pacman &> /dev/null && is_arch_package_installed bitcoin; then |
|
|
|
if is_rpm_package_installed bitcoin; then |
|
|
|
say "Uninstalling Bitcoin Core package installed with pacman" |
|
|
|
sudo dnf remove -y bitcoin |
|
|
|
sudo pacman -Rns bitcoin --noconfirm |
|
|
|
fi |
|
|
|
elif command -v brew &> /dev/null && brew list --cask bitcoin-core; then |
|
|
|
elif command -v pacman &> /dev/null; then |
|
|
|
say "Uninstalling Bitcoin Core package installed with brew" |
|
|
|
if is_arch_package_installed bitcoin; then |
|
|
|
brew uninstall --cask bitcoin-core |
|
|
|
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 |
|
|
|
else |
|
|
|
say "Unsupported package manager" |
|
|
|
# If no package manager is found, assume it was installed from source |
|
|
|
exit 1 |
|
|
|
uninstall_bitcoin_from_source |
|
|
|
fi |
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Uninstall Bitcoin |
|
|
|
# Function to uninstall Bitcoin |
|
|
|
uninstall_bitcoin() { |
|
|
|
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]* ) |
|
|
|
uninstall_bitcoin_from_source |
|
|
|
|
|
|
|
uninstall_bitcoin_package |
|
|
|
uninstall_bitcoin_package |
|
|
|
;; |
|
|
|
;; |
|
|
|
[Nn]* ) |
|
|
|
[Nn]* ) |
|
|
|