Web3CV/install-sshpass.sh

33 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# This script installs sshpass, which is needed for password automation
# Check if sshpass is already installed
if command -v sshpass &> /dev/null; then
echo "sshpass is already installed."
exit 0
fi
# Install sshpass based on the detected package manager
if command -v apt-get &> /dev/null; then
echo "Installing sshpass using apt..."
sudo apt-get update
sudo apt-get install -y sshpass
elif command -v dnf &> /dev/null; then
echo "Installing sshpass using dnf..."
sudo dnf install -y sshpass
elif command -v yum &> /dev/null; then
echo "Installing sshpass using yum..."
sudo yum install -y sshpass
elif command -v pacman &> /dev/null; then
echo "Installing sshpass using pacman..."
sudo pacman -S --noconfirm sshpass
elif command -v brew &> /dev/null; then
echo "Installing sshpass using Homebrew..."
brew install hudochenkov/sshpass/sshpass
else
echo "Error: Could not detect package manager. Please install sshpass manually."
exit 1
fi
echo "sshpass has been installed successfully."