Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
chain33-pai
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ligaishun
chain33-pai
Commits
3a943f59
Commit
3a943f59
authored
Nov 08, 2019
by
szh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
up
parent
e3111040
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
111 deletions
+26
-111
auto.sh
auto.sh
+14
-0
main1.go1
main1.go1
+0
-111
start.sh
start.sh
+4
-0
startup.sh
startup.sh
+8
-0
No files found.
auto.sh
0 → 100644
View file @
3a943f59
#!/bin/bash
ss
-tunl
|
grep
8801 &> /dev/null
Z
=
`
echo
$?
`
if
[[
$Z
!=
0
]]
;
then
S
=
`
find /media
-name
"v7-bityuan"
`
if
[[
"
$S
"
!=
""
]]
;
then
echo
"v7-bituan is starting"
nohup
$S
&
fi
else
echo
"v7-bityuan is running"
fi
main1.go1
deleted
100644 → 0
View file @
e3111040
package
main
import
(
"os/exec"
"fmt"
"io/ioutil"
"net"
"errors"
"net/http"
"bufio"
"io"
"strings"
)
var
cache
map
[
string
]
string
func
init
()
{
cache
=
make
(
map
[
string
]
string
,
0
)
getPaiConfig
(
"cat"
,
"/proc/cpuinfo"
)
getLocalIP
()
getExternalIp
()
}
func
main
()
{
fmt
.
Println
(
"cache"
,
cache
)
}
func
getPaiConfig
(
command
string
,
arg
...
string
)
(
config
map
[
string
]
string
,
err
error
)
{
//
获取操作系统版本信息
if
_
,
ok
:=
cache
[
"serial"
];
ok
{
return
cache
,
nil
}
list
:=
make
(
map
[
string
]
string
,
0
)
cmd
:=
exec
.
Command
(
"cat"
,
arg
...)
stdout
,
err
:=
cmd
.
StdoutPipe
()
//
fmt
.
Println
(
stdout
)
if
err
!= nil {
fmt
.
Println
(
err
)
return
nil
,
err
}
defer
stdout
.
Close
()
if
err
:=
cmd
.
Start
();
err
!= nil {
fmt
.
Println
(
err
)
return
nil
,
err
}
rd
:=
bufio
.
NewReader
(
stdout
)
for
{
line
,
err
:=
rd
.
ReadString
(
'\n'
)
if
err
!=nil || io.EOF==err{
break
}
else
{
fmt
.
Println
(
"line"
,
line
)
l
:=
strings
.
Split
(
line
,
":"
)
if
len
(
l
)
==
2
{
k
:=
strings
.
ToLower
(
strings
.
TrimRight
(
strings
.
Trim
(
strings
.
Replace
(
l
[
0
],
" "
,
" "
,-
1
),
" "
),
" "
))
v
:=
strings
.
Trim
(
strings
.
Replace
(
l
[
1
],
"
\n
"
,
""
,-
1
),
" "
)
fmt
.
Println
(
"KEY:"
,
k
,
"VAL:"
,
v
)
if
_
,
ok
:=
list
[
k
];
!ok {
list
[
k
]
=
v
}
cache
[
k
]
=
v
}
}
}
return
list
,
nil
}
//
获取本机网卡
IP
func
getLocalIP
()
(
ipv4
string
,
err
error
)
{
var
(
addrs
[]
net
.
Addr
addr
net
.
Addr
ipNet
*
net
.
IPNet
//
IP
地址
isIpNet
bool
)
//
获取所有网卡
if
addrs
,
err
=
net
.
InterfaceAddrs
();
err
!= nil {
return
}
//
取第一个非
lo
的网卡
IP
for
_
,
addr
=
range
addrs
{
//
这个网络地址是
IP
地址
:
ipv4
,
ipv6
if
ipNet
,
isIpNet
=
addr
.(*
net
.
IPNet
);
isIpNet
&&
!ipNet.IP.IsLoopback() {
//
跳过
IPV6
if
ipNet
.
IP
.
To4
()
!= nil {
ipv4
=
ipNet
.
IP
.
String
()
//
192.168.1.1
cache
[
"localIp"
]
=
ipv4
return
}
}
}
err
=
errors
.
New
(
"ERR_NO_LOCAL_IP_FOUND"
)
return
}
func
getExternalIp
()
(
ipv4
string
,
err
error
)
{
resp
,
err
:=
http
.
Get
(
"http://myexternalip.com/raw"
)
if
err
!= nil {
return
""
,
err
}
defer
resp
.
Body
.
Close
()
content
,
_
:=
ioutil
.
ReadAll
(
resp
.
Body
)
ipv4
=
string
(
content
)
cache
[
"externalIp"
]
=
ipv4
fmt
.
Println
(
"ext"
,
ipv4
)
return
}
start.sh
0 → 100644
View file @
3a943f59
#!/bin/sh
cd
/home/pi/chain33-pai
chmod
+x chain33-pai
./chain33-pai &
startup.sh
0 → 100644
View file @
3a943f59
#!/bin/bash
ss
-tunl
|
grep
8803 &> /dev/null
T
=
`
echo
$?
`
if
[[
$T
!=
0
]]
;
then
nohup
/home/pi/chain33-pai/start.sh &>/home/pi/chain33-pai/chain33.out &
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment