def GetPHPConfig(self,get): import re,json filename = public.GetConfigValue('setup_path') + '/php/' + get.version + '/etc/php.ini' if public.get_webserver() == 'openlitespeed': filename = '/usr/local/lsws/lsphp{}/etc/php/{}.{}/litespeed/php.ini'.format(get.version,get.version[0],get.version[1]) if os.path.exists('/etc/redhat-release'): filename = '/usr/local/lsws/lsphp' + get.version + '/etc/php.ini' if not os.path.exists(filename): return public.returnMsg(False,'PHP_NOT_EXISTS') phpini = public.readFile(filename) data = {} rep = "disable_functions\s*=\s{0,1}(.*)\n" tmp = re.search(rep,phpini).groups() data['disable_functions'] = tmp[0] rep = "upload_max_filesize\s*=\s*([0-9]+)(M|m|K|k)" tmp = re.search(rep,phpini).groups() data['max'] = tmp[0] rep = u"\n;*\s*cgi\.fix_pathinfo\s*=\s*([0-9]+)\s*\n" tmp = re.search(rep,phpini).groups() if tmp[0] == '0': data['pathinfo'] = False else: data['pathinfo'] = True self.getCloudPHPExt(get) phplib = json.loads(public.readFile('data/phplib.conf')) libs = [] tasks = public.M('tasks').where("status!=?",('1',)).field('status,name').select() for lib in phplib: lib['task'] = '1' for task in tasks: tmp = public.getStrBetween('[',']',task['name']) if not tmp:continue tmp1 = tmp.split('-') if tmp1[0].lower() == lib['name'].lower(): lib['task'] = task['status'] lib['phpversions'] = [] lib['phpversions'].append(tmp1[1]) if public.get_webserver() == 'openlitespeed': lib['status'] = False get.php_version = "{}.{}".format(get.version[0],get.version[1]) phpini = self.php_info(get)['phpinfo']['modules'].lower() phpini = phpini.split() for i in phpini: if lib['check'][:-3].lower() == i : lib['status'] = True break if "ioncube" in lib['check'][:-3].lower() and "ioncube" == i: lib['status'] = True break else: if phpini.find(lib['check']) == -1: lib['status'] = False else: lib['status'] = True libs.append(lib) data['libs'] = libs return data
def GetSoftList(self,get): #取软件列表 import json,os,web tmp = public.readFile('data/softList.conf'); data = json.loads(tmp) tasks = public.M('tasks').where("status!=?",('1',)).field('status,name').select() for i in range(len(data)): data[i]['check'] = web.ctx.session.rootPath+'/'+data[i]['check']; for n in range(len(data[i]['versions'])): #处理任务标记 isTask = '1'; for task in tasks: tmp = public.getStrBetween('[',']',task['name']) if not tmp:continue; tmp1 = tmp.split('-'); if data[i]['name'] == 'PHP': if tmp1[0].lower() == data[i]['name'].lower() and tmp1[1] == data[i]['versions'][n]['version']: isTask = task['status']; else: if tmp1[0].lower() == data[i]['name'].lower(): isTask = task['status']; #检查安装状态 if data[i]['name'] == 'PHP': data[i]['versions'][n]['task'] = isTask checkFile = data[i]['check'].replace('VERSION',data[i]['versions'][n]['version'].replace('.','')); else: data[i]['task'] = isTask version = public.readFile(web.ctx.session.rootPath+'/server/'+data[i]['name'].lower()+'/version.pl'); if not version:continue; if version.find(data[i]['versions'][n]['version']) == -1:continue; checkFile = data[i]['check']; data[i]['versions'][n]['status'] = os.path.exists(checkFile); return data
def __getTaskStatus(self, taskName): result = public.M('tasks').where( "status!=?", ('1', )).field('status,name').select() status = 1 for task in result: name = public.getStrBetween('[', ']', task['name']) if not name: continue if name.split('-')[0] == taskName: status = int(task['status']) return status #print(btp_frps_main().install({}));
def checksSetup(self,name,checks,vers = ''): tmp = checks.split(','); versions = []; path = '/www/server/' + name + '/version.pl'; v1 = ''; if os.path.exists(path): v1 = public.readFile(path) if name == 'nginx': v1 = v1.replace('1.10', '1.12'); if not self.__tasks: self.__tasks = public.M('tasks').where("status!=?",('1',)).field('status,name').select() isStatus = 0; versArr = vers.split(','); for v in versArr: version = {} v2 = v; if name == 'php': v2 = v2.replace('.',''); status = False; for tm in tmp: if name == 'php': if os.path.exists(tm.replace('VERSION',v2)): status = True; else: if os.path.exists(tm) and isStatus == 0: if len(versArr) > 1: if v1.find(v) != -1: status = True isStatus += 1; else: status = True isStatus += 1; #处理任务标记 isTask = '1'; for task in self.__tasks: tmpt = public.getStrBetween('[',']',task['name']) if not tmpt:continue; tmp1 = tmpt.split('-'); name1 = tmp1[0].lower(); if name == 'php': if name1 == name and tmp1[1] == v: isTask = task['status']; else: if name1 == 'pure': name1 = 'pure-ftpd'; if name1 == name: isTask = task['status']; version['status'] = status version['version'] = v; version['task'] = isTask; versions.append(version); return self.checkRun(name,versions);
def GetPHPConfig(self, get): import re, json filename = public.GetConfigValue( 'setup_path') + '/php/' + get.version + '/etc/php.ini' if not os.path.exists(filename): return public.returnMsg(False, 'PHP_NOT_EXISTS') phpini = public.readFile(filename) data = {} rep = "disable_functions\s*=\s{0,1}(.*)\n" tmp = re.search(rep, phpini).groups() data['disable_functions'] = tmp[0] rep = "upload_max_filesize\s*=\s*([0-9]+)(M|m|K|k)" tmp = re.search(rep, phpini).groups() data['max'] = tmp[0] rep = u"\n;*\s*cgi\.fix_pathinfo\s*=\s*([0-9]+)\s*\n" tmp = re.search(rep, phpini).groups() if tmp[0] == '0': data['pathinfo'] = False else: data['pathinfo'] = True self.getCloudPHPExt(get) phplib = json.loads(public.readFile('data/phplib.conf')) libs = [] tasks = public.M('tasks').where("status!=?", ('1', )).field('status,name').select() for lib in phplib: lib['task'] = '1' for task in tasks: tmp = public.getStrBetween('[', ']', task['name']) if not tmp: continue tmp1 = tmp.split('-') if tmp1[0].lower() == lib['name'].lower(): lib['task'] = task['status'] lib['phpversions'] = [] lib['phpversions'].append(tmp1[1]) if phpini.find(lib['check']) == -1: lib['status'] = False else: lib['status'] = True libs.append(lib) data['libs'] = libs return data
def GetPHPConfig(self,get): import web,re,json filename = web.ctx.session.setupPath + '/php/' + get.version + '/etc/php.ini' if not os.path.exists(filename): return public.returnMsg(False,'PHP_NOT_EXISTS'); phpini = public.readFile(filename); data = {} rep = "disable_functions\s*=\s{0,1}(.*)\n" tmp = re.search(rep,phpini).groups(); data['disable_functions'] = tmp[0]; rep = "upload_max_filesize\s*=\s*([0-9]+)M" tmp = re.search(rep,phpini).groups() data['max'] = tmp[0] rep = ur"\n;*\s*cgi\.fix_pathinfo\s*=\s*([0-9]+)\s*\n" tmp = re.search(rep,phpini).groups() if tmp[0] == '0': data['pathinfo'] = False else: data['pathinfo'] = True phplib = json.loads(public.readFile('data/phplib.conf')); libs = []; tasks = public.M('tasks').where("status!=?",('1',)).field('status,name').select() for lib in phplib: lib['task'] = '1'; for task in tasks: tmp = public.getStrBetween('[',']',task['name']) if not tmp:continue; tmp1 = tmp.split('-'); if tmp1[0].lower() == lib['name'].lower(): lib['task'] = task['status']; lib['phpversions'] = [] lib['phpversions'].append(tmp1[1]) if phpini.find(lib['check']) == -1: lib['status'] = False else: lib['status'] = True libs.append(lib) data['libs'] = libs; return data
def GetSoftList(self, get): #Take the software list import json, os tmp = public.readFile('data/softList.conf') data = json.loads(tmp) tasks = public.M('tasks').where("status!=?", ('1', )).field('status,name').select() for i in range(len(data)): data[i]['check'] = public.GetConfigValue( 'root_path') + '/' + data[i]['check'] for n in range(len(data[i]['versions'])): #Processing task tag isTask = '1' for task in tasks: tmp = public.getStrBetween('[', ']', task['name']) if not tmp: continue tmp1 = tmp.split('-') if data[i]['name'] == 'PHP': if tmp1[0].lower() == data[i]['name'].lower( ) and tmp1[1] == data[i]['versions'][n]['version']: isTask = task['status'] else: if tmp1[0].lower() == data[i]['name'].lower(): isTask = task['status'] #Check -installation status if data[i]['name'] == 'PHP': data[i]['versions'][n]['task'] = isTask checkFile = data[i]['check'].replace( 'VERSION', data[i]['versions'][n]['version'].replace('.', '')) else: data[i]['task'] = isTask version = public.readFile( public.GetConfigValue('root_path') + '/server/' + data[i]['name'].lower() + '/version.pl') if not version: continue if version.find(data[i]['versions'][n]['version']) == -1: continue checkFile = data[i]['check'] data[i]['versions'][n]['status'] = os.path.exists(checkFile) return data
def checksSetup(self, name, checks, vers=''): tmp = checks.split(',') versions = [] path = '/www/server/' + name + '/version.pl' v1 = '' if os.path.exists(path): v1 = public.readFile(path).strip() if name == 'nginx': v1 = v1.replace('1.10', '1.12') if not self.__tasks: self.__tasks = public.M('tasks').where( "status!=?", ('1', )).field('status,name').select() isStatus = 0 versArr = vers.split(',') for v in versArr: version = {} v2 = v if name == 'php': v2 = v2.replace('.', '') status = False for tm in tmp: if name == 'php': path = '/www/server/php/' + v2 if os.path.exists(path + '/bin/php') and not os.path.exists( path + '/version.pl'): public.ExecShell( "echo `" + path + "/bin/php 2>/dev/null -v|grep cli|awk '{print $2}'` > " + path + '/version.pl') try: v1 = public.readFile(path + '/version.pl').strip() if not v1: os.system('rm -f ' + path + '/version.pl') except: v1 = "" if os.path.exists(tm.replace('VERSION', v2)): status = True else: if os.path.exists(tm) and isStatus == 0: if len(versArr) > 1: im = v1.find(v) if im != -1 and im < 3: status = True isStatus += 1 else: status = True isStatus += 1 # 处理任务标记 isTask = '1' for task in self.__tasks: tmpt = public.getStrBetween('[', ']', task['name']) if not tmpt: continue tmp1 = tmpt.split('-') name1 = tmp1[0].lower() if name == 'php': if name1 == name and tmp1[1] == v: isTask = task['status'] else: if name1 == 'pure': name1 = 'pure-ftpd' if name1 == name: isTask = task['status'] infoFile = 'plugin/' + name + '/info.json' if os.path.exists(infoFile): try: tmps = json.loads(public.readFile(infoFile)) if tmps: v1 = tmps['versions'] except: pass if name == 'memcached': if os.path.exists('/etc/init.d/memcached'): v1 = getattr(web.ctx.session, 'memcachedv', False) if not v1: v1 = public.ExecShell( "memcached -V|awk '{print $2}'")[0].strip() web.ctx.session.memcachedv = v1 if name == 'apache': if os.path.exists('/www/server/apache/bin/httpd'): v1 = getattr(web.ctx.session, 'httpdv', False) if not v1: v1 = public.ExecShell( "/www/server/apache/bin/httpd -v|grep Apache|awk '{print $3}'|sed 's/Apache\///'" )[0].strip() web.ctx.session.httpdv = v1 # if name == 'mysql': # if os.path.exists('/www/server/mysql/bin/mysql'): v1 = public.ExecShell("mysql -V|awk '{print $5}'|sed 's/,//'")[0].strip(); version['status'] = status version['version'] = v version['task'] = isTask version['no'] = v1 versions.append(version) return self.checkRun(name, versions)
def checksSetup(self, name, checks, vers=''): tmp = checks.split(',') versions = [] path = '/www/server/' + name + '/version.pl' if name == 'mysql': path = '/usr/local/mysql/version.pl' elif name == 'jenkins': path = '/www/server/tomcat/webapps/jenkins/version.pl' elif name == 'subversion': path = '/home/svnrepos/version.pl' v1 = '' if os.path.exists(path): v1 = public.readFile(path).strip() # if name == 'nginx': v1 = v1.replace('1.10', '1.12'); if not self.__tasks: self.__tasks = public.M('tasks').where( "status!=?", ('1', )).field('status,name').select() isStatus = 0 versArr = vers.split(',') for v in versArr: version = {} v2 = v status = False for tm in tmp: if os.path.exists(tm) and isStatus == 0: if len(versArr) > 1: im = v1.find(v) if im != -1 and im < 3: status = True isStatus += 1 else: status = True isStatus += 1 #处理任务标记 isTask = '1' for task in self.__tasks: tmpt = public.getStrBetween('[', ']', task['name']) if not tmpt: continue tmp1 = tmpt.split('-') name1 = tmp1[0].lower() if name1 == 'pure': name1 = 'pure-ftpd' if name1 == name: isTask = task['status'] infoFile = 'plugin/' + name + '/info.json' if os.path.exists(infoFile): try: tmps = json.loads(public.readFile(infoFile)) if tmps: v1 = tmps['versions'] except: pass # if name == 'memcached': # if os.path.exists('/etc/init.d/memcached'): # v1 = getattr(web.ctx.session,'memcachedv',False) # if not v1: # v1 = public.ExecShell("memcached -V|awk '{print $2}'")[0].strip(); # web.ctx.session.memcachedv = v1 # if name == 'apache': # if os.path.exists('/www/server/apache/bin/httpd'): # v1 = getattr(web.ctx.session,'httpdv',False) # if not v1: # v1 = public.ExecShell("/www/server/apache/bin/httpd -v|grep Apache|awk '{print $3}'|sed 's/Apache\///'")[0].strip(); # web.ctx.session.httpdv = v1; #if name == 'mysql': # if os.path.exists('/www/server/mysql/bin/mysql'): v1 = public.ExecShell("mysql -V|awk '{print $5}'|sed 's/,//'")[0].strip(); version['status'] = status version['version'] = v version['task'] = isTask version['no'] = v1 versions.append(version) return self.checkRun(name, versions)
def checksSetup(self,name,checks,vers = ''): tmp = checks.split(','); versions = []; path = '/www/server/' + name + '/version.pl'; v1 = ''; if os.path.exists(path): v1 = public.readFile(path).strip() if name == 'nginx': v1 = v1.replace('1.10', '1.12'); if not self.__tasks: self.__tasks = public.M('tasks').where("status!=?",('1',)).field('status,name').select() isStatus = 0; versArr = vers.split(','); for v in versArr: version = {} v2 = v; if name == 'php': v2 = v2.replace('.',''); status = False; for tm in tmp: if name == 'php': path = '/www/server/php/' + v2 if not os.path.exists(path + '/version.pl'): public.ExecShell("echo `"+path+"/bin/php 2>/dev/null -v|grep cli|awk '{print $2}'` > " + path + '/version.pl') try: v1 = public.readFile(path+'/version.pl').strip(); if not v1: os.system('rm -f ' + path + '/version.pl'); except: v1 = ""; if os.path.exists(tm.replace('VERSION',v2)): status = True; else: if os.path.exists(tm) and isStatus == 0: if len(versArr) > 1: im = v1.find(v) if im != -1 and im < 3: status = True isStatus += 1; else: status = True isStatus += 1; #处理任务标记 isTask = '1'; for task in self.__tasks: tmpt = public.getStrBetween('[',']',task['name']) if not tmpt:continue; tmp1 = tmpt.split('-'); name1 = tmp1[0].lower(); if name == 'php': if name1 == name and tmp1[1] == v: isTask = task['status']; else: if name1 == 'pure': name1 = 'pure-ftpd'; if name1 == name: isTask = task['status']; infoFile = 'plugin/' + name + '/info.json' if os.path.exists(infoFile): try: tmps = json.loads(public.readFile(infoFile)); if tmps: v1 = tmps['versions']; except:pass; if name == 'memcached': if os.path.exists('/etc/init.d/memcached'): v1 = public.ExecShell("memcached -V|awk '{print $2}'")[0].strip(); if name == 'apache': if os.path.exists('/www/server/apache/bin/httpd'): v1 = public.ExecShell("/www/server/apache/bin/httpd -v|grep Apache|awk '{print $3}'|sed 's/Apache\///'")[0].strip(); #if name == 'mysql': # if os.path.exists('/www/server/mysql/bin/mysql'): v1 = public.ExecShell("mysql -V|awk '{print $5}'|sed 's/,//'")[0].strip(); version['status'] = status version['version'] = v; version['task'] = isTask; version['no'] = v1 versions.append(version); return self.checkRun(name,versions);