分类: 系统运维
2010-04-15 17:02:21
#!/bin/sh
############################
##
## Author : Ajian
## Time
: 2007-10-22
## File:cacti.sh
## autoinstall the Cati system
#################################
#Set
the varible.
#
#echo -n "How to do with
GD:(No-install[0],Install[1],delete[2]):"
#read GD
echo -n "How to
do with Apache:(No-install[0],Install[1],delete[2]):"
read Apache
echo
-n "How to do with Mysql:(No-install[0],Install[1],delete[2]):"
read
Mysql
echo -n "How to do with
PHP:(No-install[0],Install[1],delete[2]):"
read PHP
echo -n "How
to do with rrdtool:(No-install[0],Install[1],delete[2]):"
read RRD
echo -n "All software put in (/opt):"
read TAR_FILE
echo -n
"All software tar in (/opt/software):"
read TAR_SOFT
echo -n "All
software install in (/usr/local):"
read INS_SOFT
BUILD_DIR=/tmp/rrdbuild
INSTALL_DIR=/usr/local/rrdtool
if [ "$TAR_FILE" = "" ];then
TAR_FILE="/opt"
fi
if [
"$TAR_SOFT" = "" ];then
TAR_SOFT="/opt/software"
fi
if [
"$INS_SOFT" = "" ];then
INS_SOFT="/usr/local"
fi
cd $TAR_FILE
if
[ "$GD" = 1 ];then
#Install the zlib software
tar --directory
$TAR_SOFT -zxvf zlib*.gz ; cd $TAR_SOFT/zlib*
env CFLAGS="-O3
-fPIC" ./configure --prefix=$BUILD_DIR/lb
make clean ; make;make
install;cd $TAR_FILE
echo "zlib is filished....."
#install the freetype
tar --directory $TAR_SOFT -zxvf
freetype*.gz;cd $TAR_SOFT/freetype*
env
CPPFLAGS="-I$BUILD_DIR/lb/include" LDFLAGS="-L$BUILD_DIR/lb/lib"
CFLAGS="-O3 -fPIC" ./configure --disable-shared --prefix=$BUILD_DIR/lb
make
clean ; make ; make install;cd $TAR_FILE
echo "freetype is
filished......"
#install the libpng
tar --directory $TAR_SOFT -zxvf libpng*.gz;cd
$TAR_SOFT/libpng*
env CPPFLAGS="-I$BUILD_DIR/lb/include"
LDFLAGS="-L$BUILD_DIR/lb/lib" CFLAGS="-O3 -fPIC" ./configure
--disable-shared --prefix=$BUILD_DIR/lb
make clean ; make check ;
make install;cd $TAR_FILE
echo "libpng is filished......"
#install the jpegsrc
tar --directory $TAR_SOFT -zxvf
jpegsrc*.tar;cd $TAR_SOFT/jpeg*
./configure --prefix=$INS_SOFT
--enable-shared --enable-static
make clean ; make test ; mkdir -p
$INS_SOFT/man/man1 ; make install;cd $TAR_FILE
echo "jpegsrc is
filished......"
#install the jpegsrc
tar --directory $TAR_SOFT -zxvf
libart_lgpl*.gz ;cd $TAR_SOFT/libart_lgpl*
env CFLAGS="-O3 -fPIC"
./configure --disable-shared --prefix=$BUILD_DIR/lb
make clean ;
make ; make install;cd $TAR_FILE
echo "jpegsrc is filished......"
elif [ "$GD" = 2 ]; then
echo
"#######################################################################"
echo
"Notice you are deleting the GD......"
# Delete the zlib
cd
$TAR_SOFT/zlib*
make uninstall;make clean
#Delete the freetype
cd
$TAR_SOFT/freetype*
make uninstall;make clean
#Delete the libpng
cd
$TAR_SOFT/libpng*
make uninstall;make clean
#Delete the JPEG
cd
$TAR_SOFT/jpeg*
rm -Rf $INS_SOFT/man/man1 ; make clean
#Delete
the gd
make uninstall;make clean
rm -Rf $INS_SOFT/gd*
echo
"Notic the GD is deleted."
fi
echo
"#######################################################################"
if [ "$Apache" = 1 ];then
#install the apache
cd $TAR_FILE
tar
--directory $TAR_SOFT -zxvf httpd*.gz;cd $TAR_SOFT/httpd*
./configure
--prefix=$INS_SOFT/apache2 --enable-so --enable-dav --enable-rewrite
--enable-deflate --enable-mem-cache --enable-cache
make clean ; make
;make install;cd $TAR_FILE
echo "apache is filished......"
#config
the apache
echo "AddType application/x-httpd-php .php" >>
$INS_SOFT/apache2/conf/httpd.conf
sed -i 's/DirectoryIndex
index.html index.html.var/& index.htm index.php /g'
$INS_SOFT/apache2/conf/httpd.conf
sed -i
's/\/usr\/local\/apache2\/htdocs/\/var\/www\/html/g'
$INS_SOFT/apache2/conf/httpd.conf
#config the test web
echo " " >
/var/www/html/phpinfo.php
/usr/local/apache2/bin/apachectl -k start
elif [ "$Apache" = 2 ]
;then
echo
"################################################################"
echo
"Notice you are deleting the Apache......"
cp
/usr/local/apache2/conf/httpd.conf /usr/local/apache2/conf/httpd.`data`
cd
$TAR_SOFT/httpd*;make clean;rm -Rf $INS_SOFT/apache*
fi
echo
"################################################################"
if [ "$Mysql" = 1 ];then
#install the mysql
tar --directory
$INS_SOFT -zxvf mysql-*.gz ; cd $INS_SOFT ; mv mysql* mysql ;
groupadd
mysql
useradd -g mysql mysql
cp support-files/my-medium.cnf
/etc/my.cnf
scripts/mysql_install_db --user=mysql
chown -R root .
chown
-R mysql data
chgrp -R mysql .
cd $TAR_FILE
echo "mysql is
filished ......"
##config the mysql
/bin/cp
$INS_SOFT/mysql/support-files/mysql.server /etc/init.d/mysqld
/sbin/chkconfig
--add mysqld
elif [ "$Mysql" = 2 ];then
echo
"#############################################################"
echo
"Notice you are deleting the Mysql......"
rm -Rf $INS_SOFT/mysql*
userdel
mysql
rm -f /etc/my.cnf
fi
echo
"##################################################################"
if [ "$PHP" = 1 ];then
#install the php
tar --directory
$TAR_SOFT -zxvf php*.gz ; cd $TAR_SOFT/php*
./configure
--prefix=$INS_SOFT/php --with-gd --with-apxs2=$INS_SOFT/apache2/bin/apxs
--with-xml --enable-sockets --with-zlib --with-jpeg-dir=$INS_SOFT
--with-freetype-dir=$BUILD_DIR/lb --enable-gd-native-ttf
--with-png-dir=$BUILD_DIR/lb --with-ttf --with-mysql=$INS_SOFT/mysql
--disable-debug --enable-inline-optimization --enable-mm=shared
--with-mbstring --with-libmbfl --with-pcre-regex
make clean ; make ;
make install ;cd $TAR_FILE
echo "php is filished......"
##config
the php
/bin/cp $TAR_SOFT/php*/php.ini-recommended /etc/php.ini
sed
-i 's/register_globals = Off/register_globals = On/g' /etc/php.ini
sed
-i 's/allow_url_include = Off/allow_url_inclue = On/g' /etc/php.ini
elif
[ "$PHP" = 2 ];then
echo
"################################################################"
echo
"Notice you are deleting the PHP......"
rm -Rf $INS_SOFT/php*
rm
-f /etc/php.ini
fi
ranlib $BUILD_DIR/lb/lib/*.a
if [ "$RRD" = 1 ];then
IR=-I$BUILD_DIR/lb/include
CPPFLAGS="$IR $IR/libart-2.0
$IR/freetype2 $IR/libpng"
LDFLAGS="-L$BUILD_DIR/lb/lib"
CFLAGS=-O3
export
CPPFLAGS LDFLAGS CFLAGS
tar --directory $TAR_SOFT -zxvf rrdtool-*.gz ;cd $TAR_SOFT/rrdtool-*
./configure
--prefix=$INSTALL_DIR --disable-python --disable-tcl --disable-rrdcgi
make
clean ; make ; make install;cd $TAR_FILE
echo "rrdtool is
filished......"
fi