基于TrinityCore在linux上搭建wow私服

前一段时间朋友们玩wlk,找了一些私服玩玩,发现升级太慢,而且装备金币也很难弄,于是研究自己搭建wow私服玩一玩。很容易就找到了TrinityCore,看了一些说明,发现基本所有wow的私服都是基于这个搭建的。

为了搭建方便我将阿里云上的服务器重新安装了一下系统,debian9,为什么选择这个系统?首先官网上说明TrinityCore可以安装在linux,macOS,windows上,阿里云上可以装linux和windows,处于性能的考虑当然要选择linux,而选择debian系统是因为TrinityCore官网上面已经说明了,“Debian based distributions (heavy recommended debian stable, it’s the distribution we use to set minimum requirements)”,其他系统我也尝试过,都是需要重新编译安装一些软件才能达到版本要求,编译软件是很耗时的,特别是gcc。

注意:服务器重装一定要注意数据的备份。我以为数据已经备份妥当,但实际上用来备份的vps也在前一段时间被我重装了,以至于我个人的代码仓库以及过去写的博客都很难恢复了,后面我会写一篇用来备份数据的博客。

确定了以上若干条件后,我们来开始安装TrinityCore。

1.安装debian9.2系统作为服务器。

2.安装依赖包,以TrinityCore官网为准

apt-get install git clang cmake make gcc g++ libmariadbclient-dev libssl1.0-dev libbz2-dev libreadline-dev libncurses-dev libboost-all-dev mysql-server p7zip
update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100
update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang 100

3.下载Release包,下载网址

这里我们选择目前最新的巫妖王版本,TDB335.64,下载源码https://github.com/TrinityCore/TrinityCore/archive/TDB335.64.tar.gz
和数据库文件
https://github.com/TrinityCore/TrinityCore/releases/download/TDB335.64/TDB_full_world_335.64_2018_02_19.7z

4.解压源码包,并创建编译目录

cd TrinityCore
mkdir build
cd build

5.创建服务存放目录,这里以/data/wow/server为例

sudo mkdir -p /data/wow/server
sudo chown -R 当前用户 /data

6.编译,这过程很漫长,我的服务器配置很低,编译了好久

cmake ../ -DCMAKE_INSTALL_PREFIX=/data/wow/server
make -j
make install

7.下载3.35wow客户端。

首先确保服务器硬盘容量够大,这个地方大概需要40G左右空间。容量不够大的话,可以考虑临时挂载一块硬盘,最终需要用的数据只有4G左右。客户端地址从http://wlkwow.com/viewtopic.php?f=2&t=9这里获取到的。(6,7两步骤可以同时开始,两个操作都比较耗时)
wget http://222.186.15.202:12345/wowclient/wlkwowc.rar
下载后解压一下。

8.步骤6,7都结束后,我们开始提取客户端中的数据。

cd “wow客户端目录”
/data/wow/server/bin/mapextractor
/data/wow/server/bin/vmap4extractor
mkdir vmaps
/data/wow/server/bin/vmap4assembler Buildings vmaps
/data/wow/server/bin/mmaps_generator
cp -r maps vmaps mmaps /data/wow/server/data

9.修改配置

cd /data/wow/server/etc
cp worldserver.conf.dist worldserver.conf
cp authserver.conf.dist authserver.conf
worldserver.conf为游戏配置,authserver.conf为用户鉴权配置,可根据自己需要修改。worldserver.conf可以控制角色初始等级,金币,跨阵营组队等N多功能。

10.创建数据库,账号。这里使用的mysql数据库

https://github.com/TrinityCore/TrinityCore/blob/3.3.5/sql/create/create_mysql.sql
将页面里的内容(可以直接使用下面copy好的)保存到文件/tmp/create_mysql.sql中,并使用mysql的root用户执行该文件。
root>source /tmp/create_mysql.sql
GRANT USAGE ON * . * TO 'trinity'@'localhost' IDENTIFIED BY 'trinity' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 ;

