Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/container.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSameer Naik <sameer@damagehead.com>2016-03-21 10:31:13 +0300
committerSameer Naik <sameer@damagehead.com>2016-03-21 10:31:13 +0300
commit01f3a36dfae486d00eee3bb324f5d644cd4cd985 (patch)
tree860b3f01cb70c011e193d309cfa657c60264a81b
parent479e215387857c940d0160a146aef5555a70d8dc (diff)
config: avoid duplicate entries in `.user.ini`
-rw-r--r--assets/runtime/functions33
1 files changed, 28 insertions, 5 deletions
diff --git a/assets/runtime/functions b/assets/runtime/functions
index 1e596d0..2ea2541 100644
--- a/assets/runtime/functions
+++ b/assets/runtime/functions
@@ -36,6 +36,31 @@ parse_yaml() {
}'
}
+get_php_param() {
+ local key=${1?key not specified}
+ sed -n -e "s/^\(${key}=\)\(.*\)\(.*\)$/\2/p" ${OWNCLOUD_INSTALL_DIR}/.user.ini
+}
+
+set_php_param() {
+ local key=${1?key not specified}
+ local value=${2?value not specified}
+ local verbosity=${3:-verbose}
+
+ local current=$(get_php_param ${key})
+ if [[ "${current}" != "${value}" ]]; then
+ if [[ ${verbosity} == verbose ]]; then
+ echo "Setting .user.ini parameter: ${key}=${value}"
+ fi
+ fi
+
+ if [[ $(sed -n -e "s/^[;]*[ ]*\(${key}\)=.*/\1/p" .user.ini) == ${key} ]]; then
+ value="$(echo "${value}" | sed 's|[&]|\\&|g')"
+ sed -i "s|^[;]*[ ]*${key}=.*|${key}=${value}|" ${OWNCLOUD_INSTALL_DIR}/.user.ini
+ else
+ echo "${key}=${value}" >> ${OWNCLOUD_INSTALL_DIR}/.user.ini
+ fi
+}
+
## Execute a command as OWNCLOUD_USER
exec_as_owncloud() {
if [[ $(whoami) == ${OWNCLOUD_USER} ]]; then
@@ -312,15 +337,13 @@ owncloud_configure_domain() {
owncloud_configure_max_upload_size() {
echo "Configuring ownCloud::max_upload_size..."
- (
- echo "upload_max_filesize=${OWNCLOUD_UPLOAD_MAX_FILESIZE}"
- echo "post_max_size=${OWNCLOUD_UPLOAD_MAX_FILESIZE}"
- ) >> ${OWNCLOUD_INSTALL_DIR}/.user.ini
+ set_php_param upload_max_filesize ${OWNCLOUD_UPLOAD_MAX_FILESIZE}
+ set_php_param post_max_size ${OWNCLOUD_UPLOAD_MAX_FILESIZE}
}
owncloud_configure_max_file_uploads() {
echo "Configuring ownCloud::max_file_uploads..."
- echo "max_file_uploads=${OWNCLOUD_MAX_FILE_UPLOADS}" >> ${OWNCLOUD_INSTALL_DIR}/.user.ini
+ set_php_param max_file_uploads ${OWNCLOUD_MAX_FILE_UPLOADS}
}
nginx_configure_virtualhost() {