#!/bin/sh if [ -e /etc/my.init ]; then INIT="--init-file=/etc/my.init" fi export TMPDIR=/home/system/tmp ### dynamicly configure bufferpool #max size of total mysqld=4Gb on 32 bits systems, but there is other stuff in mysqld that uses memory as well. 2200000k seems the maximum for our config on 32 bit MAX_POOL=1800000 #total system mem in KB MEM_KB=`cat /proc/meminfo | grep MemTotal | sed 's/[^0-9]//g'` #manual says: pool size 50% of memory, but we use 25% (zarafa also needs a lot) (( MEM_POOL = MEM_KB / 4 )) if [ "$MEM_POOL" -ge $MAX_POOL ]; then MEM_POOL=$MAX_POOL fi #make the config update atomic. (it happend more then once that during a crash/reset the config file ended up zero bytes ) cat /etc/my.cnf | sed "s/^innodb_buffer_pool_size.*/innodb_buffer_pool_size = "$MEM_POOL"K/g" > /etc/my.cnf.tmp sync mv /etc/my.cnf.tmp /etc/my.cnf cd / umask 077 exec mysqld --basedir=/usr --datadir=/home/system/mysql5 --user=mysql --log-error=/home/system/mysql5/mysql.err --pid-file=/home/system/mysql5/mysql.pid --socket=/var/run/mysql/mysql.sock --port=3306 $INIT