CREATE DATABASE `world` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE DATABASE `characters` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE DATABASE `auth` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

GRANT ALL PRIVILEGES ON `world` . * TO 'trinity'@'localhost' WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON `characters` . * TO 'trinity'@'localhost' WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON `auth` . * TO 'trinity'@'localhost' WITH GRANT OPTION;

 11.建立游戏数据库

将我们第3步下载的数据库文件TDB_full_world_335.64_2018_02_19.7z复制到/data/wow/server/bin/并进行解压

12.启动服务器。

执行/data/wow/server/bin/authserver 和 /data/wow/server/bin/worldserver。

全部启动完成后,在/data/wow/server/bin/worldserver命令控制下创建账号:
account create userid password
设置为3级GM
account set gmlevel userid 3 1

13.修改游戏服务器IP

将auth库中的realmlist表中的address字段改为你服务器的IP地址(我这里使用的域名:happypeng.com):

14.制作客户端登录器

修改的登录IP,将如下内容保存到start.bat中,并将start.bat复制到wow客户端目录,启动start.bat,登录你的GM账号,搞定!

echo SET realmlist "你的服务器IP" > Data\zhTW\realmlist.wtf
echo SET realmlist "你的服务器IP" > Data\enTW\realmlist.wtf
echo SET realmlist "你的服务器IP" > Data\zhCN\realmlist.wtf
echo SET realmlist "你的服务器IP" > Data\enCN\realmlist.wtf
echo SET realmlist "你的服务器IP" > realmlist.wtf
start WoW.exe
goto end

15.gm命令

官网版:
我自己整理的:
还在整理中,有时间的话我会整理出来。

16.自助注册

如果你觉得给手动创建账号太low了,也可以自己写个服务器让朋友自己注册,要注意的是生成的加密密码是通过sha hash加密的,规则是将userId和password转化成大写字母,并且使用”:”连接。例如使用”USERID:PASSWORD”作为key生成的加密码后的密码,而不是单单的使用”password”。gm等级设置在account_access表中,可以在注册的时候一并将GM等级设置完成。

Cocos2dx触摸管理

用cocos2dx好长时间了,刚接触的时候觉得触摸好烦,总要要单独处理某些触摸的权限.所以自己试着封装了一个触摸管理的机制吧,现在整理一下吧.

简单介绍:

1.WPLayer 继承于 cocos2d::Layer 记录的所有Menu,ScrollView的触摸开关.
2.WPScene 继承于 cocos2d::Scene 将WPLayer以栈的形式展现在WPScene上. 每当push新的WPLayer时,关闭WPScene中的top WPLayer所有触摸. 每当pop WPLayer时,先关闭要被pop的WPLayer的触摸,pop之后开启WPScene中的Top WPLayer的触摸.
3.WPMenu 继承于 cocos2d::Menu 创建时可以选择Menu的触摸等级.方便在ScrollView中点击,并不影响ScrollView的滑动.
4.下面贴下代码吧 🙂
5.I’m so sorry for my bad English.

#include <iostream> 
#include "cocos2d.h"
#include "extensions/cocos-ext.h"
#include "WPLayer.h"

USING_NS_CC;
USING_NS_CC_EXT;

/*
 *
 * all scene should public WPScene
 * in order to switch WPLayer
 * manager the touch
 *
 */

class WPScene : public Scene
{
    
public:
    ~WPScene();
    virtual bool init();

    CREATE_FUNC(WPScene);
    //
    // push WPLayer
    //
    void pushLayer(WPLayer * layer);
    //
    // pop WPLayer
    //
    void popLayer();
    void popLayer(WPLayer * layer);
    //
    // replace top WPLayer
    //
    void replaceLayer(WPLayer * layer);
    //
    // pop all layer and push new wplayer
    //
    void resetRootLayer(WPLayer * layer);
    //
    // get top WPLayer 
    //
    WPLayer * getTopLayer();

protected:
    
private:
    __Array *_layerArray;
};


