mirror of
https://github.com/qdm12/gluetun.git
synced 2026-07-23 19:06:26 +02:00
d9cc7dcffb
- new directory structure containing manifest.json and one json file per provider, by default. - the manifest.json file can specify a filepath for each vpn provider - each vpn provider json data file can contain the `"preferred": true` field to enforce it is used even if outdated, unless there is a version mismatch - `STORAGE_SERVERS_DIRECTORY_PATH` replaces `STORAGE_FILEPATH` (which is now a migration source only). It sets the directory where server manifest and per-provider JSON files are stored (default: `/gluetun/servers/`). - First-run migration: On startup, gluetun checks for the old /gluetun/servers.json file; if found and no new manifest exists, it automatically migrates all data to /gluetun/servers/ directory structure - Silent fallback: If legacy file isn't found, uses the new directory path normally - Legacy cleanup: After successful migration, attempts to remove the old fat JSON file (logs warning only if removal fails, e.g., read-only bind mounts)
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"net/http"
|
|
"os"
|
|
"path/filepath"
|
|
"time"
|
|
|
|
"github.com/qdm12/gluetun-servers/pkg/updaters"
|
|
"github.com/qdm12/log"
|
|
)
|
|
|
|
func main() {
|
|
defaultOutputDir := filepath.Join("pkg", "servers")
|
|
outputDir := flag.String("output-dir", defaultOutputDir,
|
|
"directory to write per-provider JSON files to")
|
|
protonEmail := flag.String("proton-email", os.Getenv("GLUETUN_PROTON_EMAIL"),
|
|
"ProtonVPN account email")
|
|
protonPassword := flag.String("proton-password", os.Getenv("GLUETUN_PROTON_PASSWORD"),
|
|
"ProtonVPN account password")
|
|
ipinfoToken := flag.String("ipinfo-token", os.Getenv("IPINFO_TOKEN"),
|
|
"IPInfo token used for public IP lookups")
|
|
flag.Parse()
|
|
|
|
client := &http.Client{Timeout: time.Minute}
|
|
settings := updaters.UpdateAllSettings{
|
|
OutputPath: outputDir,
|
|
ProtonEmail: protonEmail,
|
|
ProtonPassword: protonPassword,
|
|
IpinfoToken: ipinfoToken,
|
|
}
|
|
|
|
logger := log.New()
|
|
err := updaters.UpdateAll(context.Background(), client, logger, settings)
|
|
if err != nil {
|
|
logger.Errorf("update failed: %v", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
logger.Infof("update completed successfully, data files written to %s", *outputDir)
|
|
}
|