前几天分别写了mysql/apache/php自动安装脚本,但那仅限于单个安装;这两天寻思着整个脚本,根据实际需要调用之前的三个脚本,比如只要安装mysql就只调用install_mysql.脚本,如果要安装apache+php就分别调用install_apache.sh及install_php.sh脚本
本脚本在 centos5.7 x86_64下测试通过 lamp自动安装脚本包.zip
下面是脚本的具体内容:
使用方法举例:bash install_lamp.sh mysql-5.5.19.tar.gz apache-5.3.7.tar.bz2
很简单的实现,热烈欢迎大家拍砖
-
#!/bin/bash
-
#FileName:install_lamp.sh
-
#Desc:invoke some scripts to intall mysql,apache,php
-
#Created By:xiaozhenggang(fedoracle)
-
#Date:2012/03/12
-
#Version:1.0
-
-
if [ $UID -ne 0 ];then
-
echo -e "\033[31m This script must be execute by user root!"
-
exit 1
-
fi
-
-
if [ $# -eq 1 ];then
-
PKG_VERSION=$1
-
PKG_NAME=`echo ${PKG_VERSION%%-*}`
-
case $PKG_NAME in
-
"mysql")
-
bash install_mysql.sh $PKG_VERSION
-
;;
-
"httpd")
-
bash install_apache.sh $PKG_VERSION
-
;;
-
"php")
-
bash install_php.sh $PKG_VERSION
-
;;
-
*)
-
echo -e "\033[31m Package not matched!\nPlease enter full name of the package \nwhich you'll install such as :mysql-5.5.19.tar.gz \033[0m"
-
exit 4
-
;;
-
esac
-
-
elif [ $# -eq 2 ];then
-
for PACKAGE in $1 $2
-
do
-
PKG_VERSION=$PACKAGE
-
PKG_NAME=`echo ${PACKAGE%%-*}`
-
case $PKG_NAME in
-
"httpd")
-
bash install_apache.sh $PKG_VERSION
-
;;
-
"php")
-
bash install_php.sh $PKG_VERSION
-
;;
-
*)
-
echo -e "\033[31m Package not matched!\nPlease enter full name for the package \nwhich you'll install such as:httpd-2.2.21.tar.gz \033[0m"
-
exit 3
-
esac
-
done
-
-
elif [ $# -eq 3 ];then
-
for PACKAGE in $1 $2 $3
-
do
-
PKG_VERSION=$PACKAGE
-
PKG_NAME=`echo ${PACKAGE%%-*}`
-
-
case $PKG_NAME in
-
"mysql")
-
bash install_mysql.sh $PKG_VERSION
-
;;
-
"httpd")
-
bash install_apache.sh $PKG_VERSION
-
;;
-
"php")
-
bash install_php.sh $PKG_VERSION
-
;;
-
*)
-
echo -e "\033[31m Package not matched!\nPlease enter full name for the package \nwhich you'll install such as:php-5.3.7.tar.gz \033[0m"
-
exit 2
-
;;
-
esac
-
done
-
else
-
echo -e "\033[31m Parameters enter error!Please make sure you have entired correctly!!! \033[0m"
-
exit 1
-
fi
阅读(2533) | 评论(0) | 转发(0) |