/*************************   WPScene.cpp   *************************/
#include "WPScene.h"

WPScene::~WPScene()
{
    CC_SAFE_RELEASE(_layerArray);
}

bool WPScene::init()
{
    if (!CCScene::init()) {
        return false;
    }
    _layerArray = __Array::create();
    _layerArray -> retain();
    return true;
}


void WPScene::pushLayer(WPLayer * layer)
{
    size_t zOrder = _layerArray -> count();
    if (_layerArray -> count()) {
        WPLayer * lastLayer = (WPLayer *)_layerArray -> getLastObject();
        lastLayer -> closeAllTouch();
        zOrder = lastLayer -> getLocalZOrder() + 1;
    }
    _layerArray -> addObject(layer);
    layer -> openAllTouch();
    this -> addChild(layer, (int)zOrder, (int)zOrder);
}

void WPScene::popLayer()
{
    WPLayer * layer = (WPLayer *)_layerArray -> getLastObject();
    if (layer -> getParent() == this) {
        layer -> closeAllTouch();
        this -> removeChild(layer, true);
    }
    _layerArray -> removeLastObject();
    if (_layerArray -> count()) {
        WPLayer * lastLayer = (WPLayer *)_layerArray -> getLastObject();
        lastLayer -> openAllTouch();
    }
}

void WPScene::popLayer(WPLayer * layer)
{
    if (_layerArray -> containsObject(layer)) {
        if (layer -> getParent() == this) {
            layer -> closeAllTouch();
            this -> removeChild(layer, true);
        }
        _layerArray -> removeObject(layer);
    }
    if (_layerArray -> count()) {
        WPLayer * lastLayer = (WPLayer *)_layerArray -> getLastObject();
        lastLayer -> openAllTouch();
    }
}

void WPScene::replaceLayer(WPLayer * layer)
{
    WPLayer * last = (WPLayer *)_layerArray -> getLastObject();
    if (last) {
        last -> retain();
    }
    this -> popLayer();
    this -> pushLayer(layer);
    if (last) {
        last -> release();
    }
}

void WPScene::resetRootLayer(WPLayer * layer)
{
    while (_layerArray -> count()) {
        WPLayer * layer = (WPLayer *)_layerArray -> getLastObject();
        _layerArray -> removeLastObject();
        this -> removeChild(layer, true);
    }
    pushLayer(layer);
}

WPLayer * WPScene::getTopLayer()
{
    if (_layerArray -> count()) {
        return (WPLayer *)_layerArray -> getLastObject();
    }
    return NULL;
}


/*
 *
 * all Layer need public WPLayer in order to manager touch
 *
 *
 */

class WPLayer : public Layer {
    
public:
    CREATE_FUNC(WPLayer);
    virtual bool init();
    ~WPLayer();
    WPLayer();
    //
    //  push or pop menu into touch stack
    //
    void pushMenu(Menu *menu);
    void popMenu(Menu *menu);
    //
    // push or pop ScrollView into touch stack
    //
    void pushScrollView(ScrollView * scrollView);
    void popScrollView(ScrollView * scrollView);
    //
    // replace the Running WPScene 's top WPLayer
    //
    virtual void replaceLayer(WPLayer *layer);
    //
    // push the WPLayer
    //
    virtual void pushWPLayer(WPLayer *layer);
    //
    // pop top WPLayer
    //
    virtual void popWPLayer();
    //
    // pop the WPLayer in WPScene stack
    //
    virtual void popWPLayer(WPLayer * layer);
    //
    // close all touch for this layer
    //
    virtual void closeAllTouch();
    //
    // open all touch for this layer
    //
    virtual void openAllTouch();
    //
    // get Top WPLayer
    //
    WPLayer * getTopLayer();
    //
    // pop all WPLayer and push new WPLayer;
    //
    void resetWPLayer(WPLayer *layer);
    //
    // set the Layer touch event is open or not
    //
    void setOpenOnTouch(bool can,int priority = 1);
    void setCantOnTouch();
    //
    // and key event for android or wp8
    //
    void setCanOnKeyboardTouch(bool can);
    
    
protected:
    
    bool _isOpenTouch;
    int _touchPriority;
    
    virtual bool onTouchBegan(Touch* touch, Event* event){return true;};
    virtual void onTouchEnded(Touch* touch, Event* event){};
    virtual void onTouchCancelled(Touch* touch, Event* event){};
    virtual void onTouchMoved(Touch* touch, Event* event){};
    
    virtual void onKeyPressed(EventKeyboard::KeyCode keyCode, Event* event){};
    virtual void onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event){};
    
    void addWPTouchOneByOne(int priority);
    void removeWPTouchOneByOne();
    
    
    EventListenerTouchOneByOne *_wpTouchListener;
    EventListenerKeyboard      *_wpKeyboardListener;
    __Array *_layerArray;
    __Array *_scrollViewArray;
    
    void setTouchEnable(bool touch);
};

/***********************   WPLayer.cpp   ************************/
#include "WPLayer.h"
#include "WPScene.h"


WPLayer::~WPLayer()
{
    CC_SAFE_RELEASE(_layerArray);
    CC_SAFE_RELEASE(_scrollViewArray);
    removeWPTouchOneByOne();
    setCanOnKeyboardTouch(false);
}

WPLayer::WPLayer()
:_wpTouchListener(nullptr)
,_layerArray(nullptr)
,_scrollViewArray(nullptr)
,_wpKeyboardListener(nullptr)
,_isOpenTouch(false)
{
    
}

bool WPLayer::init()
{
    if (!Layer::init()) {
        return false;
    }
    _layerArray = __Array::create();
    _layerArray -> retain();
    
    _scrollViewArray = __Array::create();
    _scrollViewArray -> retain();
    
    
    return true;
}


void WPLayer::pushMenu(Menu *menu)
{
    if (!_layerArray -> containsObject(menu)) {
        _layerArray -> addObject(menu);
    }
}
void WPLayer::popMenu(cocos2d::Menu *menu)
{
    if (_layerArray -> containsObject(menu)) {
        _layerArray -> removeObject(menu);
    }
}

void WPLayer::pushScrollView(ScrollView * scrollView)
{
    if (!_scrollViewArray -> containsObject(scrollView)) {
        _scrollViewArray -> addObject(scrollView);
    }
}

void WPLayer::popScrollView(ScrollView * scrollView)
{
    if (_layerArray -> containsObject(scrollView)) {
        _layerArray -> removeObject(scrollView);
    }
}


void WPLayer::pushWPLayer(WPLayer *layer)
{
    WPScene * scene = (WPScene *)this -> getParent();
    if (scene) {
        bool isWPScene = dynamic_cast<WPScene*>(scene) != nullptr;
        CCASSERT(isWPScene,"WPLayer 's parent isn't a WPScene");
        scene -> pushLayer(layer);
    }
}

void WPLayer::popWPLayer()
{
    WPScene * scene = (WPScene *)this -> getParent();
    if (scene) {
        bool isWPScene = dynamic_cast<WPScene*>(scene) != nullptr;
        CCASSERT(isWPScene,"WPLayer 's parent isn't a WPScene");
        scene -> popLayer();
    }
}

void WPLayer::popWPLayer(WPLayer * layer)
{
    WPScene * scene = (WPScene *)this -> getParent();
    if (scene) {
        bool isWPScene = dynamic_cast<WPScene*>(scene) != nullptr;
        CCASSERT(isWPScene,"WPLayer 's parent isn't a WPScene");
        scene -> popLayer(layer);
    }
}

void WPLayer::replaceLayer(WPLayer *layer)
{
    WPScene * scene = (WPScene *)this -> getParent();
    if (scene) {
        bool isWPScene = dynamic_cast<WPScene*>(scene) != nullptr;
        CCASSERT(isWPScene,"WPLayer 's parent isn't a WPScene");
        scene -> replaceLayer(layer);
    }
}

void WPLayer::closeAllTouch()
{
    setTouchEnable(false);
}
void WPLayer::openAllTouch()
{
    setTouchEnable(true);
}

WPLayer * WPLayer::getTopLayer()
{
    WPScene * scene = (WPScene *)getParent();
    if (!scene) {
        return NULL;
    }
    bool isWPScene = dynamic_cast<WPScene*>(scene) != nullptr;
    CCASSERT(isWPScene,"WPLayer 's parent isn't a WPScene");
    return scene -> getTopLayer();
}

void WPLayer::setTouchEnable(bool touch)
{
    for (int i = 0; i < _layerArray -> count(); i++) {
        Menu * menu = (Menu *) _layerArray -> getObjectAtIndex(i);
        menu -> setEnabled(touch);
    }
    for (int i = 0 ; i < _scrollViewArray -> count(); i++) {
        ScrollView * scrollView = (ScrollView *)_scrollViewArray -> getObjectAtIndex(i);
        scrollView -> setTouchEnabled(touch);
    }
    if (touch) {
        if (_isOpenTouch) {
            addWPTouchOneByOne(_touchPriority);
        }
        else {
            removeWPTouchOneByOne();
        }
    }
    else {
        removeWPTouchOneByOne();
    }
}

void WPLayer::resetWPLayer(WPLayer *layer)
{
    WPScene * scene = (WPScene *)getParent();
    if (!scene) {
        CCASSERT(false,"WPLayer 's parent isn't a WPScene");
    }
    bool isWPScene = dynamic_cast<WPScene*>(scene) != nullptr;
    CCASSERT(isWPScene,"WPLayer 's parent isn't a WPScene");
    scene -> resetRootLayer(layer);
}

void WPLayer::setOpenOnTouch(bool can,int priority)
{
    if (can) {
        addWPTouchOneByOne(priority);
        _isOpenTouch = can;
        _touchPriority = priority;
    }
    else {
        removeWPTouchOneByOne();
    }
}
void WPLayer::setCantOnTouch()
{
    _isOpenTouch = false;
    setOpenOnTouch(false);
}

void WPLayer::addWPTouchOneByOne(int priority)
{
    if (!_wpTouchListener) {
        _wpTouchListener = EventListenerTouchOneByOne::create();
        _wpTouchListener->setSwallowTouches(true);
        _wpTouchListener->onTouchBegan = CC_CALLBACK_2(WPLayer::onTouchBegan, this);
        _wpTouchListener->onTouchMoved = CC_CALLBACK_2(WPLayer::onTouchMoved, this);
        _wpTouchListener->onTouchEnded = CC_CALLBACK_2(WPLayer::onTouchEnded, this);
        _wpTouchListener->onTouchCancelled = CC_CALLBACK_2(WPLayer::onTouchCancelled, this);
        _eventDispatcher -> addEventListenerWithFixedPriority(_wpTouchListener, priority);
    }
}

void WPLayer::removeWPTouchOneByOne()
{
    if (_wpTouchListener) {
        _eventDispatcher -> removeEventListener(_wpTouchListener);
        _wpTouchListener = nullptr;
    }
}

void WPLayer::setCanOnKeyboardTouch(bool can)
{
    if (can) {
        if (!_wpKeyboardListener) {
            _wpKeyboardListener = EventListenerKeyboard::create();
            _wpKeyboardListener->onKeyPressed = CC_CALLBACK_2(WPLayer::onKeyPressed, this);
            _wpKeyboardListener->onKeyReleased = CC_CALLBACK_2(WPLayer::onKeyReleased, this);
            
            _eventDispatcher->addEventListenerWithSceneGraphPriority(_wpKeyboardListener, this);
        }
    }
    else if(_wpKeyboardListener){
        _eventDispatcher -> removeEventListener(_wpKeyboardListener);
        _wpKeyboardListener = nullptr;
    }
}

