Created
August 16, 2024 13:36
-
-
Save anir0y/ffe3b8b18c281ef829082ae0693420ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Step 1: Update System Packages | |
echo "Updating system packages..." | |
sudo apt-get update -y | |
# Step 2: Check if Docker is installed | |
if ! command -v docker &> /dev/null | |
then | |
echo "Docker not found, installing..." | |
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
sudo apt-get update -y | |
sudo apt-get install -y docker-ce | |
else | |
echo "Docker is already installed." | |
fi | |
# Step 3: Check if Docker Compose is installed | |
if ! command -v docker-compose &> /dev/null | |
then | |
echo "Docker Compose not found, installing..." | |
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose | |
else | |
echo "Docker Compose is already installed." | |
fi | |
# Step 4: Create a Docker Compose File for Guacamole | |
echo "Creating Docker Compose file for Guacamole..." | |
cat <<EOF > docker-compose.yml | |
version: '3' | |
services: | |
guacamole: | |
image: guacamole/guacamole | |
ports: | |
- "80:8080" | |
links: | |
- guacd | |
- mysql | |
depends_on: | |
- guacd | |
- mysql | |
guacd: | |
image: guacamole/guacd | |
mysql: | |
image: mysql:5.7 | |
environment: | |
MYSQL_ROOT_PASSWORD: some_password | |
MYSQL_DATABASE: guacamole_db | |
MYSQL_USER: guacamole_user | |
MYSQL_PASSWORD: guacamole_password | |
EOF | |
# Step 5: Check if Guacamole Docker container is already running | |
if [ "$(sudo docker ps -q -f name=guacamole)" ]; then | |
echo "Guacamole Docker container is running, restarting..." | |
sudo docker-compose down | |
sudo docker-compose up -d | |
else | |
echo "Starting Guacamole services..." | |
sudo docker-compose up -d | |
fi | |
# Step 6: Verify Installation | |
echo "Verifying Guacamole services..." | |
sudo docker ps | |
# Step 7: Print Credentials | |
echo "Apache Guacamole should be running. Access it at http://<Your-IP>:8080" | |
echo "MySQL Root Password: some_password" | |
echo "MySQL Database: guacamole_db" | |
echo "MySQL User: guacamole_user" | |
echo "MySQL User Password: guacamole_password" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment