-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.go
83 lines (67 loc) · 1.45 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
package main
import (
"flag"
"fmt"
"time"
"github.com/pritunl/pritunl-endpoint/check"
"github.com/pritunl/pritunl-endpoint/config"
"github.com/pritunl/pritunl-endpoint/constants"
"github.com/pritunl/pritunl-endpoint/disk"
"github.com/pritunl/pritunl-endpoint/diskio"
"github.com/pritunl/pritunl-endpoint/endpoint"
"github.com/pritunl/pritunl-endpoint/input"
"github.com/pritunl/pritunl-endpoint/kmsg"
"github.com/pritunl/pritunl-endpoint/load"
"github.com/pritunl/pritunl-endpoint/logger"
"github.com/pritunl/pritunl-endpoint/network"
"github.com/pritunl/pritunl-endpoint/system"
)
const help = `
Usage: pritunl-endpoint COMMAND
Commands:
version Show version
start Start endpoint service
register Get default administrator password
`
func main() {
defer time.Sleep(500 * time.Millisecond)
flag.Usage = func() {
fmt.Println(help)
}
flag.Parse()
logger.Init()
switch flag.Arg(0) {
case "start":
err := config.Init()
if err != nil {
panic(err)
}
err = endpoint.Init()
if err != nil {
panic(err)
}
system.Register()
load.Register()
disk.Register()
diskio.Register()
network.Register()
kmsg.Register()
check.Register()
input.Run()
return
case "version":
fmt.Printf("pritunl-endpoint v%s\n", constants.Version)
return
case "register":
err := config.Init()
if err != nil {
panic(err)
}
err = endpoint.RegisterCmd()
if err != nil {
panic(err)
}
return
}
fmt.Println(help)
}