重新初始化仓库
This commit is contained in:
commit
56d7a66d33
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.DS_Store
|
||||||
|
.vscode
|
42
README.md
Normal file
42
README.md
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
# 关于freeswitch及其相关技术的文档
|
||||||
|
|
||||||
|
> 这个仓库里尽可能的收录做freeswitch维护、开发、使用过程中可能遇到的所有技术问题
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## freeswitch部分
|
||||||
|
|
||||||
|
+ [centos7安装freeswitch1.10](freeswitch/安装freeswitch1.10.md)
|
||||||
|
+ [ubuntu16.04安装freeswitch1.6](freeswitch/安装freeswitch1.6.md)
|
||||||
|
+ [freeswitch命令](freeswitch/freeswitch命令.md)
|
||||||
|
+ [freeswitch问题](freeswitch/freeswitch问题.md)
|
||||||
|
+ [百度MRCPServer部署](freeswitch/部署百度mrcpserver.md)
|
||||||
|
+ [freeswitch对接百度mrcp](freeswitch/freeswitch对接百度mrcp.md)
|
||||||
|
+ [freeswitch配置SSL证书](freeswitch/freeswitch配置ssl.md)
|
||||||
|
+ [搭建STUN服务给freeswitch提供stun穿透](freeswitch/搭建STUN服务.md)
|
||||||
|
|
||||||
|
## linux部分
|
||||||
|
|
||||||
|
+ [linux系统常用命令](linux/linux常用命令.md)
|
||||||
|
+ [linux系统把网卡名称改为eth0](linux/linux改网卡名.md)
|
||||||
|
+ [ubuntu系统配置静态IP](linux/ubuntu配静态IP.md)
|
||||||
|
+ [阿里云磁盘扩容后在centos系统内做磁盘扩容](linux/阿里云centos磁盘扩容.md)
|
||||||
|
+ [批量删除某时间之前的文件或文件夹](linux/删除某时间前的文件或文件夹.md)
|
||||||
|
+ [centos7防火墙操作](linux/centos7防火墙.md)
|
||||||
|
+ [ubuntu配置nfs服务](linux/ubuntu配置nfs服务.md)
|
||||||
|
+ [ssh客户端保持连接](linux/ssh客户端保持连接.md)
|
||||||
|
+ [ssh免密码连接服务器](linux/ssh免密码连接服务器.md)
|
||||||
|
|
||||||
|
## 技巧部分
|
||||||
|
|
||||||
|
+ [vim快捷操作](skill/vim操作.md)
|
||||||
|
+ [tmux操作](skill/tmux操作.md)
|
||||||
|
|
||||||
|
## 前端部分
|
||||||
|
|
||||||
|
+ [npm切换源](frontend/npm切换源.md)
|
||||||
|
|
||||||
|
## git部分
|
||||||
|
|
||||||
|
+ [生成sshkey](git/生成sshkey.md)
|
||||||
|
+ [常用git命令](git/常用git命令.md)
|
117
freeswitch/freeswitch命令.md
Normal file
117
freeswitch/freeswitch命令.md
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
# freeswitch有用的命令
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 启动freeswitch
|
||||||
|
|
||||||
|
```bash
|
||||||
|
freeswitch -nc # 后台启动
|
||||||
|
freeswitch -nc -nonat # 后台启动且关闭自动nat(有独立公网IP时不需要开启nat功能,能明显提高启动速度)
|
||||||
|
```
|
||||||
|
|
||||||
|
## fs_cli中使用的命令
|
||||||
|
|
||||||
|
- **shutdown**
|
||||||
|
|
||||||
|
> 关闭freeswitch服务
|
||||||
|
|
||||||
|
- **reloadxml**
|
||||||
|
|
||||||
|
> 重载配置(如拨号计划)
|
||||||
|
|
||||||
|
- **reloadacl**
|
||||||
|
|
||||||
|
> 重载acl
|
||||||
|
|
||||||
|
- **sofia profile internal restart**
|
||||||
|
|
||||||
|
> 重启internal服务
|
||||||
|
|
||||||
|
- **sofia profile external restart**
|
||||||
|
|
||||||
|
> 重启external服务
|
||||||
|
|
||||||
|
- **sofia status profile internal**
|
||||||
|
|
||||||
|
> 查看服务端口等信息
|
||||||
|
|
||||||
|
结果示例:
|
||||||
|
|
||||||
|
```text
|
||||||
|
=================================================================================================
|
||||||
|
Name internal
|
||||||
|
Domain Name N/A
|
||||||
|
Auto-NAT false
|
||||||
|
DBName sofia_reg_internal
|
||||||
|
Pres Hosts 183.211.245.46,183.211.245.46
|
||||||
|
Dialplan XML
|
||||||
|
Context public
|
||||||
|
Challenge Realm auto_from
|
||||||
|
RTP-IP 183.211.245.46
|
||||||
|
SIP-IP 183.211.245.46
|
||||||
|
URL sip:mod_sofia@183.211.245.46:5060
|
||||||
|
BIND-URL sip:mod_sofia@183.211.245.46:5060;transport=udp,tcp
|
||||||
|
WS-BIND-URL sip:mod_sofia@183.211.245.46:5066;transport=ws
|
||||||
|
WSS-BIND-URL sips:mod_sofia@183.211.245.46:7443;transport=wss
|
||||||
|
HOLD-MUSIC local_stream://moh
|
||||||
|
OUTBOUND-PROXY N/A
|
||||||
|
CODECS IN OPUS,G722,PCMU,PCMA,VP8
|
||||||
|
CODECS OUT OPUS,G722,PCMU,PCMA,VP8
|
||||||
|
TEL-EVENT 101
|
||||||
|
DTMF-MODE rfc2833
|
||||||
|
CNG 13
|
||||||
|
SESSION-TO 0
|
||||||
|
MAX-DIALOG 0
|
||||||
|
NOMEDIA false
|
||||||
|
LATE-NEG true
|
||||||
|
PROXY-MEDIA false
|
||||||
|
ZRTP-PASSTHRU true
|
||||||
|
AGGRESSIVENAT false
|
||||||
|
CALLS-IN 8
|
||||||
|
FAILED-CALLS-IN 0
|
||||||
|
CALLS-OUT 2
|
||||||
|
FAILED-CALLS-OUT 0
|
||||||
|
REGISTRATIONS 2
|
||||||
|
```
|
||||||
|
|
||||||
|
- **sofia status profile internal reg**
|
||||||
|
|
||||||
|
> 查看注册用户
|
||||||
|
|
||||||
|
结果示例:
|
||||||
|
|
||||||
|
```text
|
||||||
|
Registrations:
|
||||||
|
=================================================================================================
|
||||||
|
Call-ID: G7ZfP264pLJawfNLKuFg1A..
|
||||||
|
User: 1002@183.211.245.46
|
||||||
|
Contact: "" <sip:1002@39.152.207.190:43502;transport=TCP;rinstance=c8aef170677f30f6>
|
||||||
|
Agent: Zoiper rv2.10.6.2
|
||||||
|
Status: Registered(TCP)(unknown) EXP(2021-09-14 13:42:51) EXPSECS(359)
|
||||||
|
Ping-Status: Reachable
|
||||||
|
Ping-Time: 0.00
|
||||||
|
Host: fstesting
|
||||||
|
IP: 39.152.207.190
|
||||||
|
Port: 43502
|
||||||
|
Auth-User: 1002
|
||||||
|
Auth-Realm: 183.211.245.46
|
||||||
|
MWI-Account: 1002@183.211.245.46
|
||||||
|
|
||||||
|
Call-ID: JRlQZx3SoV0ElHunKRrQNg..
|
||||||
|
User: 1001@183.211.245.46
|
||||||
|
Contact: "" <sip:1001@39.152.207.190:41043;transport=UDP;rinstance=eaf774985a9b3b03>
|
||||||
|
Agent: Zoiper rv2.10.6.2
|
||||||
|
Status: Registered(UDP)(unknown) EXP(2021-09-14 13:38:15) EXPSECS(83)
|
||||||
|
Ping-Status: Reachable
|
||||||
|
Ping-Time: 0.00
|
||||||
|
Host: fstesting
|
||||||
|
IP: 39.152.207.190
|
||||||
|
Port: 41043
|
||||||
|
Auth-User: 1001
|
||||||
|
Auth-Realm: 183.211.245.46
|
||||||
|
MWI-Account: 1001@183.211.245.46
|
||||||
|
|
||||||
|
Total items returned: 2
|
||||||
|
=================================================================================================
|
||||||
|
|
||||||
|
```
|
170
freeswitch/freeswitch对接百度mrcp.md
Normal file
170
freeswitch/freeswitch对接百度mrcp.md
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
# Freeswitch通过mod_unimrcp与百度mrcp-server对接(lua版)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 参考链接
|
||||||
|
|
||||||
|
[https://freeswitch.org/confluence/display/FREESWITCH/mod_unimrcp]
|
||||||
|
[https://ptorch.com/news/206.html]
|
||||||
|
[https://ptorch.com/news/207.html]
|
||||||
|
|
||||||
|
## 安装并加载mod_unimrcp模块
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 在freeswitch源码目录(不是安装目录)
|
||||||
|
make mod_unimrcp-install
|
||||||
|
# 在freeswitch安装目录中编译modules.conf.xml文件
|
||||||
|
cd /usr/local/freeswitch
|
||||||
|
vim conf/autoload_configs/modules.conf.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<!-- 添加如下配置 -->
|
||||||
|
<load module="mod_unimrcp"/>
|
||||||
|
```
|
||||||
|
|
||||||
|
## 设置profile文件和conf文件
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim /usr/local/freeswitch/conf/mrcp_profiles/unimrcpserver-mrcp-v2.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
输入以下内容:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<include>
|
||||||
|
<!-- UniMRCP Server MRCPv2 -->
|
||||||
|
<!-- 后面我们使用该配置文件,均使用 name 作为唯一标识,而不是文件名 -->
|
||||||
|
<profile name="unimrcpserver-mrcp2" version="2">
|
||||||
|
<!-- MRCP 服务器地址和SIP端口号 -->
|
||||||
|
<param name="server-ip" value="192.168.16.4"/>
|
||||||
|
<!-- mrcp服务器的sip-port -->
|
||||||
|
<param name="server-port" value="15060"/>
|
||||||
|
<param name="resource-location" value=""/>
|
||||||
|
|
||||||
|
<!-- FreeSWITCH IP、端口以及 SIP 传输方式 -->
|
||||||
|
<param name="client-ip" value="192.168.16.4" />
|
||||||
|
<!-- freeswitch的sip-port -->
|
||||||
|
<param name="client-port" value="5069"/>
|
||||||
|
<param name="sip-transport" value="udp"/>
|
||||||
|
|
||||||
|
<param name="speechsynth" value="speechsynthesizer"/>
|
||||||
|
<param name="speechrecog" value="speechrecognizer"/>
|
||||||
|
<!--param name="rtp-ext-ip" value="auto"/-->
|
||||||
|
<!-- 也是freeswitch的ip和rtp端口范围(不是mrcp里配置的rtp范围) -->
|
||||||
|
<param name="rtp-ip" value="192.168.16.4"/>
|
||||||
|
<param name="rtp-port-min" value="4000"/>
|
||||||
|
<param name="rtp-port-max" value="5000"/>
|
||||||
|
<param name="codecs" value="PCMU PCMA L16/96/8000"/>
|
||||||
|
|
||||||
|
<!-- Add any default MRCP params for SPEAK requests here -->
|
||||||
|
<synthparams>
|
||||||
|
</synthparams>
|
||||||
|
|
||||||
|
<!-- Add any default MRCP params for RECOGNIZE requests here -->
|
||||||
|
<recogparams>
|
||||||
|
<!--param name="start-input-timers" value="false"/-->
|
||||||
|
</recogparams>
|
||||||
|
</profile>
|
||||||
|
</include>
|
||||||
|
```
|
||||||
|
|
||||||
|
编辑`unimrcp.conf.xml`文件改`default-tts-profile`和`default-asr-profile`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim /usr/local/freeswitch/conf/autoload_configs/unimrcp.conf.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<!-- UniMRCP profile to use for TTS -->
|
||||||
|
<param name="default-tts-profile" value="unimrcpserver-mrcp2"/>
|
||||||
|
<!-- UniMRCP profile to use for ASR -->
|
||||||
|
<param name="default-asr-profile" value="unimrcpserver-mrcp2"/>
|
||||||
|
```
|
||||||
|
|
||||||
|
## 设置dialplan
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim /usr/local/freeswitch/conf/dialplan/default.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
添加一个extension:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<extension name="unimrcp">
|
||||||
|
<condition field="destination_number" expression="^5001$">
|
||||||
|
<action application="answer"/>
|
||||||
|
<!-- 对应scripts/baidu.lua文件 -->
|
||||||
|
<action application="lua" data="baidu.lua"/>
|
||||||
|
</condition>
|
||||||
|
</extension>
|
||||||
|
```
|
||||||
|
|
||||||
|
在`/usr/local/freeswitch/scripts`目录下创建`baidu.lua`文件:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
touch /usr/local/freeswitch/scripts/baidu.lua
|
||||||
|
vim /usr/local/freeswitch/scripts/baidu.lua
|
||||||
|
```
|
||||||
|
|
||||||
|
文件内容如下:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
session:answer()
|
||||||
|
|
||||||
|
--freeswitch.consoleLog("INFO", "Called extension is '".. argv[1]"'\n")
|
||||||
|
welcome = "/usr/local/freeswitch/sounds/en/us/callie/ivr/8000/ivr-welcome_to_freeswitch.wav"
|
||||||
|
--
|
||||||
|
grammar = "baidu"
|
||||||
|
no_input_timeout = 80000
|
||||||
|
recognition_timeout = 80000
|
||||||
|
--
|
||||||
|
|
||||||
|
tryagain = 1
|
||||||
|
while (tryagain == 1) do
|
||||||
|
--
|
||||||
|
session:execute("play_and_detect_speech", welcome .. " detect:unimrcp {start-input-timers=false,no-input-timeout=" .. no_input_timeout .. ",recognition-timeout=" .. recognition_timeout .. "} " .. grammar)
|
||||||
|
xml = session:getVariable('detect_speech_result')
|
||||||
|
--
|
||||||
|
if (xml == nil) then
|
||||||
|
freeswitch.consoleLog("CRIT","Result is 'nil'\n")
|
||||||
|
tryagain = 0
|
||||||
|
else
|
||||||
|
freeswitch.consoleLog("CRIT","Result is '" .. xml .. "'\n")
|
||||||
|
tryagain = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--
|
||||||
|
-- put logic to forward call here
|
||||||
|
--
|
||||||
|
session:sleep(250)
|
||||||
|
session:hangup()
|
||||||
|
```
|
||||||
|
|
||||||
|
> 以上脚本实现当分机用户拨打5001时,freeswitch会自动播放一段录音,并接收用户发出的声音,同时把声音传给mrcp服务器并接收返回结果
|
||||||
|
|
||||||
|
在`/usr/local/freeswitch/grammar`目录新增`hello.gram`语法文件,内容为百度mrcp程序句中的语法文件内容:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<grammar xmlns="http://www.w3.org/2001/06/grammar" xml:lang="en-US" version="1.0" mode="voice" root="digit">
|
||||||
|
<rule id="digit">
|
||||||
|
<one-of>
|
||||||
|
<item>one</item>
|
||||||
|
<item>two</item>
|
||||||
|
<item>three</item>
|
||||||
|
</one-of>
|
||||||
|
</rule>
|
||||||
|
</grammar>
|
||||||
|
```
|
||||||
|
|
||||||
|
## 让配置生效并测试
|
||||||
|
|
||||||
|
```bash
|
||||||
|
fs_cli
|
||||||
|
reloadxml
|
||||||
|
```
|
||||||
|
|
||||||
|
## 防火墙
|
||||||
|
|
||||||
|
在freeswitch服务器和mrcp服务器都不需要额外开放端口。
|
40
freeswitch/freeswitch配置ssl.md
Normal file
40
freeswitch/freeswitch配置ssl.md
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# Freeswitch配置SSL证书
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 申请证书
|
||||||
|
|
||||||
|
向域名提供商申请SSL证书,然后下载证书文件,应该会得到2个文件,分别是`xxx.key`和`xxx.pem`。
|
||||||
|
|
||||||
|
## 上传证书(至freeswitch目录)
|
||||||
|
|
||||||
|
把`xxx.key`文件和`xxx.pem`文件上传到freeswitch安装目录的`certs`目录下,如`/usr/local/freeswitch/certs`。
|
||||||
|
|
||||||
|
## 合成wss.pem文件
|
||||||
|
|
||||||
|
> 先备份原有的wss.pem文件
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cat xxx.pem xxx.key > wss.pem
|
||||||
|
```
|
||||||
|
|
||||||
|
## 配置wss端口
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim /usr/local/freeswitch/conf/sip_profiles/internal.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<param name="wss-binding" value=":7443"/>
|
||||||
|
```
|
||||||
|
|
||||||
|
## 重启freeswitch服务
|
||||||
|
|
||||||
|
```bash
|
||||||
|
freeswitch -stop
|
||||||
|
freeswitch -nc -nonat
|
||||||
|
```
|
||||||
|
|
||||||
|
## 客户端配置
|
||||||
|
|
||||||
|
在sip.js或jssip或其他webrtc客户端配置服务器访问地址为`wss://域名:7443`
|
13
freeswitch/freeswitch问题.md
Normal file
13
freeswitch/freeswitch问题.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# freeswitch问题(和解决)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
[toc]
|
||||||
|
|
||||||
|
## 网内通话,在conf/dialplan/default.xml中设置的拨号计划不生效,只走public.xml
|
||||||
|
|
||||||
|
在`conf/sip_profiles/internal.xml`文件中:
|
||||||
|
|
||||||
|
把`<param name="context" value="public"/>`改成`<param name="context" value="default"/>`
|
||||||
|
|
||||||
|
> 它默认是public
|
362
freeswitch/安装freeswitch1.10.md
Normal file
362
freeswitch/安装freeswitch1.10.md
Normal file
@ -0,0 +1,362 @@
|
|||||||
|
# 基于centos7.9(2009)安装freeswitch1.10
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 安装centos7.9(2009)操作系统
|
||||||
|
|
||||||
|
略
|
||||||
|
|
||||||
|
## 系统更新和安装依赖
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yum update -y
|
||||||
|
yum install -y yum-utils git gcc gcc-c++ automake autoconf libtool libtiff-devel libjpeg-devel openssl-devel vim
|
||||||
|
|
||||||
|
# 单独下载spandsp源码
|
||||||
|
cd /usr/local/src
|
||||||
|
git clone https://github.com/freeswitch/spandsp.git
|
||||||
|
cd spandsp
|
||||||
|
./bootstrap.sh
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
ldconfig
|
||||||
|
|
||||||
|
# 单独下载sofia-sip(SIP协议栈)源码
|
||||||
|
cd /usr/local/src
|
||||||
|
git clone https://github.com/freeswitch/sofia-sip.git
|
||||||
|
cd sofia-sip
|
||||||
|
./bootstrap.sh
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
ldconfig
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# 编译安装cmake 3.7.2
|
||||||
|
cd /usr/local/src
|
||||||
|
wget https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz
|
||||||
|
tar zxvf cmake-3.7.2.tar.gz
|
||||||
|
cd cmake-3.7.2
|
||||||
|
./bootstrap
|
||||||
|
gmake
|
||||||
|
gmake install
|
||||||
|
|
||||||
|
# 安装libatomic
|
||||||
|
yum install -y libatomic
|
||||||
|
|
||||||
|
# 单独下载libks源码(需要cmake 3.7.2以上版本)
|
||||||
|
cd /usr/local/src
|
||||||
|
git clone https://github.com/signalwire/libks.git
|
||||||
|
cmake .
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
|
||||||
|
|
||||||
|
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
|
||||||
|
|
||||||
|
# 安装fs依赖
|
||||||
|
yum install -y http://files.freeswitch.org/freeswitch-release-1-6.noarch.rpm epel-release
|
||||||
|
# 安装ffmpeg需要
|
||||||
|
rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
|
||||||
|
rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm
|
||||||
|
|
||||||
|
yum install -y alsa-lib-devel bison broadvoice-devel bzip2 curl-devel libdb4-devel e2fsprogs-devel erlang flite-devel g722_1-devel gdbm-devel gnutls-devel ilbc2-devel ldns-devel libcodec2-devel libcurl-devel libedit-devel libidn-devel libmemcached-devel libogg-devel libsilk-devel libsndfile-devel libtheora-devel libuuid-devel libvorbis-devel libxml2-devel lua-devel lzo-devel ncurses-devel net-snmp-devel opus-devel pcre-devel perl perl-ExtUtils-Embed pkgconfig portaudio-devel postgresql-devel python-devel python-devel soundtouch-devel speex-devel sqlite-devel unbound-devel unixODBC-devel which yasm zlib-devel libshout-devel libmpg123-devel lame-devel rpm-build libX11-devel libyuv-devel swig wget ffmpeg ffmpeg-devel
|
||||||
|
|
||||||
|
# 安装python组件
|
||||||
|
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip-2.7.py
|
||||||
|
python get-pip-2.7.py
|
||||||
|
# 验证pip是否安装成功
|
||||||
|
pip --version
|
||||||
|
# pip安装python组件
|
||||||
|
pip install pydub
|
||||||
|
pip install python-ESL
|
||||||
|
pip install pika
|
||||||
|
pip install dbutils
|
||||||
|
```
|
||||||
|
|
||||||
|
## 开始安装
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /usr/local/src
|
||||||
|
git clone -b v1.10 https://github.com/signalwire/freeswitch.git freeswitch
|
||||||
|
# 如果github连接不顺畅的话,可以试试码云镜像仓库(更新慢1天)
|
||||||
|
# git clone -b v1.10 https://gitee.com/mirrors/FreeSWITCH.git freeswitch
|
||||||
|
cd freeswitch
|
||||||
|
./bootstrap.sh -j
|
||||||
|
```
|
||||||
|
|
||||||
|
- 编辑modules.conf文件
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim modules
|
||||||
|
```
|
||||||
|
|
||||||
|
根据需要打开或关闭注释
|
||||||
|
|
||||||
|
```conf
|
||||||
|
formats/mod_shout
|
||||||
|
languages/mod_python
|
||||||
|
#event_handlers/mod_cdr_pg_csv
|
||||||
|
asr_tts/mod_unimrcp
|
||||||
|
```
|
||||||
|
|
||||||
|
如果需要使用mod_xml_curl的话
|
||||||
|
|
||||||
|
```conf
|
||||||
|
xml_int/mod_xml_curl
|
||||||
|
```
|
||||||
|
|
||||||
|
给不需要的模块加上注释
|
||||||
|
|
||||||
|
```conf
|
||||||
|
#applications/mod_av
|
||||||
|
#applications/mod_signalwire
|
||||||
|
```
|
||||||
|
|
||||||
|
然后保存退出
|
||||||
|
|
||||||
|
- 开始编译安装
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./configure --with-python=/usr/bin/python2.7 --with-lua=/usr/bin/lua --enable-core-pgsql-support
|
||||||
|
# 如果在spandsp位置报错,可以尝试执行下面这句
|
||||||
|
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
|
||||||
|
make
|
||||||
|
#make mod_cdr_pg_csv-install
|
||||||
|
make mod_unimrcp-install
|
||||||
|
# 如果需要xml_curl模块的话
|
||||||
|
make mod_xml_curl-install
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
|
- 安装音频文件(英文)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make cd-sounds-install
|
||||||
|
make cd-moh-install
|
||||||
|
make uhd-sounds-install
|
||||||
|
make uhd-moh-install
|
||||||
|
make hd-sounds-install
|
||||||
|
make hd-moh-install
|
||||||
|
make sounds-install
|
||||||
|
make moh-install
|
||||||
|
```
|
||||||
|
|
||||||
|
- 建立软连接
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ln -sf /usr/local/freeswitch/bin/freeswitch /usr/local/bin/
|
||||||
|
sudo ln -sf /usr/local/freeswitch/bin/fs_cli /usr/local/bin/
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置mod
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim /usr/local/freeswitch/conf/autoload_configs/modules.conf.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
在前3行开启
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<load module="mod_console"/>
|
||||||
|
<load module="mod_logfile"/>
|
||||||
|
<load module="mod_xml_curl"/>
|
||||||
|
```
|
||||||
|
|
||||||
|
打开注释
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<load module="mod_python"/>
|
||||||
|
<load module="mod_shout"/>
|
||||||
|
```
|
||||||
|
|
||||||
|
添加配置
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<load module="mod_cdr_pg_csv"/>
|
||||||
|
<load module="mod_unimrcp"/>
|
||||||
|
<!--<load module="mod_vad"/>-->
|
||||||
|
```
|
||||||
|
|
||||||
|
注释掉其他不需要的模块
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<!-- <load module="mod_av"/> -->
|
||||||
|
<!-- <load module="mod_signalwire"/> -->
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置acl白名单
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim /usr/local/freeswitch/conf/autoload_configs/acl.conf.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
根据自己网络的实际情况进行配置(照抄大概率无效)
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<list name="domains" default="deny">
|
||||||
|
<!-- domain= is special it scans the domain from the directory to build t$ -->
|
||||||
|
<node type="allow" domain="$${domain}"/>
|
||||||
|
<!-- use cidr= if you wish to allow ip ranges to this domains acl. -->
|
||||||
|
<!-- <node type="allow" cidr="192.168.0.0/24"/> -->
|
||||||
|
<node type="allow" cidr="192.168.0.112/24"/>
|
||||||
|
<node type="allow" cidr="192.168.0.50/24"/>
|
||||||
|
<!-- ==================这里添加 本机ip 127.0.0.1 ======================== -->
|
||||||
|
<!-- ==================这里添加 本机内网ip ======================== -->
|
||||||
|
<!-- ==================这里添加 本机外网ip ======================== -->
|
||||||
|
<!-- ==================这里添加 web内网ip 192.168.2.173======================== -->
|
||||||
|
<!-- ==================这里添加 web外网ip 39.107.68.127======================== -->
|
||||||
|
<!-- ==================这里添加 runcall 内外网Ip======================== -->
|
||||||
|
<node type="allow" cidr="192.168.2.178/24"/>
|
||||||
|
<node type="allow" cidr="39.107.70.84/24"/>
|
||||||
|
</list>
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置ESL
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim /usr/local/freeswitch/conf/autoload_configs/event_socket.conf.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<configuration name="event_socket.conf" description="Socket Client">
|
||||||
|
<settings>
|
||||||
|
<param name="nat-map" value="false"/>
|
||||||
|
<!--ip 统一为0.0.0.0-->
|
||||||
|
<param name="listen-ip" value="0.0.0.0"/>
|
||||||
|
<!-- 端口号 默认8021 -->
|
||||||
|
<param name="listen-port" value="8021"/>
|
||||||
|
<!-- 密码统一Aicyber -->
|
||||||
|
<param name="password" value="Aicyber"/>
|
||||||
|
<!-- 允许acl白名单内的IP 访问 -->
|
||||||
|
<param name="apply-inbound-acl" value="domains"/>
|
||||||
|
<!--<param name="apply-inbound-acl" value="loopback.auto"/>-->
|
||||||
|
<!--<param name="stop-on-bind-error" value="true"/>-->
|
||||||
|
</settings>
|
||||||
|
</configuration>
|
||||||
|
```
|
||||||
|
|
||||||
|
- 适配WebRTC(JSSIP/SIPJS)
|
||||||
|
|
||||||
|
在`/usr/local/freeswitch/conf/sip_profiles/internal.xml`中添加或修改下面这些配置
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<param name="apply-candidate-acl" value="rfc1918.auto"/>
|
||||||
|
<param name="apply-candidate-acl" value="localnet.auto"/>
|
||||||
|
<param name="apply-candidate-acl" value="candidate"/>
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<!-- 取消注释这一行(让前端可以得到早期媒体) -->
|
||||||
|
<param name="enable-100rel" value="true"/>
|
||||||
|
```
|
||||||
|
|
||||||
|
- 适配特定终端(以云翌通安卓SDK为例)
|
||||||
|
|
||||||
|
在`/usr/local/freeswitch/conf/sip_profiles/internal.xml`中添加下面这些配置
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<param name="user-agent-string" value="YunEasy"/>
|
||||||
|
```
|
||||||
|
|
||||||
|
- 拨号计划规则
|
||||||
|
|
||||||
|
在`/usr/local/freeswitch/conf/sip_profiles/internal.xml`中修改下面这些配置
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<!-- 默认是public -->
|
||||||
|
<param name="context" value="default"/>
|
||||||
|
```
|
||||||
|
|
||||||
|
## 安全配置
|
||||||
|
|
||||||
|
- 配置端口
|
||||||
|
|
||||||
|
在`/var/local/freeswitch/conf/vars.xml`文件中:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<!-- sip端口:终端通过tcp协议连接到这个端口,默认5060 -->
|
||||||
|
<X-PRE-PROCESS cmd="set" data="internal_sip_port=5060"/>
|
||||||
|
<!-- tls端口:终端通过tls协议连接到这个端口,默认5061 -->
|
||||||
|
<X-PRE-PROCESS cmd="set" data="internal_tls_port=5061"/>
|
||||||
|
```
|
||||||
|
|
||||||
|
在`/var/local/freeswitch/conf/sip_profiles/internal.xml`文件中:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<!-- ws端口:通过ws协议使用webrtc时需要连接到这个端口,默认5066 -->
|
||||||
|
<param name="ws-binding" value=":5066"/>
|
||||||
|
<!-- wss端口:通过wss协议使用webrtc时需要连接到这个端口,默认7443 -->
|
||||||
|
<param name="wss-binding" value=":7443"/>
|
||||||
|
```
|
||||||
|
|
||||||
|
- 默认密码
|
||||||
|
|
||||||
|
在`/var/local/freeswitch/conf/vars.xml`文件中:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<!-- 初始的1000~1019分机使用的默认密码,建议修改 -->
|
||||||
|
<X-PRE-PROCESS cmd="set" data="default_password=1234"/>
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置防火墙
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 开放sip端口tcp协议
|
||||||
|
sudo firewall-cmd --permanent --add-port=5060/tcp
|
||||||
|
# 开放sip端口udp协议
|
||||||
|
sudo firewall-cmd --permanent --add-port=5060/udp
|
||||||
|
# 开放ws端口
|
||||||
|
sudo firewall-cmd --permanent --add-port=5066/tcp
|
||||||
|
# 开放wss端口
|
||||||
|
sudo firewall-cmd --permanent --add-port=7443/tcp
|
||||||
|
# 开放rtp端口(范围)
|
||||||
|
sudo firewall-cmd --permanent --add-port=16384-32768/udp
|
||||||
|
# 让防火墙配置生效
|
||||||
|
sudo firewall-cmd --reload
|
||||||
|
```
|
||||||
|
|
||||||
|
- 参考资料
|
||||||
|
|
||||||
|
|FireWall Ports|Network Protocol|Application Protocol|Description|
|
||||||
|
|---|---|---|---|
|
||||||
|
|1719|UDP|H.323|Gatekeeper RAS port|
|
||||||
|
|1720|TCP|H.323|Call Signaling|
|
||||||
|
|3478|UDP|STUN service|Used for NAT traversal|
|
||||||
|
|3479|UDP|STUN service|Used for NAT traversal|
|
||||||
|
|5002|TCP|MLP|protocol server|
|
||||||
|
|5003|UDP| |Neighborhood service|
|
||||||
|
|5060|UDP & TCP|SIP UAS|Used for SIP signaling (Standard SIP Port, for default Internal Profile)|
|
||||||
|
|5070|UDP & TCP|SIP UAS|Used for SIP signaling (For default "NAT" Profile)|
|
||||||
|
|5080|UDP & TCP|SIP UAS|Used for SIP signaling (For default "External" Profile)|
|
||||||
|
|8021|TCP|ESL|Used for mod_event_socket *|
|
||||||
|
|16384-32768|UDP|RTP/ RTCP multimedia streaming|Used for audio/video data in SIP and other protocols|
|
||||||
|
|5066|TCP|Websocket|Used for WebRTC|
|
||||||
|
|7443|TCP|Websocket|Used for WebRTC|
|
||||||
|
|
||||||
|
## 效率
|
||||||
|
|
||||||
|
- 关闭ipv6
|
||||||
|
|
||||||
|
在`/usr/local/freeswitch/conf/sip_profiles/`目录下
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /usr/local/freeswitch/conf/sip_profiles
|
||||||
|
mv internal-ipv6.xml internal-ipv6.xml.removed
|
||||||
|
mv external-ipv6.xml external-ipv6.xml.removed
|
||||||
|
```
|
||||||
|
|
||||||
|
## 启动
|
||||||
|
|
||||||
|
- 后台快速启动
|
||||||
|
|
||||||
|
```bash
|
||||||
|
freeswitch -nc -nonat
|
||||||
|
```
|
||||||
|
|
||||||
|
- 控制台启动(退出即关闭服务)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
freeswitch
|
||||||
|
```
|
307
freeswitch/安装freeswitch1.6.md
Normal file
307
freeswitch/安装freeswitch1.6.md
Normal file
@ -0,0 +1,307 @@
|
|||||||
|
# 初步在ubuntu16.04系统上安装freeswitch1.6
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
## 1. 操作系统和软件版本
|
||||||
|
|
||||||
|
ubuntu16.04
|
||||||
|
|
||||||
|
freeswitch v1.6
|
||||||
|
|
||||||
|
python2.7
|
||||||
|
|
||||||
|
lua5.3
|
||||||
|
|
||||||
|
## 2. 准备工作
|
||||||
|
|
||||||
|
### 安装系统
|
||||||
|
|
||||||
|
最小安装ubuntu16.04系统,安装ssh server
|
||||||
|
|
||||||
|
### 网络等必要配置
|
||||||
|
|
||||||
|
根据实际网络环境和个要习惯来配置
|
||||||
|
|
||||||
|
- 静态IP:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo vim /etc/network/interfaces
|
||||||
|
```
|
||||||
|
|
||||||
|
示例(根据实际情况设置,照抄大概率无效)
|
||||||
|
|
||||||
|
```txt
|
||||||
|
auto eth0
|
||||||
|
iface eth0 inet static
|
||||||
|
address 192.168.0.234
|
||||||
|
netmask 255.255.255.0
|
||||||
|
gateway 192.168.0.1
|
||||||
|
dns-nameserver 219.148.204.66
|
||||||
|
dns-nameserver 219.149.6.99
|
||||||
|
dns-nameserver 114.114.114.114
|
||||||
|
```
|
||||||
|
|
||||||
|
- root登录:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo vim /etc/ssh/sshd_config
|
||||||
|
```
|
||||||
|
|
||||||
|
- root密码:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo passwd root
|
||||||
|
```
|
||||||
|
|
||||||
|
- 修改更新源:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo vim /etc/apt/sources.list
|
||||||
|
```
|
||||||
|
|
||||||
|
```txt
|
||||||
|
deb http://mirrors.aliyun.com/ubuntu/ xenial main
|
||||||
|
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
|
||||||
|
|
||||||
|
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
|
||||||
|
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
|
||||||
|
|
||||||
|
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
|
||||||
|
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
|
||||||
|
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
|
||||||
|
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
|
||||||
|
|
||||||
|
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
|
||||||
|
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
|
||||||
|
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
|
||||||
|
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe
|
||||||
|
```
|
||||||
|
|
||||||
|
> 在mirrors.aliyun.com里可以查看具体配置方法
|
||||||
|
|
||||||
|
- 更新系统
|
||||||
|
|
||||||
|
```bash
|
||||||
|
apt update && apt upgrade -y
|
||||||
|
```
|
||||||
|
|
||||||
|
### 安装依赖
|
||||||
|
|
||||||
|
- apt部分
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt install python-dev swig ffmpeg yasm unixodbc-dev libshout3-dev libmpg123-dev libmp3lame-dev libsndfile-dev autoconf automake devscripts libopus-dev libvorbis0a libogg0 libogg-dev libvorbis-dev gawk g++ git-core libjpeg-dev libncurses5-dev libtool-bin pkg-config libtiff5-dev libperl-dev libgdbm-dev libdb-dev gettext libssl-dev libcurl4-openssl-dev libpcre3-dev libspeex-dev libspeexdsp-dev libsqlite3-dev libedit-dev libldns-dev libpq-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
如果需要开启mod_lua模块,还需要安装lua
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt install lua5.3 liblua5.3-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
- pip安装
|
||||||
|
|
||||||
|
```bash
|
||||||
|
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
|
||||||
|
python get-pip.py
|
||||||
|
pip install pydub
|
||||||
|
pip install python-ESL
|
||||||
|
pip install pika
|
||||||
|
pip install dbutils
|
||||||
|
```
|
||||||
|
|
||||||
|
### 下载源码
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/signalwire/freeswitch.git
|
||||||
|
cd freeswitch
|
||||||
|
git checkout v1.6
|
||||||
|
git remote rm origin
|
||||||
|
```
|
||||||
|
|
||||||
|
> 最后一句是断开本地目录和远程代码库的关联
|
||||||
|
|
||||||
|
## 3. 安装freeswitch
|
||||||
|
|
||||||
|
- 配置lua(如果不需要mod_lua模块,可跳过)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp /usr/include/lua5.3/*.h src/mod/languages/mod_lua/
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ln -s /usr/lib/x86_64-linux-gnu/liblua5.3.so /usr/lib/x86_64-linux-gnu/liblua.so
|
||||||
|
```
|
||||||
|
|
||||||
|
- 预处理
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ./bootstrap.sh -j
|
||||||
|
```
|
||||||
|
|
||||||
|
- 预配置模块
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim modules.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
打开注释
|
||||||
|
|
||||||
|
```conf
|
||||||
|
formats/mod_shout
|
||||||
|
languages/mod_python
|
||||||
|
event_handlers/mod_cdr_pg_csv
|
||||||
|
asr_tts/mod_unimrcp
|
||||||
|
```
|
||||||
|
|
||||||
|
如果不需要使用lua语言模块,则将下面内容加注释
|
||||||
|
|
||||||
|
```conf
|
||||||
|
#languages/mod_lua
|
||||||
|
```
|
||||||
|
|
||||||
|
- 预编译
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./configure --with-python=/usr/bin/python2.7 --with-lua=/usr/bin/lua5.3 --enable-core-pgsql-support
|
||||||
|
```
|
||||||
|
|
||||||
|
- 编译安装
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo make
|
||||||
|
sudo make mod_cdr_pg_csv-install
|
||||||
|
sudo make mod_unimrcp-install
|
||||||
|
sudo make install
|
||||||
|
```
|
||||||
|
|
||||||
|
- 安装声音包
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo make sounds-install
|
||||||
|
sudo make moh-install
|
||||||
|
sudo make cd-sounds-install
|
||||||
|
sudo make cd-moh-install
|
||||||
|
sudo make uhd-sounds-install
|
||||||
|
sudo make uhd-moh-install
|
||||||
|
```
|
||||||
|
|
||||||
|
- 建立软连接
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ln -sf /usr/local/freeswitch/bin/freeswitch /usr/local/bin/
|
||||||
|
sudo ln -sf /usr/local/freeswitch/bin/fs_cli /usr/local/bin/
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置mod
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim /usr/local/freeswitch/conf/autoload_configs/modules.conf.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
打开注释
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<load module="mod_python"/>
|
||||||
|
<load module="mod_shout"/>
|
||||||
|
```
|
||||||
|
|
||||||
|
添加配置
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<load module="mod_cdr_pg_csv"/>
|
||||||
|
<load module="mod_unimrcp"/>
|
||||||
|
<load module="mod_vad"/>
|
||||||
|
```
|
||||||
|
|
||||||
|
如果不需要lua支持,则注释下面内容
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<!-- <load module="mod_lua"> -->
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置acl白名单
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim /usr/local/freeswitch/conf/autoload_configs/acl.conf.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
根据自己网络的实际情况进行配置(照抄大概率无效)
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<list name="domains" default="deny">
|
||||||
|
<!-- domain= is special it scans the domain from the directory to build t$ -->
|
||||||
|
<node type="allow" domain="$${domain}"/>
|
||||||
|
<!-- use cidr= if you wish to allow ip ranges to this domains acl. -->
|
||||||
|
<!-- <node type="allow" cidr="192.168.0.0/24"/> -->
|
||||||
|
<node type="allow" cidr="192.168.0.112/24"/>
|
||||||
|
<node type="allow" cidr="192.168.0.50/24"/>
|
||||||
|
<!-- ==================这里添加 本机ip 127.0.0.1 ======================== -->
|
||||||
|
<!-- ==================这里添加 本机内网ip ======================== -->
|
||||||
|
<!-- ==================这里添加 本机外网ip ======================== -->
|
||||||
|
<!-- ==================这里添加 web内网ip 192.168.2.173======================== -->
|
||||||
|
<!-- ==================这里添加 web外网ip 39.107.68.127======================== -->
|
||||||
|
<!-- ==================这里添加 runcall 内外网Ip======================== -->
|
||||||
|
<node type="allow" cidr="192.168.2.178/24"/>
|
||||||
|
<node type="allow" cidr="39.107.70.84/24"/>
|
||||||
|
</list>
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置ESL
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim /usr/local/freeswitch/conf/autoload_configs/event_socket.conf.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<configuration name="event_socket.conf" description="Socket Client">
|
||||||
|
<settings>
|
||||||
|
<param name="nat-map" value="false"/>
|
||||||
|
<!--ip 统一为0.0.0.0-->
|
||||||
|
<param name="listen-ip" value="0.0.0.0"/>
|
||||||
|
<!-- 端口号 默认8021 -->
|
||||||
|
<param name="listen-port" value="8021"/>
|
||||||
|
<!-- 密码统一Aicyber -->
|
||||||
|
<param name="password" value="Aicyber"/>
|
||||||
|
<!-- 允许acl白名单内的IP 访问 -->
|
||||||
|
<param name="apply-inbound-acl" value="domains"/>
|
||||||
|
<!--<param name="apply-inbound-acl" value="loopback.auto"/>-->
|
||||||
|
<!--<param name="stop-on-bind-error" value="true"/>-->
|
||||||
|
</settings>
|
||||||
|
</configuration>
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置VAD(可暂时省略)
|
||||||
|
|
||||||
|
把mod_vad.so(到已经配置好的服务器上去拉)和mod_G729.so(已经有了)放到/usr/local/freeswitch/mod目录下,并给可执行权
|
||||||
|
|
||||||
|
```bash
|
||||||
|
chmod +x mod_vad.so
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置网关(可暂时省略)
|
||||||
|
|
||||||
|
在/usr/local/freeswitch/conf/sip_profiles/external 目录下上传网关模板gw1.xml(这个模板在动态生成xml时会用到)
|
||||||
|
|
||||||
|
手动添加网关配置(可暂时省略)
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<include>
|
||||||
|
<gateway name="gw1"><!--PSTN -->
|
||||||
|
<param name="realm" value="192.168.0.153"/>
|
||||||
|
<param name="register" value="false"/>
|
||||||
|
</gateway>
|
||||||
|
</include>
|
||||||
|
```
|
||||||
|
|
||||||
|
## 4. 启动freeswitch
|
||||||
|
|
||||||
|
```bash
|
||||||
|
freeswitch -nc
|
||||||
|
```
|
||||||
|
|
||||||
|
通过fs_cli可以进入freeswitch控制台(freeswitch服务启动需要等一段时间,而且可能会很长)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
fs_cli --password=Aicyber
|
||||||
|
```
|
53
freeswitch/搭建STUN服务.md
Normal file
53
freeswitch/搭建STUN服务.md
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# 搭建STUN服务
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> 以centos7为例
|
||||||
|
|
||||||
|
* github地址:
|
||||||
|
|
||||||
|
```url
|
||||||
|
https://github.com/jselbie/stunserver
|
||||||
|
```
|
||||||
|
|
||||||
|
* STUNServer官网:
|
||||||
|
|
||||||
|
```url
|
||||||
|
http://www.stunprotocol.org/
|
||||||
|
```
|
||||||
|
|
||||||
|
## 部署过程
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 安装依赖
|
||||||
|
yum install gcc g++ make
|
||||||
|
yum install boost-devel
|
||||||
|
yum install openssl-devel
|
||||||
|
# 下载安装包
|
||||||
|
cd /usr/local/src
|
||||||
|
curl -OL http://www.stunprotocol.org/stunserver-1.2.16.tgz
|
||||||
|
# 解压
|
||||||
|
tar xvf stunserver-1.2.16.tgz
|
||||||
|
# 安装
|
||||||
|
cd stunserver
|
||||||
|
make
|
||||||
|
# 校验
|
||||||
|
./stuntestcode
|
||||||
|
# 运行
|
||||||
|
./stunserver &
|
||||||
|
```
|
||||||
|
|
||||||
|
## 防火墙
|
||||||
|
|
||||||
|
```bash
|
||||||
|
firewall-cmd --permanent --add-port="3478/udp"
|
||||||
|
```
|
||||||
|
|
||||||
|
## 配置freeswitch
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /usr/local/freeswitch/conf
|
||||||
|
vim vars.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
把stun-set中的服务地址换成刚配置好的stun服务器地址
|
265
freeswitch/部署百度mrcpserver.md
Normal file
265
freeswitch/部署百度mrcpserver.md
Normal file
@ -0,0 +1,265 @@
|
|||||||
|
# 部署百度智能呼叫中心的MRCPServer
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 官方链接
|
||||||
|
|
||||||
|
<https://cloud.baidu.com/doc/SPEECH/s/8kay0g6pq>
|
||||||
|
|
||||||
|
## 系统要求
|
||||||
|
|
||||||
|
centos7+
|
||||||
|
|
||||||
|
## 操作系统 & 必要配置
|
||||||
|
|
||||||
|
- 最小安装centos7+系统(比如7.9)
|
||||||
|
- 网卡名称配置为eth0
|
||||||
|
- 配置服务器IP
|
||||||
|
- 安装必要软件
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yum install -y net-tools telnet git vim wget
|
||||||
|
```
|
||||||
|
|
||||||
|
## 部署MRCPServer
|
||||||
|
|
||||||
|
### 下载sdk
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl https://ai.baidu.com/download?sdkId=111 -L -o mrcpserver.tar.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
### 解压
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tar zxvf mrcpserver.tar.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
### 部署配置
|
||||||
|
|
||||||
|
- 预处理
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd MRCPServer
|
||||||
|
./bootstrap.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置IP和端口
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd mrcp-server
|
||||||
|
vim conf/unimrcpserver.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
定位到`unimrcpserver->properties->ip`节点对绑定IP进行配置,可以有多种配置方式
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<!-- 可以直接设置IP地址(客户端无论在远程还是本地都只能通过这个ip来调用) -->
|
||||||
|
<ip>183.211.245.48</ip>
|
||||||
|
<!-- 可以设置成type="auto",由程序自动获取机器IP(默认只支持本机127.0.0.1) -->
|
||||||
|
<ip type="auto">
|
||||||
|
<!-- 可以填写网卡名称,自动获取网口的IP(少用,客户端无论在远程还是本地都只能通过这个网口的ip来调用) -->
|
||||||
|
<ip type="iface">eth0</ip>
|
||||||
|
<!-- 同时支持127.0.0.1调用和公网IP调用 -->
|
||||||
|
<ip>0.0.0.0</ip>
|
||||||
|
```
|
||||||
|
|
||||||
|
定位到`unimrcpserver->components->sip-uas->sip-port`节点,可以配置SIP端口
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<!-- 软件默认SIP端口是5060,可以自定义如8060,不要与其他服务冲突(udp和tcp) -->
|
||||||
|
<sip-port>5060</sip-port>
|
||||||
|
```
|
||||||
|
|
||||||
|
定位到`unimrcpserver->components->rtsp-uas->rtsp-port`节点,可以配置RTSP端口
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<!-- 软件默认RTSP端口是1554,可以自定义如8554,不要与其他服务冲突(TCP) -->
|
||||||
|
<rtsp-port>1554</rtsp-port>
|
||||||
|
```
|
||||||
|
|
||||||
|
定位到`unimrcpserver->components->mrcpv2-uas->mrcp-port`节点,可以配置mrcp端口
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<!-- 软件默认MRCP端口是1544,可以自定义如8544,不要与其他服务冲突(TCP) -->
|
||||||
|
<mrcp-port>1544</mrcp-port>
|
||||||
|
```
|
||||||
|
|
||||||
|
定位到`unimrcpserver->components->rtp-factory`节点,可以配置rtp端口范围
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<!-- 软件默认是5000~6000,可以自定义,注意不要和其他服务冲突(TCP) -->
|
||||||
|
<rtp-port-min>5000</rtp-port-min>
|
||||||
|
<rtp-port-max>6000</rtp-port-max>
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置asr
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim conf/mrcp-asr.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
定位到`AUTH_APPID`和`AUTH_APPKEY`,这两个值分别对应百度控制台语音技术应用的AppID和API Key,网址<https://console.bce.baidu.com/ai/#/ai/speech/app/list>
|
||||||
|
|
||||||
|
```conf
|
||||||
|
# AppID(照抄无效)
|
||||||
|
AUTH_APPID : 2400000
|
||||||
|
# API Key(照抄无效)
|
||||||
|
AUTH_APPKEY : "FfMfDOdAdjBqCaLKAmNfqquW"
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置tts
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim conf/mrcp-proxy.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
定位到`AUTH_APPID`和`AUTH_APPKEY`,这两个值分别对应百度控制台语音技术应用的AppID和API Key,网址<https://console.bce.baidu.com/ai/#/ai/speech/app/list>
|
||||||
|
|
||||||
|
```conf
|
||||||
|
# AppID(照抄无效)
|
||||||
|
AUTH_APPID : 2400000
|
||||||
|
# API Key(照抄无效)
|
||||||
|
AUTH_APPKEY : "FfMfDOdAdjBqCaLKAmNfqquW"
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置启动控制文件
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim conf/unimrcpserver_control.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
定位到`_check_cmd_pro="./bin/check 127.0.0.1 1544"`,把127.0.0.1替换成unimrcpserver.xml配置的ip(如果auto这里就不用换了),把1544替换成在unimrcpserver.xml配置的mrcp-port
|
||||||
|
|
||||||
|
## 启动服务
|
||||||
|
|
||||||
|
### 以调试模式启动系统
|
||||||
|
|
||||||
|
做好配置后,首次启动服务建议以调试模式启动,以便可以在console里看到启动过程。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 根据sdk保存位置不同,你的具体路径不一定跟这里一样
|
||||||
|
cd /root/MRCPServer/mrcp-server
|
||||||
|
./bin/unimrcpserver -r . &
|
||||||
|
```
|
||||||
|
|
||||||
|
正常情况下,应该会看到类似下面的输出
|
||||||
|
|
||||||
|
```console
|
||||||
|
Version: mrcp-asr | v2.0.0 | 20200609-175030 | 0e285e16 | mrcp-asr-ctrip-1.5
|
||||||
|
Version: mrcp-tts | v2.0.0 | 20200601-212708 | 24a1c9b1 | dev-liantong.mrcp1.5.0
|
||||||
|
```
|
||||||
|
|
||||||
|
> 调试模式启动后,如果想要关闭服务,需要用`ps -aux | grep mrcp`查看相关进程的PID,然后用`kill -9 PID`杀掉进程
|
||||||
|
|
||||||
|
### 以启护进程方式启动服务
|
||||||
|
|
||||||
|
在生产环境时,建使用启动脚本,以守护进程方式启动服务。
|
||||||
|
|
||||||
|
执行`${SERVER_ROOT}/mrcp-server/bin/`下的`unimrcpserver_control`并带上控制参数:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /root/MRCPServer/mrcp-server/bin
|
||||||
|
#启动
|
||||||
|
./unimrcpserver_control start
|
||||||
|
#停止
|
||||||
|
./unimrcpserver_control stop
|
||||||
|
#重启
|
||||||
|
./unimrcpserver_control restart
|
||||||
|
```
|
||||||
|
|
||||||
|
> restart指令必须在start状态下才可以使用,修改配置文件后需要restart才能生效,但是如果修改的是ip或者端口,restart会出错,这时就只能`ps -aux | grep mrcp`然后再`kill -9 PID`杀掉相关进程后,再发重新start
|
||||||
|
|
||||||
|
### 安全设置
|
||||||
|
|
||||||
|
MRCPServer对于客户端没有安全校验机制,如果不启用防火墙或者中是单纯的开放端口,结果可能会被任意freeswitch接入,为了避免这种情况发生,应该对MRCPServer开启防火墙并采用指定IP机制,具体操作如下:
|
||||||
|
|
||||||
|
```txt
|
||||||
|
MRCPServer服务器
|
||||||
|
IP:183.211.245.48
|
||||||
|
SIP-PORT:8060/udp, 8060/tcp
|
||||||
|
RTSP-PORT:1554/tcp
|
||||||
|
MRCP-PORT:1544/tcp
|
||||||
|
RTP:5000-6000/udp
|
||||||
|
|
||||||
|
freeswitch服务器
|
||||||
|
IP:112.4.97.6
|
||||||
|
```
|
||||||
|
|
||||||
|
在MRCP服务端配置防火墙规则如下:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 向112.4.97.6开放sip端口8060/tcp
|
||||||
|
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="112.4.97.6" port protocol="tcp" port="8060" accept'
|
||||||
|
# 向112.4.97.6开放sip端口8060/udp
|
||||||
|
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="112.4.97.6" port protocol="udp" port="8060" accept'
|
||||||
|
# 向112.4.97.6开放rtsp端口1554/tcp
|
||||||
|
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="112.4.97.6" port protocol="tcp" port="1554" accept'
|
||||||
|
# 向112.4.97.6开放mrcp端口1544/tcp
|
||||||
|
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="112.4.97.6" port protocol="tcp" port="1544" accept'
|
||||||
|
# 向112.4.97.6开放rtp范围5000-6000/udp
|
||||||
|
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="112.4.97.6" port protocol="udp" port="5000-6000" accept'
|
||||||
|
```
|
||||||
|
|
||||||
|
### 用sdk中的客户端进行asr测试
|
||||||
|
|
||||||
|
#### 在本机测试
|
||||||
|
|
||||||
|
- 保证${SERVER_ROOT}/mrcp-server/conf/mrcp-asr.conf文件中的相关配置填写正确
|
||||||
|
|
||||||
|
```text
|
||||||
|
* AUDIO_CONTROLLER_ADDR,百度上游服务地址(默认值当前有效)
|
||||||
|
* AUTH_APPID和AUTH_APPKEY,从百度官网中获取的APPID和API Key的值。
|
||||||
|
* NEED_SAVE_AUDIO,是否保存语音识别时用户语音,默认1为保存
|
||||||
|
* AUDIO_SPLIT_TIME,是VAD判断的间隔时间(单位毫秒)
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置LD_LIBRARY_PATH变量
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 注意把${SERVER_ROOT}替换成真实路径
|
||||||
|
export LD_LIBRARY_PATH=${SERVER_ROOT}/mrcp-server/lib:$LD_LIBRARY_PATH
|
||||||
|
```
|
||||||
|
|
||||||
|
- 修改测试程序配置文件
|
||||||
|
|
||||||
|
conf/client-profiles/unimrcp.xml 是测试工具的配置文件,需要将其中的unimrcpclient->settings->sip-settings->server-ip的值修改为本机IP,端口设置为主程序端口,如5060。
|
||||||
|
|
||||||
|
- 执行测试程序
|
||||||
|
|
||||||
|
- 切换到 ${SERVER_ROOT}/mrcp-server/bin 目录下
|
||||||
|
- 执行 ./asrclient
|
||||||
|
- 待测试程序启动后,在控制台输入 run grammar.xml xeq.pcm
|
||||||
|
- 在控制台会显示识别结果,在log目录下的mrcp_debug.log中也可以看到整个识别过程
|
||||||
|
|
||||||
|
> 更多信息可参考<https://ai.baidu.com/ai-doc/SPEECH/Ekaxz1mkz>
|
||||||
|
|
||||||
|
### 用sdk中的客户端进行tts测试
|
||||||
|
|
||||||
|
待完善
|
||||||
|
|
||||||
|
### 服务开机自启动
|
||||||
|
|
||||||
|
待完善
|
||||||
|
|
||||||
|
### 配置文件说明
|
||||||
|
|
||||||
|
#### vad配置文件conf/vad.conf
|
||||||
|
|
||||||
|
```conf
|
||||||
|
sp_threshold : 0.2 # 有效声音的音量阈值(多少以上有效)
|
||||||
|
sil_threshold : 0.1 # 被认为无效声音的音量阈值(多少以下无效)
|
||||||
|
max_wait_duration : 150 # 最大等待时长
|
||||||
|
max_sp_duration : 24000 # 最长说话时间
|
||||||
|
max_sp_pause : 150 # 最大说话暂停时长
|
||||||
|
head_sil_duration : 18000 # 开头允许的最大静音时长
|
||||||
|
start_back_frame : 40
|
||||||
|
end_back_frame : 40
|
||||||
|
debug_log : 0
|
||||||
|
sample_rate : 8000
|
||||||
|
cmvnfile : global.cmvn
|
||||||
|
dnnfile : vad.dnn
|
||||||
|
package_len : 1600
|
||||||
|
|
||||||
|
vad_num : 10
|
||||||
|
```
|
33
frontend/npm切换源.md
Normal file
33
frontend/npm切换源.md
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# npm切换源
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 查看源来的镜像地址
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm get registry
|
||||||
|
```
|
||||||
|
|
||||||
|
## 设置成淘宝源
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm config set registry http://registry.npm.taobao.org
|
||||||
|
```
|
||||||
|
|
||||||
|
## 设置成初始的源
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm config set registry https://registry.npmjs.org/
|
||||||
|
```
|
||||||
|
|
||||||
|
## 将npm替换成cnpm
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install -g cnpm --registry=https://registry.npm.taobao.org
|
||||||
|
```
|
||||||
|
|
||||||
|
## 全局安装yarn
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cnpm install yarn -g
|
||||||
|
```
|
61
git/常用git命令.md
Normal file
61
git/常用git命令.md
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
# 常用git命令
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 给本地的一个文件夹添加git管理并关联远程仓库
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 在这个文件夹内执行
|
||||||
|
git init
|
||||||
|
# 给本地的一个git文件夹关联一个远程服务器
|
||||||
|
git remote add origin git@gitee.com:wandoubaba517/ps.git
|
||||||
|
# 对目录内所有文件建立跟踪
|
||||||
|
git add .
|
||||||
|
# 提交本次跟踪
|
||||||
|
git commit -m "这次提交的说明"
|
||||||
|
# 推送当前分支并建立与远程上游的跟踪
|
||||||
|
git push --set-upstream origin master
|
||||||
|
```
|
||||||
|
|
||||||
|
## 从远程克隆一个仓库
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 通过SSH连接克隆一个仓库(可能需要事先配置SSH公钥)
|
||||||
|
# 执行成功后会在当前路径创建一个名为fsdoc的目录,进入目录后即可以用git命令操作仓库了
|
||||||
|
git clone git@gitee.com:wandoubaba517/fsdoc.git
|
||||||
|
# 通过HTTP连接克隆一个仓库(有时可能会需要用户名和密码)
|
||||||
|
# 执行成功后会在当前路径创建一个名为callapp_mrcp的目录
|
||||||
|
git clone https://gitee.com/polaris-arvin_admin/callapp_mrcp.git
|
||||||
|
```
|
||||||
|
|
||||||
|
> 除了`git clone`命令外,其他git命令都需要在仓库目录下进行操作
|
||||||
|
|
||||||
|
## 分支操作
|
||||||
|
|
||||||
|
> 别忘了在仓库目录下操作
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 查看所有分支(本地和远程)
|
||||||
|
git branch -a
|
||||||
|
# 切换分支
|
||||||
|
git checkout develop
|
||||||
|
```
|
||||||
|
|
||||||
|
## 代码推拉
|
||||||
|
|
||||||
|
> 别忘了在仓库目录下操作
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 从远程分支拉取代码到本地
|
||||||
|
git pull # 会提取默认关联的远程分支
|
||||||
|
|
||||||
|
# 添加本次要跟踪的代码(全部)
|
||||||
|
git add .
|
||||||
|
# 提交变更(在本地)
|
||||||
|
git commit -m "本次提交说明内容"
|
||||||
|
|
||||||
|
# 把变更推送到远程服务器
|
||||||
|
git push # 推送到默认关联的远程分支
|
||||||
|
git push origin # 有些时候当关联有问题时,可能需要手写origin
|
||||||
|
git push origin bob # 可以指定目标远程分支
|
||||||
|
```
|
90
git/生成sshkey.md
Normal file
90
git/生成sshkey.md
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
# 各操作系统生成sshkey的方法
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Windows 10
|
||||||
|
|
||||||
|
> 其他版本系统类似
|
||||||
|
|
||||||
|
### 1. 先得安装git
|
||||||
|
|
||||||
|
> 如果电脑里已经有git bash就跳过这一步
|
||||||
|
|
||||||
|
- 上git官网 `https://git-scm.com/` 去下载最新版,注意对应操作系统。
|
||||||
|
- 安装git,按照向导操作,明白选项意思的就根据自己实际情况配置,不明白的就留下默认值。
|
||||||
|
|
||||||
|
### 2. 检查系统内是否已经有sshkey文件
|
||||||
|
|
||||||
|
```cmd
|
||||||
|
cd ~/.ssh
|
||||||
|
dir
|
||||||
|
```
|
||||||
|
|
||||||
|
> 如果~/.ssh目录下已经存有id_rsa和id_rsa.pub文件的话,那就不需要执行 `3` 了
|
||||||
|
|
||||||
|
### 3. (在git bash中)创建sshkey
|
||||||
|
|
||||||
|
先打开git bash(是git带的命令行工具)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ssh-keygen -t rsa -C "yourname@yourpc"
|
||||||
|
```
|
||||||
|
|
||||||
|
> 一路回车(如果希望以后操作git每次push时都输入密码的话,那这里可以设置一个密码)
|
||||||
|
|
||||||
|
以上操作完成后,默认会在~/.ssh/目录下生成名为id_rsa和id_rsa.pub的文件。
|
||||||
|
|
||||||
|
### 4. 给自己的公钥文件起一个个性化的名字
|
||||||
|
|
||||||
|
> 还是在git bash中操作
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd ~/.ssh
|
||||||
|
cp id_rsa.pub yourname_yourpc.pub
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. 完成
|
||||||
|
|
||||||
|
在需要用到sshkey的地方(比如git服务器)把你的pub文件部署上去就可以了。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## MAC
|
||||||
|
|
||||||
|
### 1. 先检查系统内是否已经有sshkey文件
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd ~/.ssh
|
||||||
|
ls
|
||||||
|
```
|
||||||
|
|
||||||
|
> 如果~/.ssh目录下已经存有id_rsa和id_rsa.pub文件的话,那就不需要执行 `2` 了
|
||||||
|
|
||||||
|
### 2. 创建sshkey
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ssh-keygen -t rsa -C "yourname@yourpc"
|
||||||
|
```
|
||||||
|
|
||||||
|
> 一路回车(如果希望以后操作git每次push时都输入密码的话,那这里可以设置一个密码)
|
||||||
|
|
||||||
|
以上操作完成后,默认会在~/.ssh/目录下生成名为id_rsa和id_rsa.pub的文件。
|
||||||
|
|
||||||
|
### 3. 给自己的公钥文件起一个个性化的名字
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd ~/.ssh
|
||||||
|
cp id_rsa.pub yourname_yourpc.pub
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. 完成
|
||||||
|
|
||||||
|
在需要用到sshkey的地方(比如git服务器)把你的pub文件部署上去就可以了。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## linux
|
||||||
|
|
||||||
|
> linux下的操作方式与mac非常非常类似。
|
84
linux/centos7防火墙.md
Normal file
84
linux/centos7防火墙.md
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
# centos7防火墙操作
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
centos7默认使用firewall作为防火墙(iptables仍然有效)。
|
||||||
|
|
||||||
|
## 查看防火墙服务状态
|
||||||
|
|
||||||
|
```bash
|
||||||
|
firewall-cmd --state
|
||||||
|
```
|
||||||
|
|
||||||
|
## 启动、关闭、状态
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 查看状态
|
||||||
|
systemctl status firewalld
|
||||||
|
# 启动
|
||||||
|
systemctl start firewalld
|
||||||
|
# 停止
|
||||||
|
systemctl stop firewalld
|
||||||
|
# 重启
|
||||||
|
systemctl restart firewalld
|
||||||
|
# 禁卡开机启动
|
||||||
|
systemctl disable firewalld
|
||||||
|
# 开机启动
|
||||||
|
systemctl enable firewalld
|
||||||
|
```
|
||||||
|
|
||||||
|
## 端口操作
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 查看已经打开的端口
|
||||||
|
firewall-cmd --list-ports
|
||||||
|
# 查看当前所有配置(包括端口、服务等所有)
|
||||||
|
firewall-cmd --list-all
|
||||||
|
# 查看firewall所有可识别的服务
|
||||||
|
firewall-cmd --get-service
|
||||||
|
# 查看端口是否开通(如果开的是服务,直接查端口有可能会是no)
|
||||||
|
firewall-cmd --query-port=22/tcp
|
||||||
|
# 查看服务是否开通
|
||||||
|
firewall-cmd --query-service=ssh
|
||||||
|
# 开放某个端口(permanent是永久生效)
|
||||||
|
firewall-cmd --permanent --add-port=80/tcp
|
||||||
|
# 开放某段端口范围
|
||||||
|
firewall-cmd --permanent --add-port=5000-6000/tcp
|
||||||
|
# 关闭某个端口
|
||||||
|
firewall-cmd --permanent --remove-port=80/tcp
|
||||||
|
# 开放某个服务(的默认端口)
|
||||||
|
firewall-cmd --permanent --add-service=http
|
||||||
|
# 关闭某个服务(的默认端口)
|
||||||
|
firewall-cmd --permanent --remove-service=http
|
||||||
|
# 对指定IP开放(相当于白名单)
|
||||||
|
firewall-cmd --permanent --add-source=192.168.1.100
|
||||||
|
# 对指定IP段开放(相当于白名单)
|
||||||
|
firewall-cmd --permanent --add-source=192.168.1.0/24
|
||||||
|
# 移除某IP
|
||||||
|
firewall-cmd --permanent --remove-source=192.168.1.100
|
||||||
|
```
|
||||||
|
|
||||||
|
## 复杂操作
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 允许指定IP访问本机指定端口
|
||||||
|
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.100" port protocol="tcp" port="80" accept'
|
||||||
|
# 允许指定IP段访问本机端口范围
|
||||||
|
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.0/24" port protocol="tcp" port="8080-8090" accept'
|
||||||
|
# 禁止指定IP访问本机指定端口
|
||||||
|
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.100" port protocol="tcp" port="80" reject'
|
||||||
|
# 屏蔽某个IP的所有请求
|
||||||
|
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=103.145.13.92 reject'
|
||||||
|
```
|
||||||
|
|
||||||
|
## 配置生效
|
||||||
|
|
||||||
|
任何操作执行完成后,都需要重新装载或重启服务以使其生效:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
firewall-cmd --reload
|
||||||
|
# 或
|
||||||
|
service firewalld restart
|
||||||
|
# 或
|
||||||
|
systemctl restart firewalld
|
||||||
|
```
|
60
linux/linux常用命令.md
Normal file
60
linux/linux常用命令.md
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
# linux常用命令和操作技巧
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 查看linux发行版本
|
||||||
|
|
||||||
|
- centos
|
||||||
|
|
||||||
|
```bash
|
||||||
|
rpm -q centos-release
|
||||||
|
```
|
||||||
|
|
||||||
|
结果大概如下:
|
||||||
|
|
||||||
|
centos-release-7-9.2009.1.el7.centos.x86_64
|
||||||
|
|
||||||
|
- ubuntu
|
||||||
|
|
||||||
|
```bash
|
||||||
|
lsb_release -a
|
||||||
|
```
|
||||||
|
|
||||||
|
## 查看本机的公网IP
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl cip.cc
|
||||||
|
```
|
||||||
|
|
||||||
|
## 用curl下载文件(不需要单独安装wget)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl http://domain/path -L -O
|
||||||
|
```
|
||||||
|
|
||||||
|
将会在path的最后一段作为文件名来保存文件
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl http://domain/path -L -o filename
|
||||||
|
```
|
||||||
|
|
||||||
|
将会以filename为文件名保存文件
|
||||||
|
|
||||||
|
## centos系统临时切换成英文/中文
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export LANG=en_US.UTF-8
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export LANG=zh_CN.UTF-8
|
||||||
|
```
|
||||||
|
|
||||||
|
## ll按时间或大小排序
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 按时间降序(最新的在最后)
|
||||||
|
ll -rt
|
||||||
|
# 按大小降序(最小的在最后)
|
||||||
|
ll -Sh
|
||||||
|
```
|
138
linux/linux改网卡名.md
Normal file
138
linux/linux改网卡名.md
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
# 在ubuntu系统里把网卡名称改为eth0
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 在ubuntu16.04系统
|
||||||
|
|
||||||
|
> 非root用户需要在命令前加sudo
|
||||||
|
|
||||||
|
### 1. 修改grub文件
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim /etc/default/grub
|
||||||
|
```
|
||||||
|
|
||||||
|
原文
|
||||||
|
|
||||||
|
```conf
|
||||||
|
GRUB_CMDLINE_LINUX=""
|
||||||
|
```
|
||||||
|
|
||||||
|
改为
|
||||||
|
|
||||||
|
```conf
|
||||||
|
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
|
||||||
|
```
|
||||||
|
|
||||||
|
保存退出
|
||||||
|
|
||||||
|
### 2. grub生效
|
||||||
|
|
||||||
|
```bash
|
||||||
|
grub-mkconfig -o /boot/grub/grub.cfg
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. 改网络配置
|
||||||
|
|
||||||
|
> 适用于ubuntu16.04,其他版本不一定有效
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim /etc/network/interfaces
|
||||||
|
```
|
||||||
|
|
||||||
|
原文(类似)
|
||||||
|
|
||||||
|
```txt
|
||||||
|
auto ens160
|
||||||
|
|
||||||
|
iface ens160 inet static
|
||||||
|
```
|
||||||
|
|
||||||
|
改为
|
||||||
|
|
||||||
|
```txt
|
||||||
|
auto eth0
|
||||||
|
|
||||||
|
iface eth0 inet static
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. 网卡开机自启(大部分情况可省略)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
systemctl enable networking.service
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. 重启
|
||||||
|
|
||||||
|
```bash
|
||||||
|
reboot
|
||||||
|
```
|
||||||
|
|
||||||
|
或
|
||||||
|
|
||||||
|
```bash
|
||||||
|
init 6
|
||||||
|
```
|
||||||
|
|
||||||
|
### 6. 查看网络信息
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ip addr
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 在centos7系统
|
||||||
|
|
||||||
|
### 1. 先确定当前网卡名
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ip addr
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. 改网卡配置文件
|
||||||
|
|
||||||
|
> 原网卡名称有可能不一样
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim /etc/sysconfig/network-scripts/ifcfg-ens192
|
||||||
|
```
|
||||||
|
|
||||||
|
把`DEVICE=ens192`改为`DEVICE=eth0`
|
||||||
|
|
||||||
|
把`NAME=ens192`改为`NAME=eth0`
|
||||||
|
|
||||||
|
保存退出
|
||||||
|
|
||||||
|
再把网卡配置文件的文件名改了
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /etc/sysconfig/network-scripts
|
||||||
|
mv ifcfg-ens192 ifcfg-eth0
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. 修改grub
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim /etc/default/grub
|
||||||
|
```
|
||||||
|
|
||||||
|
往`GRUB_COMLINE_LINUX`里面加上`net.ifnames=0 biosdevname=0`
|
||||||
|
|
||||||
|
保存退出
|
||||||
|
|
||||||
|
执行命令
|
||||||
|
|
||||||
|
```bash
|
||||||
|
grub2-mkconfig -o /boot/grub2/grub.cfg
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. 重启系统并校验效果
|
||||||
|
|
||||||
|
```bash
|
||||||
|
init 6
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ip a
|
||||||
|
```
|
40
linux/ssh免密码连接服务器.md
Normal file
40
linux/ssh免密码连接服务器.md
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# SSH免密码连接服务器
|
||||||
|
|
||||||
|
> 前提:服务器已经部署了你的私钥对应的公钥文件
|
||||||
|
---
|
||||||
|
|
||||||
|
## 使用默认密钥文件连接服务器
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ssh username@server
|
||||||
|
```
|
||||||
|
|
||||||
|
例:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ssh root@192.168.0.8
|
||||||
|
```
|
||||||
|
|
||||||
|
> 使用`~/.ssh/id_rsa`文件以root身份登录192.168.0.8主机
|
||||||
|
|
||||||
|
## 使用指定密钥文件连接服务
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ssh -i keyfile username@server
|
||||||
|
```
|
||||||
|
|
||||||
|
例:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ssh -i ~/.ssh/bob root@192.168.0.8
|
||||||
|
```
|
||||||
|
|
||||||
|
> 使用`~/.ssh/bob`私钥文件以root身份登录192.168.0.8主机
|
||||||
|
|
||||||
|
## 指定密钥文件并且服务器ssh端口不是默认的22
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ssh -i ~/.ssh/bob root@192.168.0.8 -p 22222
|
||||||
|
```
|
||||||
|
|
||||||
|
> 服务器把ssh端口设置成22222,需要凭`~/.ssh/bob`文件登录
|
12
linux/ssh客户端保持连接.md
Normal file
12
linux/ssh客户端保持连接.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# SSH客户端保持连接的方法
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
在客户端电脑的`~/.ssh/config`文件开头做如下配置:
|
||||||
|
|
||||||
|
```conf
|
||||||
|
Host *
|
||||||
|
ServerAliveInterval 30
|
||||||
|
```
|
||||||
|
|
||||||
|
> 表示每隔30秒自动向服务端发送一个no-op包
|
114
linux/ubuntu配置nfs服务.md
Normal file
114
linux/ubuntu配置nfs服务.md
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
# ubuntu系统配置NFS服务端及客户端
|
||||||
|
|
||||||
|
## 配置nfs服务端与客户端
|
||||||
|
|
||||||
|
> nfs的作用是实现各主机间的共享存储空间,`切记不要在公网环境中使用nfs!!!`
|
||||||
|
|
||||||
|
### 1. NFS服务端安装与配置
|
||||||
|
|
||||||
|
- 安装nfs服务,需要先安装:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
sudo apt install nfs-kernel-server nfs-common
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置nfs共享目录:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim /etc/exports
|
||||||
|
```
|
||||||
|
|
||||||
|
- 添加如下两行:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
/storage 192.168.1.0/24(rw,sync,no_subtree_check,no_root_squash,fsid=0)
|
||||||
|
/storage 127.0.0.1/24(rw,sync,no_subtree_check,no_root_squash,fsid=0)
|
||||||
|
```
|
||||||
|
|
||||||
|
> 其中`/storage`为需要共享的路径,`Tab`键后的ip地址是允许访问的网段(根据实际情况修改),括号内则是一些权限(不建议改动)。
|
||||||
|
|
||||||
|
- 重启nfs服务并刷新共享配置:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
/etc/init.d/nfs-kernel-server restart
|
||||||
|
exportfs -rv
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. NFS服务端的端口处理
|
||||||
|
|
||||||
|
> NFS服务是基于RPC协议的服务,通过`rpcinfo -p`命令会发现除了`111`和`2049`端口外,其`mountd`和`nlockmgr`以及`status`对应的端口是随机分配的,这样几乎无法搞防火墙和端口映射了,为了不让服务器裸奔,需要对nfs-kernel-server主机做一些配置以固定其端口。
|
||||||
|
|
||||||
|
- 修改`/etc/default/nfs-common`文件,配置`status`服务端口为`40001`:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
STATDOPTS="--port 40001"
|
||||||
|
```
|
||||||
|
|
||||||
|
- 修改`/etc/default/nfs-kernel-server`文件,配置`mountd`服务端口为`40002`:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
RPCMOUNTDOPTS="--manage-gids -p 40002"
|
||||||
|
```
|
||||||
|
|
||||||
|
- 创建`/etc/modprobe.d/options.conf`文件,添加如下内容,配置`nlockmgr`端口为`40003`:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
options lockd nlm_udpport=40003 nlm_tcpport=40003
|
||||||
|
```
|
||||||
|
|
||||||
|
- 在`/etc/modules`文件中添加`lockd`:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
# /etc/modules: kernel modules to load at boot time.
|
||||||
|
#
|
||||||
|
# This file contains the names of kernel modules that should be loaded
|
||||||
|
# at boot time, one per line. Lines beginning with "#" are ignored.
|
||||||
|
lockd
|
||||||
|
```
|
||||||
|
|
||||||
|
- 重启服务器(`reboot`),然后再运行`rpcinfo -p localhost`,就会看到,各种端口都已经被固定了。
|
||||||
|
|
||||||
|
### 3. NFS客户端安装与配置
|
||||||
|
|
||||||
|
- 安装nfs客户端(以ubuntu为例):
|
||||||
|
|
||||||
|
```shell
|
||||||
|
sudo apt install nfs-common -y
|
||||||
|
```
|
||||||
|
|
||||||
|
- 确保客户端与服务端的网络连接正常,在客户端主机上执行以下操作:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
showmount -e 192.168.1.68
|
||||||
|
```
|
||||||
|
|
||||||
|
> 正常情况下会命令执行后会返回服务器开放出来的共享目录路径,包含类似`/storage 192.168.1.0/24`的信息。
|
||||||
|
|
||||||
|
- 打开`/etc/fstab`文件:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
vim /etc/fstab
|
||||||
|
```
|
||||||
|
|
||||||
|
- 在文件末尾所加行(`tab`键间隔)后保存并退出编辑器:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
192.168.1.68:/storage /storage nfs defaults 0 0
|
||||||
|
```
|
||||||
|
|
||||||
|
> 其中第1段IP为本机IP地址,第2段为要挂载到`/storage`目录,后面几段原样照抄。
|
||||||
|
> 如果在nfs服务端本机内配置,可将ip地址改为127.0.0.1。
|
||||||
|
|
||||||
|
- 创建挂载点目录:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
mkdir /storage
|
||||||
|
```
|
||||||
|
|
||||||
|
> 完成以上操作后,就会在系统启动时自动将服务器的/storage目录挂载到本机的/storage目录。
|
||||||
|
|
||||||
|
- 以下命令可实现一次性的手动挂载(如果未在fstab中配置的话,重启服务器将失效):
|
||||||
|
|
||||||
|
```shell
|
||||||
|
sudo mount -t nfs -o nolock 192.168.1.68:/storage /storage
|
||||||
|
```
|
30
linux/ubuntu配静态IP.md
Normal file
30
linux/ubuntu配静态IP.md
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# 为ubuntu系统配置静态ip地址
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> 如果使用非root用户,需要在命令前加sudo
|
||||||
|
|
||||||
|
## ubuntu 16.04
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim /etc/network/interfaces
|
||||||
|
```
|
||||||
|
|
||||||
|
只修改eth0部分(或者是别的网卡名)
|
||||||
|
|
||||||
|
```conf
|
||||||
|
auto eth0
|
||||||
|
iface eth0 inet static
|
||||||
|
address 183.211.245.49
|
||||||
|
netmask 255.255.255.128
|
||||||
|
broadcast 183.211.245.127
|
||||||
|
gateway 183.211.245.1
|
||||||
|
dns-nameservers 221.131.143.69
|
||||||
|
```
|
||||||
|
|
||||||
|
如果想用dhcp自动获取ip的话,照下面改
|
||||||
|
|
||||||
|
```conf
|
||||||
|
auto eth0
|
||||||
|
iface eth0 inet dhcp
|
||||||
|
```
|
19
linux/删除某时间前的文件或文件夹.md
Normal file
19
linux/删除某时间前的文件或文件夹.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# 删除某时间前的文件或文件夹(比如录音文件)
|
||||||
|
|
||||||
|
## 命令示例
|
||||||
|
|
||||||
|
```bash
|
||||||
|
find /usr/local/freeswitch/log/freeswitch.log.*.1 -mtime +5 -exec rm -rf {} \;
|
||||||
|
```
|
||||||
|
|
||||||
|
解读:
|
||||||
|
|
||||||
|
删除5天前的freeswitch日志
|
||||||
|
|
||||||
|
```bash
|
||||||
|
find /usr/local/freeswitch/recordings/ -type d -mtime +10 -exec rm -rf {} \;
|
||||||
|
```
|
||||||
|
|
||||||
|
解读:
|
||||||
|
|
||||||
|
删除10天前的freeswitch录音
|
41
linux/阿里云centos磁盘扩容.md
Normal file
41
linux/阿里云centos磁盘扩容.md
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# 阿里云磁盘扩容(centos7)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 场景
|
||||||
|
|
||||||
|
在阿里云控制台对主机云盘成功完成磁盘扩容操作。
|
||||||
|
|
||||||
|
## centos系统内操作
|
||||||
|
|
||||||
|
查看磁盘和分区
|
||||||
|
|
||||||
|
```bash
|
||||||
|
fdisk -l
|
||||||
|
```
|
||||||
|
|
||||||
|
结果有可能会看到有一个名为/dev/vda的磁盘,同时有一个名为/dev/vda1的分区,而且/dev/vda的磁盘容量已经是扩容后的容量了。
|
||||||
|
|
||||||
|
查看分区大小
|
||||||
|
|
||||||
|
```bash
|
||||||
|
df -h
|
||||||
|
```
|
||||||
|
|
||||||
|
结果可以看到分区大小还是扩容前的大小。
|
||||||
|
|
||||||
|
为分区扩容
|
||||||
|
|
||||||
|
```bash
|
||||||
|
growpart /dev/vda 1
|
||||||
|
```
|
||||||
|
|
||||||
|
> 语法 growpart <DeviceName> <PartionNumber>
|
||||||
|
|
||||||
|
扩容文件系统
|
||||||
|
|
||||||
|
```bash
|
||||||
|
resize2fs /dev/vda1
|
||||||
|
```
|
||||||
|
|
||||||
|
> 语法 resize2fs <PartitionName>
|
33
skill/tmux操作.md
Normal file
33
skill/tmux操作.md
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# tmux操作
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ctrl+b s 退出 tmux 到列表
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ctrl+b d 退出到root
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tmux ls 查看所有窗口
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tmux kill-window -t 2 杀掉编号为2的窗口
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tumx a 上一次进入的窗口
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tmux new -s py 新建窗口
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /usr/local/freeswitch/scripts/call_outivr python listen_event_process.py 启动esl监听程序
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /usr/local/freeswitch ./freeswitch 启动freeswitch 如果发现已经启动 则退出到root界面杀掉进程pid
|
||||||
|
```
|
40
skill/vim操作.md
Normal file
40
skill/vim操作.md
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# vim快捷操作
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 定义tab键为4个空格
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# ubuntu
|
||||||
|
vim /etc/vim/vimrc
|
||||||
|
# centos
|
||||||
|
vim /etc/vimrc
|
||||||
|
```
|
||||||
|
|
||||||
|
在最后添加如下配置
|
||||||
|
|
||||||
|
```text
|
||||||
|
set ts=4
|
||||||
|
set sw=4
|
||||||
|
set expandtab
|
||||||
|
```
|
||||||
|
|
||||||
|
## 查找替换
|
||||||
|
|
||||||
|
把每一行中的所有fromstring替换为tostring
|
||||||
|
|
||||||
|
```txt
|
||||||
|
:%s/fromstring/tostring/g
|
||||||
|
```
|
||||||
|
|
||||||
|
把每一行中的第一个fromstring替换为tostring
|
||||||
|
|
||||||
|
```txt
|
||||||
|
:%s/fromstring/tostring
|
||||||
|
```
|
||||||
|
|
||||||
|
## 粘贴时缩进错乱
|
||||||
|
|
||||||
|
```txt
|
||||||
|
:set paste
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user