Skip to content

Commit

Permalink
core: Alias servicectl to systemctl
Browse files Browse the repository at this point in the history
fix #17
  • Loading branch information
mirkobrombin committed Oct 7, 2022
1 parent 2c2acea commit b5b2d16
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions atoms_core/entities/atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def new(
# Finalize and distro specific workarounds
# install servicectl to be able to manage services in the chroot
ServicectlWrapper().install_to_path(os.path.join(atom.fs_path, "usr/local/bin"))
ServicectlWrapper().link_to_systemctl(atom.fs_path)

if finalizing_fn:
instance.client_bridge.exec_on_main(finalizing_fn, 0)
Expand Down
7 changes: 7 additions & 0 deletions atoms_core/wrappers/servicectl.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ def install_to_path(self, path: str):
if os.path.exists(os.path.join(path, "serviced")):
os.remove(os.path.join(path, "serviced"))
shutil.copy(self.__serviced_path, path)

def link_to_systemctl(self, path: str):
if not self.is_supported:
return

with open(os.path.join(path, "etc/bash.bashrc"), "a") as bashrc:
bashrc.write(f"alias systemctl=/usr/local/bin/servicectl")

@property
def is_supported(self) -> bool:
Expand Down

0 comments on commit b5b2d16

Please sign in to comment.