From 06655136e6f444c44976c47647bd5dbce2ba0fe4 Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Wed, 2 Jul 2014 09:35:12 +0200 Subject: [PATCH] support baikal, fallback on radicale --- conf/caldav.php | 4 ++-- scripts/install | 35 ++++++++++++++++++++++++++++------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/conf/caldav.php b/conf/caldav.php index 0702c0a..945521c 100755 --- a/conf/caldav.php +++ b/conf/caldav.php @@ -44,7 +44,7 @@ $config['caldav_http_auth_method'] = CURLAUTH_BASIC; * - Apple Calendar Server: https://host/calendars/users/%u/ */ -$config['caldav_principal_url'] = 'https://YNH_DOMAINYNH_RADICALE_PATH/%u/'; +$config['caldav_principal_url'] = 'YNH_CALDAV_PRINCIPAL_URL'; /* * CalDAV calendars URL template @@ -59,7 +59,7 @@ $config['caldav_principal_url'] = 'https://YNH_DOMAINYNH_RADICALE_PATH/%u/'; * - Apple Calendar Server: https://host/calendars/users/%s/ */ -$config['caldav_calendar_url'] = 'https://YNH_DOMAINYNH_RADICALE_PATH/%s/'; +$config['caldav_calendar_url'] = 'YNH_CALDAV_CALENDAR_URL'; /* * Public CalDAV URL for calendars diff --git a/scripts/install b/scripts/install index 89dc0ca..6b87069 100644 --- a/scripts/install +++ b/scripts/install @@ -11,10 +11,24 @@ if [[ ! $? -eq 0 ]]; then exit 1 fi +baikal=0 +radicale=0 + +sudo yunohost app list --json | grep -q '"id": "baikal"' +if [[ $? -eq 0 ]]; then + baikal=1 + caldavapp=baikal +fi + sudo yunohost app list --json | grep -q '"id": "radicale"' -if [[ ! $? -eq 0 ]]; then - echo "Error : Radicale app is not installed" - exit 1 +if [[ $? -eq 0 ]]; then + radicale=1 + caldavapp=radicale +fi + +if [ $baikal -eq 0 ] && [ $radicale -eq 0 ]; then + echo "Error : You must install Baikal or Radicale before" + exit 1 fi # Install dependencies @@ -41,10 +55,17 @@ currentpath=$(pwd) cd $final_path/web/application && ln -s ../config config && cd $currentpath # caldav config -radicale_path=$(sudo yunohost app setting radicale path) -radicale_path=${radicale_path%/} -sed -i "s@YNH_DOMAIN@$domain@g" ../conf/caldav.php -sed -i "s@YNH_RADICALE_PATH@$radicale_path@g" ../conf/caldav.php +caldavdomain=$(sudo yunohost app setting $caldavapp domain) +caldavpath=$(sudo yunohost app setting $caldavapp path) +if [ $baikal -eq 1 ]; then + caldav_principal_url="https://$(caldavdomain)$(caldavpath)/cal.php/%u/" + caldav_calendar_url="https://$(caldavdomain)$(caldavpath)/cal.php/calendars/%s/" +elif [ $radicale -eq 1 ]; then + caldav_principal_url="https://$(caldavdomain)$(caldavpath)/%u/" + caldav_calendar_url="https://$(caldavdomain)$(caldavpath)/%s/" +fi +sed -i "s@YNH_CALDAV_PRINCIPAL_URL@$caldav_principal_url@g" ../conf/caldav.php +sed -i "s@YNH_CALDAV_CALENDAR_URL@$caldav_calendar_url@g" ../conf/caldav.php # database config sed -i "s/YNH_DB_USER/$db_user/g" ../conf/database.php