Skip to content

Commit

Permalink
Small script updates
Browse files Browse the repository at this point in the history
  • Loading branch information
turt2live committed Jul 16, 2023
1 parent f23d6b2 commit 27de3a2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/gdpr_export/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func main() {
return
}

config.Runtime.IsImportProcess = true
config.Runtime.IsImportProcess = true // prevents us from creating media by accident
config.Path = *configPath
assets.SetupMigrations(*migrationsPath)
assets.SetupTemplates(*templatesPath)
Expand Down
8 changes: 7 additions & 1 deletion cmd/gdpr_import/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"errors"
"flag"
"os"
"path"
Expand All @@ -12,6 +13,7 @@ import (
"github.com/turt2live/matrix-media-repo/common/logging"
"github.com/turt2live/matrix-media-repo/common/rcontext"
"github.com/turt2live/matrix-media-repo/common/runtime"
"github.com/turt2live/matrix-media-repo/util/ids"
)

func main() {
Expand All @@ -28,10 +30,14 @@ func main() {
configPath = &configEnv
}

config.Runtime.IsImportProcess = true
config.Runtime.IsImportProcess = true // prevents us from creating media by accident
config.Path = *configPath
assets.SetupMigrations(*migrationsPath)

if ids.GetMachineId() == 0 {
panic(errors.New("expected custom machine ID for import process (unsafe to import as Machine 0)"))
}

var err error
err = logging.Setup(
config.Get().General.LogDirectory,
Expand Down
13 changes: 3 additions & 10 deletions cmd/import_synapse/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/turt2live/matrix-media-repo/common/logging"
"github.com/turt2live/matrix-media-repo/common/rcontext"
"github.com/turt2live/matrix-media-repo/common/runtime"
"github.com/turt2live/matrix-media-repo/common/version"
"github.com/turt2live/matrix-media-repo/database"
"github.com/turt2live/matrix-media-repo/datastores"
"github.com/turt2live/matrix-media-repo/homeserver_interop/synapse"
Expand Down Expand Up @@ -46,20 +45,14 @@ func main() {
configPath = &configEnv
}

version.SetDefaults()
version.Print(true)
config.Runtime.IsImportProcess = true
config.Runtime.IsImportProcess = true // prevents us from creating media by accident
config.Path = *configPath
assets.SetupMigrations(*migrationsPath)

if ids.GetMachineId() == 0 {
_ = os.Setenv("MACHINE_ID", "1023")
if ids.GetMachineId() != 1023 {
panic(errors.New("expected machine ID 1023 or custom ID for import process"))
}
panic(errors.New("expected custom machine ID for import process (unsafe to import as Machine 0)"))
}

assets.SetupMigrations(*migrationsPath)

var realPsqlPassword string
if *postgresPassword == "" {
if !terminal.IsTerminal(int(os.Stdin.Fd())) {
Expand Down

0 comments on commit 27de3a2

Please sign in to comment.