#include <iostream>
#include "cocos2d.h"
using namespace cocos2d;

class WPMenu : public Menu  {
    
public:
    ~WPMenu();
    //
    //   sett the menu scroll type for when touch scroll cancel the item event
    //
    enum MenuScrollType{
        kMenuScrollNone,
        kMenuScrollHorizontal,
        kMenuScrollVertical,
    };
    //
    // create WPMenu  scroll type and touch priority
    //
    static WPMenu * create(MenuScrollType type,int pro = 2);
protected:
    virtual bool init();
    bool initWithArray(const Vector<MenuItem*>& arrayOfItems);
    
    virtual void onEnter();
    virtual void onExit();
    
    virtual bool onTouchBegan(Touch* touch, Event* event);
    virtual void onTouchEnded(Touch* touch, Event* event);
    virtual void onTouchCancelled(Touch* touch, Event* event);
    virtual void onTouchMoved(Touch* touch, Event* event);
    
    Point _startPoint;
    bool _isMoving;
    MenuScrollType _scrollType;
    
    EventListenerTouchOneByOne *_listener;
    
    int _priority;
};

/*************************   WPMenu.cpp   ********************/

#include "WPMenu.h"

#define kDISTANCE_SEQ      40

WPMenu::~WPMenu()
{
    _eventDispatcher -> removeEventListener(_listener);
}


WPMenu * WPMenu::create(MenuScrollType type,int priority)
{
    WPMenu * pRet = new WPMenu;
    pRet -> _priority = priority;
    pRet -> _scrollType = type;
    if (pRet && pRet -> init()) {
        pRet -> autorelease();
    }
    else {
        CC_SAFE_DELETE(pRet);
    }
    return pRet;
}

bool WPMenu::init()
{
    _isMoving = false;
    return initWithArray(Vector<MenuItem*>());
}

bool WPMenu::initWithArray(const Vector<MenuItem*>& arrayOfItems)
{
    if (Layer::init())
    {
        _enabled = true;
        // menu in the center of the screen
        Size s = Director::getInstance()->getWinSize();
        
        this->ignoreAnchorPointForPosition(true);
        
        setAnchorPoint(Point(0.5f, 0.5f));
        this->setContentSize(s);
        
        setPosition(Point(s.width/2, s.height/2));
        
        int z=0;
        
        for (auto& item : arrayOfItems)
        {
            this->addChild(item, z);
            z++;
        }
        
        _selectedItem = nullptr;
        _state = Menu::State::WAITING;
        
        // enable cascade color and opacity on menus
        setCascadeColorEnabled(true);
        setCascadeOpacityEnabled(true);
        
        
        _listener = EventListenerTouchOneByOne::create();
        _listener->setSwallowTouches(true);
        
        _listener->onTouchBegan = CC_CALLBACK_2(Menu::onTouchBegan, this);
        _listener->onTouchMoved = CC_CALLBACK_2(Menu::onTouchMoved, this);
        _listener->onTouchEnded = CC_CALLBACK_2(Menu::onTouchEnded, this);
        _listener->onTouchCancelled = CC_CALLBACK_2(Menu::onTouchCancelled, this);
        _eventDispatcher -> addEventListenerWithFixedPriority(_listener, _priority);

        return true;
    }
    return false;
}

void WPMenu::onEnter()
{
    Menu::onEnter();
}

void WPMenu::onExit()
{
    Menu::onExit();
}

