Atualizar install.sh

This commit is contained in:
wallaceosmar 2024-11-23 17:02:16 +00:00
parent e25feea97b
commit f07e72a98a

View File

@ -116,27 +116,49 @@ load_env_file() {
fi
}
# Function to prompt for Docker or K3s installation
prompt_installation_choice() {
echo "Neither Docker nor Kubernetes is installed."
while true; do
# Main installation logic
install_application() {
ensure_data_directory
check_disk_space
handle_env_file
load_env_file
if command_exists docker; then
echo "Docker detected. Proceeding with Docker setup..."
curl -o docker-compose.yml $DOCKER_COMPOSE_URL
echo "docker-compose.yml downloaded successfully."
echo "Running Docker Compose with the environment variables..."
docker-compose --env-file "$ENV_FILE" up -d
elif command_exists kubectl || command_exists k3s; then
echo "K3s or Kubernetes detected. Proceeding with Kubernetes setup..."
curl -o kubernetes-deploy.yaml $KUBERNETES_DEPLOY_URL
echo "kubernets-deploy.yaml downloaded successfully."
echo "Applying Kubernetes deployment..."
kubectl apply -f kubernetes-deploy.yaml
else
echo "Neither Docker nor Kubernetes is installed."
read -r -p "Would you like to install Docker or K3s? (docker/k3s): " choice
case "$choice" in
docker)
install_docker
setup_docker
break
curl -o docker-compose.yml $DOCKER_COMPOSE_URL
echo "docker-compose.yml downloaded successfully."
echo "Running Docker Compose with the environment variables..."
docker-compose --env-file "$ENV_FILE" up -d
;;
k3s)
install_k3s
setup_k3s
break
curl -o kubernetes-deploy.yaml $KUBERNETES_DEPLOY_URL
echo "kubernets-deploy.yaml downloaded successfully."
echo "Applying Kubernetes deployment..."
kubectl apply -f kubernetes-deploy.yaml
;;
*)
echo "Invalid choice. Please enter 'docker' or 'k3s'."
echo "Invalid choice. Exiting."
exit 1
;;
esac
done
fi
}
# Function to install Docker
@ -148,14 +170,6 @@ install_docker() {
echo "Docker installed successfully."
}
# Function to set up Docker
setup_docker() {
curl -o docker-compose.yml $DOCKER_COMPOSE_URL
echo "docker-compose.yml downloaded successfully."
echo "Running Docker Compose with the environment variables..."
docker-compose --env-file "$ENV_FILE" up -d
}
# Function to install K3s
install_k3s() {
echo "K3s is not installed. Installing K3s..."
@ -163,31 +177,5 @@ install_k3s() {
echo "K3s installed successfully."
}
# Function to set up K3s
setup_k3s() {
curl -o kubernetes-deploy.yaml $KUBERNETES_DEPLOY_URL
echo "kubernets-deploy.yaml downloaded successfully."
echo "Applying Kubernetes deployment..."
kubectl apply -f kubernetes-deploy.yaml
}
# Main installation logic
install_application() {
ensure_data_directory
check_disk_space
handle_env_file
load_env_file
if command_exists docker; then
echo "Docker detected. Proceeding with Docker setup..."
setup_docker
elif command_exists kubectl || command_exists k3s; then
echo "K3s or Kubernetes detected. Proceeding with Kubernetes setup..."
setup_k3s
else
prompt_installation_choice
fi
}
# Run the installation process
install_application