blob: 8993648b29ae9834c48c8bf70ec5f59ce0a95f87 (
plain)
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
32
33
34
35
36
37
38
39
40
41
|
#!/bin/bash -e
# Get the multiplier based on the memvalue
mem=`cat /proc/meminfo | grep MemTotal | awk '{print $2/524288}'`
base_cutoff="0.7"
ceil() {
awk -vnumber="$mem" '
function ceiling(x){return (x == int(x)) ? x : int(x)+1 }
BEGIN{ print ceiling(number) }'
}
multiplier=`ceil`
# If the mem is less than base_cutoff which is 512MB, just use
# the default which is for anything less than 512MB
if [[ $mem < $base_cutoff ]]; then
exit 0
fi
MYSQL_CONF_DIR="/etc/dbaas/my.cnf"
# Create the individual templates from the master template
if [ -e "$MYSQL_CONF_DIR/my.cnf.base" ]; then
cat $MYSQL_CONF_DIR/my.cnf.base | while read line; do
if [[ `expr "$line" : ".*{.*}"` != "0" ]]; then
oldval=`echo $line | sed -e 's/.*{\(.*\)}.*/\1/'`
if [[ $prop == "max_connections" ]]; then
newval=`echo "($oldval * $multiplier) + 10" | bc`
else
newval=`echo "$oldval * $multiplier" | bc`
fi
line=`echo $line | sed -e "s/{$oldval}/$newval/"`
fi
echo $line >> $MYSQL_CONF_DIR/my.cnf.default.tmp
done
mv $MYSQL_CONF_DIR/my.cnf.default.tmp $MYSQL_CONF_DIR/my.cnf.default
fi
#DEBHELPER#
|