| 1 | // Package main implements fs-repo-16-to-17 migration for IPFS repositories. |
| 2 | // |
| 3 | // This migration transitions repositories from version 16 to 17, introducing |
| 4 | // the AutoConf system that replaces hardcoded network defaults with dynamic |
| 5 | // configuration fetched from autoconf.json. |
| 6 | // |
| 7 | // Changes made: |
| 8 | // - Enables AutoConf system with default settings |
| 9 | // - Migrates default bootstrap peers to "auto" sentinel value |
| 10 | // - Sets DNS.Resolvers["."] to "auto" for dynamic DNS resolver configuration |
| 11 | // - Migrates Routing.DelegatedRouters to ["auto"] |
| 12 | // - Migrates Ipns.DelegatedPublishers to ["auto"] |
| 13 | // - Preserves user customizations (custom bootstrap peers, DNS resolvers) |
| 14 | // |
| 15 | // The migration is reversible and creates config.16-to-17.bak for rollback. |
| 16 | // |
| 17 | // Usage: |
| 18 | // |
| 19 | // fs-repo-16-to-17 -path /path/to/ipfs/repo [-verbose] [-revert] |
| 20 | // |
| 21 | // This migration is embedded in Kubo starting from version 0.37 and runs |
| 22 | // automatically during daemon startup. This standalone binary is provided |
| 23 | // for manual migration scenarios. |
| 24 | package main |
| 25 | |
| 26 | import ( |
| 27 | "flag" |
| 28 | "fmt" |
| 29 | "os" |
| 30 | |
| 31 | "github.com/ipfs/kubo/repo/fsrepo/migrations/common" |
| 32 | mg16 "github.com/ipfs/kubo/repo/fsrepo/migrations/fs-repo-16-to-17/migration" |
| 33 | ) |
| 34 | |
| 35 | func main() { |
| 36 | var path = flag.String("path", "", "Path to IPFS repository") |
| 37 | var verbose = flag.Bool("verbose", false, "Enable verbose output") |
| 38 | var revert = flag.Bool("revert", false, "Revert migration") |
| 39 | flag.Parse() |
| 40 | |
| 41 | if *path == "" { |
| 42 | fmt.Fprintf(os.Stderr, "Error: -path flag is required\n") |
| 43 | flag.Usage() |
| 44 | os.Exit(1) |
| 45 | } |
| 46 | |
| 47 | opts := common.Options{ |
| 48 | Path: *path, |
| 49 | Verbose: *verbose, |
| 50 | } |
| 51 | |
| 52 | var err error |
| 53 | if *revert { |
| 54 | err = mg16.Migration.Revert(opts) |
| 55 | } else { |
| 56 | err = mg16.Migration.Apply(opts) |
| 57 | } |
| 58 | |
| 59 | if err != nil { |
| 60 | fmt.Fprintf(os.Stderr, "Migration failed: %v\n", err) |
| 61 | os.Exit(1) |
| 62 | } |
| 63 | } |