#!/usr/bin/env python3
# This file is placed in the Public Domain.


"service"


import getpass
import os
import sys


sys.path.insert(0, os.getcwd())


from otpcr.config  import Config
from otpcr.command import parse, scanner
from otpcr.main    import forever, modnames, pidfile, privileges, wrap
from otpcr.modules import face
from otpcr.runtime import errors


def main():
    "main"
    modstr = ",".join(modnames(face))
    user = getpass.getuser()
    privileges(user)
    pidfile(Config.pidfile)
    for mod in scanner(modstr, face):
        if "init" in dir(mod):
            mod.init()
    forever()


if __name__ == "__main__":
    wrap(main, print)
    errors(print)
