uykjgfh 发表于 2015-7-31 09:05:06

python自动化安装源码软件包

#!/usr/bin/env python
# -*- coding:utf:8 -*-
#create by 、矿泉水 2015/7/30
import sys,commands
if len(sys.argv) == 2:
    SOFTWARE = sys.argv
    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 == '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:
            commands.getstatusoutput('echo "Installation Failed" >> install.log')
      else:
            commands.getstatusoutput('echo "Successful Installation" >> install.log')
    elif SOFTWARE_NAME == '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:
            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相关即可

页: [1]
查看完整版本: python自动化安装源码软件包