-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
65 lines (53 loc) · 1.46 KB
/
Copy pathmain.go
File metadata and controls
65 lines (53 loc) · 1.46 KB
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
package main
import (
"flag"
"log"
"os"
"strconv"
"time"
"github.com/vanilla-os/Hermes/pkg/downloader"
"github.com/vanilla-os/Hermes/pkg/utils"
)
func main() {
var (
interval int
releaseIndex string
codename string
root string
)
flag.IntVar(&interval, "interval", 0, "time interval in minutes")
flag.StringVar(&releaseIndex, "releaseIndex", "", "JSON link to use for the instance")
flag.StringVar(&codename, "codename", "", "codename to use for the path")
flag.StringVar(&root, "root", "", "root of builds")
flag.Parse()
if interval == 0 {
intervalEnv := os.Getenv("HERMES_INTERVAL")
if intervalEnv != "" {
intervalParsed, err := strconv.Atoi(intervalEnv)
if err != nil {
log.Fatalf("invalid value for HERMES_INTERVAL: %v", err)
}
interval = intervalParsed
}
}
if releaseIndex == "" {
releaseIndex = os.Getenv("HERMES_RELEASE_INDEX")
}
if codename == "" {
codename = os.Getenv("HERMES_CODENAME")
}
if root == "" {
root = os.Getenv("HERMES_ROOT")
}
if interval == 0 || releaseIndex == "" || codename == "" || root == "" {
log.Fatalf("all flags or environment variables must be set. usage: -interval=30 -releaseIndex=<URL> -codename=<name> -root=<path>")
}
buildsPath := utils.GetBuildsPath(root, codename)
utils.CreateDir(buildsPath)
ticker := time.NewTicker(time.Duration(interval) * time.Minute)
defer ticker.Stop()
for {
downloader.CheckForNewRelease(releaseIndex, buildsPath)
<-ticker.C
}
}