Skip to content

Commit

Permalink
Change IP-Adress: Also change the IP-Adress in the /etc/resolv.conf #84
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean 28518 committed Apr 20, 2024
1 parent 3d508aa commit 97830e8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lac/unix/unix_scripts/unix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 97830e8

Please sign in to comment.