bool WPMenu::onTouchBegan(Touch* touch, Event* event)
{
    bool ans = Menu::onTouchBegan(touch, event);
    if (ans) {
        _startPoint = touch->getLocationInView();
    }
    _isMoving = false;
    return ans;
}

void WPMenu::onTouchEnded(Touch* touch, Event* event)
{
    this -> retain();
    if (!_isMoving) {
        Menu::onTouchEnded(touch,event);
    }
    else {
        if (_selectedItem)
        {
            _selectedItem->unselected();
        }
        _state = Menu::State::WAITING;
    }
    _isMoving = false;
    this -> release();
}

void WPMenu::onTouchCancelled(Touch* touch, Event* event)
{
    Menu::onTouchCancelled(touch,event);
}

void WPMenu::onTouchMoved(Touch* touch, Event* event)
{
    if (!_isMoving) {
        float dis = 0;
        Point endPoint = touch -> getLocationInView();
        if (_scrollType == kMenuScrollNone) {
            dis = (endPoint.getDistanceSq(_startPoint));
        }
        else if (_scrollType == kMenuScrollHorizontal){
            dis = fabs(endPoint.x - _startPoint.x);
        }
        else if (_scrollType == kMenuScrollVertical){
            dis = fabs(endPoint.y - _startPoint.y);

        }
        
        if (dis > kDISTANCE_SEQ) {
            _isMoving = true;
            if (_selectedItem)
            {
                _selectedItem->unselected();
            }
        }
        else {
            Menu::onTouchMoved(touch,event);
        }
    }
}

ADB命令大全

1、获取序列号:

 adb get-serialno

2、查看连接计算机的设备:

 adb devices

3、重启机器:

 adb reboot

4、重启到bootloader,即刷机模式:

 adb reboot bootloader

5、重启到recovery,即恢复模式:

 adb reboot recovery

6、查看log:

 adb logcat

7、终止adb服务进程:

 adb kill-server

8、重启adb服务进程:

 adb start-server

9、获取机器MAC地址:

 adb shell  cat /sys/class/net/wlan0/address

10、获取CPU序列号:

adb shell cat /proc/cpuinfo

11、安装APK:

adb install <apkfile> //比如:adb install baidu.apk

12、保留数据和缓存文件,重新安装apk:

adb install -r <apkfile> //比如:adb install -r baidu.apk

13、安装apk到sd卡:

adb install -s <apkfile> // 比如:adb install -s baidu.apk

14、卸载APK:

adb uninstall <package> //比如:adb uninstall com.baidu.search

15、卸载app但保留数据和缓存文件:

adb uninstall -k <package> //比如:adb uninstall -k com.baidu.search

16、启动应用:

adb shell am start -n <package_name>/.<activity_class_name>

17、查看设备cpu和内存占用情况:

adb shell top

18、查看占用内存前6的app:

adb shell top -m 6

19、刷新一次内存信息,然后返回:

adb shell top -n 1

20、查询各进程内存使用情况:

adb shell procrank

21、杀死一个进程:

adb shell kill [pid]

22、查看进程列表:

adb shell ps

23查看指定进程状态:

adb shell ps -x [PID]

24、查看后台services信息:

adb shell service list

25、查看当前内存占用:

adb shell cat /proc/meminfo

26、查看IO内存分区:

adb shell cat /proc/iomem

27、将system分区重新挂载为可读写分区:

adb remount

28、从本地复制文件到设备:

adb push <local> <remote>

29、从设备复制文件到本地:

adb pull <remote>  <local>

30、列出目录下的文件和文件夹,等同于dos中的dir命令:

adb shell ls

31、进入文件夹,等同于dos中的cd 命令:

adb shell cd <folder>

32、重命名文件:

adb shell rename path/oldfilename path/newfilename

33、删除system/avi.apk:

adb shell rm /system/avi.apk

34、删除文件夹及其下面所有文件:

adb shell rm -r <folder>

35、移动文件:

adb shell mv path/file newpath/file

