1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/roundcube_ynh.git synced 2024-09-03 20:16:28 +02:00

Merge pull request #97 from YunoHost-Apps/fix-carddav

Fix CardDAV plugin setup
This commit is contained in:
Éric Gaspar 2020-11-27 21:32:41 +01:00 committed by GitHub
commit cfcc6cfffc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 60 additions and 83 deletions

View file

@ -12,6 +12,7 @@
setup_private=0 setup_private=0
setup_public=0 setup_public=0
upgrade=1 upgrade=1
upgrade=1 from_commit=337b120eb3b97ac6b616cbf400af3aa98e409a99
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
incorrect_path=1 incorrect_path=1
@ -23,3 +24,6 @@
Email= Email=
Notification=none Notification=none
;;; Upgrade options ;;; Upgrade options
; commit=337b120eb3b97ac6b616cbf400af3aa98e409a99
name=Fix carddav
manifest_arg=domain=DOMAIN&path=PATH&with_carddav=1&with_enigma=1&

16
conf/baikal.inc.php Normal file
View file

@ -0,0 +1,16 @@
$prefs['{baikal_id}'] = array(
// required attributes
'name' => '{baikal_id}',
'username' => '%u',
'password' => '%p',
'url' => '{baikal_url}/card.php/addressbooks/%u/',
// optional attributes
'active' => true,
'readonly' => false,
'refresh_time' => '00:05:00',
'fixed' => array('username', 'password'),
'hide' => false,
);

View file

@ -1,59 +0,0 @@
<?php
// RCMCardDAV Plugin Admin Settings
// ** ADDRESSBOOK PRESETS
/* PRESET FOR: baikal
$prefs['Baïkal'] = array(
// required attributes
'name' => 'Baïkal',
'username' => '%u',
'password' => '%p',
'url' => '{baikal_url}/card.php/addressbooks/%u/',
// optional attributes
'active' => true,
'readonly' => false,
'refresh_time' => '00:05:00',
'fixed' => array('username', 'password'),
'hide' => false,
);
END: baikal */
/* PRESET FOR: owncloud
$prefs['ownCloud'] = array(
// required attributes
'name' => 'ownCloud',
'username' => '%u',
'password' => '%p',
'url' => '{owncloud_url}/remote.php/dav/addressbooks/users/%u/default/',
// optional attributes
'active' => true,
'readonly' => false,
'refresh_time' => '00:05:00',
'fixed' => array('username', 'password'),
'hide' => false,
);
END: owncloud */
/* PRESET FOR: nextcloud
$prefs['NextCloud'] = array(
// required attributes
'name' => 'nextCloud',
'username' => '%u',
'password' => '%p',
'url' => '{nextcloud_url}/remote.php/dav/addressbooks/users/%u/contacts/',
// optional attributes
'active' => true,
'readonly' => false,
'refresh_time' => '00:05:00',
'fixed' => array('username', 'password'),
'hide' => false,
);
END: nextcloud */

16
conf/nextcloud.inc.php Normal file
View file

@ -0,0 +1,16 @@
$prefs['{nextcloud_id}'] = array(
// required attributes
'name' => '{nextcloud_id}',
'username' => '%u',
'password' => '%p',
'url' => '{nextcloud_url}/remote.php/dav/addressbooks/users/%u/contacts/',
// optional attributes
'active' => true,
'readonly' => false,
'refresh_time' => '00:05:00',
'fixed' => array('username', 'password'),
'hide' => false,
);

View file

