diff --git a/main.go b/main.go index 0fafdee..f91ee4d 100644 --- a/main.go +++ b/main.go @@ -39,13 +39,18 @@ const ( cacheFile = "public/romcache.json" // persistence between server restarts so we don't have to rehash all the ROM files each time the program starts ) -var ( // evil global variable +var ( // evil global variables romCache ROMCache + baseURL string ) func init() { // intialize and load ROMCache from file - so we don't have to rehash all the big files again romCache = ROMCache{} + baseURL = os.Getenv("baseurl") + if len(baseURL) < 1 { + log.Fatalf("required environment variable 'baseurl' is not set.") + } romCacheJson, err := os.ReadFile(cacheFile) if err != nil { @@ -140,7 +145,7 @@ func updateROMCache() { ID: fileHash, Romtype: splitName[3], // UNOFFICIAL Size: int(fInfo.Size()), - URL: fmt.Sprintf("https://lineageos-ota.deadbeef.codes/public/%s", v.Name()), + URL: fmt.Sprintf("%s/public/%s", baseURL, v.Name()), Version: splitName[1], }