<?xml version='1.0' encoding='utf-8'?>

<creole>

    <files>
        <service method='apache' servicelist='genconfig_apache'>genconfig</service>
        <file name='/etc/nginx/web.d/genconfig.conf' source='genconfig.nginx.conf' mkdir='True' rm='True' filelist='genconfig_nginx' />
        <file name='/etc/apache2/sites-available/genconfig.conf' source='genconfig.apache.conf' filelist='genconfig_apache' />
        <file name='/etc/nginx/sites-enabled/minimal-standalone-genconfig.conf'  source="genconfig-standalone-nginx.conf" filelist='genconfig_nginx_norevprox' rm="True"/>
    </files>

    <variables>

        <family name='Services'>

            <variable name='test_activer_genconfig_nginx' type='oui/non' description='Vérifier si l’on peut exposer l’interface de configuration du module (GenConfig) par nginx' />

            <variable name='test_activer_genconfig_https' type='oui/non' description='Vérifier si HTTPS Nginx est désactivé pour l’interface de configuration du module (GenConfig)' />

            <variable name='test_activer_minimal_nginx' type='oui/non' description='Vérifier si nous devons activer une configuration nginx minimale' />

            <variable name='activer_genconfig' type='oui/non' description='Activer l’interface de configuration du module (GenConfig)' mode='expert'>
                <value>oui</value>
            </variable>

            <!-- Workaround when eole-reverseproxy is not installed -->
            <variable name='activer_nginx_web' type='oui/non' exists='False' hidden='True'>
                <value>non</value>
            </variable>

            <variable name='nginx_degrade_http' type='oui/non' exists='False' hidden='True'>
                <value>non</value>
            </variable>

            <!-- Workaround when eole-web is not installed -->
            <variable name='activer_apache' type='oui/non' exists='False' hidden='True'>
                <value>non</value>
            </variable>

        </family>

        <family name='Applications web Nginx' icon='nginx'>

            <variable name='genconfig_http_path' type='string' description='Chemin d’accès de l’application GenConfig' mode='expert'>
                <value>/genconfig</value>
            </variable>

        </family>

        <separators>
            <!-- Make GenConfig more readable: each application under its own separator -->
            <separator name='genconfig_http_path'>GenConfig</separator>
        </separators>

    </variables>

    <constraints>

        <!-- User can disable GenConfig -->
        <condition name='disabled_if_in' source='activer_genconfig'>
            <param>non</param>
            <target type='variable'>genconfig_http_path</target>
            <target type='filelist'>genconfig_apache</target>
            <target type='filelist'>genconfig_nginx</target>
            <target type='servicelist'>genconfig_apache</target>
        </condition>

        <!-- GenConfig requires HTTPS
             Use calc_multi_condition to by-pass the absence of:

                 “do not disable target if source is disabled”
        -->
        <auto name='calc_multi_condition' target='test_activer_genconfig_https'>
            <param>non</param>
            <param type='eole' name='condition_1' hidden='False'>nginx_degrade_http</param>
            <param name='match'>oui</param>
            <param name='mismatch'>non</param>
        </auto>

        <condition name='disabled_if_in' source='test_activer_genconfig_https'>
            <param>non</param>
            <target type='variable'>activer_genconfig</target>
        </condition>

        <!-- Do not configure Nginx if Nginx is disabled -->
        <condition name='disabled_if_in' source='test_activer_genconfig_nginx' fallback='True'>
            <param>non</param>
            <target type='filelist'>genconfig_nginx</target>
        </condition>

        <!-- Do not configure Apache if we use Nginx -->
        <condition name='disabled_if_in' source='activer_nginx_web' fallback='True'>
            <param>oui</param>
            <target type='filelist'>genconfig_apache</target>
            <target type='servicelist'>genconfig_apache</target>
        </condition>

        <!-- Do not configure Apache if Apache is disabled -->
        <condition name='disabled_if_in' source='activer_apache' fallback='True'>
            <param>non</param>
            <target type='filelist'>genconfig_apache</target>
            <target type='servicelist'>genconfig_apache</target>
        </condition>

        <!-- Enable a minimal configuration when nginx and apache are disabled -->
        <auto name='calc_multi_condition' target='test_activer_minimal_nginx'>
            <param>non</param>
            <param type='eole' name='condition_1' hidden='False'>activer_nginx_web</param>
            <param type='eole' name='condition_2' hidden='False'>activer_apache</param>
            <param name='match'>oui</param>
            <param name='mismatch'>non</param>
        </auto>

        <condition name='disabled_if_in' source='test_activer_minimal_nginx' fallback='True'>
            <param>non</param>
            <target type='filelist'>genconfig_nginx_norevprox</target>
        </condition>

        <!-- Either we have nginx reverse proxy or minimal nginx configuration -->
        <auto name='calc_multi_condition' target='test_activer_genconfig_nginx'>
            <param>oui</param>
            <param name="operator">OR</param>
            <param type='eole' name='condition_1' hidden='False'>activer_nginx_web</param>
            <param type='eole' name='condition_2' hidden='False'>test_activer_minimal_nginx</param>
            <param name='match'>oui</param>
            <param name='mismatch'>non</param>
        </auto>

    </constraints>

    <help>

        <family name='Applications web Nginx'>Personnalisation de l'accès aux applications</family>
        <variable name='test_activer_genconfig_nginx'>Soit activer_nginx_web est 'oui', soit test_activer_minimal_nginx est 'oui'</variable>
        <variable name='test_activer_minimal_nginx'>Cette variable est active lorsque nginx et apache sont désactivés</variable>
        <variable name='activer_genconfig'>Publier l’interface de configuration du module sur le port standard HTTPS (443)</variable>
        <variable name='genconfig_http_path'>Chemin absolu (commençant par un /) sous lequel le service GenConfig sera accessible</variable>

    </help>

</creole>
<!-- vim: ts=4 sw=4 expandtab
-->
