<?xml version="1.0" encoding="utf-8"?>
<creole>
    <files>
        <file filelist='nextcloud' name='/etc/eole/eole-db.d/nextcloud-db.yml' rm='True' mkdir='True'/>
        <file filelist='nextcloud' name='/usr/share/envole/eoledb/nextcloud' source='nextcloud.db' rm='True' mkdir='True'/>
        <file filelist='nextcloud-bareos' name='/etc/bareos/bareosfichiers.d/nextcloud.conf' source='nextcloud-bareos.conf' rm='True'/>
    </files>
    <containers>
        <container name="fichier" id='12'>
            <file filelist='nextcloud' name='/etc/samba/conf.d/nextcloud.conf' source='nextcloud-samba.conf' rm='True' mkdir='True'/>
        </container>

        <container name='web'>
            <package>smbclient</package>
            <package>nextcloud-apps</package>

            <service method="apache" servicelist="nextcloud">nextcloud</service>

            <file filelist='nextcloud' name='/etc/apache2/sites-available/nextcloud' source='nextcloud-apache.conf' rm='True'/>
            <file filelist='nextcloud' name='/var/www/html/nextcloud/config/config.php' source='nextcloud-config.php' rm='True' mkdir='True'/>
            <file filelist='nextcloud' name='/var/www/nextcloud/maj-nextcloud.sh' source='nextcloud-maj-nextcloud.sh' rm='True' mkdir='True' mode='700' />
            <file filelist='nextcloud' name='/var/www/nextcloud/patch/ftpcas/appinfo/info.xml' source='nextcloud-ftpcas-info.xml' rm='True' mkdir='True' mode='700' />
            <file filelist='nextcloud' name='/var/www/nextcloud/nextcloud-12.0.3/config/config.php' source='nextcloud-config-12.0.3.php' rm='True' mkdir='True'/>
            <file filelist='nextcloud' name='/var/www/nextcloud/nextcloud-13.0.6/config/config.php' source='nextcloud-config-13.0.6.php' rm='True' mkdir='True'/>
            <file filelist='nextcloud' name='/var/www/nextcloud/nextcloud-14.0.3/config/config.php' source='nextcloud-config-14.0.3.php' rm='True' mkdir='True'/>
            <file filelist='nextcloud' name='/var/www/html/posh-profil/include/nextcloud.php' source='nextcloud-synchro.php' rm='True' mkdir='True'/>
        </container>
    </containers>

    <variables>
        <family name='applications web'>
            <variable name='activer_nextcloud' type='oui/non' description='Activer nextcloud (gestionnaire de fichiers)'>
                <value>oui</value>
            </variable>
            <variable name='nextcloud_postsize' type='string' description='Taille max. des téléversements dans nextcloud (en Mo)'>
                <value>32</value>
            </variable>
            <variable name='nextcloud_activer_ftpdistant' type='oui/non' description='Activer un repository distant en FTP pour Nextcloud'>
                <value>non</value>
            </variable>   
            <variable name='nextcloud_ftpdistant' type='string' mandatory='True' description='IP / Domaine du repository distant en FTP pour Nextcloud' />
        </family>

        <family name='nextcloud' mode='expert'>
            <variable type='string' name='nextcloud_db_mode' description='Serveur de bases de données à utiliser'/>
            <variable type='string' name='nextcloud_dbserver' description='Adresse du serveur de base de données'/>
            <variable type='number' name='nextcloud_dbport' description="Port d'écoute du serveur de base de données"/>
            <variable type='string' name='nextcloud_allow_hosts' description="Hôtes authorisés à utiliser la base de données" multi='True'/>
            <variable type='string' name='nextcloud_dbuser' description='Utilisateur du serveur de base de données'/>
            <variable type='string' name='nextcloud_dbpass' description='Fichier de mot de passe du serveur'/>
        </family>
    </variables>

    <constraints>
        <condition name='hidden_if_in' source='activer_apache'>
            <param>non</param>
            <target type='filelist'>nextcloud</target>
            <target type='filelist'>nextcloud-bareos</target>
            <target type='servicelist'>nextcloud</target>
        </condition>

        <condition name='hidden_if_in' source='activer_nextcloud'>
            <param>non</param>
            <target type='filelist'>nextcloud</target>
            <target type='filelist'>nextcloud-bareos</target>
            <target type='servicelist'>nextcloud</target>
            <target type='variable'>nextcloud_postsize</target>
            <target type='variable'>nextcloud_activer_ftpdistant</target>
            <target type='variable'>nextcloud_ftpdistant</target>
        </condition>

        <condition name='hidden_if_in' source='activer_proftpd' fallback='True'>
            <param>oui</param>
            <target type='variable'>nextcloud_activer_ftpdistant</target>
		</condition>

        <condition name='hidden_if_in' source='nextcloud_activer_ftpdistant'>
            <param>non</param>
            <target type='variable'>nextcloud_ftpdistant</target>
        </condition>

        <check name='valid_enum' target='nextcloud_db_mode'>
            <param>['default', 'externe', 'local']</param>
        </check>
        <condition name='disabled_if_in' source='nextcloud_db_mode'>
            <param>local</param>
            <target type='variable'>nextcloud_dbserver</target>
            <target type='variable'>nextcloud_dbuser</target>
            <target type='variable'>nextcloud_dbport</target>
            <target type='variable'>nextcloud_dbpass</target>
        </condition>
        <condition name='disabled_if_in' source='nextcloud_db_mode'>
            <param>default</param>
            <target type='variable'>nextcloud_dbserver</target>
            <target type='variable'>nextcloud_dbuser</target>
            <target type='variable'>nextcloud_dbport</target>
            <target type='variable'>nextcloud_dbpass</target>
            <target type='variable'>nextcloud_allow_hosts</target>
        </condition>

        <condition name='hidden_if_in' source='activer_bareos_dir' fallback='True'>
            <param>non</param>
            <target type='filelist'>nextcloud-bareos</target>
		</condition>
    </constraints>

    <help>
        <variable name='activer_nextcloud'>nextcloud vous donne un accès universel a vos fichiers via une interface web ou WebDAV</variable>
    </help>
</creole>