36、设置文件权限:

adb shell chmod 777 /system/fonts/DroidSansFallback.ttf

37、新建文件夹:

adb shell mkdir path/foldelname

38、查看文件内容:

adb shell cat <file>

39、查看wifi密码:

adb shell cat /data/misc/wifi/*.conf

40、清除log缓存:

adb logcat -c

41、查看bug报告:

adb bugreport

42、获取设备名称:

adb shell cat /system/build.prop

43、查看ADB帮助:

adb help

44、monkey启动:

adb shell monkey -v -p your.package.name 500

45、查看已经安装的packages

adb shell pm list packages

46、使用aapt查看apk信息

aapt dump badging name.apk
aapt dump xmltree name.apk AndroidManifest.xml

整理自 http://zmywly8866.github.io/2015/01/24/all-adb-command.html

Ubuntu下搭建git服务器

自己做一个git服务端
1、安装相关软件: ssh以及python等

sudo apt-get install openssh-server openssh-client git-core python-setuptools

2、获取并安装gitosis

cd /tmp
git clone https://github.com/res0nat0r/gitosis.git
cd gitosis
sudo python setup.py install

3、创建个人公钥和私钥,默认情况下,公钥和私钥会保存在~/.ssh目录下。产生文件 id_rsa id_rsa.pub known_hosts

ssh-keygen -t rsa

4、初始化全局设置,设置每次git提交时作者的名字和邮箱

git config --global user.name "HappyPeng" 
git config --global user.email "wangpeng2015@gmail.com"

5、git服务器管理用户,在服务器上添加用户git,用来创建git仓库

sudo useradd -m git
sudo passwd git

6、创建git仓库存储目录

sudo mkdir /home/git/repositories

7、设置git仓库权限

sudo chown git:git /home/git/repositories 
sudo chmod 755 /home/git/repositories

8、配置gitosis

scp ~/.ssh/id_rsa.pub /tmp
sudo -H -u git gitosis-init < /tmp/id_rsa.pub
sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update

9、在服务器上新建一个测试项目仓库。切换到git用户

su - git
cd /home/git/repositories 
mkdir gamedev.git
cd  gamedev.git
git init --bare
exit

10、添加公钥,各个用户按照前面提到的办法生成各自的ssh公钥文件后,服务器管理员把所有人的ssh公钥文件都拿来,拷贝到keydir目录下(用户的区分以.pub文件命名为用户如:root@ubuntu.pub,user1.pub)。

cd ~
clone git@:gitosis-admin.git
cd ~/gitosis-admin/

修改gitosis.conf文件

[gitosis]
[group gitosis-admin]
writable = gitosis-admin
members = root@ubuntu

[group developers]
writable = gamedev
members = root@ubuntu user1

[group test] 
readonly = gamedev
members = user2

这个配置文件表达了如下含义:gitosis-admin组成员有 root@ubuntu ,该组对gitosis-admin仓库有读写权限; developers组有 root@ubuntu ,user1两个成员,该组对gamedev仓库有读写权限; test组有user2一个成员,对gamedev仓库有只读权限。当然目前这些配置文件的修改只是在你的本地,你必须推送到gitserver上才能真正生效。加入新文件、提交并push到git服务器:

git add .
git commit -a -m "add users to projects"
git push origin master

现在服务器就搭建完了,并且有一个空的项目gamedev在服务器上。在 gitosis.conf文件中developers中所有用户都可以对gamedev.git进行读写。
11、创建测试
下面以user1为例,进行创建。
user1:

mkdir gamedev-origin
cd gamedev-origin/
git init
echo "" > hello
git add .
git commit -a -m “initial version”
git remote add origin git@<</span>hostname>:gamedev.git 
git push origin master

12、读写测试
以root@ubuntu为列,进行clone
root@ubuntu:

cd ~
mkdir proj
cd proj/
git clone git@happypeng.com:gitosis-admin.git