initial commit
This commit is contained in:
parent
6ca95cf3dd
commit
3db6797e53
2 changed files with 2 additions and 10 deletions
|
@ -1,7 +1,7 @@
|
||||||
FROM python:3
|
FROM python:3
|
||||||
RUN apt update && apt install -y docker.io libglib2.0-dev libdbus-1-dev ca-certificates curl avahi-daemon
|
RUN apt update && apt install -y docker.io
|
||||||
|
|
||||||
RUN pip install docker dbus-python
|
RUN pip install docker
|
||||||
|
|
||||||
COPY ./monitor.py /monitor.py
|
COPY ./monitor.py /monitor.py
|
||||||
|
|
||||||
|
|
|
@ -149,16 +149,8 @@ def update_hosts_file(container_ips):
|
||||||
os.makedirs(os.path.dirname(HOSTS_FILE), exist_ok=True)
|
os.makedirs(os.path.dirname(HOSTS_FILE), exist_ok=True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Write to temporary file first
|
|
||||||
temp_file = f"{HOSTS_FILE}.tmp"
|
|
||||||
with open(HOSTS_FILE, 'w') as f:
|
with open(HOSTS_FILE, 'w') as f:
|
||||||
f.write(hosts_content)
|
f.write(hosts_content)
|
||||||
|
|
||||||
# Check file permissions
|
|
||||||
# os.chmod(temp_file, 0o644)
|
|
||||||
|
|
||||||
# Atomic replace
|
|
||||||
# os.rename(temp_file, HOSTS_FILE)
|
|
||||||
logging.info(f"Successfully updated {HOSTS_FILE}")
|
logging.info(f"Successfully updated {HOSTS_FILE}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error writing hosts file: {e}")
|
logging.error(f"Error writing hosts file: {e}")
|
||||||
|
|
Loading…
Reference in a new issue