Skip to content

Commit

Permalink
enable and disable via xmanage
Browse files Browse the repository at this point in the history
  • Loading branch information
zoumingzhe committed Aug 22, 2024
1 parent 3372ce1 commit 520220d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion casm/utils/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from urllib.parse import urljoin

__project__ = "casm"
__version__ = "0.4"
__version__ = "0.5.alpha.1"
__description__ = "container assembler"
__url_home__ = "https://github.com/podboy/casm"
__url_code__ = __url_home__
Expand Down
8 changes: 5 additions & 3 deletions casm/utils/podman.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
from typing import List
from typing import Optional

from xmanage import systemd_path
from xmanage import systemd_service

SERVICE_NAME = "container-{name}.service"
SYSTEMD_PATH = "/etc/systemd/system/{service_name}"


class podman_cmd:
Expand Down Expand Up @@ -41,7 +43,7 @@ def stop_service(cls, name: str) -> int:
def enable_service(cls, name: str) -> int:
assert isinstance(name, str)
service_name = SERVICE_NAME.format(name=name)
path = SYSTEMD_PATH.format(service_name=service_name)
path = os.path.join(systemd_path.systemd_system_conf_dir, service_name)
errno = os.system(f"podman generate systemd --name {name} > {path}")
if errno != 0:
if os.path.isfile(path):
Expand All @@ -62,7 +64,7 @@ def disable_service(cls, name: str) -> int:
errno = os.system(f"systemctl disable {service_name}")
if errno != 0:
return errno
path = SYSTEMD_PATH.format(service_name=service_name)
path = os.path.join(systemd_path.systemd_system_conf_dir, service_name)
if os.path.isfile(path):
os.remove(path)
return 0
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
makefile-help
xarg-python >= 1.5.1
podman_compose >= 1.0.6
xmanage >= 0.3

0 comments on commit 520220d

Please sign in to comment.