#!/bin/sh

# Installation of JFFNMS

TMPDIR=/tmp
BUILDDIR=$TMPDIR/jffnms.build-$$
JFFNMS_FILE_CACHE=/usr/src/jffnms
MYSQL_PREFIX=/usr/local/mysql
APACHE_PREFIX=/usr/local/apache
PROFILE_D=/etc/profile.d
MYSQL_PATH_SH=$PROFILE_D/mysql.sh

mkdir $BUILDDIR
cd $BUILDDIR

echo Building MYSQL

echo adding mysql group
groupadd mysql

echo adding mysql user

# -M don't create a user dir

useradd -M -g mysql mysql

echo Untarring Files
tar zxf $JFFNMS_FILE_CACHE/mysql-*
cd mysql-*


./configure --prefix=$MYSQL_PREFIX \
		--localstatedir=/usr/local/mysql/data \
		--disable-maintainer-mode \
		--with-mysqld-user=mysql \
		--enable-large-files \
		--without-comment \
		--without-debug \
		# --without-bench Include this if you don't want to run the benchmark tests
		--without-bench \
		--with-named-curses-libs=/lib/libncurses.so.5
		# added --with-named-curses-libs=/lib/libncurses.so.5 to suppress ncurses/termcap error



make

make install


scripts/mysql_install_db

# set correct permission on mysql dirs
chown -R root:mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/data

# update ld library
echo "$MYSQL_PREFIX/lib/mysql" >> /etc/ld.so.conf
ldconfig -v | grep libmysqlclient

# This next line adds the MySQL startup command into your rc.local file so that MySQL starts automatically everytime your server comes up.
echo "$MYSQL_PREFIX/bin/safe_mysqld --user=mysql &" >> /etc/rc.d/rc.local


$MYSQL_PREFIX/bin/safe_mysqld --user=mysql &

# if we get a reply we are working woo hoo
$MYSQL_PREFIX/bin/mysqladmin --version


echo -n "Please change the password for mysql root account "
get $new-password

if [ -z $new-password ] ; then
	echo warning password is blank still
fi

# change blank password for new-password
$MYSQL_PREFIX/bin/mysqladmin -uroot -p password $new-password


# add the mysql bin dir to the path
touch $MYSQL_PATH_SH

cat << EOF > $MYSQL_PATH_SH
# Mysql Path Initialisation Script
# James McDonald

if [ ! \`echo \$PATH | grep $MYSQL_PREFIX/bin\` ] ; then

	\$PATH=\$PATH:$MYSQL_PREFIX/bin

fi
export PATH

EOF










































