#!/usr/bin/env python
# -*- coding:utf:8 -*-
#create by 、矿泉水 2015/7/30
import sys,commands
if len(sys.argv) == 2:
SOFTWARE = sys.argv[1]
commands.getstatusoutput(‘tar zxvf %s &> install.log 2>&1‘%SOFTWARE)
SOFTWARE = SOFTWARE.split(‘.‘)
SOFTWARE.pop(-1)
SOFTWARE.pop(-1)
SOFTWARE = ‘.‘.join(SOFTWARE)
SOFTWARE_NAME = SOFTWARE.split(‘-‘)
if SOFTWARE_NAME[0] == ‘httpd‘:
SOFTWARE_INSTALL = commands.getstatusoutput(‘cd %s && ./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --enable-proxy --enable-ssl --with-ssl &>> ../install.log 2>&1 && make &>> ../install.log 2>&1 && make install &>> ../install.log 2>&1‘%SOFTWARE)
if SOFTWARE_INSTALL[0] != 0:
commands.getstatusoutput(‘echo "Installation Failed" >> install.log‘)
else:
commands.getstatusoutput(‘echo "Successful Installation" >> install.log‘)
elif SOFTWARE_NAME[0] == ‘php‘:
SOFTWARE_INSTALL = commands.getstatusoutput(‘cd %s && ./configure --prefix=/usr/local/%s --with-config-file-path=/usr/local/domob/%s/etc --with-apxs2=/usr/local/apache/bin/apxs --enable-mbstring --enable-ftp --with-jpeg-dir=/usr --with-png-dir=/usr --enable-magic-quotes --enable-magic-quotes --enable-sockets --enable-sockets --with-zlib --with-libxml-dir=/usr --without-xmlrpc --enable-xml --enable-shmop --enable-shmop --with-mhash --with-mhash --with-curlwrappers --with-curlwrappers &>> ../install.log 2>&1 && make &>> ../install.log 2>&1 && make install &>> ../install.log 2>&1‘%(SOFTWARE,SOFTWARE,SOFTWARE))
if SOFTWARE_INSTALL[0] != 0:
commands.getstatusoutput(‘echo "Installation Failed" >> install.log‘)
else:
commands.getstatusoutput(‘echo "Successful Installation" >> install.log‘)
else:
print ‘目前只有apche和php的自动化安装方式‘
sys.exit(2)
else:
print ‘Usage: python install.py httpd-2.2.31.tar.gz &‘
sys.exit(2)
#其他软件包增加elif相关即可
本文出自 “、矿泉水” 博客,请务必保留此出处http://guwenqiang.blog.51cto.com/5462040/1680050
原文地址:http://guwenqiang.blog.51cto.com/5462040/1680050