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:
commit
cfcc6cfffc
6 changed files with 60 additions and 83 deletions
|
@ -12,6 +12,7 @@
|
|||
setup_private=0
|
||||
setup_public=0
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=337b120eb3b97ac6b616cbf400af3aa98e409a99
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
incorrect_path=1
|
||||
|
@ -23,3 +24,6 @@
|
|||
Email=
|
||||
Notification=none
|
||||
;;; 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
16
conf/baikal.inc.php
Normal 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,
|
||||
);
|
|
@ -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
16
conf/nextcloud.inc.php
Normal 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,
|
||||
);
|
|
@ -159,28 +159,28 @@ then
|
|||
carddav_tmp_config="../conf/carddav.config.inc.php"
|
||||
carddav_server=0
|
||||
|
||||
# Copy the plugin configuration file
|
||||
cp $final_path/plugins/carddav/config.inc.php{.dist,}
|
||||
|
||||
# Look for installed and supported CardDAV servers
|
||||
for carddav_app in "nextcloud" "baikal"
|
||||
do
|
||||
carddav_app_id=$(yunohost app list --installed -f $carddav_app \
|
||||
--output-as json | grep -Po '"id":[ ]?"\K.*?(?=")' | head -1)
|
||||
if [ -n "$carddav_app_id" ]
|
||||
then
|
||||
carddav_app_ids=$(yunohost app list | grep "id: $carddav_app" | grep -Po 'id: \K(.*)' || echo "")
|
||||
for carddav_app_id in $carddav_app_ids
|
||||
do
|
||||
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
|
||||
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_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="/* PRESET FOR: $carddav_app" --replace_string="" --target_file="$carddav_tmp_config"
|
||||
ynh_replace_string --match_string="END: $carddav_app */" --replace_string="" --target_file="$carddav_tmp_config"
|
||||
fi
|
||||
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="{${carddav_app}_url}" --replace_string="$carddav_url" --target_file="$final_path/plugins/carddav/config.inc.php"
|
||||
done
|
||||
done
|
||||
|
||||
# Copy the plugin configuration file
|
||||
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...
|
||||
# Do not actualy add the carddav plugin if there's no carddav server available...
|
||||
if [ $carddav_server -eq 1 ]
|
||||
then
|
||||
installed_plugins+=" 'carddav',"
|
||||
|
|
|
@ -206,28 +206,28 @@ then
|
|||
carddav_tmp_config="../conf/carddav.config.inc.php"
|
||||
carddav_server=0
|
||||
|
||||
# Copy the plugin configuration file
|
||||
cp $final_path/plugins/carddav/config.inc.php{.dist,}
|
||||
|
||||
# Look for installed and supported CardDAV servers
|
||||
for carddav_app in "nextcloud" "baikal"
|
||||
do
|
||||
carddav_app_id=$(yunohost app list --installed -f $carddav_app \
|
||||
--output-as json | grep -Po '"id":[ ]?"\K.*?(?=")' | head -1)
|
||||
if [ -n "$carddav_app_id" ]
|
||||
then
|
||||
carddav_app_ids=$(yunohost app list | grep "id: $carddav_app" | grep -Po 'id: \K(.*)' || echo "")
|
||||
for carddav_app_id in $carddav_app_ids
|
||||
do
|
||||
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
|
||||
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_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="\/\* PRESET FOR: $carddav_app" --replace_string="" --target_file="$carddav_tmp_config"
|
||||
ynh_replace_string --match_string="END: $carddav_app \*\/" --replace_string="" --target_file="$carddav_tmp_config"
|
||||
fi
|
||||
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="{${carddav_app}_url}" --replace_string="$carddav_url" --target_file="$final_path/plugins/carddav/config.inc.php"
|
||||
done
|
||||
done
|
||||
|
||||
# Copy the plugin configuration file
|
||||
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...
|
||||
# Do not actually add the carddav plugin if there's no carddav server available...
|
||||
if [ $carddav_server -eq 1 ]
|
||||
then
|
||||
installed_plugins+=" 'carddav',"
|
||||
|
|
Loading…
Reference in a new issue