-
Notifications
You must be signed in to change notification settings - Fork 0
/
launcher.go
29 lines (24 loc) · 843 Bytes
/
launcher.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
package main
import "os"
import "fmt"
import "runtime"
import "path/filepath"
import "github.com/tidwall/gjson"
func LauncherUpdate() {
expath, _ := filepath.Abs(os.Args[0])
local_sum := Sha256Sum(expath)
remote_sum := gjson.Get(GetRemoteText("https://mcboop.boops.org/McBoop/McBoop.json"), runtime.GOOS).String()
// Auto clean old binary if there
if runtime.GOOS == "windows" && CheckForFile(expath + ".old") {
os.RemoveAll(expath + ".old")
}
if local_sum != remote_sum {
fmt.Println("A launcher update has been found and will now be downloaded")
if runtime.GOOS == "windows" {
os.Rename(expath, expath + ".old")
}
WriteFile(ReadRemote("https://mcboop.boops.org/McBoop/" + filepath.Base(expath)), expath)
fmt.Println("Update done, re-run your last command and enjoy! :)")
os.Exit(0)
}
}