-
Notifications
You must be signed in to change notification settings - Fork 36
/
start-helper.sh
executable file
·31 lines (30 loc) · 1011 Bytes
/
start-helper.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/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 (currently matching incl. closing quote)
true|TRUE|false|FALSE)
sed -ri "s#(\s*define).+(${cfg_setting}\x22|${cfg_setting}\x27).+#\tdefine(\x22${cfg_setting}\x22, ${cfg_value}\);#g" "$cfg_file"
;;
*)
sed -ri "s#(\s*define).+(${cfg_setting}\x22|${cfg_setting}\x27).+#\tdefine(\x22${cfg_setting}\x22, \x22${cfg_value}\x22\);#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
}