31 lines
868 B
Python
31 lines
868 B
Python
import argparse
|
|
import asyncio
|
|
import os
|
|
from .sys_service import rpc
|
|
|
|
|
|
def main(args):
|
|
# Parser
|
|
parser = argparse.ArgumentParser("home-backup", description="Manage backup tools")
|
|
parser.add_argument("--sys-server", dest="sys_server", action="store_const", const=True, default=False, help="Run system service (root required).")
|
|
|
|
# Arguments
|
|
if not args:
|
|
args = ["--help"]
|
|
result = parser.parse_args(args)
|
|
|
|
# Deamon mode
|
|
if not isinstance(result.sys_server, bool):
|
|
raise RuntimeError("Arg parser has the wrong type.")
|
|
if result.sys_server:
|
|
# Check if root
|
|
if os.getuid() != 0:
|
|
raise RuntimeError("System service has to run as root.")
|
|
|
|
# Run deamon
|
|
asyncio.run(rpc.run_deamon()) # TODO: Change default path
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import sys
|
|
main(sys.argv[1:]) |