diff --git a/common/docker-installer.sh b/common/docker-installer.sh new file mode 100644 index 000000000..d076a56a3 --- /dev/null +++ b/common/docker-installer.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Check if Docker is installed, if not, install it +command -v docker &>/dev/null || curl -fsSL https://get.docker.com | sh + +# Set the default tag if not provided +TAG=${1:-latest} + +# Check if the 'hiddify-manager' folder exists +if [ -d "hiddify-manager" ]; then + echo 'Folder "hiddify-manager" already exists. Please change the directory to install with Docker.' + exit 1 +fi + +# Create the 'hiddify-manager' directory +mkdir hiddify-manager +cd hiddify-manager + +# Download the docker-compose.yml file +wget https://raw.githubusercontent.com/hiddify/Hiddify-Manager/refs/heads/main/docker-compose.yml + +# Generate random passwords for MySQL and Redis +mysqlpassword=$(openssl rand -base64 40) +redispassword=$(openssl rand -base64 40) + +# Update docker-compose.yml with the specified tag and passwords +sed -i "s/hiddify-manager:latest/hiddify-manager:$TAG" docker-compose.yml +sed -i "s/REDIS_STRONG_PASS/$redispassword/g" docker-compose.yml +sed -i "s/MYSQL_STRONG_PASS/$mysqlpassword/g" docker-compose.yml + +# Start the containers using Docker Compose +docker compose up -d + +# Follow the logs from the containers +docker compose logs -f \ No newline at end of file