Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions XSConsoleData.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,8 @@ def AddDHCPNTP(self):
for interface in interfaces:
ntpServer = self.GetDHCPNTPServer(interface)

with open("/var/lib/dhclient/chrony.servers.%s" % interface, "w") as chronyFile:
chronyFile.write("%s iburst prefer\n" % ntpServer)
with open("/run/chrony-dhcp/%s.sources" % interface, "w") as chronyFile:
chronyFile.write("server %s iburst prefer\n" % ntpServer)

# Ensure chrony is enabled
self.EnableService("chronyd")
Expand Down Expand Up @@ -655,7 +655,7 @@ def RemoveDHCPNTP(self):
newPermissions = oldPermissions & ~(stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
os.chmod("/etc/dhcp/dhclient.d/chrony.sh", newPermissions)

getstatusoutput("rm -f /var/lib/dhclient/chrony.servers.*")
getstatusoutput("rm -f /run/chrony-dhcp/*.sources")
Copy link
Collaborator

@liulinC liulinC Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file is removed,
what happens if user want to change back to dhcp mode? (without interface configure update, e.g: chrony.sh has no chance to run to regenerate the file)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See L605 above in AddDHCPNTP, the file will be created and filled.


def SetTimeManually(self, date):
# Double-check authentication
Expand Down