ft_onion/start.sh

29 lines
784 B
Bash
Executable File

#!/bin/bash
IMAGE_NAME="ft_onion_image"
CONTAINER_NAME="ft_onion_container"
#remove any existing container with the same name
if [ "$(docker ps -aq -f name=$CONTAINER_NAME)" ]; then
docker rm -f $CONTAINER_NAME
fi
# Build the Docker image
docker build -t $IMAGE_NAME -f Dockerfile .
# Run the Docker container
docker run --name $CONTAINER_NAME -d -p 4242:4242 --restart unless-stopped $IMAGE_NAME
# Wait for the container to start
echo "Waiting for the container to start..."
sleep 5
# Check if the container is running
if [ "$(docker ps -q -f name=$CONTAINER_NAME)" ]; then
echo "Container $CONTAINER_NAME is running."
docker exec $CONTAINER_NAME cat /var/lib/tor/hidden_service/hostname
else
echo "Failed to start container $CONTAINER_NAME."
exit 1
fi