mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
feat: webdav sync default settings in env variables of container
In the docker setup, allow admin to provide the default values for WebDAV settings in the "Sync" section of the "Settings" page, via setting some environment variables of the docker container. This could be used for single user instances to pre-fill those settings. The available environment variables are: - WEBDAV_BASE_URL=<base-url> - WEBDAV_USERNAME=<username> - WEBDAV_SYNC_FOLDER_PATH=<sync-folder-path> - SYNC_INTERVAL=<integer-in-minutes> - IS_COMPRESSION_ENABLED=<true-or-false> - IS_ENCRYPTION_ENABLED=<true-or-false> These configurations are provided as environment variables after the build process of the app, so they have to be loaded at runtime, instead of build process. This can be achieved by the following way: 1. The environment variables are loaded into the docker container. 2. The container starts with `docker-entrypoint.sh`. 3. `docker-entrypoint.sh` converts the variables into a JSON file placed at `assets/sync-config-default-override.json`. 4. `sync-config.service.ts` fetches `assets/sync-config-default-override.json` dynamically at runtime to override the default values from `default-global-config.const.ts`.
This commit is contained in:
parent
94b77b46d8
commit
ab3d2824a5
6 changed files with 86 additions and 13 deletions
34
docker-entrypoint.sh
Executable file
34
docker-entrypoint.sh
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Generate ./assets/sync-config-default-override.json from environment variables
|
||||
JSON="{}"
|
||||
JSON_PATH=./assets/sync-config-default-override.json
|
||||
if [ -n "${WEBDAV_BASE_URL}" ]; then
|
||||
JSON=$(echo "$JSON" | jq ".webDav.baseUrl |= \"$WEBDAV_BASE_URL\"")
|
||||
fi
|
||||
if [ -n "${WEBDAV_USERNAME}" ]; then
|
||||
JSON=$(echo "$JSON" | jq ".webDav.userName |= \"$WEBDAV_USERNAME\"")
|
||||
fi
|
||||
if [ -n "${WEBDAV_SYNC_FOLDER_PATH}" ]; then
|
||||
JSON=$(echo "$JSON" | jq ".webDav.syncFolderPath |= \"$WEBDAV_SYNC_FOLDER_PATH\"")
|
||||
fi
|
||||
if [ "$JSON" != "{}" ]; then
|
||||
# Change syncProvider if previous variables are set
|
||||
JSON=$(echo "$JSON" | jq '.syncProvider |= "WebDAV"')
|
||||
fi
|
||||
if [ -n "${SYNC_INTERVAL}" ]; then
|
||||
JSON=$(echo "$JSON" | jq ".syncInterval |= $(expr $SYNC_INTERVAL \* 60000)")
|
||||
fi
|
||||
if [ -n "${IS_COMPRESSION_ENABLED}" ]; then
|
||||
JSON=$(echo "$JSON" | jq ".isCompressionEnabled |= $IS_COMPRESSION_ENABLED")
|
||||
fi
|
||||
if [ -n "${IS_ENCRYPTION_ENABLED}" ]; then
|
||||
JSON=$(echo "$JSON" | jq ".isEncryptionEnabled |= $IS_ENCRYPTION_ENABLED")
|
||||
fi
|
||||
if [ "$JSON" != "{}" ]; then
|
||||
# Write the resultant json
|
||||
echo "$JSON" >$JSON_PATH
|
||||
fi
|
||||
|
||||
# run nginx
|
||||
nginx -g "daemon off;"
|
||||
Loading…
Add table
Add a link
Reference in a new issue