summaryrefslogtreecommitdiff
path: root/contrib/dbaas-mycnf/builddeb.sh
blob: 9bc3acc6d67149e203ad1541050681c67e8b3c8d (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
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# Build the debian package for my.cnf templates

# chdir to the script dir
self="${0#./}"
base="${self%/*}"
current=`pwd`

if [ "$base" = "$self" ] ; then
    home=$current
elif [[ $base =~ ^/ ]]; then
    home="$base"
else
    home="$current/$base"
fi

cd $home

# Setup the build directory for building the package
build_dir="build"
rm -rf $build_dir
mkdir -p $build_dir
cp -R debian $build_dir
cp -R etc $build_dir

cd $build_dir

# Define the various templates
MEMSIZE=( "512M:1" "1024M:2" "2048M:4" "4096M:8" "8192M:16" "16384M:32" "32768M:64" )

# Create the individual templates from the master template
for i in "${MEMSIZE[@]}"; do
    key=${i%%:*}
    multiplier=${i##*:}
    cat ../etc/my.cnf.base | while read line; do
        if [[ `expr "$line" : ".*{.*}"` != "0" ]]; then
            oldval=`echo $line | sed -e 's/.*{\(.*\)}.*/\1/'`
            prop=`echo $line | sed -e 's/^\(.*\) = {100}/\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 >> etc/my.cnf.$key
    done
done

# Build the package
DEB_BUILD_OPTIONS=nocheck,nodocs dpkg-buildpackage -rfakeroot -b -uc -us -d