- 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
来源: http://www.bubuko.com/infodetail-3008856.html