mirror of
https://github.com/zokradonh/kopano-docker
synced 2025-06-06 15:36:40 +00:00
Added automatic Z-Push shared folder registration.
Via a new environment variable containing the relevant information in a JSON string, shared folders can be specifified which will be set using Z-Push's $additionalFolders configuration option.
This commit is contained in:
parent
cbe582b8ff
commit
4dac253cf2
@ -210,6 +210,9 @@ services:
|
||||
- zpushstates/:/var/lib/z-push/
|
||||
environment:
|
||||
- TZ=${TZ}
|
||||
# Shared folders automatically assigned to all users in the format: [{"name":"<folder name>","id":"<kopano folder id>","type":"<type>","flags":"<flags>"},...]
|
||||
# For more information on the parameters see the z-push-admin help for the addshared-action.
|
||||
- ZPUSH_ADDITIONAL_FOLDERS=[]
|
||||
env_file:
|
||||
- kopano_zpush.env
|
||||
networks:
|
||||
|
@ -35,6 +35,41 @@ tests:
|
||||
stdout:
|
||||
contains:
|
||||
- "define('USERNAME', 'SYSTEM');"
|
||||
start-service script (no additional folders):
|
||||
command: bash -c "shopt -s expand_aliases; alias exec='echo exec'; alias php-fpm7.0='echo php-fpm7.0'; . /kopano/start.sh" && cat /etc/z-push/z-push.conf.php
|
||||
exit-code: 0
|
||||
stdout:
|
||||
contains:
|
||||
- " $additionalFolders = array(\n );"
|
||||
not-contains: # default entry
|
||||
- "\t$additionalFolders = array("
|
||||
- "\t);"
|
||||
start-service script (empty additional folders):
|
||||
command: bash -c "shopt -s expand_aliases; alias exec='echo exec'; alias php-fpm7.0='echo php-fpm7.0'; . /kopano/start.sh" && cat /etc/z-push/z-push.conf.php
|
||||
exit-code: 0
|
||||
stdout:
|
||||
contains:
|
||||
- " $additionalFolders = array(\n );"
|
||||
not-contains: # default entry
|
||||
- "\t$additionalFolders = array("
|
||||
- "\t);"
|
||||
config:
|
||||
env:
|
||||
ZPUSH_ADDITIONAL_FOLDERS: "[]"
|
||||
start-service script (set additional folders):
|
||||
command: bash -c "shopt -s expand_aliases; alias exec='echo exec'; alias php-fpm7.0='echo php-fpm7.0'; . /kopano/start.sh" && cat /etc/z-push/z-push.conf.php
|
||||
exit-code: 0
|
||||
stdout:
|
||||
contains:
|
||||
- " $additionalFolders = array(\n array('store' => \"SYSTEM\", 'folderrid' => \"42\", 'name' => \"Calendar\", 'type' => \"SYNC_FOLDER_TYPE_USER_APPOINTMENT\", 'flags' => \"4\"),\n array('store' => \"SYSTEM\", 'folderrid' => \"21\", 'name' => \"Mail\", 'type' => \"SYNC_FOLDER_TYPE_USER_MAIL\", 'flags' => \"0\"),\n );"
|
||||
not-contains: # default entry
|
||||
- "\t$additionalFolders = array("
|
||||
- "\t);"
|
||||
config:
|
||||
env:
|
||||
ZPUSH_ADDITIONAL_FOLDERS: "[{\"name\":\"Calendar\",\"id\":\"42\",\"type\":\"SYNC_FOLDER_TYPE_USER_APPOINTMENT\",\"flags\":\"4\"},{\"name\":\"Mail\",\"id\":\"21\",\"type\":\"SYNC_FOLDER_TYPE_USER_MAIL\",\"flags\":\"0\"}]"
|
||||
|
||||
|
||||
config:
|
||||
env:
|
||||
DEBUG: ${DEBUG}
|
||||
|
@ -1,9 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
# define default value for serverhostname and serverport if not passed into container
|
||||
# define default value for serverhostname, serverport, additional packages and shared folders if not passed into container
|
||||
KCCONF_SERVERHOSTNAME=${KCCONF_SERVERHOSTNAME:-127.0.0.1}
|
||||
KCCONF_SERVERPORT=${KCCONF_SERVERPORT:-236}
|
||||
ADDITIONAL_KOPANO_PACKAGES=${ADDITIONAL_KOPANO_PACKAGES:-""}
|
||||
ZPUSH_ADDITIONAL_FOLDERS=${ZPUSH_ADDITIONAL_FOLDERS:-"[]"}
|
||||
|
||||
set -eu # unset variables are errors & non-zero return values exit the whole script
|
||||
[ "$DEBUG" ] && set -x
|
||||
@ -100,6 +101,15 @@ for setting in $(compgen -A variable KCCONF_ZPUSHGA2CONTACTS_); do
|
||||
php_cfg_gen /etc/z-push/gab2contacts.conf.php "${setting2}" "${!setting}"
|
||||
done
|
||||
|
||||
# configuring z-push shared folders
|
||||
perl -i -0pe 's/\$additionalFolders.*\);//s' /etc/z-push/z-push.conf.php
|
||||
echo -e " \$additionalFolders = array(" >> /etc/z-push/z-push.conf.php
|
||||
echo "$ZPUSH_ADDITIONAL_FOLDERS" | jq -c '.[]' | while read -r folder; do
|
||||
eval "$(echo "$folder" | jq -r '@sh "NAME=\(.name) ID=\(.id) TYPE=\(.type) FLAGS=\(.flags)"')"
|
||||
echo -e " array('store' => \"SYSTEM\", 'folderrid' => \"$ID\", 'name' => \"$NAME\", 'type' => \"$TYPE\", 'flags' => \"$FLAGS\")," >> /etc/z-push/z-push.conf.php
|
||||
done
|
||||
echo -e ' );' >> /etc/z-push/z-push.conf.php
|
||||
|
||||
echo "Ensure config ownership"
|
||||
chown -R www-data:www-data /run/sessions
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user