Skip to content

Commit

Permalink
pd daemon service: remove redundant subprocess 'sudo' in dhcp6_pd_dae…
Browse files Browse the repository at this point in the history
…mon.py
  • Loading branch information
yangsong-cnyn committed Nov 13, 2024
1 parent ef7bb73 commit b7eef58
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions script/reference-device/dhcp6_pd_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ def restart_dhcpcd_service(config_path):
logging.error(f"{config_path} not found. Cannot apply configuration.")
return
try:
subprocess.run(["sudo", "cp", config_path, DHCP_CONFIG_PATH],
check=True)
subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True)
subprocess.run(["sudo", "service", "dhcpcd", "restart"], check=True)
subprocess.run(["cp", config_path, DHCP_CONFIG_PATH], check=True)
subprocess.run(["systemctl", "daemon-reload"], check=True)
subprocess.run(["service", "dhcpcd", "restart"], check=True)
logging.info(
f"Successfully restarted dhcpcd service with {config_path}.")
except subprocess.CalledProcessError as e:
Expand Down Expand Up @@ -124,8 +123,7 @@ def main():
# By restarting dhcpcd here, we ensure it runs after network.target is active, allowing
# radvd to start correctly and dhcpcd to configure the interface.
try:
subprocess.run(["sudo", "systemctl", "reload-or-restart", "dhcpcd"],
check=True)
subprocess.run(["systemctl", "reload-or-restart", "dhcpcd"], check=True)
logging.info("Successfully restarting dhcpcd service.")
except subprocess.CalledProcessError as e:
logging.error(f"Error restarting dhcpcd service: {e}")
Expand Down

0 comments on commit b7eef58

Please sign in to comment.