From b18a7e69d15c3164c2804c0fdc9f975eef6a7263 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Mon, 31 Oct 2022 18:55:19 -0700 Subject: [PATCH] service --- wiki_postbot/service.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wiki_postbot/service.py b/wiki_postbot/service.py index 62780e7..46a6b1a 100644 --- a/wiki_postbot/service.py +++ b/wiki_postbot/service.py @@ -48,10 +48,15 @@ class Service: service = SERVICE_TEMPLATE.format( **asdict(self) ) - with open('/etc/systemd/system/wikibot.service', 'w') as sfile: - sfile.write(service) + try: + with open('/etc/systemd/system/wikibot.service', 'w') as sfile: + sfile.write(service) + print('System file created, you should now enable it with \nsystemctl enable wikibot\nand start it with\nsystemctl start wikibot') + + except PermissionError: + print('Could not write to system file, copy the following service file to /etc/systemd/system/wikibot.service') + print(service) - print('System file created, you should now enable it with \nsystemctl enable wikibot\nand start it with\nsystemctl start wikibot') def main(): parser = argparser()