<?xml version="1.0" encoding="utf-8"?>
<creole>
    <files>
        <file filelist='etherpad' name='/etc/eole/eole-db.d/etherpad-db.yml' rm='True' mkdir='True'/>
    </files>
    <containers>
        <container name='web'>
	    <package>etherpad-apps</package>
            <service method="apache" servicelist="etherpad">etherpad</service>
            <service servicelist="etherpad">etherpad-apps</service>

            <file filelist='etherpad' name='/etc/cron.d/etherpad' source='etherpad.cron' rm='True'/>
            <file filelist='etherpad' name='/etc/apache2/sites-available/etherpad' source='etherpad-apache.conf' rm='True' />
            <file filelist='etherpad' name='/usr/share/eole/nodejs/etherpad/settings.json' source='etherpad-settings.json' rm='True'/>
            <file filelist='etherpad' name='/usr/share/eole/nodejs/etherpad/eoleDeps.sh' source='etherpad-eoleDeps.sh' rm='True'/>

            <!-- fichier de configuration pour etherhome (gestion des pads) -->
            <file filelist='etherpadhome' name='/var/www/html/etherhome/confSqlEtherpad.inc.php' source='etherpad-etherhome.php' rm='True'/>

        </container>
    </containers>

    <variables>
        <family name='applications web'>
            <variable name='activer_etherpad' type='oui/non' description='Activer Etherpad-Lite (éditeur de texte collaboratif)'>
                <value>oui</value>
            </variable>
            <variable name='activer_etherhome' type='oui/non' description="Activer Etherhome (gestion etherpad, ethercalc et scrumblr)" hidden='True' exists='False'>
                <value>non</value>
            </variable>            
            <variable name="etherpad_port" type="string" description="Port d'écoute d'etherpad">
                <value>9001</value>
            </variable>
        </family>

        <family name='EoleDB' icon='database' mode='expert'>
            <variable type='string' name='etherpad_db_mode' description='Serveur de bases de données à utiliser'/>
            <variable type='string' name='etherpad_dbserver' description='Adresse du serveur de base de données'/>
            <variable type='number' name='etherpad_dbport' description="Port d'écoute du serveur de base de données"/>
            <variable type='string' name='etherpad_allow_hosts' description="Hôtes autorisés à utiliser la base de données" multi='True'/>
            <variable type='string' name='etherpad_dbuser' description='Utilisateur du serveur de base de données'/>
            <variable type='string' name='etherpad_dbpass' description='Fichier de mot de passe du serveur'/>
        </family>	     

        <separators>
            <separator name="etherpad_db_mode">Paramètres EoleDB associés à Etherpad</separator>
        </separators>             
    </variables>

    <constraints>
        <condition name='disabled_if_in' source='activer_etherpad'>
            <param>non</param>
            <target type='filelist'>etherpad</target>
            <target type='filelist'>etherpadhome</target>
            <target type='servicelist'>etherpad</target>
            <target type='variable'>etherpad_port</target>
        </condition>
        
        <condition name='disabled_if_in' source='activer_etherhome'>
            <param>non</param>
            <target type='filelist'>etherpadhome</target>
        </condition>

        <check name='valid_enum' target='etherpad_db_mode'>
            <param>['default', 'externe', 'local']</param>
        </check>
        <condition name='disabled_if_in' source='etherpad_db_mode'>
            <param>local</param>
            <target type='variable'>etherpad_dbserver</target>
            <target type='variable'>etherpad_dbuser</target>
            <target type='variable'>etherpad_dbport</target>
            <target type='variable'>etherpad_dbpass</target>
        </condition>
        <condition name='disabled_if_in' source='etherpad_db_mode'>
            <param>default</param>
            <target type='variable'>etherpad_dbserver</target>
            <target type='variable'>etherpad_dbuser</target>
            <target type='variable'>etherpad_dbport</target>
            <target type='variable'>etherpad_dbpass</target>
            <target type='variable'>etherpad_allow_hosts</target>
        </condition>          
    </constraints>
    <help>
        <variable name='activer_etherpad'>Etherpad est un éditeur de texte collaboratif en ligne propulsé par Node.js</variable>
    </help>
</creole>
