#!/bin/bash

if [ -f /usr/bin/ParseDico ];
then
    RunCmd=RunCmd
    . ParseDico
    . /etc/eole/containers.conf
    . /usr/share/eole/FonctionsEoleNg
else
    activer_etherhome=$(CreoleGet activer_etherhome)
    activer_etherpad=$(CreoleGet activer_etherpad)
    RunCmd=CreoleRun
fi

if [[ "$activer_etherhome" == "oui" && "$activer_etherpad" == "oui" ]]
then
    # Récupération de la clé d'API d'etherpad
    apikey=$( $RunCmd "cat /usr/share/eole/nodejs/etherpad/APIKEY.txt" web)
    
    etherhome_conf="/var/www/html/etherhome/config.inc.php"

    $RunCmd "sed -i \"s/apikey='.*';/apikey='${apikey}';/\" ${etherhome_conf} " web
fi

