You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: main.go
+47-4Lines changed: 47 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,14 @@ package main
2
2
3
3
import (
4
4
"context"
5
+
"errors"
5
6
"flag"
6
7
"fmt"
7
8
"log"
8
9
"math/rand"
9
10
"net/url"
10
11
"os"
12
+
"os/exec"
11
13
"os/signal"
12
14
"syscall"
13
15
"time"
@@ -21,6 +23,14 @@ type opts struct {
21
23
checkFrequencystring
22
24
destinationDirstring
23
25
runOncebool
26
+
pluginstring
27
+
pluginArgs []string
28
+
}
29
+
30
+
typepluginstruct {
31
+
binPathstring
32
+
namestring
33
+
args []string
24
34
}
25
35
26
36
const (
@@ -33,15 +43,22 @@ func main() {
33
43
34
44
log.Print("gokrazy's selfupdate service starting up..")
35
45
46
+
gokrazy.WaitForClock()
47
+
36
48
varoopts
37
49
38
50
flag.StringVar(&o.gusServer, "gus_server", "", "the HTTP/S endpoint of the GUS (gokrazy Update System) server (required)")
39
51
flag.StringVar(&o.checkFrequency, "check_frequency", "1h", "the time frequency for checks to the update service. The very first check is done on startup. default: 1h")
40
52
flag.StringVar(&o.destinationDir, "destination_dir", "/tmp/selfupdate", "the destination directory for the fetched update file. default: /tmp/selfupdate")
41
53
flag.BoolVar(&o.runOnce, "run_once", false, "exits right after the initial update attempt. default: false")
54
+
flag.StringVar(&o.plugin, "plugin", "", "name of the desired plugin to be loaded (this will be used when needed). default: ''")
42
55
43
56
flag.Parse()
44
57
58
+
// Gather args after flag parsing termination "--".
59
+
// They will be directly passed to the plugin binary.
0 commit comments