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


"daemon"


import getpass
import os
import sys


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


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


def main():
    "main"
    daemon()
    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)
