-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb.go
More file actions
37 lines (28 loc) · 763 Bytes
/
web.go
File metadata and controls
37 lines (28 loc) · 763 Bytes
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
package main
import (
"./downloader"
"fmt"
"os"
"path/filepath"
)
const webURL string = "https://github.com/bsep/server-web/archive/master.zip"
func initWeb() {
app_path, err := downloader.GetAppPath()
if err != nil {
errorAndExit(err, 2)
}
if _, err := os.Stat(filepath.Join(app_path, "public/index.html")); os.IsNotExist(err) {
public_path := filepath.Join(app_path, "public")
if err := os.Mkdir(public_path, os.ModeDir|os.ModePerm); os.IsPermission(err) {
errorAndExit(err, 3)
}
fmt.Println("Downloading web files")
tmp_path, err := downloader.Download(webURL)
if err != nil {
errorAndExit(err, 4)
}
if err := downloader.Unzip(tmp_path, public_path, "server-web-master/"); err != nil {
errorAndExit(err, 5)
}
}
}