@ -159,28 +159,28 @@ then
carddav_tmp_config="../conf/carddav.config.inc.php" carddav_tmp_config="../conf/carddav.config.inc.php"
carddav_server=0 carddav_server=0
# Copy the plugin configuration file
cp $final_path/plugins/carddav/config.inc.php{.dist,}
# Look for installed and supported CardDAV servers # Look for installed and supported CardDAV servers
for carddav_app in "nextcloud" "baikal" for carddav_app in "nextcloud" "baikal"
do do
carddav_app_id=$(yunohost app list --installed -f $carddav_app \ carddav_app_ids=$(yunohost app list | grep "id: $carddav_app" | grep -Po 'id: \K(.*)' || echo "")
--output-as json | grep -Po '"id":[ ]?"\K.*?(?=")' | head -1) for carddav_app_id in $carddav_app_ids
if [ -n "$carddav_app_id" ] do
then
carddav_server=1 carddav_server=1
# Append preset configuration to the config file
cat "../conf/${carddav_app}.inc.php" >> $final_path/plugins/carddav/config.inc.php
# Retrieve app settings and enable relevant preset # Retrieve app settings and enable relevant preset
carddav_domain=$(ynh_app_setting_get --app=$carddav_app_id --key=domain) carddav_domain=$(ynh_app_setting_get --app=$carddav_app_id --key=domain)
carddav_path=$(ynh_app_setting_get --app=$carddav_app_id --key=path) carddav_path=$(ynh_app_setting_get --app=$carddav_app_id --key=path)
carddav_url="https://${carddav_domain}${carddav_path%/}" carddav_url="https://${carddav_domain}${carddav_path%/}"
ynh_replace_string --match_string="{${carddav_app}_url}" --replace_string="$carddav_url" --target_file="$carddav_tmp_config" ynh_replace_string --match_string="{${carddav_app}_id}" --replace_string="$carddav_app_id" --target_file="$final_path/plugins/carddav/config.inc.php"
ynh_replace_string --match_string="/* PRESET FOR: $carddav_app" --replace_string="" --target_file="$carddav_tmp_config" ynh_replace_string --match_string="{${carddav_app}_url}" --replace_string="$carddav_url" --target_file="$final_path/plugins/carddav/config.inc.php"
ynh_replace_string --match_string="END: $carddav_app */" --replace_string="" --target_file="$carddav_tmp_config" done
fi
done done
# Copy the plugin configuration file # Do not actualy add the carddav plugin if there's no carddav server available...
cp "$carddav_tmp_config" ""$final_path/plugins/carddav/config.inc.php""
# Do not actualy add the carddav plugin if there's no CardDAV server available...
if [ $carddav_server -eq 1 ] if [ $carddav_server -eq 1 ]
then then
installed_plugins+=" 'carddav'," installed_plugins+=" 'carddav',"

View file

@ -206,28 +206,28 @@ then
carddav_tmp_config="../conf/carddav.config.inc.php" carddav_tmp_config="../conf/carddav.config.inc.php"
carddav_server=0 carddav_server=0
# Copy the plugin configuration file
cp $final_path/plugins/carddav/config.inc.php{.dist,}
# Look for installed and supported CardDAV servers # Look for installed and supported CardDAV servers
for carddav_app in "nextcloud" "baikal" for carddav_app in "nextcloud" "baikal"
do do
carddav_app_id=$(yunohost app list --installed -f $carddav_app \ carddav_app_ids=$(yunohost app list | grep "id: $carddav_app" | grep -Po 'id: \K(.*)' || echo "")
--output-as json | grep -Po '"id":[ ]?"\K.*?(?=")' | head -1) for carddav_app_id in $carddav_app_ids
if [ -n "$carddav_app_id" ] do
then
carddav_server=1 carddav_server=1
# Append preset configuration to the config file
cat "../conf/${carddav_app}.inc.php" >> $final_path/plugins/carddav/config.inc.php
# Retrieve app settings and enable relevant preset # Retrieve app settings and enable relevant preset
carddav_domain=$(ynh_app_setting_get --app=$carddav_app_id --key=domain) carddav_domain=$(ynh_app_setting_get --app=$carddav_app_id --key=domain)
carddav_path=$(ynh_app_setting_get --app=$carddav_app_id --key=path) carddav_path=$(ynh_app_setting_get --app=$carddav_app_id --key=path)
carddav_url="https://${carddav_domain}${carddav_path%/}" carddav_url="https://${carddav_domain}${carddav_path%/}"
ynh_replace_string --match_string="{${carddav_app}_url}" --replace_string="$carddav_url" --target_file="$carddav_tmp_config" ynh_replace_string --match_string="{${carddav_app}_id}" --replace_string="$carddav_app_id" --target_file="$final_path/plugins/carddav/config.inc.php"
ynh_replace_string --match_string="\/\* PRESET FOR: $carddav_app" --replace_string="" --target_file="$carddav_tmp_config" ynh_replace_string --match_string="{${carddav_app}_url}" --replace_string="$carddav_url" --target_file="$final_path/plugins/carddav/config.inc.php"
ynh_replace_string --match_string="END: $carddav_app \*\/" --replace_string="" --target_file="$carddav_tmp_config" done
fi
done done
# Copy the plugin configuration file # Do not actually add the carddav plugin if there's no carddav server available...
cp "$carddav_tmp_config" ""$final_path/plugins/carddav/config.inc.php""
# Do not actually add the cardDAV plugin if there's no carddav server available...
if [ $carddav_server -eq 1 ] if [ $carddav_server -eq 1 ]
then then
installed_plugins+=" 'carddav'," installed_plugins+=" 'carddav',"