-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
133 lines (128 loc) · 2.63 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package main
import (
"fmt"
"os"
"runtime"
"github.com/rinetd/drone-rsync/cmd"
"github.com/urfave/cli"
)
var Version string = fmt.Sprintf("1.0.2")
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
app := cli.NewApp()
app.Name = "Drone-rsync"
app.Usage = "Rsync to Remote Hosts"
app.Copyright = "Copyright (c) 2017 rinetd"
app.Authors = []cli.Author{
{
Name: "rinetd",
Email: "[email protected]",
},
}
app.Action = cmd.Run
app.Version = Version
app.Flags = []cli.Flag{
cli.StringSliceFlag{
Name: "hosts,host,H",
Usage: "connect to host",
EnvVar: "PLUGIN_HOSTS",
},
cli.StringFlag{
Name: "port,p",
Usage: "connect to port ",
EnvVar: "PLUGIN_PORT",
Value: "22",
},
cli.StringFlag{
Name: "username,user,u",
Usage: "connect as user ",
EnvVar: "PLUGIN_USERNAME,PLUGIN_USER",
Value: "root",
},
cli.StringFlag{
Name: "ssh-key,key",
Usage: "private ssh key",
EnvVar: "PLUGIN_SSH_KEY,PLUGIN_KEY",
},
cli.StringFlag{
Name: "password,P",
Usage: "user password",
EnvVar: "PLUGIN_PASSWORD",
},
cli.StringFlag{
Name: "source",
Usage: "source",
EnvVar: "PLUGIN_SOURCE",
Value: ".",
},
cli.StringFlag{
Name: "target",
Usage: "target",
EnvVar: "PLUGIN_TARGET",
},
cli.StringSliceFlag{
Name: "args",
Usage: "args commands",
EnvVar: "PLUGIN_ARGS",
},
cli.BoolFlag{
Name: "recursive",
Usage: "recursive mode",
EnvVar: "PLUGIN_RECURSIVE",
},
cli.BoolFlag{
Name: "delete",
Usage: "delete mode",
EnvVar: "PLUGIN_DELETE",
},
cli.BoolFlag{
Name: "sync",
Usage: "sync mode",
EnvVar: "PLUGIN_SYNC",
},
cli.StringFlag{
Name: "chmod",
Usage: "chmod commands",
EnvVar: "PLUGIN_CHMOD",
},
cli.StringFlag{
Name: "verbose",
Usage: "verbose -q -v -vv -vvv",
EnvVar: "PLUGIN_VERBOSE",
},
cli.StringFlag{
Name: "chown",
Usage: "chown commands",
EnvVar: "PLUGIN_CHOWN",
},
cli.StringSliceFlag{
Name: "include",
Usage: "include commands",
EnvVar: "PLUGIN_INCLUDE",
},
cli.StringSliceFlag{
Name: "exclude",
Usage: "exclude commands",
EnvVar: "PLUGIN_EXCLUDE",
},
cli.StringSliceFlag{
Name: "filter",
Usage: "filter commands",
EnvVar: "PLUGIN_FILTER",
},
cli.StringSliceFlag{
Name: "export",
Usage: "export envirment to remote hosts",
EnvVar: "PLUGIN_EXPORT",
},
cli.StringFlag{
Name: "scripts,script,s",
Usage: "execute commands",
EnvVar: "PLUGIN_SCRIPTS,PLUGIN_SCRIPT",
},
}
if err := app.Run(os.Args); err != nil {
fmt.Println("drone-rsync error: ", err)
os.Exit(1)
}
}