Check Docker is installed or not

This commit is contained in:
2025-01-02 09:52:52 +09:00
parent 3691d31e17
commit 4c99a1c8bd
3 changed files with 48 additions and 2 deletions
+20 -2
View File
@@ -12,6 +12,24 @@ source "${SCRIPT_DIR}/lib/docker.sh"
source "${SCRIPT_DIR}/lib/caddy.sh" source "${SCRIPT_DIR}/lib/caddy.sh"
source "${SCRIPT_DIR}/lib/wordpress.sh" source "${SCRIPT_DIR}/lib/wordpress.sh"
# Check if Docker is installed
if ! command_exists docker; then
install_docker
# Verify installation
if ! command_exists docker; then
echo "Docker installation failed. Please install Docker manually."
exit 1
fi
fi
# Check if Docker service is running
if ! systemctl is-active --quiet docker; then
echo "Docker service is not running. Starting Docker..."
sudo systemctl start docker
fi
# Function to install a new WordPress site # Function to install a new WordPress site
install_site() { install_site() {
@@ -243,11 +261,11 @@ case "$1" in
;; ;;
*) *)
echo "KazeW - PWordPress Site Management Script" echo "KazeWP - WordPress Site Management Script"
echo "Usage:" echo "Usage:"
echo " $0 install <domain> - Install a new WordPress site" echo " $0 install <domain> - Install a new WordPress site"
echo " $0 list - List all installed WordPress sites" echo " $0 list - List all installed WordPress sites"
echo " $0 delete <domain> - Delete a WordPress site" echo " $0 delete <domain> - Delete a WordPress site"
echo " $0 delete all - Delete everything" echo " $0 delete all - Delete everything"
exit 1 exit 1
;; ;;
+24
View File
@@ -1,5 +1,29 @@
#!/bin/bash #!/bin/bash
# Function to install Docker
install_docker() {
echo -n "Docker is not installed. Do you want to install Docker? (y/n): "
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
echo "Installing Docker..."
curl -fsSL https://get.docker.com -o get-docker.sh > /dev/null 2>&1
sudo sh get-docker.sh > /dev/null 2>&1
rm get-docker.sh > /dev/null 2>&1
# Add current user to docker group
sudo usermod -aG docker $USER
#newgrp docker
echo "Docker has been installed successfully!"
else
echo "Docker installation skipped. Please install Docker manually to use this script."
exit 1
fi
}
check_container_running() { check_container_running() {
docker ps --format '{{.Names}}' | grep -q "^$1$" docker ps --format '{{.Names}}' | grep -q "^$1$"
return $? return $?
+4
View File
@@ -5,6 +5,10 @@ function generate_password() {
} }
export -f generate_password export -f generate_password
command_exists() {
command -v "$1" >/dev/null 2>&1
}
function save_credentials() { function save_credentials() {
local WP_PROJECT_DIR=$1 local WP_PROJECT_DIR=$1
local DOMAIN=$2 local DOMAIN=$2