set -x
src="/home/software"
tgt="/usr/local"
install_file="/home/software/install_file.log"
error_file="/home/software/error_file.log"
makeinstall(){
[ $1 -ne 0 ] && tail -30 $install_file |tee -a $error_file && exit 1;
make >>$install_file 2>&1
[ $1 -ne 0 ] && tail -30 $install_file |tee -a $error_file && exit 1;
make install >>$install_file 2>&1
[ $1 -ne 0 ] && tail -30 $install_file |tee -a $error_file && exit 1;
}
install(){
#install cmake
cd $src
touch {install_file,error_file}.log
tar zxvf cmake-2.8.12.1.tar.gz >>$install_file 2>&1
cd cmake-2.8.12.1
./bootstrap >>$install_file 2>&1
makeinstall $?
#install mysql
yum -y install ncurses* >>$install_file 2>&1
cd $src
tar zxvf mysql-5.5.35.tar.gz
cd mysql-5.5.35
$src/cmake-2.8.12.1/bin/cmake -DCMAKE-INSTALL-PRIFIX=/usr/local/mysql -DDEFAULT-CHARSET=utf8 >>$install_file 2>&1
makeinstall $?
cp -f support-files/my-large.cnf /etc/my.cnf >>$install_file 2>&1
cp support-files/mysql.server /etc/init.d/mysqld >>$install_file 2>&1
chmod 755 /etc/init.d/mysqld
useradd mysql >>$install_file 2>&1
cd /usr/local/mysql/ >>$install_file 2>&1
chown -R mysql:mysql * >>$install_file 2>&1
./scripts/mysql_install_db --user=mysql >>$install_file 2>&1
chown -R root * >>$install_file 2>&1
chown -R mysql data >>$install_file 2>&1
echo "/usr/local/mysql/bin/mysqld_safe &" >> /etc/rc.local
service mysqld start
}
install