diff --git a/conf/baikal.inc.php b/conf/baikal.inc.php new file mode 100644 index 0000000..99a192b --- /dev/null +++ b/conf/baikal.inc.php @@ -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, +); diff --git a/conf/carddav.config.inc.php b/conf/carddav.config.inc.php deleted file mode 100644 index 13c4509..0000000 --- a/conf/carddav.config.inc.php +++ /dev/null @@ -1,59 +0,0 @@ - '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 */ diff --git a/conf/nextcloud.inc.php b/conf/nextcloud.inc.php new file mode 100644 index 0000000..46d3158 --- /dev/null +++ b/conf/nextcloud.inc.php @@ -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, +); diff --git a/scripts/install b/scripts/install index 25bf89a..f9a2132 100644 --- a/scripts/install +++ b/scripts/install @@ -159,27 +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 | grep "id: $carddav_app" | grep -Po 'id: \K(.*)' | head -n 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'," diff --git a/scripts/upgrade b/scripts/upgrade index d0f9342..4fa6690 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -206,27 +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 | grep "id: $carddav_app" | grep -Po 'id: \K(.*)' | head -n 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',"