Esempio n. 1
0
def collectionList():
    path = getServerDir() + '/server/solr'
    listDir = os.listdir(path)
    data = {}
    dlist = []
    for dirname in listDir:
        dirpath = path + '/' + dirname
        if not os.path.isdir(dirpath):
            continue
        if dirname == 'configsets':
            continue

        tmp = {}
        tmp['name'] = dirname
        dlist.append(tmp)
    data['list'] = dlist
    data['ip'] = mw.getLocalIp()
    data['port'] = '8983'

    content = mw.readFile(path + '/solr.xml')

    rep = "jetty.port:(.*)\}</int>"
    tmp = re.search(rep, content)
    port = tmp.groups()[0]
    data['port'] = port

    return mw.returnJson(True, 'OK', data)
Esempio n. 2
0
def projectList():
    import math
    args = getArgs()

    page = 1
    page_size = 10
    search = ''
    if 'page' in args:
        page = int(args['page'])

    if 'page_size' in args:
        page_size = int(args['page_size'])

    if 'search' in args:
        search = args['search']

    dlist = getALlProjectList(search)
    dlist_sum = len(dlist)

    start = (page - 1) * page_size
    ret_data = dlist[start:start + page_size]
    ret_data = checkProjectListIsHasScript(ret_data)

    data = {}
    data['data'] = ret_data
    data['list'] = mw.getPage(
        {'count': dlist_sum, 'p': page, 'row': 10, 'tojs': 'csvnProjectList'})
    data['ip'] = mw.getLocalIp()
    data['port'] = getHttpPort()
    data['csvn_port'] = getCsvnPort()

    return mw.getJson(data)
Esempio n. 3
0
def contentReplace(content, version):
    service_path = mw.getServerDir()
    content = content.replace('{$ROOT_PATH}', mw.getRootDir())
    content = content.replace('{$SERVER_PATH}', service_path)
    content = content.replace('{$PHP_VERSION}', version)
    content = content.replace('{$LOCAL_IP}', mw.getLocalIp())

    if mw.isAppleSystem():
        # user = mw.execShell(
        #     "who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
        content = content.replace('{$PHP_USER}', 'nobody')
        content = content.replace('{$PHP_GROUP}', 'nobody')

        rep = 'listen.owner\s*=\s*(.+)\r?\n'
        val = ';listen.owner = nobody\n'
        content = re.sub(rep, val, content)

        rep = 'listen.group\s*=\s*(.+)\r?\n'
        val = ';listen.group = nobody\n'
        content = re.sub(rep, val, content)

        rep = 'user\s*=\s*(.+)\r?\n'
        val = ';user = nobody\n'
        content = re.sub(rep, val, content)

        rep = r'[^\.]group\s*=\s*(.+)\r?\n'
        val = ';group = nobody\n'
        content = re.sub(rep, val, content)

    else:
        content = content.replace('{$PHP_USER}', 'www')
        content = content.replace('{$PHP_GROUP}', 'www')
    return content
Esempio n. 4
0
def getHomePage():
    try:
        port = getPort()
        ip = '127.0.0.1'
        if not mw.isAppleSystem():
            ip = mw.getLocalIp()
        url = 'http://' + ip + ':' + port + '/index.php'
        return mw.returnJson(True, 'OK', url)
    except Exception as e:
        return mw.returnJson(False, '插件未启动!')
Esempio n. 5
0
def cmdRec():
    args = getArgs()
    data = checkArgs(args, ['name'])
    if not data[0]:
        return data[1]

    an = args['name']
    pwd_list = getUPwdList()
    ip = mw.getLocalIp()

    cmd = 'echo "' + pwd_list[an] + '" > /tmp/p.pass' + "<br>"
    cmd += 'chmod 600 /tmp/p.pass' + "<br>"
    cmd += 'rsync -arv --password-file=/tmp/p.pass --progress --delete  /project  ' + \
        an + '@' + ip + '::' + an
    return mw.returnJson(True, 'OK!', cmd)
Esempio n. 6
0
def getFtpList():
    args = getArgs()
    page = 1
    page_size = 10
    search = ''
    if 'page' in args:
        page = int(args['page'])

    if 'page_size' in args:
        page_size = int(args['page_size'])

    if 'search' in args:
        search = args['search']

    data = {}
    conn = pftpDB()
    limit = str((page - 1) * page_size) + ',' + str(page_size)
    # print limit, search
    condition = ''
    if not search == '':
        condition = "name like '%" + search + "%'"
    field = 'id,pid,name,password,path,status,ps,addtime'
    clist = conn.where(condition,
                       ()).field(field).limit(limit).order('id desc').select()

    count = conn.where(condition, ()).count()
    _page = {}
    _page['count'] = count
    _page['p'] = page
    _page['row'] = page_size
    _page['tojs'] = 'ftpList'
    data['page'] = mw.getPage(_page)

    info = {}
    info['ip'] = mw.getLocalIp()
    info['port'] = getFtpPort()
    data['info'] = info
    data['data'] = clist

    return mw.getJson(data)
Esempio n. 7
0
def initInitD():
    script = mw.getRunDir() + '/scripts/init.d/mw.tpl'
    script_bin = mw.getRunDir() + '/scripts/init.d/mw'
    # if os.path.exists(script_bin):
    #     return

    content = mw.readFile(script)
    content = content.replace("{$SERVER_PATH}", mw.getRunDir())

    mw.writeFile(script_bin, content)
    mw.execShell('chmod +x ' + script_bin)

    mw.setHostAddr(mw.getLocalIp())

    if not mw.isAppleSystem():
        initd_bin = '/etc/init.d/mw'
        if not os.path.exists(initd_bin):
            import shutil
            shutil.copyfile(script_bin, initd_bin)
            mw.execShell('chmod +x ' + initd_bin)
        # 加入自启动
        mw.execShell('chkconfig --add mw')
Esempio n. 8
0
 def createSSL(self):
     if os.path.exists('ssl/input.pl'):
         return True
     import OpenSSL
     key = OpenSSL.crypto.PKey()
     key.generate_key(OpenSSL.crypto.TYPE_RSA, 2048)
     cert = OpenSSL.crypto.X509()
     cert.set_serial_number(0)
     cert.get_subject().CN = mw.getLocalIp()
     cert.set_issuer(cert.get_subject())
     cert.gmtime_adj_notBefore(0)
     cert.gmtime_adj_notAfter(86400 * 3650)
     cert.set_pubkey(key)
     cert.sign(key, 'md5')
     cert_ca = OpenSSL.crypto.dump_certificate(
         OpenSSL.crypto.FILETYPE_PEM, cert)
     private_key = OpenSSL.crypto.dump_privatekey(
         OpenSSL.crypto.FILETYPE_PEM, key)
     if len(cert_ca) > 100 and len(private_key) > 100:
         mw.writeFile('ssl/certificate.pem', cert_ca)
         mw.writeFile('ssl/privateKey.pem', private_key)
         print cert_ca, private_key
         return True
     return False
Esempio n. 9
0
def test():
    print(sys.version_info)
    print(session)
    os = mw.getOs()
    print(os)
    return mw.getLocalIp()
Esempio n. 10
0
def test():
    print sys.version_info
    print session
    os = mw.getOs()
    print os
    return mw.getLocalIp()