Skip to content

Instantly share code, notes, and snippets.

@shreyasborse
Last active May 26, 2024 20:34
Show Gist options
  • Save shreyasborse/c122b4fa42b63130e81f26459d2ef6ce to your computer and use it in GitHub Desktop.
Save shreyasborse/c122b4fa42b63130e81f26459d2ef6ce to your computer and use it in GitHub Desktop.
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
# Update the system
echo "Updating the system..."
sudo apt update
sudo apt upgrade -y
# Install Docker
echo "Installing Docker..."
sudo apt install -y docker.io
# Start and enable Docker
echo "Starting and enabling Docker..."
sudo systemctl start docker
sudo systemctl enable docker
# Add current user to the Docker group
echo "Adding current user to the Docker group..."
sudo usermod -aG docker $USER
# Inform the user to log out and log back in
echo "Please reboot and , then run the script two script_two.sh"
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
# Verify Docker installation
echo "Verifying Docker installation..."
docker --version
# Create a directory for the Dockerfile
echo "Creating directory for the Dockerfile..."
mkdir -p ~/guacamole-client-docker
cd ~/guacamole-client-docker
# Remove the existing guacamole-client directory if it exists
if [ -d "guacamole-client" ]; then
echo "Removing existing guacamole-client directory..."
rm -rf guacamole-client
fi
# Clone the Guacamole client repository
echo "Cloning the Guacamole client repository..."
git clone https://github.com/apache/guacamole-client.git
# Create a Dockerfile
echo "Creating Dockerfile..."
cat <<EOF > Dockerfile
# Use a Maven image with JDK 11 as the base image
FROM maven:3.8.5-openjdk-11 AS build
# Set the working directory
WORKDIR /usr/src/app
# Copy the Guacamole client source code to the container
COPY guacamole-client /usr/src/app
# Build the Guacamole client
RUN mvn package
# Use the Tomcat image as the base image for deployment
FROM tomcat:9-jdk11
# Copy the built Guacamole client WAR file to Tomcat's webapps directory
COPY --from=build /usr/src/app/guacamole/target/guacamole-*.war /usr/local/tomcat/webapps/guacamole.war
# Expose port 8080
EXPOSE 8080
# Start Tomcat when the container launches
CMD ["catalina.sh", "run"]
EOF
# Build the Docker image
echo "Building the Docker image..."
docker build -t guacamole-client .
# Run the Docker container, mapping host port 80 to container port 8080
echo "Running the Docker container..."
docker run -d -p 80:8080 --name guacamole-client-container guacamole-client
# Check the status of the container
echo "Checking the status of the Docker container..."
docker ps -a
# If the container is not running, display the logs
container_id=$(docker ps -a -q --filter "name=guacamole-client-container")
if [ "$(docker inspect -f '{{.State.Running}}' $container_id)" != "true" ]; then
echo "Container is not running. Displaying logs..."
docker logs $container_id
fi
echo "Installation is complete. Access the Guacamole client at http://localhost/guacamole"
@shreyasborse
Copy link
Author

shreyasborse commented May 26, 2024

For AWS instance (optional)

  1. Create a new instance with Ubuntu 24.04 LTS
  2. Open ports HTTP, HTTPS
  3. Add sufficient memory and processing power t2.medium + server
  4. Add sufficient Hard disk space

All instructions are tested on Ubuntu 24.04 LTS

1.Create a file in the /tmp folder
script_one.sh and script_two.sh
2. Give appropriate permissions to run
sudo chmod +x script_one.sh
sudo chmod +x script_two.sh

3. run the file 1
./script_one.sh
4. Reboot to apply permissions
5. . run the file 2
./script_two.sh

In case of any errors or if docker is not running, try to set environment variables and try to run the docker again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment