
export download_file=__MYSQL_FILE__
export mysql_compile_dir=__MYSQL_COMPILE_DIR__
export ftp_dir=__FTP_DIR__

export prefix=__PREFIX__
  ### Change this variable to whereever you downloaded your files to.
export compile_home=__COMPILE_HOME__

  ### We don't use root_password and mysql_password in this script. 
  ### However, if you edit this script, you can enable it. 
export root_password='this is a dumb password, please change.'
export mysql_password='simple password'

#-------------------------------------------------
  ## Lets add the mysql.mysql account in case it doesn't exist. 
adduser -g mysql mysql

#------------------------------------------------------------
  # Cd to the directory where we will build MySQL 4.1
mkdir -p $compile_home
cd $compile_home

  # Download the version of MySQL you want. 
if [ ! -e $download_file ]; then 
  wget -O $download_file $ftp_dir/$download_file
fi

  ### Remove the previous compile
#rm -rf $mysql_compile_dir
  ## We will delete the previous install. Hope you don't have data you need.
#rm -rf $prefix

#------------------------------------------------------------------

  ## Compile the program and install it.
tar -zxvf $download_file
cd $mysql_compile_dir
make clean
  ### Even though we try to isolate mysql to a specific directory, 
  ### the lock file, pid file, and data dir end up being outside prefix. 
  ### We have to change some things later to isolate mysql to the prefix.
./configure --prefix=$prefix --with-openssl --with-ndbcluster --datadir=$prefix/data --libdir=$prefix/lib --localstatedir=$prefix/var --with-vio --with-ndb-shm
make 
if ! make install ; then
 echo "Installation failed." 
 exit
fi

mkdir -p $prefix/var/lib/mysql
mkdir -p $prefix/var/log/
mkdir -p $prefix/var/run/mysqld/
mkdir -p $prefix/data/mysql
mkdir -p $prefix/var/lock/subsys/
mkdir -p $prefix/tmp
mkdir -p $prefix/slave_load
mkdir -p $prefix/data
mkdir -p $prefix/instance

chown -R mysql $prefix
chown -R mysql.mysql $prefix
chmod 700 $prefix/data
