Exemple #1
0
    def wrapper(*args, **kwargs):
        if not enabled:
            return

        (conf, _) = config.load_data()
        if not conf.getboolean("enable_nuke"):
            return

        return fn(*args, **kwargs)
Exemple #2
0
def main():
    global log

    if os.geteuid() != 0:
        exit("Comitup requires root privileges")

    args = parse_args()

    (conf, data) = config.load_data()

    log = deflog(args.verbose or conf.getboolean("verbose"))
    log.info("Starting comitup")

    if args.info:
        for (key, val) in statemgr.get_info(conf, data).items():
            print("{}: {}".format(key, val))
        sys.exit(0)

    if args.check:
        if wificheck.run_checks():
            sys.exit(1)
        else:
            sys.exit(0)
    else:
        wificheck.run_checks(verbose=False)

    check_environment(log)

    webmgr.init_webmgr(conf.web_service)
    iptmgr.init_iptmgr()

    statemgr.init_state_mgr(
        conf,
        data,
        [
            webmgr.state_callback,
            iptmgr.state_callback,
            cdns.state_callback,
        ],
    )

    nuke.init_nuke()

    signal.signal(signal.SIGTERM, handle_term)

    loop = MainLoop()

    try:
        loop.run()
    except Exception:
        log.error("Terminal exception encountered")
        raise
    finally:
        cleanup()
Exemple #3
0
def add_service(host, devindex, addr):
    name = host
    (conf, data) = config.load_data()
    if '.local' in name:
        name = name[:-len('.local')]

    group.AddService(
        devindex, PROTO_INET, dbus.UInt32(0), name,
        "_%s._tcp" % conf.service_name, "", host, dbus.UInt16(9),
        string_array_to_txt_array([
            "hostname=%s" % host,
            "ipaddr=%s" % addr,
            "comitup-home=https://davesteele.github.io/comitup/",
        ]))
Exemple #4
0
def main():
    if os.geteuid() != 0:
        exit("Comitup requires root privileges")

    args = parse_args()

    log = deflog()
    log.info("Starting comitup")

    (conf, data) = config.load_data()

    if args.info:
        for (key, val) in statemgr.get_info(conf, data).items():
            print("{}: {}".format(key, val))
        sys.exit(0)

    if args.check:
        if wificheck.run_checks():
            sys.exit(1)
        else:
            sys.exit(0)
    else:
        wificheck.run_checks(verbose=False)

    check_environment(log)

    webmgr.init_webmgr(conf.web_service)
    iptmgr.init_iptmgr()

    statemgr.init_state_mgr(
        conf,
        data,
        [
            webmgr.state_callback,
            iptmgr.state_callback,
            cdns.state_callback,
        ],
    )

    loop = MainLoop()
    loop.run()
Exemple #5
0
def add_service(host: str, devindex: int, addr: Optional[str],
                addr6: Optional[str]) -> None:
    name = host
    (conf, data) = config.load_data()
    if ".local" in name:
        name = name[:-len(".local")]

    if group:
        group.AddService(
            devindex,
            PROTO_UNSPECIFIED,
            dbus.UInt32(0),
            name,
            "_%s._tcp" % conf.service_name,
            "",
            host,
            dbus.UInt16(9),
            string_array_to_txt_array([
                "hostname=%s" % host,
                "ipaddr=%s" % addr if (addr and addr != "0.0.0.0") else "",
                "ip6addr=%s" % addr6 if addr6 else "",
                "comitup-home=https://davesteele.github.io/comitup/",
            ]),
        )
Exemple #6
0
def get_conf() -> config.Config:
    (conf, _) = config.load_data()
    return conf
Exemple #7
0
def test_ciu_loadconf(conf_fxt, persist_fxt):
    (conf, data) = config.load_data()
    assert conf.ap_name == "test"
    assert os.path.isfile(persist_fxt)