-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
244 lines (240 loc) · 5.14 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
package main
import (
"log"
"os"
"github.com/urfave/cli"
)
const (
defaultEthernetConfig = "ethernet@%s.json"
defaultWifiClientConfig = "wifi-client@%s.json"
defaultAccessPointConfig = "access-point@%s.json"
defaultFougGConfig = "4g-ndis@%s.json"
defaultThreeGGConfig = "3g-ras@%s.json"
defaultVoiceChanConfig = "voice-channel@%s.json"
)
func main() {
app := cli.NewApp()
app.Version = "0.4.10"
app.Name = "fconf"
app.Usage = "fessbox configuration manager"
app.Commands = []cli.Command{
{
Name: "ethernet",
Aliases: []string{"e"},
Usage: "configures ethernet with systemd",
Flags: []cli.Flag{
cli.StringFlag{
Name: "name",
Usage: "The name of the unit file",
Value: ethernetService,
},
cli.StringFlag{
Name: "dir",
Usage: "The directory in which to write the file",
Value: networkBase,
},
cli.StringFlag{
Name: "config",
Usage: "The path to the json configuration file",
Value: defaultEthernetConfig,
},
cli.BoolFlag{
Name: "enable",
Usage: "Enables ethernet",
},
cli.BoolFlag{
Name: "disable",
Usage: "Disable ethernet",
},
cli.BoolFlag{
Name: "remove",
Usage: "Remove ethernet",
},
},
Action: EthernetCMD,
},
{
Name: "4g-ndis",
Aliases: []string{"4g"},
Usage: "configures 4G with systemd",
Flags: []cli.Flag{
cli.StringFlag{
Name: "name",
Usage: "The name of the unit file",
Value: fourgService,
},
cli.StringFlag{
Name: "dir",
Usage: "The directory in which to write the file",
Value: networkBase,
},
cli.StringFlag{
Name: "config",
Usage: "The path to the json configuration file",
Value: defaultFougGConfig,
},
cli.BoolFlag{
Name: "enable",
Usage: "Enables 4G",
},
cli.BoolFlag{
Name: "disable",
Usage: "Disable 4G",
},
cli.BoolFlag{
Name: "remove",
Usage: "Remove 4G",
},
},
Action: FourgCMD,
},
{
Name: "3g-ras",
Aliases: []string{"3g"},
Usage: "configures 3G ",
Flags: []cli.Flag{
cli.StringFlag{
Name: "name",
Usage: "The name of the config file",
Value: threeGService,
},
cli.StringFlag{
Name: "dir",
Usage: "The directory in which to write the file",
Value: apConfigBase,
},
cli.StringFlag{
Name: "config",
Usage: "The path to the json configuration file",
},
cli.BoolFlag{
Name: "enable",
Usage: "Enables 3G",
},
cli.BoolFlag{
Name: "disable",
Usage: "Disable 3G",
},
cli.BoolFlag{
Name: "remove",
Usage: "Remove 3G",
},
},
Action: ThreegCMD,
},
{
Name: "wifi-client",
Aliases: []string{"w"},
Usage: "configures wifi client with systemd",
Flags: []cli.Flag{
cli.StringFlag{
Name: "name",
Usage: "The name of the unit file",
Value: wirelessService,
},
cli.StringFlag{
Name: "dir",
Usage: "The directory in which to write the file",
Value: networkBase,
},
cli.StringFlag{
Name: "config",
Usage: "The path to the json configuration file",
Value: defaultWifiClientConfig,
},
cli.BoolFlag{
Name: "enable",
Usage: "Enables wifi",
},
cli.BoolFlag{
Name: "disable",
Usage: "Disable wifi",
},
cli.BoolFlag{
Name: "remove",
Usage: "Remove wifi",
},
},
Action: WifiClientCMD,
},
{
Name: "access-point",
Aliases: []string{"a"},
Usage: "configures access point with systemd",
Flags: []cli.Flag{
cli.StringFlag{
Name: "name",
Usage: "The name of the unit file",
Value: apConfigFile,
},
cli.StringFlag{
Name: "dir",
Usage: "The directory in which to write the file",
Value: apConfigBase,
},
cli.StringFlag{
Name: "config",
Usage: "The path to the json configuration file",
Value: defaultAccessPointConfig,
},
cli.BoolFlag{
Name: "enable",
Usage: "Enables access point",
},
cli.BoolFlag{
Name: "disable",
Usage: "Disable access point",
},
cli.BoolFlag{
Name: "remove",
Usage: "Remove access point",
},
},
Action: ApCMD,
},
{
Name: "voice-channel",
Aliases: []string{"v"},
Usage: "configures voice channel for 3g dongle",
Flags: []cli.Flag{
cli.StringFlag{
Name: "config",
Usage: "The path to the json configuration file",
},
cli.BoolFlag{
Name: "enable",
Usage: "Enables access point",
},
cli.BoolFlag{
Name: "disable",
Usage: "Disable access point",
},
cli.BoolFlag{
Name: "remove",
Usage: "Remove access point",
},
},
Action: VoiceChannelCMD,
},
{
Name: "list-interface",
Aliases: []string{"i"},
Usage: "prints a json array of all interfaces",
Action: ListInterface,
},
}
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "interface",
Usage: "the interface",
},
cli.IntFlag{
Name: "pid",
Usage: "process id to send SIGHUP to",
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatalf("fconf: %v", err)
}
}