mirror of
https://github.com/10h30/kazewp.git
synced 2026-05-12 15:21:20 +09:00
detect os to install curl if missing, then install docker
This commit is contained in:
+49
-7
@@ -2,21 +2,62 @@
|
|||||||
|
|
||||||
# Function to install Docker
|
# Function to install Docker
|
||||||
install_docker() {
|
install_docker() {
|
||||||
|
# Detect OS
|
||||||
|
OS=""
|
||||||
|
if [ -f /etc/os-release ]; then
|
||||||
|
. /etc/os-release
|
||||||
|
OS=$ID
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Function to install curl if missing
|
||||||
|
install_curl() {
|
||||||
|
if ! command -v curl &> /dev/null; then
|
||||||
|
echo "curl is not installed. Installing curl..."
|
||||||
|
case "$OS" in
|
||||||
|
ubuntu|debian)
|
||||||
|
sudo apt update && sudo apt install -y curl
|
||||||
|
;;
|
||||||
|
centos|rhel|rocky|alma)
|
||||||
|
sudo yum install -y curl
|
||||||
|
;;
|
||||||
|
fedora)
|
||||||
|
sudo dnf install -y curl
|
||||||
|
;;
|
||||||
|
arch)
|
||||||
|
sudo pacman -Sy --noconfirm curl
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported OS: $OS. Please install curl manually."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install curl if missing
|
||||||
|
install_curl
|
||||||
|
|
||||||
|
# Check if Docker is already installed
|
||||||
|
if command -v docker &> /dev/null; then
|
||||||
|
echo "Docker is already installed."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prompt user to install Docker
|
||||||
echo -n "Docker is not installed. Do you want to install Docker? (y/n): "
|
echo -n "Docker is not installed. Do you want to install Docker? (y/n): "
|
||||||
read answer
|
read answer
|
||||||
|
|
||||||
if [ "$answer" != "${answer#[Yy]}" ]; then
|
if [[ "$answer" =~ ^[Yy]$ ]]; then
|
||||||
echo "Installing Docker..."
|
echo "Installing Docker..."
|
||||||
curl -fsSL https://get.docker.com -o get-docker.sh > /dev/null 2>&1
|
curl -fsSL https://get.docker.com -o get-docker.sh
|
||||||
sudo sh get-docker.sh > /dev/null 2>&1
|
sudo sh get-docker.sh
|
||||||
rm get-docker.sh > /dev/null 2>&1
|
rm get-docker.sh
|
||||||
|
|
||||||
# Add current user to docker group
|
# Add the current user to the docker group
|
||||||
sudo usermod -aG docker $USER
|
sudo usermod -aG docker $USER
|
||||||
|
|
||||||
#newgrp docker
|
|
||||||
|
|
||||||
echo "Docker has been installed successfully!"
|
echo "Docker has been installed successfully!"
|
||||||
|
echo "You may need to log out and back in for group changes to take effect."
|
||||||
else
|
else
|
||||||
echo "Docker installation skipped. Please install Docker manually to use this script."
|
echo "Docker installation skipped. Please install Docker manually to use this script."
|
||||||
exit 1
|
exit 1
|
||||||
@@ -24,6 +65,7 @@ install_docker() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
check_container_running() {
|
check_container_running() {
|
||||||
docker ps --format '{{.Names}}' | grep -q "^$1$"
|
docker ps --format '{{.Names}}' | grep -q "^$1$"
|
||||||
return $?
|
return $?
|
||||||
|
|||||||
Reference in New Issue
Block a user