CentOS6.x下通过shell脚本交互安装Web服务
# cat auto_install_web.sh#!/bin/bash
#blog http://cfwlxf.blog.51cto.com
#create date of 2013-10-30
#Load user environment variable
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH
#source system functions library.
. /etc/init.d/functions
#definition software download and install directoy
SOURCE_DIR=/download/source/
INSTALL_DIR=/application/
#Judge SOURCE_DIR INSTALL_DIR directoy if exits.
[ ! -d ${SOURCE_DIR} ] && mkdir ${SOURCE_DIR} -p
[ ! -d ${INSTALL_DIR} ] && mkdir ${INSTALL_DIR} -p && sleep 1 && printf "\033[32mDirectory $SOURCE_DIR $INSTALL_DIR by create.\033[0m"
#Download httpd software
printf "\033[33m
----------------------------------------------------------------------------
| Welcome to use apache auto install scripts |
----------------------------------------------------------------------------\033[0m\n"
printf "\033[36mDownload Web Server of sourece package,please input staring \'y/n\': \033[0m" STR
read STR
#Judge User input of string if by 'y'
if [ $STR = "y" ]
then
printf "\033[32m
----------------------------------------------------------------------------
| Apache Software List |
----------------------------------------------------------------------------
|1.Download web server software of httpd.2.4.4 versions. |
|2.Download web server software of httpd.2.2.25 versions. |
|3.Download web server software of httpd.2.4.6 versions. |
----------------------------------------------------------------------------
\033[0m\n\n"
read -p "Please you input number'1-4', select httpd install of httpd versions: " VERSIONS
case "$VERSIONS" in
1)
cd ${SOURCE_DIR}
wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.4.tar.gz
;;
2)
cd ${SOURCE_DIR}
wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.2.25.tar.gz
;;
3)
cd ${SOURCE_DIR}
wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.6.tar.gz
;;
*)
sleep 1
printf "\033[31mError: Please input number \'1-4\',select httpd versions.\033[0m\n"
exit 0
esac
else
sleep 2
printf "\033[31mError: You enter the error string,Please anew input.\033[0m\n"
exit 0
fi
#Uncompress httpd software package
cd ${SOURCE_DIR}
HTTPD_SOFTWARE=$(find /download/source/ -type f | grep httpd |awk 'BEGIN{FS="/"}END{print $4}')
tar -xf ${HTTPD_SOFTWARE} && sleep 2 && printf "\033[35mUncompress software by successfully.\033[0m\n"
#Judge current directoy yes or on uncompress later of directory
HTTPD_UNCOMPRESS=$(find ./ -maxdepth 1 -type d | grep httpd)
cd ${HTTPD_UNCOMPRESS}
RETURN_PWD=$(pwd | cut -d '/' -f4)
ECHO_HTTPD=$(echo ${HTTPD_UNCOMPRESS}|awk 'BEGIN{FS="/"}END{print $2}')
#Judge whether the current directory if uncompress after of directory
if [ ${RETURN_PWD} = ${ECHO_HTTPD} ]
then
sleep 1
printf "\033[33mIf you need support \'--with-included-arp\',please download software after install,\'yes/no\': \033[0m" DOWNLOAD
read DOWNLOAD
if [ "$DOWNLOAD" = "yes" ]
then
wget http://mirrors.hust.edu.cn/apache/apr/apr-1.4.6.tar.gz
wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.4.1.tar.gz
#Judge download apr apr-util file of exits.
APR_FILE=$(find ./ -maxdepth 1 -type f |sed -n '/apr-1/p' | grep -Po '(?
页:
[1]