#!/bin/bash

. /usr/lib/envole-tools/e-ihm.sh

RunCmd=CreoleRun
activer_nextcloud=$(CreoleGet activer_nextcloud non)
container_path_web=$(CreoleGet container_path_web non)

rm -f /etc/cron.d/nextcloud

if [ "$activer_nextcloud" == "oui" ]
then
	TitleSimple "NEXTCLOUD"

    rm -rf ${container_path_web}/var/www/nextcloud/nextcloud.db
    cp /usr/share/envole/eoledb/nextcloud ${container_path_web}/var/www/nextcloud/nextcloud.db

	# Executer la montée de version
    $RunCmd "systemctl stop nextcloud.timer" web
	$RunCmd "/var/www/nextcloud/maj-nextcloud.sh" web
	$RunCmd "systemctl start nextcloud.timer" web
	$RunCmd "systemctl enable nextcloud.timer" web

	EchoVert ""
	EchoVert ""
else
	$RunCmd "systemctl stop nextcloud.timer" web
	$RunCmd "systemctl disable nextcloud.timer" web
fi

exit 0

