spire/spire.go

48 lines
741 B
Go
Raw Normal View History

2024-09-13 18:53:05 -03:00
package main
2024-09-19 22:22:49 -03:00
import (
"fmt"
"os"
"time"
)
2024-09-19 22:28:17 -03:00
const (
TMPDIR = "/tmp/spire"
PAYLOAD = TMPDIR + "/payload.json"
)
2024-09-13 18:53:05 -03:00
2024-09-20 14:53:18 -03:00
var GAME_LOCATION = os.Getenv("GAME_PATH")
2024-09-13 18:53:05 -03:00
func main() {
2024-09-20 14:53:18 -03:00
getCache()
2024-09-19 22:22:49 -03:00
}
2024-09-20 14:53:18 -03:00
func getCache() error {
2024-09-19 22:22:49 -03:00
info, err := os.Stat(PAYLOAD)
if err != nil {
fmt.Println("payload isn't accessible, requesting")
2024-09-20 14:53:18 -03:00
DownloadCache()
2024-09-19 22:22:49 -03:00
} else if !(info.ModTime().After(time.Now().Add(-2 * time.Hour))) {
2024-09-20 14:53:18 -03:00
// download again if payload is older than 2 hours
DownloadCache()
2024-09-19 22:22:49 -03:00
} else {
fmt.Println("payload was updated recently, won't update")
}
return nil
}
2024-09-20 14:53:18 -03:00
func installBepinex() error {
_, err := os.Stat(GAME_LOCATION + "/BepInEx")
2024-09-19 22:22:49 -03:00
if err != nil {
2024-09-20 14:53:18 -03:00
// install bepinex
2024-09-19 22:22:49 -03:00
2024-09-20 14:53:18 -03:00
} else {
// bepinex already installed
2024-09-19 22:22:49 -03:00
}
return nil
2024-09-13 18:53:05 -03:00
}