github.com/jlevesy/mattermost-server@v5.3.2-0.20181003190404-7468f35cb0c8+incompatible/cmd/mattermost/commands/init.go (about) 1 // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package commands 5 6 import ( 7 "github.com/mattermost/mattermost-server/app" 8 "github.com/mattermost/mattermost-server/model" 9 "github.com/mattermost/mattermost-server/utils" 10 "github.com/spf13/cobra" 11 ) 12 13 func InitDBCommandContextCobra(command *cobra.Command) (*app.App, error) { 14 config, err := command.Flags().GetString("config") 15 if err != nil { 16 return nil, err 17 } 18 19 a, err := InitDBCommandContext(config) 20 21 if err != nil { 22 // Returning an error just prints the usage message, so actually panic 23 panic(err) 24 } 25 26 a.InitPlugins(*a.Config().PluginSettings.Directory, *a.Config().PluginSettings.ClientDirectory) 27 a.DoAdvancedPermissionsMigration() 28 a.DoEmojisPermissionsMigration() 29 30 return a, nil 31 } 32 33 func InitDBCommandContext(configFileLocation string) (*app.App, error) { 34 if err := utils.TranslationsPreInit(); err != nil { 35 return nil, err 36 } 37 model.AppErrorInit(utils.T) 38 39 a, err := app.New(app.ConfigFile(configFileLocation)) 40 if err != nil { 41 return nil, err 42 } 43 44 if model.BuildEnterpriseReady == "true" { 45 a.LoadLicense() 46 } 47 48 return a, nil 49 }