1
0
mirror of https://github.com/zokradonh/kopano-docker synced 2025-12-20 13:46:37 +00:00
kopano-docker/php/start-helper.sh
Felix Bartels 0dd0f49866
also update config settings for plugins installed during runtime (#447)
* also update config settings for plugins installed during runtime
* update webapp example
* skip duplicate handling of config.php
* add todo
2020-09-21 16:14:47 +02:00

31 lines
919 B
Bash
Executable File

#!/bin/bash
php_cfg_gen() {
local cfg_file="$1"
local cfg_setting="$2"
local cfg_value="$3"
if [ -e "$cfg_file" ]; then
echo "Setting $cfg_setting = $cfg_value in $cfg_file"
if ! grep -q "$cfg_setting" "$cfg_file"; then
echo "WARNING: Config option $cfg_setting not found in $cfg_file! You may have misspelled the confing setting."
echo "define('$cfg_setting', '$cfg_value');" >> "$cfg_file"
cat "$cfg_file"
return
fi
case $cfg_value in
# TODO stop after the first match
true|TRUE|false|FALSE)
sed -ri "s#(\s*define).+${cfg_setting}.+#\tdefine(\x27${cfg_setting}\x27, ${cfg_value}\);#g" "$cfg_file"
;;
*)
sed -ri "s#(\s*define).+${cfg_setting}.+#\tdefine(\x27${cfg_setting}\x27, \x27${cfg_value}\x27\);#g" "$cfg_file"
;;
esac
else
echo "Error: Config file $cfg_file not found. Plugin not installed?"
local dir
dir=$(dirname "$cfg_file")
ls -la "$dir"
exit 1
fi
}