forked from x/ContextOS
mac opt ssh.send
This commit is contained in:
parent
15d4da1b18
commit
0a01fe3f0c
@ -127,6 +127,7 @@ set keywordprg=man\ -a
|
|||||||
autocmd BufNewFile,BufReadPost *.shy set filetype=shy
|
autocmd BufNewFile,BufReadPost *.shy set filetype=shy
|
||||||
autocmd BufNewFile,BufReadPost *.shy set commentstring=#%s
|
autocmd BufNewFile,BufReadPost *.shy set commentstring=#%s
|
||||||
autocmd BufNewFile,BufReadPost *.conf set filetype=nginx
|
autocmd BufNewFile,BufReadPost *.conf set filetype=nginx
|
||||||
|
autocmd BufNewFile,BufReadPost *.go set foldmethod=syntax
|
||||||
|
|
||||||
command! RR wa | source ~/.vimrc |e
|
command! RR wa | source ~/.vimrc |e
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ ZSH_THEME="robbyrussell"
|
|||||||
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
|
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
|
||||||
# Example format: plugins=(rails git textmate ruby lighthouse)
|
# Example format: plugins=(rails git textmate ruby lighthouse)
|
||||||
# Add wisely, as too many plugins slow down shell startup.
|
# Add wisely, as too many plugins slow down shell startup.
|
||||||
plugins=(tmux git)
|
plugins=(tmux docker git)
|
||||||
|
|
||||||
source $ZSH/oh-my-zsh.sh
|
source $ZSH/oh-my-zsh.sh
|
||||||
source ~/.oh-my-zsh/plugins/z/z.sh
|
source ~/.oh-my-zsh/plugins/z/z.sh
|
||||||
|
@ -100,7 +100,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
if _, ok := m.Target().Server.(*SSH); m.Assert(ok) {
|
if _, ok := m.Target().Server.(*SSH); m.Assert(ok) {
|
||||||
m.Sess("nfs").Call(func(sub *ctx.Message) *ctx.Message {
|
m.Sess("nfs").Call(func(sub *ctx.Message) *ctx.Message {
|
||||||
sub.Start(fmt.Sprintf("host%d", Pulse.Capi("nhost", 1)), "远程主机")
|
sub.Start(fmt.Sprintf("host%d", Pulse.Capi("nhost", 1)), "远程主机")
|
||||||
// sub.Spawn().Cmd("pwd", "init")
|
sub.Spawn().Cmd("pwd", "")
|
||||||
return sub
|
return sub
|
||||||
}, m.Meta["detail"])
|
}, m.Meta["detail"])
|
||||||
if !m.Caps("domain") {
|
if !m.Caps("domain") {
|
||||||
@ -123,9 +123,18 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
domain := ""
|
domain := ""
|
||||||
if len(arg) > 1 && arg[0] == "domain" {
|
if len(arg) > 1 && arg[0] == "domain" {
|
||||||
domain, arg = arg[1], arg[2:]
|
domain, arg = arg[1], arg[2:]
|
||||||
domain = strings.TrimPrefix(strings.TrimPrefix(domain, m.Cap("domain")), ".")
|
if d := strings.TrimPrefix(domain, m.Cap("domain")); len(d) > 0 && d[0] == '.' {
|
||||||
|
domain = d[1:]
|
||||||
|
} else if d == "" {
|
||||||
|
domain = d
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if domain == "" {
|
||||||
|
msg := m.Spawn().Cmd(arg)
|
||||||
|
m.Copy(msg, "result").Copy(msg, "append")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if m.Has("send_code") {
|
if m.Has("send_code") {
|
||||||
msg := m.Spawn().Cmd(arg)
|
msg := m.Spawn().Cmd(arg)
|
||||||
m.Copy(msg, "result").Copy(msg, "append")
|
m.Copy(msg, "result").Copy(msg, "append")
|
||||||
@ -133,11 +142,43 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
msg := m.Spawn(ssh.Message().Source())
|
msg := m.Spawn(ssh.Message().Source())
|
||||||
msg.Cmd("send", arg)
|
msg.Cmd("send", arg)
|
||||||
m.Copy(msg, "result").Copy(msg, "append")
|
m.Copy(msg, "result").Copy(msg, "append")
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
miss := true
|
||||||
|
host := strings.SplitN(domain, ".", 2)
|
||||||
|
m.Travel(func(m *ctx.Message, i int) bool {
|
||||||
|
if i == 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if m.Cap("hostname") == host[0] {
|
||||||
|
if len(host) > 1 {
|
||||||
|
ssh, ok := m.Target().Server.(*SSH)
|
||||||
|
m.Assert(ok)
|
||||||
|
|
||||||
|
msg := m.Spawn(ssh.Message().Source())
|
||||||
|
msg.Cmd("send", "domain", host[1], arg)
|
||||||
|
m.Copy(msg, "result").Copy(msg, "append")
|
||||||
|
} else {
|
||||||
|
msg := m.Spawn()
|
||||||
|
msg.Cmd("send", arg)
|
||||||
|
m.Copy(msg, "result").Copy(msg, "append")
|
||||||
|
}
|
||||||
|
|
||||||
|
miss = false
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}, c)
|
||||||
|
|
||||||
|
if miss {
|
||||||
|
msg := m.Spawn(c.Message().Source())
|
||||||
|
msg.Cmd("send", "domain", domain, arg)
|
||||||
|
m.Copy(msg, "result").Copy(msg, "append")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
if domain != "" {
|
if domain != "" {
|
||||||
domain_miss := true
|
domain_miss := true
|
||||||
host := strings.SplitN(domain, ".", 2)
|
host := strings.SplitN(domain, ".", 2)
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"contexts"
|
"contexts"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -20,7 +21,9 @@ func (tcp *TCP) Read(b []byte) (n int, e error) {
|
|||||||
m.Assert(tcp.Conn != nil)
|
m.Assert(tcp.Conn != nil)
|
||||||
n, e = tcp.Conn.Read(b)
|
n, e = tcp.Conn.Read(b)
|
||||||
m.Capi("nrecv", n)
|
m.Capi("nrecv", n)
|
||||||
|
if e != io.EOF {
|
||||||
m.Assert(e)
|
m.Assert(e)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func (tcp *TCP) Write(b []byte) (n int, e error) {
|
func (tcp *TCP) Write(b []byte) (n int, e error) {
|
||||||
@ -28,7 +31,9 @@ func (tcp *TCP) Write(b []byte) (n int, e error) {
|
|||||||
m.Assert(tcp.Conn != nil)
|
m.Assert(tcp.Conn != nil)
|
||||||
n, e = tcp.Conn.Write(b)
|
n, e = tcp.Conn.Write(b)
|
||||||
m.Capi("nsend", n)
|
m.Capi("nsend", n)
|
||||||
|
if e != io.EOF {
|
||||||
m.Assert(e)
|
m.Assert(e)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user