首页 » SSH » 正文

rtty_服务端_ubuntu_安装文档(测试通过)

#简介:
#一个反向代理WebTTY,它由客户端和服务端组成,服务端采用GO语言实现,以及使用了vue+iview,你可以基于你设置的设备ID(不设置则为设备的MAC地址)通过Web浏览器访问你的任意一台终端。
#rtty非常适合远程维护你的或者你公司的部署在全球各地的成千上万的Linux设备。
#参考地址:
#https://gitee.com/zhaojh329/rtty
#http://blog.csdn.net/wh211212/article/details/53523457
#https://superuser.com/questions/823757/update-rc-d-equivalent-on-centos
#特性:
#1.部署简单,使用方便
#2.反向代理
#3.根据你设置的ID连接你的设备
#4.基于Xterm.js的全功能终端
#5.支持SSL: openssl, mbedtls, CyaSSl(wolfssl)
#6.支持上传文件到设备
#7.支持从设备下载文件
#8.跨平台: macOS, Linux, FreeBSD/OpenBSD, OpenWrt/LEDE

#客户端依赖:
#1.libubox-用于OpenWrt的C工具函数库,但也可以用于其他Linux系统中.参考
#2.libuwsc-一个轻量的针对嵌入式Linux的基于libubox的WebSocket客户端C库。
#3.ustream-ssl-如果你需要支持SSL
#4.mbedtls-如果你选择mbedtls作为你的SSL后端
#5.CyaSSl(wolfssl)-如果你选择wolfssl作为你的SSL后端
#6.openssl-如果你选择openssl作为你的SSL后端

#服务端系统环境:
mazhenguo@mazhenguo:~$ cat /etc/issue
Ubuntu 16.04.3 LTS \n \l

mazhenguo@mazhenguo:~$ cat /proc/version
Linux version 4.10.0-28-generic (buildd@lgw01-12) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #32~16.04.2-Ubuntu SMP Thu Jul 20 10:19:48 UTC 2017

mazhenguo@mazhenguo:~$ uname -a
Linux mazhenguo 4.10.0-28-generic #32~16.04.2-Ubuntu SMP Thu Jul 20 10:19:48 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

mazhenguo@mazhenguo:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial
mazhenguo@mazhenguo:~$

#安装GO语言环境(如果您还未安装)
# For ubuntu
sudo apt-get install golang
[sudo] mazhenguo 的密码:
正在读取软件包列表… 完成
正在分析软件包的依赖关系树
正在读取状态信息… 完成
将会同时安装下列软件:
golang-1.6 golang-1.6-doc golang-1.6-go golang-1.6-race-detector-runtime golang-1.6-src golang-doc golang-go
golang-race-detector-runtime golang-src
建议安装:
bzr git mercurial subversion
下列【新】软件包将被安装:
golang golang-1.6 golang-1.6-doc golang-1.6-go golang-1.6-race-detector-runtime golang-1.6-src golang-doc
golang-go golang-race-detector-runtime golang-src
升级了 0 个软件包,新安装了 10 个软件包,要卸载 0 个软件包,有 378 个软件包未被升级。
需要下载 29.7 MB 的归档。
解压缩后会消耗 202 MB 的额外空间。
您希望继续执行吗? [Y/n] y
获取:1 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 golang-1.6-src amd64 1.6.2-0ubuntu5~16.04.4 [6,416 kB]
获取:2 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 golang-1.6-go amd64 1.6.2-0ubuntu5~16.04.4 [20.5 MB]
获取:3 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 golang-1.6-doc all 1.6.2-0ubuntu5~16.04.4 [2,368 kB]
获取:4 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 golang-1.6 all 1.6.2-0ubuntu5~16.04.4 [16.8 kB]
获取:5 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 golang-src amd64 2:1.6-1ubuntu4 [3,066 B]
获取:6 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 golang-go amd64 2:1.6-1ubuntu4 [21.8 kB]
获取:7 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 golang-doc all 2:1.6-1ubuntu4 [2,808 B]
获取:8 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 golang all 2:1.6-1ubuntu4 [2,766 B]
获取:9 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 golang-1.6-race-detector-runtime amd64 0.0+svn252922-0ubuntu1 [404 kB]
获取:10 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 golang-race-detector-runtime amd64 2:1.6-1ubuntu4 [2,854 B]
已下载 29.7 MB,耗时 12秒 (2,459 kB/s)
正在选中未选择的软件包 golang-1.6-src。
(正在读取数据库 … 系统当前共安装有 181617 个文件和目录。)
正准备解包 …/golang-1.6-src_1.6.2-0ubuntu5~16.04.4_amd64.deb …
正在解包 golang-1.6-src (1.6.2-0ubuntu5~16.04.4) …
正在选中未选择的软件包 golang-1.6-go。
正准备解包 …/golang-1.6-go_1.6.2-0ubuntu5~16.04.4_amd64.deb …
正在解包 golang-1.6-go (1.6.2-0ubuntu5~16.04.4) …
正在选中未选择的软件包 golang-1.6-doc。
正准备解包 …/golang-1.6-doc_1.6.2-0ubuntu5~16.04.4_all.deb …
正在解包 golang-1.6-doc (1.6.2-0ubuntu5~16.04.4) …
正在选中未选择的软件包 golang-1.6。
正准备解包 …/golang-1.6_1.6.2-0ubuntu5~16.04.4_all.deb …
正在解包 golang-1.6 (1.6.2-0ubuntu5~16.04.4) …
正在选中未选择的软件包 golang-src。
正准备解包 …/golang-src_2%3a1.6-1ubuntu4_amd64.deb …
正在解包 golang-src (2:1.6-1ubuntu4) …
正在选中未选择的软件包 golang-go。
正准备解包 …/golang-go_2%3a1.6-1ubuntu4_amd64.deb …
正在解包 golang-go (2:1.6-1ubuntu4) …
正在选中未选择的软件包 golang-doc。
正准备解包 …/golang-doc_2%3a1.6-1ubuntu4_all.deb …
正在解包 golang-doc (2:1.6-1ubuntu4) …
正在选中未选择的软件包 golang。
正准备解包 …/golang_2%3a1.6-1ubuntu4_all.deb …
正在解包 golang (2:1.6-1ubuntu4) …
正在选中未选择的软件包 golang-1.6-race-detector-runtime。
正准备解包 …/golang-1.6-race-detector-runtime_0.0+svn252922-0ubuntu1_amd64.deb …
正在解包 golang-1.6-race-detector-runtime (0.0+svn252922-0ubuntu1) …
正在选中未选择的软件包 golang-race-detector-runtime。
正准备解包 …/golang-race-detector-runtime_2%3a1.6-1ubuntu4_amd64.deb …
正在解包 golang-race-detector-runtime (2:1.6-1ubuntu4) …
正在处理用于 man-db (2.7.5-1) 的触发器 …
正在设置 golang-1.6-src (1.6.2-0ubuntu5~16.04.4) …
正在设置 golang-1.6-go (1.6.2-0ubuntu5~16.04.4) …
正在设置 golang-1.6-doc (1.6.2-0ubuntu5~16.04.4) …
正在设置 golang-1.6 (1.6.2-0ubuntu5~16.04.4) …
正在设置 golang-src (2:1.6-1ubuntu4) …
正在设置 golang-go (2:1.6-1ubuntu4) …
正在设置 golang-doc (2:1.6-1ubuntu4) …
正在设置 golang (2:1.6-1ubuntu4) …
正在设置 golang-1.6-race-detector-runtime (0.0+svn252922-0ubuntu1) …
正在设置 golang-race-detector-runtime (2:1.6-1ubuntu4) …
mazhenguo@mazhenguo:~$

#设置环境变量GOPATH(如果您未设置)(从Go 1.8开始,默认为$HOME/go)
mazhenguo@mazhenguo:~$ export GOPATH=$HOME/go

mazhenguo@mazhenguo:~$ echo $GOPATH
/home/mazhenguo/go

mazhenguo@mazhenguo:~$
#安装rtty server
mazhenguo@mazhenguo:~$ go get -u github.com/zhaojh329/rttys
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/zhaojh329/rttys: exec: “git”: executable file not found in $PATH

mazhenguo@mazhenguo:~$ sudo apt-get install git
正在读取软件包列表… 完成
正在分析软件包的依赖关系树
正在读取状态信息… 完成
将会同时安装下列软件:
git-man liberror-perl
建议安装:
git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-arch git-cvs git-mediawiki
git-svn
下列【新】软件包将被安装:
git git-man liberror-perl
升级了 0 个软件包,新安装了 3 个软件包,要卸载 0 个软件包,有 378 个软件包未被升级。
需要下载 3,857 kB 的归档。
解压缩后会消耗 25.6 MB 的额外空间。
您希望继续执行吗? [Y/n] y
获取:1 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 liberror-perl all 0.17-1.2 [19.6 kB]
获取:2 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 git-man all 1:2.7.4-0ubuntu1.3 [736 kB]
获取:3 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 git amd64 1:2.7.4-0ubuntu1.3 [3,102 kB]
已下载 3,857 kB,耗时 5秒 (759 kB/s)
正在选中未选择的软件包 liberror-perl。
(正在读取数据库 … 系统当前共安装有 187435 个文件和目录。)
正准备解包 …/liberror-perl_0.17-1.2_all.deb …
正在解包 liberror-perl (0.17-1.2) …
正在选中未选择的软件包 git-man。
正准备解包 …/git-man_1%3a2.7.4-0ubuntu1.3_all.deb …
正在解包 git-man (1:2.7.4-0ubuntu1.3) …
正在选中未选择的软件包 git。
正准备解包 …/git_1%3a2.7.4-0ubuntu1.3_amd64.deb …
正在解包 git (1:2.7.4-0ubuntu1.3) …
正在处理用于 man-db (2.7.5-1) 的触发器 …
正在设置 liberror-perl (0.17-1.2) …
正在设置 git-man (1:2.7.4-0ubuntu1.3) …
正在设置 git (1:2.7.4-0ubuntu1.3) …

mazhenguo@mazhenguo:~$ go get -u github.com/zhaojh329/rttys
mazhenguo@mazhenguo:~$

#手动运行
$GOPATH/bin/rttys -port 5912
#安装自启动脚本,后台运行(debian/ubuntu)
mazhenguo@mazhenguo:~$ cd $GOPATH/src/github.com/zhaojh329/rttys

mazhenguo@mazhenguo:~/go/src/github.com/zhaojh329/rttys$ pwd
/home/mazhenguo/go/src/github.com/zhaojh329/rttys

mazhenguo@mazhenguo:~/go/src/github.com/zhaojh329/rttys$ sudo ./install.sh

mazhenguo@mazhenguo:~/go/src/github.com/zhaojh329/rttys$ sudo /etc/init.d/rttys start
[ ok ] Starting rttys (via systemctl): rttys.service.

mazhenguo@mazhenguo:~/go/src/github.com/zhaojh329/rttys$ ps -ef |grep rttys
root 8788 1 0 20:14 ? 00:00:00 /usr/local/sbin/rttys -port 5912
mazheng+ 8837 4704 0 20:15 pts/1 00:00:00 grep –color=auto rttys

mazhenguo@mazhenguo:~/go/src/github.com/zhaojh329/rttys$ sudo netstat -antlp |grep 5912
tcp6 0 0 :::5912 :::* LISTEN 8788/rttys
tcp6 0 0 192.168.1.129:5912 192.168.1.108:62625 ESTABLISHED 8788/rttys

mazhenguo@mazhenguo:~/go/src/github.com/zhaojh329/rttys$ sudo apt-get install vim
正在读取软件包列表… 完成
正在分析软件包的依赖关系树
正在读取状态信息… 完成
将会同时安装下列软件:
vim-runtime
建议安装:
ctags vim-doc vim-scripts vim-gnome-py2 | vim-gtk-py2 | vim-gtk3-py2 | vim-athena-py2 | vim-nox-py2
下列【新】软件包将被安装:
vim vim-runtime
升级了 0 个软件包,新安装了 2 个软件包,要卸载 0 个软件包,有 378 个软件包未被升级。
需要下载 6,199 kB 的归档。
解压缩后会消耗 30.0 MB 的额外空间。
您希望继续执行吗? [Y/n] y
获取:1 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 vim-runtime all 2:7.4.1689-3ubuntu1.2 [5,164 kB]
获取:2 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 vim amd64 2:7.4.1689-3ubuntu1.2 [1,036 kB]
已下载 6,199 kB,耗时 6秒 (923 kB/s)
正在选中未选择的软件包 vim-runtime。
(正在读取数据库 … 系统当前共安装有 188250 个文件和目录。)
正准备解包 …/vim-runtime_2%3a7.4.1689-3ubuntu1.2_all.deb …
正在添加 vim-runtime 导致 /usr/share/vim/vim74/doc/help.txt 转移到 /usr/share/vim/vim74/doc/help.txt.vim-tiny
正在添加 vim-runtime 导致 /usr/share/vim/vim74/doc/tags 转移到 /usr/share/vim/vim74/doc/tags.vim-tiny
正在解包 vim-runtime (2:7.4.1689-3ubuntu1.2) …
正在选中未选择的软件包 vim。
正准备解包 …/vim_2%3a7.4.1689-3ubuntu1.2_amd64.deb …
正在解包 vim (2:7.4.1689-3ubuntu1.2) …
正在处理用于 man-db (2.7.5-1) 的触发器 …
正在设置 vim-runtime (2:7.4.1689-3ubuntu1.2) …
正在设置 vim (2:7.4.1689-3ubuntu1.2) …
update-alternatives: 使用 /usr/bin/vim.basic 来在自动模式中提供 /usr/bin/vim (vim)
update-alternatives: 使用 /usr/bin/vim.basic 来在自动模式中提供 /usr/bin/vimdiff (vimdiff)
update-alternatives: 使用 /usr/bin/vim.basic 来在自动模式中提供 /usr/bin/rvim (rvim)
update-alternatives: 使用 /usr/bin/vim.basic 来在自动模式中提供 /usr/bin/rview (rview)
update-alternatives: 使用 /usr/bin/vim.basic 来在自动模式中提供 /usr/bin/vi (vi)
update-alternatives: 使用 /usr/bin/vim.basic 来在自动模式中提供 /usr/bin/view (view)
update-alternatives: 使用 /usr/bin/vim.basic 来在自动模式中提供 /usr/bin/ex (ex)

mazhenguo@mazhenguo:~/go/src/github.com/zhaojh329/rttys$

#修改启动端口
mazhenguo@mazhenguo:~/go/src/github.com/zhaojh329/rttys$ sudo vim /etc/init.d/rttys
#修改第17行的数字
PORT=8888

#重新启动
mazhenguo@mazhenguo:~/go/src/github.com/zhaojh329/rttys$ sudo /etc/init.d/rttys restart
[….] Restarting rttys (via systemctl): rttys.serviceWarning: rttys.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.
. ok

mazhenguo@mazhenguo:~/go/src/github.com/zhaojh329/rttys$ systemctl daemon-reload
==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon ===
Authentication is required to reload the systemd state.
Authenticating as: mazhenguo,,, (mazhenguo)
Password:
==== AUTHENTICATION COMPLETE ===

mazhenguo@mazhenguo:~/go/src/github.com/zhaojh329/rttys$

#客户端部署(以centos为例)
#如何编译和安装rtty客户端
#针对Linux发行版,例如Ubuntu和Centos
#安装编译工具
# For Ubuntu
sudo apt install gcc cmake git
# For Centos
[root@admin ~]# yum install gcc cmake git -y
已加载插件:fastestmirror, refresh-packagekit, security
设置安装进程
Determining fastest mirrors
* base: mirror.bit.edu.cn
* extras: mirrors.aliyun.com
* updates: mirror.bit.edu.cn
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
解决依赖关系
–> 执行事务检查
—> Package cmake.x86_64 0:2.8.12.2-4.el6 will be 安装
—> Package gcc.x86_64 0:4.4.7-18.el6 will be 安装
–> 处理依赖关系 cpp = 4.4.7-18.el6,它被软件包 gcc-4.4.7-18.el6.x86_64 需要
–> 处理依赖关系 cloog-ppl >= 0.15,它被软件包 gcc-4.4.7-18.el6.x86_64 需要
—> Package git.x86_64 0:1.7.1-9.el6_9 will be 安装
–> 处理依赖关系 perl-Git = 1.7.1-9.el6_9,它被软件包 git-1.7.1-9.el6_9.x86_64 需要
–> 处理依赖关系 perl(Git),它被软件包 git-1.7.1-9.el6_9.x86_64 需要
–> 处理依赖关系 perl(Error),它被软件包 git-1.7.1-9.el6_9.x86_64 需要
–> 执行事务检查
—> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be 安装
–> 处理依赖关系 libppl_c.so.2()(64bit),它被软件包 cloog-ppl-0.15.7-1.2.el6.x86_64 需要
–> 处理依赖关系 libppl.so.7()(64bit),它被软件包 cloog-ppl-0.15.7-1.2.el6.x86_64 需要
—> Package cpp.x86_64 0:4.4.7-18.el6 will be 安装
–> 处理依赖关系 libmpfr.so.1()(64bit),它被软件包 cpp-4.4.7-18.el6.x86_64 需要
—> Package perl-Error.noarch 1:0.17015-4.el6 will be 安装
—> Package perl-Git.noarch 0:1.7.1-9.el6_9 will be 安装
–> 执行事务检查
—> Package mpfr.x86_64 0:2.4.1-6.el6 will be 安装
—> Package ppl.x86_64 0:0.10.2-11.el6 will be 安装
–> 完成依赖关系计算

依赖关系解决

======================================================================================================================
软件包 架构 版本 仓库 大小
======================================================================================================================
正在安装:
cmake x86_64 2.8.12.2-4.el6 base 8.0 M
gcc x86_64 4.4.7-18.el6 base 10 M
git x86_64 1.7.1-9.el6_9 updates 4.6 M
为依赖而安装:
cloog-ppl x86_64 0.15.7-1.2.el6 base 93 k
cpp x86_64 4.4.7-18.el6 base 3.7 M
mpfr x86_64 2.4.1-6.el6 base 157 k
perl-Error noarch 1:0.17015-4.el6 base 29 k
perl-Git noarch 1.7.1-9.el6_9 updates 29 k
ppl x86_64 0.10.2-11.el6 base 1.3 M

事务概要
======================================================================================================================
Install 9 Package(s)

总下载量:28 M
Installed size: 76 M
下载软件包:
(1/9): cloog-ppl-0.15.7-1.2.el6.x86_64.rpm | 93 kB 00:00
(2/9): cmake-2.8.12.2-4.el6.x86_64.rpm | 8.0 MB 00:04
(3/9): cpp-4.4.7-18.el6.x86_64.rpm | 3.7 MB 00:02
(4/9): gcc-4.4.7-18.el6.x86_64.rpm | 10 MB 00:11
(5/9): git-1.7.1-9.el6_9.x86_64.rpm | 4.6 MB 00:06
(6/9): mpfr-2.4.1-6.el6.x86_64.rpm | 157 kB 00:00
(7/9): perl-Error-0.17015-4.el6.noarch.rpm | 29 kB 00:00
(8/9): perl-Git-1.7.1-9.el6_9.noarch.rpm | 29 kB 00:00
(9/9): ppl-0.10.2-11.el6.x86_64.rpm | 1.3 MB 00:01
———————————————————————————————————————-
总计 1.1 MB/s | 28 MB 00:26
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
Package: centos-release-6-9.el6.12.3.x86_64 (@anaconda-CentOS-201703281317.x86_64/6.9)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
运行 rpm_check_debug
执行事务测试
事务测试成功
执行事务
正在安装 : 1:perl-Error-0.17015-4.el6.noarch 1/9
正在安装 : perl-Git-1.7.1-9.el6_9.noarch 2/9
正在安装 : git-1.7.1-9.el6_9.x86_64 3/9
正在安装 : ppl-0.10.2-11.el6.x86_64 4/9
正在安装 : cloog-ppl-0.15.7-1.2.el6.x86_64 5/9
正在安装 : mpfr-2.4.1-6.el6.x86_64 6/9
正在安装 : cpp-4.4.7-18.el6.x86_64 7/9
正在安装 : gcc-4.4.7-18.el6.x86_64 8/9
正在安装 : cmake-2.8.12.2-4.el6.x86_64 9/9
Verifying : 1:perl-Error-0.17015-4.el6.noarch 1/9
Verifying : perl-Git-1.7.1-9.el6_9.noarch 2/9
Verifying : cpp-4.4.7-18.el6.x86_64 3/9
Verifying : mpfr-2.4.1-6.el6.x86_64 4/9
Verifying : cmake-2.8.12.2-4.el6.x86_64 5/9
Verifying : gcc-4.4.7-18.el6.x86_64 6/9
Verifying : git-1.7.1-9.el6_9.x86_64 7/9
Verifying : ppl-0.10.2-11.el6.x86_64 8/9
Verifying : cloog-ppl-0.15.7-1.2.el6.x86_64 9/9

已安装:
cmake.x86_64 0:2.8.12.2-4.el6 gcc.x86_64 0:4.4.7-18.el6 git.x86_64 0:1.7.1-9.el6_9

作为依赖被安装:
cloog-ppl.x86_64 0:0.15.7-1.2.el6 cpp.x86_64 0:4.4.7-18.el6 mpfr.x86_64 0:2.4.1-6.el6
perl-Error.noarch 1:0.17015-4.el6 perl-Git.noarch 0:1.7.1-9.el6_9 ppl.x86_64 0:0.10.2-11.el6

完毕!

[root@admin ~]# yum install epel-release -y
已加载插件:fastestmirror, refresh-packagekit, security
设置安装进程
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirrors.aliyun.com
* updates: mirror.bit.edu.cn
解决依赖关系
–> 执行事务检查
—> Package epel-release.noarch 0:6-8 will be 安装
–> 完成依赖关系计算

依赖关系解决

======================================================================================================================
软件包 架构 版本 仓库 大小
======================================================================================================================
正在安装:
epel-release noarch 6-8 extras 14 k

事务概要
======================================================================================================================
Install 1 Package(s)

总下载量:14 k
Installed size: 22 k
下载软件包:
epel-release-6-8.noarch.rpm | 14 kB 00:00
运行 rpm_check_debug
执行事务测试
事务测试成功
执行事务
正在安装 : epel-release-6-8.noarch 1/1
Verifying : epel-release-6-8.noarch 1/1

已安装:
epel-release.noarch 0:6-8

完毕!

#编译和安装依赖软件包
# For Ubuntu
sudo apt install libjson-c-dev
# For Centos
yum install json-c-devel -y
yum install libjson* json-c-devel -y

[root@admin ~]# mkdir /home/app
[root@admin ~]# cd /home/app/
[root@admin ~]# git clone https://git.openwrt.org/project/libubox.git
[root@admin app]# cd libubox && cmake -DBUILD_LUA=OFF . && sudo make install
— The C compiler identification is GNU 4.4.7
— Check for working C compiler: /usr/bin/cc
— Check for working C compiler: /usr/bin/cc — works
— Detecting C compiler ABI info
— Detecting C compiler ABI info – done
— Found PkgConfig: /usr/bin/pkg-config (found version “0.23”)
— checking for one of the modules ‘json-c’
— Looking for clock_gettime
— Looking for clock_gettime – not found
— Looking for clock_gettime in rt
— Looking for clock_gettime in rt – found
— checking for one of the modules ‘lua5.1;lua-5.1’
— Configuring done
— Generating done
— Build files have been written to: /home/app/libubox
Scanning dependencies of target ubox
[ 2%] Building C object CMakeFiles/ubox.dir/avl.c.o
[ 5%] Building C object CMakeFiles/ubox.dir/avl-cmp.c.o
[ 7%] Building C object CMakeFiles/ubox.dir/blob.c.o
[ 10%] Building C object CMakeFiles/ubox.dir/blobmsg.c.o
[ 12%] Building C object CMakeFiles/ubox.dir/uloop.c.o
[ 15%] Building C object CMakeFiles/ubox.dir/usock.c.o
[ 17%] Building C object CMakeFiles/ubox.dir/ustream.c.o
[ 20%] Building C object CMakeFiles/ubox.dir/ustream-fd.c.o
[ 22%] Building C object CMakeFiles/ubox.dir/vlist.c.o
[ 25%] Building C object CMakeFiles/ubox.dir/utils.c.o
[ 27%] Building C object CMakeFiles/ubox.dir/safe_list.c.o
[ 30%] Building C object CMakeFiles/ubox.dir/runqueue.c.o
[ 32%] Building C object CMakeFiles/ubox.dir/md5.c.o
[ 35%] Building C object CMakeFiles/ubox.dir/kvlist.c.o
[ 37%] Building C object CMakeFiles/ubox.dir/ulog.c.o
[ 40%] Building C object CMakeFiles/ubox.dir/base64.c.o
Linking C shared library libubox.so
[ 40%] Built target ubox
Scanning dependencies of target blobmsg_json
[ 42%] Building C object CMakeFiles/blobmsg_json.dir/blobmsg_json.c.o
Linking C shared library libblobmsg_json.so
[ 42%] Built target blobmsg_json
Scanning dependencies of target blobmsg_json-static
[ 45%] Building C object CMakeFiles/blobmsg_json-static.dir/blobmsg_json.c.o
Linking C static library libblobmsg_json.a
[ 45%] Built target blobmsg_json-static
Scanning dependencies of target jshn
[ 47%] Building C object CMakeFiles/jshn.dir/jshn.c.o
Linking C executable jshn
[ 47%] Built target jshn
Scanning dependencies of target json_script
[ 50%] Building C object CMakeFiles/json_script.dir/json_script.c.o
Linking C shared library libjson_script.so
[ 50%] Built target json_script
Scanning dependencies of target ubox-static
[ 52%] Building C object CMakeFiles/ubox-static.dir/avl.c.o
[ 55%] Building C object CMakeFiles/ubox-static.dir/avl-cmp.c.o
[ 57%] Building C object CMakeFiles/ubox-static.dir/blob.c.o
[ 60%] Building C object CMakeFiles/ubox-static.dir/blobmsg.c.o
[ 62%] Building C object CMakeFiles/ubox-static.dir/uloop.c.o
[ 65%] Building C object CMakeFiles/ubox-static.dir/usock.c.o
[ 67%] Building C object CMakeFiles/ubox-static.dir/ustream.c.o
[ 70%] Building C object CMakeFiles/ubox-static.dir/ustream-fd.c.o
[ 72%] Building C object CMakeFiles/ubox-static.dir/vlist.c.o
[ 75%] Building C object CMakeFiles/ubox-static.dir/utils.c.o
[ 77%] Building C object CMakeFiles/ubox-static.dir/safe_list.c.o
[ 80%] Building C object CMakeFiles/ubox-static.dir/runqueue.c.o
[ 82%] Building C object CMakeFiles/ubox-static.dir/md5.c.o
[ 85%] Building C object CMakeFiles/ubox-static.dir/kvlist.c.o
[ 87%] Building C object CMakeFiles/ubox-static.dir/ulog.c.o
[ 90%] Building C object CMakeFiles/ubox-static.dir/base64.c.o
Linking C static library libubox.a
[ 90%] Built target ubox-static
Scanning dependencies of target blobmsg-example
[ 92%] Building C object examples/CMakeFiles/blobmsg-example.dir/blobmsg-example.c.o
Linking C executable blobmsg-example
[ 92%] Built target blobmsg-example
Scanning dependencies of target json_script-example
[ 95%] Building C object examples/CMakeFiles/json_script-example.dir/json_script-example.c.o
Linking C executable json_script-example
[ 95%] Built target json_script-example
Scanning dependencies of target runqueue-example
[ 97%] Building C object examples/CMakeFiles/runqueue-example.dir/runqueue-example.c.o
Linking C executable runqueue-example
[ 97%] Built target runqueue-example
Scanning dependencies of target ustream-example
[100%] Building C object examples/CMakeFiles/ustream-example.dir/ustream-example.c.o
Linking C executable ustream-example
[100%] Built target ustream-example
Install the project…
— Install configuration: “”
— Installing: /usr/local/include/libubox/blob.h
— Installing: /usr/local/include/libubox/runqueue.h
— Installing: /usr/local/include/libubox/uloop.h
— Installing: /usr/local/include/libubox/blobmsg_json.h
— Installing: /usr/local/include/libubox/safe_list.h
— Installing: /usr/local/include/libubox/list.h
— Installing: /usr/local/include/libubox/usock.h
— Installing: /usr/local/include/libubox/vlist.h
— Installing: /usr/local/include/libubox/ulog.h
— Installing: /usr/local/include/libubox/utils.h
— Installing: /usr/local/include/libubox/json_script.h
— Installing: /usr/local/include/libubox/ustream.h
— Installing: /usr/local/include/libubox/blobmsg.h
— Installing: /usr/local/include/libubox/md5.h
— Installing: /usr/local/include/libubox/avl-cmp.h
— Installing: /usr/local/include/libubox/avl.h
— Installing: /usr/local/include/libubox/kvlist.h
— Installing: /usr/local/lib/libubox.so
— Installing: /usr/local/lib/libubox.a
— Installing: /usr/local/lib/libblobmsg_json.so
— Removed runtime path from “/usr/local/lib/libblobmsg_json.so”
— Installing: /usr/local/lib/libblobmsg_json.a
— Installing: /usr/local/bin/jshn
— Removed runtime path from “/usr/local/bin/jshn”
— Installing: /usr/local/lib/libjson_script.so
— Removed runtime path from “/usr/local/lib/libjson_script.so”
— Installing: /usr/local/share/libubox/jshn.sh

[root@admin libubox]# cd /home/app/
[root@admin app]# git clone https://github.com/zhaojh329/libuwsc.git
Initialized empty Git repository in /home/app/libuwsc/.git/
remote: Counting objects: 385, done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 385 (delta 10), reused 15 (delta 7), pack-reused 360
Receiving objects: 100% (385/385), 95.55 KiB, done.
Resolving deltas: 100% (255/255), done.
[root@admin app]# cd libuwsc && cmake -DUWSC_SSL_SUPPORT=OFF . && sudo make install
— The C compiler identification is GNU 4.4.7
— Check for working C compiler: /usr/bin/cc
— Check for working C compiler: /usr/bin/cc — works
— Detecting C compiler ABI info
— Detecting C compiler ABI info – done
— Found Libubox: /usr/local/lib/libubox.so

— UWSC_VERSION: 2.0.0
— UWSC_SSL_SUPPORT: OFF

— Configuring done
— Generating done
— Build files have been written to: /home/app/libuwsc
Scanning dependencies of target uwsc
[ 25%] Building C object src/CMakeFiles/uwsc.dir/uwsc.c.o
[ 50%] Building C object src/CMakeFiles/uwsc.dir/log.c.o
[ 75%] Building C object src/CMakeFiles/uwsc.dir/utils.c.o
Linking C shared library libuwsc.so
[ 75%] Built target uwsc
Scanning dependencies of target helloworld
[100%] Building C object example/CMakeFiles/helloworld.dir/helloworld.c.o
Linking C executable helloworld
[100%] Built target helloworld
Install the project…
— Install configuration: “”
— Installing: /usr/local/include/uwsc/config.h
— Installing: /usr/local/include/uwsc/uwsc.h
— Installing: /usr/local/lib/libuwsc.so.2.0.0
— Installing: /usr/local/lib/libuwsc.so
— Removed runtime path from “/usr/local/lib/libuwsc.so.2.0.0”
[root@admin libuwsc]#

#编译和安装RTTY
[root@admin libuwsc]# cd /home/app/
[root@admin app]# git clone https://github.com/zhaojh329/rtty.git
Initialized empty Git repository in /home/app/rtty/.git/
remote: Counting objects: 1324, done.
remote: Compressing objects: 100% (10/10), done.
Receiving objects: 100% (1324/1324), 3.82 MiB | 278 KiB/s, done.
remote: Total 1324 (delta 2), reused 7 (delta 1), pack-reused 1313
Resolving deltas: 100% (839/839), done.
[root@admin app]# cd rtty && cmake . && sudo make install
— The C compiler identification is GNU 4.4.7
— Check for working C compiler: /usr/bin/cc
— Check for working C compiler: /usr/bin/cc — works
— Detecting C compiler ABI info
— Detecting C compiler ABI info – done
— Found Libubox: /usr/local/lib/libubox.so
— Found Libuwsc: /usr/local/lib/libuwsc.so (found suitable version “2.0”, minimum required is “1.2”)
— Configuring done
— Generating done
— Build files have been written to: /home/app/rtty
Scanning dependencies of target rtty
[ 33%] Building C object src/CMakeFiles/rtty.dir/main.c.o
[ 66%] Building C object src/CMakeFiles/rtty.dir/utils.c.o
[100%] Building C object src/CMakeFiles/rtty.dir/protocol.c.o
Linking C executable rtty
[100%] Built target rtty
Install the project…
— Install configuration: “”
— Installing: /usr/local/bin/rtty
— Removed runtime path from “/usr/local/bin/rtty”
[root@admin rtty]#

#运行RTTY将下面的参数替换为你自己的参数(在客户端上操作)
[root@admin rtty]# echo ‘/usr/local/lib’ >>/etc/ld.so.conf

[root@admin rtty]# ldconfig

#设备ID
[root@admin rtty]# rtty -I ‘192_168_1_104’ -h ‘192.168.1.129’ -p 80 -a -v -s -d ‘本地测试’
rtty version 4.0.0
onopen
#说明
rtty -I ‘192_168_1_104’ -h ‘192.168.1.129’ -p 80 -a -v -d ‘本地测试’
[root@admin rtty]# rtty
You must specify the ifname or id
Usage: rtty [option]
-i ifname # Network interface name – Using the MAC address of the interface as the device ID
-I id # Set an ID for the device(Maximum 63 bytes, valid character:letters and numbers and underlines and short lines) – If set, it will cover the MAC address(if you have specify the ifname)
-h host # Server host
-p port # Server port
-P interval # Set ping interval(s)
-a # Auto reconnect to the server
-v # verbose
-d # Adding a description to the device(Maximum 126 bytes)
-s # SSL on

#默认是前台运行这个语句,一旦断开,就连接不上了,可以使用screen后台运行

#查询在线设备列表
[root@admin rtty]# curl http://192.168.1.129/devs
[{“id”:”192_168_1_104″,”uptime”:126,”description”:”本地测试”}]
[root@admin rtty]#

#嵌入式Linux平台,你需要自行交叉编译
#如何在OpenWRT中使用
#安装
opkg update
opkg list | grep rtty
opkg install rtty-nossl
#如果安装失败,你可以自己编译(https://gitee.com/zhaojh329/rtty/blob/master/BUILDOPENWRT_ZH.md)。
#配置服务器参数
uci add rtty rtty # If it’s the first configuration
uci set rtty.@rtty[0].host=’your server host’
uci set rtty.@rtty[0].port=’your server port’
#你可以给你的设备自定义一个ID。如果未指定,RTTY将使用指定的网络接口的MAC地址作为其ID,以MAC地址作为ID的格式为:1A2A3A4A5A6A
uci set rtty.@rtty[0].id=’your-device-id’
#保存配置并应用
uci commit
/etc/init.d/rtty restart

#如何使用
#1.使用你的Web浏览器访问你的服务器:
http://192.168.1.129/,然后点击connect按钮。
#2.你可以非常方便的将RTTY嵌入到你现有的平台(未测试通过):
http://192.168.1.129/?id=192_168_1_104
#3.自动登录(未测试通过):
http://192.168.1.129/?id=192_168_1_104&username=admin&password=123456
#上传文件和下载文件
#使用快捷键打开菜单(登录服务器以后起作用):
Ctrl+Shift+f

发表评论