#!/bin/bash# @Name:install_ansible.sh# @Author:Eivllom# @Create time:2015-08-27# @Modify time:2015-08-27app_soft="/app/soft" #软件包存放目录if [ `ls "${app_soft}" |wc -l` -le 0 ];then echo '软件包可能还没上传到${app_soft}目录,请检查后再执行脚本!'; exit 1fiecho "正在安装python2.7"(cd ${app_soft}tar xzf Python-2.7.8.tgzcd Python-2.7.8./configure --prefix=/usr/localmake --jobs=`grep processor /proc/cpuinfo | wc -l`make install# 将python头文件拷贝到标准目录,以避免编译ansible时,找不到所需的头文件cd /usr/local/include/python2.7cp -a ./* /usr/local/include/# 备份旧版本的python,并符号链接新版本的pythoncd /usr/binmv python python2.6ln -s /usr/local/bin/python python) &> /dev/null && echo 'python2.7安装完成' || exitecho "正在安装setuptools模块"(cd ${app_soft}tar xzf setuptools-7.0.tar.gzcd setuptools-7.0python setup.py install) &> /dev/null && echo 'setuptools模块安装完成' || exitecho "正在安装pycrypto模块"(cd ${app_soft}tar xvzf pycrypto-2.6.1.tar.gzcd pycrypto-2.6.1python setup.py install) &> /dev/null && echo 'pycrypto模块安装完成' || exitecho "正在安装PyYAML模块"(cd ${app_soft}tar xvzf yaml-0.1.5.tar.gzcd yaml-0.1.5./configure --prefix=/usr/localmake --jobs=`grep processor /proc/cpuinfo | wc -l`make installcd ${app_soft}tar xvzf PyYAML-3.11.tar.gzcd PyYAML-3.11python setup.py install) &> /dev/null && echo 'PyYAML模块安装完成' || exitecho "正在安装Jinja2模块"(cd ${app_soft}tar xvzf MarkupSafe-0.9.3.tar.gzcd MarkupSafe-0.9.3python setup.py installcd ${app_soft}tar xvzf Jinja2-2.7.3.tar.gz cd Jinja2-2.7.3python setup.py install) &> /dev/null && echo 'Jinja2模块安装完成' || exitecho "正在安装paramiko模块"(cd ${app_soft}tar xvzf ecdsa-0.11.tar.gzcd ecdsa-0.11python setup.py installcd ${app_soft}tar xvzf paramiko-1.15.1.tar.gzcd paramiko-1.15.1python setup.py install) &> /dev/null && echo 'paramiko模块安装完成' || exitecho "正在安装simplejson模块"(cd ${app_soft}tar xvzf simplejson-3.6.5.tar.gzcd simplejson-3.6.5python setup.py install) &> /dev/null && echo 'simplejson模块安装完成' || exitecho "正在安装ansible"(cd ${app_soft}tar xvzf ansible-1.7.2.tar.gzcd ansible-1.7.2python setup.py install) &> /dev/null && echo 'ansible安装完成' || exitecho 'Completed!'