Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A server restart is required in order for any config changes to take effect #295

Open
mzb2xeo opened this issue Jan 1, 2025 · 1 comment

Comments

@mzb2xeo
Copy link

mzb2xeo commented Jan 1, 2025

Problem: Configuration is done via a single YAML file and a server restart is required in order for any changes to take effect. Trying to start the server with an invalid config file will result in an error.

Solution: Create a Bash script for install and rebuild.
1. Docker must be installed. (Confirmed works with 27.2.02)
2. Create a new files "install.sh" and "glance.yml" in the same folder.
3. Use the below code and the linked preconfigured page
4. Run ./install.sh

Explanation: Container Check and Removal : The script checks if a container with the name glance exists, stops it, and removes it if
necessary.

Container Creation: It then creates and starts a new Docker container for glance, mapping port 8080 of the host to the same port in the container. Additional volumes are mounted to provide configuration files and timezone settings.

Host IP Address Determination: The script uses Docker's internal networking capabilities by calling docker inspect to get the IP address assigned to the container on startup. If this method fails (which should be rare if Docker is properly configured), it falls back to using a Linux command (ip route get 1 | awk '{print $7}') to obtain the external IP address.

Output: Finally, the script outputs the URL that can be used to access the service, based on the determined host IP address and the mapped port.

#!/bin/bash

# Define the service name
SERVICE_NAME="glance"

# Function to check if the container exists
container_exists() {
  docker ps -a --filter "name=^/$SERVICE_NAME$" > /dev/null 2>&1
}

# Check if the container exists
if container_exists; then
  # Stop and remove the existing container
  echo "Stopping and removing existing $SERVICE_NAME container..."
  docker stop $SERVICE_NAME > /dev/null
  docker rm $SERVICE_NAME > /dev/null
fi

# Create and start a new container with port mapping
echo "Creating and starting $SERVICE_NAME container..."
docker run -d \
  --name $SERVICE_NAME \
  -p 8080:8080 \
  -v ./glance.yml:/app/glance.yml \
  -v /etc/timezone:/etc/timezone:ro \
  -v /etc/localtime:/etc/localtime:ro \
  glanceapp/glance > /dev/null

echo "$SERVICE_NAME container has been recreated."

# Display the URL to navigate to the HTTP site using the host's external IP and port number
HOST_IP=$(ip route get 1 | awk '{print $7}') # Linux command to get external IP

echo "You can access the service at: http://$HOST_IP:8080"
@svilenmarkov
Copy link
Member

Hey, I'm not sure what the issue is here as you seem to have also provided a solution? Would this maybe benefit from being converted to a discussion instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants