diff --git a/src/parch-profiler/profiler.py b/src/parch-profiler/profiler.py index 25f18c7..7922efa 100644 --- a/src/parch-profiler/profiler.py +++ b/src/parch-profiler/profiler.py @@ -1,16 +1,21 @@ -from typing import Dict, Type +from typing import Dict, Type, List, Optional from pydantic import BaseModel from pckmng import PackageConfig, pckmng_gen, pckmng_ins, PACKAGES +from .systemd import services_list, enable_service_list class Config(BaseModel): packages: PACKAGES + systemd_services: Optional[services_list] = [] def install_config(conf: Config): - pckmng_ins(conf.packages) + pckmng_ins(conf.packages) # installing packages + + if conf.systemd_services: + enable_service_list(conf.systemd_services) def generate_config(*pm_names): diff --git a/src/parch-profiler/systemd.py b/src/parch-profiler/systemd.py new file mode 100644 index 0000000..56eca15 --- /dev/null +++ b/src/parch-profiler/systemd.py @@ -0,0 +1,15 @@ +from typing import List, NewType + +from plumbum.cmd import sudo, systemctl + +services_list = NewType("services_list", List[str]) + +systemctl = sudo[systemctl] +enable_service = systemctl["enable"] +start_service = systemctl["start"] + + +def enable_service_list(services: services_list): + for service in services: + enable_service[service]() + start_service[service]()