add enabling systemd services
This commit is contained in:
parent
140a09baa5
commit
cabdc7c129
2 changed files with 22 additions and 2 deletions
|
@ -1,16 +1,21 @@
|
||||||
from typing import Dict, Type
|
from typing import Dict, Type, List, Optional
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from pckmng import PackageConfig, pckmng_gen, pckmng_ins, PACKAGES
|
from pckmng import PackageConfig, pckmng_gen, pckmng_ins, PACKAGES
|
||||||
|
from .systemd import services_list, enable_service_list
|
||||||
|
|
||||||
|
|
||||||
class Config(BaseModel):
|
class Config(BaseModel):
|
||||||
packages: PACKAGES
|
packages: PACKAGES
|
||||||
|
systemd_services: Optional[services_list] = []
|
||||||
|
|
||||||
|
|
||||||
def install_config(conf: Config):
|
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):
|
def generate_config(*pm_names):
|
||||||
|
|
15
src/parch-profiler/systemd.py
Normal file
15
src/parch-profiler/systemd.py
Normal file
|
@ -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]()
|
Loading…
Add table
Reference in a new issue