Skip to content

Commit

Permalink
Add a cut-down version of the sync-site binary
Browse files Browse the repository at this point in the history
  • Loading branch information
Karl Hepworth committed Jul 5, 2017
1 parent 02320ac commit a16adb7
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions cmd/yoink-sync-remote-site/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package main

import (
"flag"
log "github.com/Sirupsen/logrus"
"github.com/fubarhouse/golang-drush/command"
"os"
"strings"
)

func main() {

var SourceAlias = flag.String("source-alias", "", "Alias of source site")
var DestAlias = flag.String("dest-alias", "", "Alias of destination site")
var Forbidden = flag.String("forbid", "", "For automation/security purposes, do not allow destination aliases to contain this string.")
var SyncDB = flag.Bool("db", false, "Mark database for synchronization")
var SyncFiles = flag.Bool("files", false, "Mark files for synchronization")

flag.Parse()

if *SourceAlias == "" {
log.Infoln("Source input is empty")
}
if *DestAlias == "" {
log.Infoln("Destination input is empty")
}
if !*SyncDB {
log.Infoln("Database flag is switched off")
}
if !*SyncFiles {
log.Infoln("Files flag is switched off")
}

if *SourceAlias == "" || *DestAlias == "" {
flag.Usage()
os.Exit(1)
}

if *SyncDB {
log.Infoln("Database was marked for syncing, working now...")
if !strings.Contains(*DestAlias, *Forbidden) {
command.DrushDatabaseSync(*SourceAlias, *DestAlias)
} else {
log.Errorln("Destination alias contains a forbidden string")
}
}
if *SyncFiles {
log.Infoln("Files were marked for syncing, working now...")
if !strings.Contains(*DestAlias, *Forbidden) {
command.DrushFilesSync(*SourceAlias, *DestAlias)
} else {
log.Errorln("Destination alias contains a forbidden string")
}
}
if *SyncDB || *SyncFiles {
log.Infoln("Attempting to rebuild registries...")
command.DrushRebuildRegistry(*DestAlias)
}
}

0 comments on commit a16adb7

Please sign in to comment.