From 97830e8fa1c86841fcb5ad5d4de3cebda9d14220 Mon Sep 17 00:00:00 2001 From: Jean 28518 Date: Sat, 20 Apr 2024 09:50:58 +0200 Subject: [PATCH] Change IP-Adress: Also change the IP-Adress in the /etc/resolv.conf #84 --- src/lac/unix/unix_scripts/unix.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lac/unix/unix_scripts/unix.py b/src/lac/unix/unix_scripts/unix.py index d2fb6a1..f74cf17 100644 --- a/src/lac/unix/unix_scripts/unix.py +++ b/src/lac/unix/unix_scripts/unix.py @@ -790,10 +790,18 @@ def change_ip(ip): # Change the IP in the /etc/hosts file os.system(f"sed -i 's/{old_ip}/{ip}/g' /etc/hosts") + # Change the IP-Adress in /etc/resolv.conf + os.system("chattr -i -a /etc/resolv.conf") + os.system(f"sed -i 's/{old_ip}/{ip}/g' /etc/resolv.conf") + os.system("chattr +i +a /etc/resolv.conf") + + # Change the IP in the DNS server of samba domain = get_env_sh_variables().get("DOMAIN", "") admin_password = get_env_sh_variables().get("ADMIN_PASSWORD", "") + # This only works if the domain of samba-ac-dc is the same as the real domain. + # (See SHORTEND_DOMAIN in setup_samba_ad_dc.sh) for subdomain in welcome.views.subdomains: os.system(f"samba-tool dns update {subdomain}.{domain} {domain} {ip} A -U administrator%{admin_password}") for addon in get_all_addon_modules():