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