mirror of
https://github.com/moghtech/komodo.git
synced 2026-04-28 19:59:46 -05:00
fix: check if systemd is available for install (#89)
Adds a check at the beginning of setup-periphery.py to verify if `systemctl` is executable by the current user and if systemd is the init system in use. These changes will inform the user we've decided systemd is unavailable and exits before we attempt to use any systemd functionality, but modify this logic to configure other init systems in the future. Relates to (but doesn't close) https://github.com/mbecker20/komodo/issues/66.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import sys
|
||||
import os
|
||||
import shutil
|
||||
import platform
|
||||
import json
|
||||
import urllib.request
|
||||
@@ -16,6 +17,10 @@ def load_version():
|
||||
def load_latest_version():
|
||||
return json.load(urllib.request.urlopen("https://api.github.com/repos/mbecker20/komodo/releases/latest"))["tag_name"]
|
||||
|
||||
def uses_systemd():
|
||||
# First check if systemctl is an available command, then check if systemd is the init system
|
||||
return shutil.which("systemctl") is not None and os.path.exists("/run/systemd/system/")
|
||||
|
||||
def load_paths():
|
||||
# Checks if setup.py is passed --user arg
|
||||
user_install = sys.argv.count("--user") > 0
|
||||
@@ -132,6 +137,10 @@ def main():
|
||||
print(" PERIPHERY INSTALLER ")
|
||||
print("=====================")
|
||||
|
||||
if not uses_systemd():
|
||||
print("This installer requires systemd and systemd wasn't found. Exiting")
|
||||
sys.exit(1)
|
||||
|
||||
version = load_version()
|
||||
[user_install, bin_dir, config_dir, service_dir] = load_paths()
|
||||
|
||||
@@ -160,4 +169,4 @@ def main():
|
||||
print(f'Note. Use "systemctl{user} status periphery" to make sure periphery is running')
|
||||
print(f'Note. Use "systemctl{user} enable periphery" to have periphery start on system boot')
|
||||
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user