Ejemplo n.º 1
0
def main():
    global config_file
    time.sleep(5)
    configPath = Path("db/config.ini")
    if not configPath.is_file():
        config.create_config()
    config_file = config.read_config()

    passdb_conf = config.read_dovecot_passdb_conf_template()
    plist_ldap = config.read_sogo_plist_ldap_template()
    extra_conf = config.read_dovecot_extra_conf()

    passdb_conf_changed = config.apply_config('conf/dovecot/ldap/passdb.conf',
                                              config_data=passdb_conf)
    extra_conf_changed = config.apply_config('conf/dovecot/extra.conf',
                                             config_data=extra_conf)
    plist_ldap_changed = config.apply_config('conf/sogo/plist_ldap',
                                             config_data=plist_ldap)

    if passdb_conf_changed or extra_conf_changed or plist_ldap_changed:
        logging.info(
            "One or more config files have been changed, please make sure to restart dovecot-mailcow and sogo-mailcow!"
        )

    api.api_host = config_file['MailHostName']
    api.api_key = config_file['API-Key']

    while (True):
        sync()
        interval = int(config_file['Sync-Interval'])
        logging.info(
            f"Sync finished, sleeping {interval} seconds before next cycle")
        time.sleep(interval)
Ejemplo n.º 2
0
def init(environ, content):
    "initialize the environment by applying a configuration file once"
    _statewarn(environ, content)
    if config.apply_config(config.get_configpath()):
        content.append(u"initialized <br />")
    else:
        content.append(u"not initialized <br />")
    show(environ, content)
Ejemplo n.º 3
0
Archivo: lite.py Proyecto: pobv/lite
def init(environ, content):
    "initialize the environment by applying a configuration file once"
    _statewarn(environ, content)
    if config.apply_config(config.get_configpath()):
        content.append(u"initialized <br />")
    else:
        content.append(u"not initialized <br />")
    show(environ, content)
        arg = args[i]

        #HELP
        if arg == '-h':
            print('--help')
            sys.exit()

        # List filters (version du pauvre)
        if arg == '--list-filters':
            print('List of supported filters\nblur\ndilate\ngrayscale\nmessage')
            sys.exit()

        #CONFIG INI
        if arg == '--config-file':
            path_ini = args[i + 1]
            config.apply_config(path_ini)

        # OUTPUT
        if arg == '-o':
            path_output = args[i + 1] # Prends l'argument qui suit le '-o'
            if os.path.exists(path_output) == False: # Vérifie que le dossier n'existe pas
                os.makedirs(path_output) # Si il n'existe pas, le crée

        #INPUT
        if arg == '-i':
            path_input = args[i + 1] # Prends l'argument qui suit le '-i'
            if os.path.exists(path_input): # Vérifie que le dossier existe
                input_dir = path_input  # Chemin dossier 'input'
                files = os.listdir(input_dir)  # Retourne une liste de ce qui se trouve dans le dossier 'input'

            else:
Ejemplo n.º 5
0
    except FetchConfigError:
        post_error_status('config')
    print('------------------------------------------')

    print('----------------Run Update----------------')
    try:
        run_update(repoPath, remoteConfig)
    except RunUpdateError:
        post_error_status('update')
    print('------------------------------------------')

    updateConfig = args['update_config']
    if currentConfig != remoteConfig or updateConfig:
        print('---------------Apply Config---------------')
        try:
            apply_config(remoteConfig, currentConfig, configDir, etcDir)
        except ApplyConfigError:
            post_error_status('config')
        print('------------------------------------------')

        print('--------------Apply Crontab---------------')
        try:
            apply_crontab(remoteConfig, cronFile)
        except ApplyCrontabError:
            post_error_status('crontab')
        print('------------------------------------------')

        print('----------------Save Config---------------')
        try:
            save_config(remoteConfig, envFile)
        except SaveConfigError:
Ejemplo n.º 6
0
from flask import Flask
from flask import render_template

from config import apply_config

app = Flask(__name__)
apply_config(app)


@app.route(
    "/", )
def index():
    return render_template("index.html", )