Add reload-or-restart service
This commit is contained in:
parent
f58ea58bd6
commit
85c3636a1b
|
@ -12,7 +12,8 @@
|
|||
},
|
||||
"owner": "user",
|
||||
"group": "group",
|
||||
"perm": "600"
|
||||
"perm": "600",
|
||||
"service": "example.service"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import json
|
|||
import logging
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import urllib3
|
||||
|
||||
|
@ -40,6 +41,7 @@ class CertEntry:
|
|||
self.owner: str = d['owner']
|
||||
self.group: str = d['group']
|
||||
self.perm: int = int(d['perm'], base=8)
|
||||
self.service: str = d['service']
|
||||
|
||||
class Config:
|
||||
def __init__(self, d: Dict):
|
||||
|
@ -65,6 +67,7 @@ def copyFile(src: str, dst: str):
|
|||
logger.info('Copying file: {} --> {}'.format(src, dst))
|
||||
shutil.copyfile(src, dst)
|
||||
|
||||
|
||||
def copyCert(entry: CertEntry):
|
||||
copyFile(entry.priv.src, entry.priv.dst)
|
||||
copyFile(entry.cert.src, entry.cert.dst)
|
||||
|
@ -75,6 +78,9 @@ def copyCert(entry: CertEntry):
|
|||
os.chmod(entry.priv.dst, entry.perm)
|
||||
os.chmod(entry.cert.dst, entry.perm)
|
||||
|
||||
if entry.service is not None and entry.service != '':
|
||||
subprocess.run(['systemctl', 'reload-or-restart', entry.service])
|
||||
|
||||
def notifyError(cert_idx: int, ntfy_endpoint: str, error_msg: str):
|
||||
if ('' == ntfy_endpoint):
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue