forked from d3vilh/openvpn-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (33 loc) · 1.11 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
package main
import (
"flag"
"fmt"
"path/filepath"
"github.com/beego/beego/v2/server/web"
"github.com/d3vilh/openvpn-ui/lib"
"github.com/d3vilh/openvpn-ui/models"
"github.com/d3vilh/openvpn-ui/routers"
"github.com/d3vilh/openvpn-ui/state"
)
func main() {
configDir := flag.String("config", "conf", "Path to config dir")
flag.Parse()
configFile := filepath.Join(*configDir, "app.conf")
fmt.Println("Config file:", configFile)
if err := web.LoadAppConfig("ini", configFile); err != nil {
panic(err)
}
models.InitDB()
models.CreateDefaultUsers()
defaultSettings, err := models.CreateDefaultSettings()
if err != nil {
panic(err)
}
models.CreateDefaultOVConfig(*configDir, defaultSettings.OVConfigPath, defaultSettings.MIAddress, defaultSettings.MINetwork)
models.CreateDefaultOVClientConfig(*configDir, defaultSettings.OVConfigPath, defaultSettings.MIAddress, defaultSettings.MINetwork)
models.CreateDefaultEasyRSAConfig(*configDir, defaultSettings.EasyRSAPath, defaultSettings.MIAddress, defaultSettings.MINetwork)
state.GlobalCfg = *defaultSettings
routers.Init(*configDir)
lib.AddFuncMaps()
web.Run()
}