python自动化安装软件_python自动化安装源码软件包

#!/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相关即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值