2022-08-25 17:03:56 +00:00
|
|
|
"""Class representing ocserv service."""
|
|
|
|
import base64
|
|
|
|
import subprocess
|
|
|
|
import typing
|
2023-07-27 23:31:28 +00:00
|
|
|
from selfprivacy_api.jobs import Job
|
2024-03-05 08:55:52 +00:00
|
|
|
from selfprivacy_api.utils.systemd import get_service_status
|
2024-03-01 00:21:31 +00:00
|
|
|
from selfprivacy_api.services.service import Service, ServiceStatus
|
2023-08-02 05:54:18 +00:00
|
|
|
from selfprivacy_api.utils.block_devices import BlockDevice
|
2022-08-25 17:03:56 +00:00
|
|
|
from selfprivacy_api.services.ocserv.icon import OCSERV_ICON
|
|
|
|
|
|
|
|
|
|
|
|
class Ocserv(Service):
|
|
|
|
"""Class representing ocserv service."""
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_id() -> str:
|
|
|
|
return "ocserv"
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_display_name() -> str:
|
|
|
|
return "OpenConnect VPN"
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_description() -> str:
|
|
|
|
return "OpenConnect VPN to connect your devices and access the internet."
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_svg_icon() -> str:
|
|
|
|
return base64.b64encode(OCSERV_ICON.encode("utf-8")).decode("utf-8")
|
|
|
|
|
2024-06-26 12:00:51 +00:00
|
|
|
@classmethod
|
|
|
|
def get_url(cls) -> typing.Optional[str]:
|
2022-08-25 17:03:56 +00:00
|
|
|
"""Return service url."""
|
|
|
|
return None
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def is_movable() -> bool:
|
|
|
|
return False
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def is_required() -> bool:
|
|
|
|
return False
|
|
|
|
|
2023-06-29 10:45:00 +00:00
|
|
|
@staticmethod
|
|
|
|
def can_be_backed_up() -> bool:
|
|
|
|
return False
|
|
|
|
|
2023-06-29 11:27:08 +00:00
|
|
|
@staticmethod
|
|
|
|
def get_backup_description() -> str:
|
|
|
|
return "Nothing to backup."
|
|
|
|
|
2022-08-25 17:03:56 +00:00
|
|
|
@staticmethod
|
|
|
|
def get_status() -> ServiceStatus:
|
|
|
|
return get_service_status("ocserv.service")
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def stop():
|
2023-07-27 23:31:28 +00:00
|
|
|
subprocess.run(["systemctl", "stop", "ocserv.service"], check=False)
|
2022-08-25 17:03:56 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def start():
|
2023-07-27 23:31:28 +00:00
|
|
|
subprocess.run(["systemctl", "start", "ocserv.service"], check=False)
|
2022-08-25 17:03:56 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def restart():
|
2023-07-27 23:31:28 +00:00
|
|
|
subprocess.run(["systemctl", "restart", "ocserv.service"], check=False)
|
2022-08-25 17:03:56 +00:00
|
|
|
|
2024-07-02 19:35:28 +00:00
|
|
|
@classmethod
|
|
|
|
def get_configuration(cls):
|
2022-08-25 17:03:56 +00:00
|
|
|
return {}
|
|
|
|
|
2024-07-02 19:35:28 +00:00
|
|
|
@classmethod
|
|
|
|
def set_configuration(cls, config_items):
|
2022-08-25 17:03:56 +00:00
|
|
|
return super().set_configuration(config_items)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_logs():
|
|
|
|
return ""
|
|
|
|
|
2023-04-17 13:47:49 +00:00
|
|
|
@staticmethod
|
|
|
|
def get_folders() -> typing.List[str]:
|
|
|
|
return []
|
|
|
|
|
2022-08-25 17:03:56 +00:00
|
|
|
def move_to_volume(self, volume: BlockDevice) -> Job:
|
|
|
|
raise NotImplementedError("ocserv service is not movable")
|