cmd

package
v4.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2024 License: AGPL-3.0 Imports: 115 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvPrefixOld = "pydio"
	EnvPrefixNew = "cells"
)
View Source
const (
	EnvDisplayHiddenFlags = "CELLS_DISPLAY_HIDDEN_FLAGS"
)

Variables

View Source
var AclCmd = &cobra.Command{
	Use:   "acl",
	Short: "Manage access control lists",
	Long: `
DESCRIPTION

  ACLs are managed in a dedicated microservice.

  It is simpler to manage them in the frontend, but you can use this command to create/delete/search ACLs directly.
  ACLs are used to grant permissions to a given node (retrieved by UUID) for a given Role.
`,
	Run: func(cmd *cobra.Command, args []string) {
		cmd.Help()
	},
}

AclCmd represents the acl command

View Source
var AdminCmd = &cobra.Command{
	Use:   "admin",
	Short: "Direct Read/Write access to Cells data",
	Long: `
DESCRIPTION

  Set of commands with direct access to Cells data.
	
  These commands require a running Cells instance. They connect directly to low-level services
  using gRPC connections. They are not authenticated.
`,
	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {

		bindViperFlags(cmd.Flags())

		_, _, er := initConfig(cmd.Context(), true)

		return er
	},
	Run: func(cmd *cobra.Command, args []string) {
		cmd.Help()
	},
}

AdminCmd groups the data manipulation commands The sub-commands are connecting via gRPC to a **running** Cells instance.

View Source
var CertCmd = &cobra.Command{
	Use:   "cert",
	Short: "Certification manager",
	Long: `
DESCRIPTION

  Set of commands providing programmatic access to stored certificates.

`,
	Run: func(cmd *cobra.Command, args []string) {
		cmd.Help()
	},
}

CertCmd represents the certs command

View Source
var CleanCmd = &cobra.Command{
	Use: "clean",
	Run: func(cmd *cobra.Command, args []string) {
		cmd.Help()
	},
	Short: "Housekeeping commands",
	Long:  "Collection of tools for purging Cells internal data (activities, logs, etc)",
}
View Source
var ConfigCmd = &cobra.Command{
	Use:   "config",
	Short: "Configuration manager",
	Long: `
DESCRIPTION

  Set of commands providing programmatic access to stored configuration.

`,
	Run: func(cmd *cobra.Command, args []string) {
		cmd.Help()
	},
}

ConfigCmd represents the config command

View Source
var ConfigureCmd = &cobra.Command{
	Use:     "configure",
	Aliases: []string{"install"},
	Short:   "Setup required configurations",
	Long: `
DESCRIPTION

  Launch the configuration process of Pydio Cells.

REQUIREMENTS

  You must have an available MySQL database, along with a privileged user (for instance 'pydio').
  Supported databases are:
   - MariaDB version 10.3 and above,
   - MySQL version 5.7 and above (except 8.0.22 that has a bug preventing Cells to run correctly).

  As recommended by database documentation, tune the 'max_connections' parameter to a value in line
  with your production database server specifications. For reference, the default value of 151 will have a 
  maximum memory usage of about 575MB, but will not scale up for a multiple users load in production.

BROWSER-BASED INSTALLER

  If you are on a desktop machine, pick browser-based installation at first prompt, or you can force it with:
  $ ` + os.Args[0] + ` configure --bind default
 
  The installer opens a web page on port 8080 with a wizard for you to provide various configuration parameters, 
  including DB connection info and the login/password of the main administrator.

  In case where default port is busy, you can choose another one via the 'bind' flag, for instance:
  $ ` + os.Args[0] + ` configure --bind 0.0.0.0:12345
  or   
  $ ` + os.Args[0] + ` configure --bind <your server IP or FQDN>:12345

  After browser configuration, all microservices are started automatically and you can directly start using Cells. 
  It is yet good practice to stop the installer and restart Cells in normal mode before going live.

COMMAND-LINE INSTALLER

  If you are more a shell person, you can perform the configuration process directly using this CLI (using the '--cli' 
  flag or by choosing so at first prompt). You will then be able to choose to either use the default bindings for the 
  embedded webserver or adapt these to your specific setup.
 
  You can always reconfigure the webserver bindings afterwards by calling this command:
  $ ` + os.Args[0] + ` configure sites
  See corresponding inline documentation for further details.

AUTOMATED PROVISIONING

  For automated, non-interactive installation, you can pass a YAML or a JSON config file that contains all necessary 
  information, please refer to the documentation on https://pydio.com

ENVIRONMENT

  All the command flags documented below are mapped to their associated ENV var using upper case and CELLS_ prefix.
  For example :
  $ ` + os.Args[0] + ` configure --bind :9876
  is equivalent to 
  $ export CELLS_BIND=":9876"; ` + os.Args[0] + ` configure

  For backward compatibility reasons, the --cli, --yaml and --json flags do not respect the above rule (this might evolve in a future version).
  They are respectively equivalent to CELLS_INSTALL_CLI, CELLS_INSTALL_YAML and CELLS_INSTALL_JSON ENV vars.

 `,
	PreRunE: func(cmd *cobra.Command, args []string) error {

		if err := checkFdlimit(); err != nil {
			return err
		}

		replaceKeys := map[string]string{
			cruntime.KeyInstallYamlLegacy: cruntime.KeyInstallYaml,
			cruntime.KeyInstallJsonLegacy: cruntime.KeyInstallJson,
			cruntime.KeyInstallCliLegacy:  cruntime.KeyInstallCli,
		}

		cmd.Flags().VisitAll(func(flag *pflag.Flag) {
			key := flag.Name
			if replace, ok := replaceKeys[flag.Name]; ok {
				key = replace
			}
			_ = cellsViper.BindPFlag(key, flag)
		})

		niModeCli = cruntime.GetBool(cruntime.KeyInstallCli)
		niYamlFile = cruntime.GetString(cruntime.KeyInstallYaml)
		niJsonFile = cruntime.GetString(cruntime.KeyInstallJson)
		niExitAfterInstall = cruntime.GetBool(cruntime.KeyInstallExitAfter)

		niBindUrl = cruntime.GetString(cruntime.KeySiteBind)
		niExtUrl = cruntime.GetString(cruntime.KeySiteExternal)
		niNoTls = cruntime.GetBool(cruntime.KeySiteNoTLS)
		niCertFile = cruntime.GetString(cruntime.KeySiteTlsCertFile)
		niKeyFile = cruntime.GetString(cruntime.KeySiteTlsKeyFile)
		niLeEmailContact = cruntime.GetString(cruntime.KeySiteLetsEncryptEmail)
		niLeAcceptEula = cruntime.GetBool(cruntime.KeySiteLetsEncryptAgree)
		niLeUseStagingCA = cruntime.GetBool(cruntime.KeySiteLetsEncryptStaging)

		return nil
	},
	Run: func(cmd *cobra.Command, args []string) {

		cmd.Println("")
		cmd.Println("\033[1mWelcome to " + common.PackageLabel + " installation\033[0m ")
		cmd.Println(common.PackageLabel + " (v" + common.Version().String() + ") will be configured to run on this machine.")
		cmd.Println("Make sure to prepare access and credentials to a MySQL 5.6+ (or MariaDB equivalent) server.")
		cmd.Println("Pick your installation mode when you are ready.")
		cmd.Println("")

		var proxyConf *install.ProxyConfig
		var kr crypto.Keyring

		if niYamlFile != "" || niJsonFile != "" || niBindUrl != "" {

			var er error
			_, kr, er = initConfig(cmd.Context(), false)
			fatalIfError(cmd, er)

			installConf, err := nonInteractiveInstall(cmd, args)
			fatalIfError(cmd, err)
			if installConf.FrontendLogin != "" {

				<-time.After(1 * time.Second)
				return
			}

			proxyConf = installConf.GetProxyConfig()
			if len(proxyConf.Binds) == 0 {
				fatalIfError(cmd, fmt.Errorf("no bind was found in default site, non interactive install probably has a wrong format"))
			}

		} else {
			if !niModeCli {

				p := promptui.Select{Label: "Installation mode", Items: []string{"Browser-based (requires a browser access)", "Command line (performed in this terminal)"}}
				installIndex, _, err := p.Run()
				fatalIfError(cmd, err)
				niModeCli = installIndex == 1
			}

			var er error
			_, kr, er = initConfig(cmd.Context(), !niModeCli)
			fatalIfError(cmd, er)

			sites, err := config.LoadSites()
			fatalIfError(cmd, err)
			proxyConf = sites[0]

			proxyConf, err = switchDefaultTls(cmd, proxyConf, niNoTls)
			fatalIfError(cmd, err)

			if !niModeCli {
				var message string
				proxyConf, message, err = checkDefaultBusy(cmd, proxyConf, true)
				fatalIfError(cmd, err)
				if message != "" {
					cmd.Println(promptui.IconWarn, message)
				}
			}
		}

		if niModeCli {
			_, err := cliInstall(cmd, proxyConf)
			fatalIfError(cmd, err)
		} else {

			ctx = servicecontext.WithKeyring(ctx, kr)
			performBrowserInstall(cmd, ctx, proxyConf)
		}

		<-time.After(1 * time.Second)

		if niExitAfterInstall || (niModeCli && cmd.Name() != "start") {
			cmd.Println("")
			cmd.Println(promptui.IconGood + "\033[1m Installation Finished\033[0m")
			cmd.Println("")
			return
		}

		initViperRuntime()
		bin := os.Args[0]
		os.Args = []string{bin, "start"}
		e := DefaultStartCmd.ExecuteContext(cmd.Context())
		if e != nil {
			panic(e)
		}
	},
}

ConfigureCmd launches a wizard (either in this CLI or in your web browser) to configure a new instance of Pydio Cells.

View Source
var DataSourceCmd = &cobra.Command{
	Use: "datasource",
	Run: func(cmd *cobra.Command, args []string) {
		cmd.Help()
	},
	Short: "Datasource management commands",
	Long:  "Collection of tools for manipulating datasources.",
}
View Source
var (
	DefaultStartCmd *cobra.Command
)
View Source
var DocCmd = &cobra.Command{
	Use:    "doc",
	Hidden: true,
	Short:  "Manage documentation about Cells and this CLI tool",
	Run: func(cmd *cobra.Command, args []string) {
		cmd.Help()
	},
}
View Source
var FileCmd = &cobra.Command{
	Use:   "file",
	Short: "Directly manage files and metadata on the nodes",
	Long: `
DESCRIPTION

  Manage metadata linked to nodes.
  Metadata are stored as simple key/values and attached to a node UUID.

`,
	Run: func(cmd *cobra.Command, args []string) {
		cmd.Help()
	},
}
View Source
var JsonRequest = &cobra.Command{
	Use:    "json",
	Hidden: true,
	Run: func(cmd *cobra.Command, args []string) {
		action := &cmd2.RpcAction{}
		action.Init(&jobs.Job{}, &jobs.Action{
			Parameters: map[string]string{
				"service": "pydio.grpc.mailer",
				"method":  "mailer.MailerService.ConsumeQueue",
				"request": "{}",
			},
		})
		action.Run(context.Background(), nil, &jobs.ActionMessage{})

		action2 := &cmd2.RpcAction{}
		action2.Init(&jobs.Job{}, &jobs.Action{
			Parameters: map[string]string{
				"service": "pydio.grpc.role",
				"method":  "idm.RoleService.SearchRole",
				"request": "{}",
			},
		})
		_, e := action2.Run(context.Background(), nil, &jobs.ActionMessage{})
		fmt.Println(e)

	},
}
View Source
var ResetJobCmd = &cobra.Command{
	Use:   "reset-jobs",
	Short: "Reset a job to its default",
	Long: `
DESCRIPTION

Display a list of all automatically inserted jobs and choose one to reset it to its factory default settings. 
	
This feature can be useful when a job requires an upgrade.
Please ensure that the server is running. 

EXAMPLE

  $ ` + os.Args[0] + ` admin clean reset-jobs

  +----+----------------------+--------------------------------+
  | #  |       SERVICE        |             LABEL              |
  +----+----------------------+--------------------------------+
  |  1 | pydio.grpc.jobs      | Extract image thumbnails and   |
  |    |                      | Exif data                      |
  |  2 | pydio.grpc.jobs      | Clean jobs and tasks in        |
  |    |                      | scheduler                      |
  |  3 | pydio.grpc.jobs      | Clean or transfer user data on |
  |    |                      | deletion                       |
  |  4 | pydio.grpc.jobs      | Clean orphan files after 24h   |
  |  5 | pydio.grpc.jobs      | Clean expired ACLs after 10    |
  |    |                      | days                           |
  |  6 | pydio.grpc.versions  | Event Based Job for            |
  |    |                      | replicating data for           |
  |    |                      | versioning                     |
  |  7 | pydio.grpc.activity  | Users activities digest        |
  |  8 | pydio.grpc.mailer    | Flush Mails Queue              |
  |  9 | pydio.grpc.oauth     | Prune revoked tokens and       |
  |    |                      | expired reset password keys    |
  +----+----------------------+--------------------------------+

  Select a job number to reset it in the scheduler: 9

 `,
	RunE: func(cmd *cobra.Command, args []string) error {

		T := lang.Bundle().GetTranslationFunc("en-us")

		dd := jobs.ListDefaults()
		table := tablewriter.NewWriter(cmd.OutOrStdout())
		table.SetHeader([]string{"#", "Service", "Label"})
		for i, d := range dd {
			table.Append([]string{
				fmt.Sprintf("%d", i+1),
				d.ServiceName,
				T(d.Job.Label),
			})
		}
		table.Render()
		prompt := &promptui.Prompt{
			Label:     "Select a job number to reset it in the scheduler",
			AllowEdit: true,
			Validate: func(s string) error {
				if s == "" {
					return fmt.Errorf("use a number between 1 and %d", len(dd))
				} else if in, e := strconv.ParseInt(s, 10, 32); e != nil {
					return e
				} else if in < 1 || in > int64(len(dd)) {
					return fmt.Errorf("use a number between 1 and %d", len(dd))
				}
				return nil
			},
		}
		sel, er := prompt.Run()
		if er != nil {
			return er
		}
		in, _ := strconv.ParseInt(sel, 10, 32)
		job := dd[in-1]
		confirm := &promptui.Prompt{Label: "You are about to reset '" + T(job.Label) + "'. Are you sure you want to continue", IsConfirm: true, Default: "y"}
		if _, er := confirm.Run(); er != nil {
			return er
		}
		jobClient := jobs.NewJobServiceClient(grpc.GetClientConnFromCtx(ctx, common.ServiceJobs))

		if _, er = jobClient.PutJob(ctx, &jobs.PutJobRequest{Job: job.Job}); er != nil {
			fmt.Println(promptui.IconBad + " Error while inserting job " + er.Error())
		} else {
			msg := " Job was successfully reset"
			if job.Inactive {
				msg += " (if it was previously enabled, beware that it has been reset to its disabled status)"
			}
			fmt.Println(promptui.IconGood + msg)
		}
		return nil
	},
}
View Source
var RootCmd = &cobra.Command{
	Use:   os.Args[0],
	Short: "Secure File Sharing for business",
	Long: `
DESCRIPTION

  Pydio Cells is self-hosted Document Sharing & Collaboration software for organizations that need 
  advanced sharing without security trade-offs. Cells gives you full control of your document sharing 
  environment – combining fast performance, huge file transfer sizes, granular security, and advanced 
  workflow automations in an easy-to-set-up and easy-to-support self-hosted platform.

CONFIGURE

  For the very first run, use '` + os.Args[0] + ` configure' to begin the browser-based or command-line based installation wizard. 
  Services will automatically start at the end of a browser-based installation.

RUN

  Run '$ ` + os.Args[0] + ` start' to load all services.

WORKING DIRECTORIES

  By default, application data is stored under the standard OS application dir: 
  
   - Linux: ${USER_HOME}/.config/pydio/cells
   - Darwin: ${USER_HOME}/Library/Application Support/Pydio/cells
   - Windows: ${USER_HOME}/ApplicationData/Roaming/Pydio/cells

  You can customize the storage locations with the following ENV variables: 
  
   - CELLS_WORKING_DIR: replace the whole standard application dir
   - CELLS_DATA_DIR: replace the location for storing default datasources (default CELLS_WORKING_DIR/data)
   - CELLS_LOG_DIR: replace the location for storing logs (default CELLS_WORKING_DIR/logs)
   - CELLS_SERVICES_DIR: replace location for services-specific data (default CELLS_WORKING_DIR/services) 

LOGS LEVEL

  By default, logs are outputted in console format at the Info level and appended to a CELLS_LOG_DIR/pydio.log file. You can: 
   - Change the level (debug, info, warn or error) with the --log flag
   - Output the logs in json format with --log_json=true 
   - Prevent logs from being written to a file with --log_to_file=false

  For backward compatibility:
   - The CELLS_LOGS_LEVEL environment variable still works to define the --log flag (or CELLS_LOG env var)
     but is now deprecated and will disappear in version 4.     
   - The --log=production flag still works and is equivalent to "--log=info --log_json=true --log_to_file=true"
      
`,
}

RootCmd represents the base command when called without any subcommands

View Source
var StartCmd = &cobra.Command{
	Use:     "start",
	Aliases: []string{"daemon"},
	Short:   "Start one or more services",
	Long: `
DESCRIPTION

  Start one or more services on this machine. 
  $ ` + os.Args[0] + ` start [flags] args...

  No arguments will start all services available (see 'ps' command).  
   - Select specific services with regular expressions in the additional arguments. 
   - The -t/--tags flag may limit to only a certain category of services (see usage below)
   - The -x/--exclude flag may exclude one or more services
  All these may be used in conjunction (-t, -x, regexp arguments).

REQUIREMENTS
  
  Ulimit: set a number of allowed open files greater or equal to 2048.
  For production use, a minimum of 8192 is recommended (see ulimit -n).

  Setcap: if you intend to bind the server to standard http ports (80, 443), 
  you must grant necessary permissions on cells binary with this command:
  $ sudo setcap 'cap_net_bind_service=+ep' <path to your binary>    

EXAMPLES

  1. Start all Cells services
  $ ` + os.Args[0] + ` start

  2. Start all services whose name starts with pydio.grpc
  $ ` + os.Args[0] + ` start pydio.grpc

  3. Start only services for scheduler
  $ ` + os.Args[0] + ` start --tag=scheduler

  4. Start whole plateform except the roles service
  $ ` + os.Args[0] + ` start --exclude=pydio.grpc.idm.role

ENVIRONMENT

  1. Flag mapping

  All the command flags documented below are mapped to their associated ENV var, using upper case and CELLS_ prefix.
  For example :
  $ ` + os.Args[0] + ` start --grpc_port 54545
  is equivalent to 
  $ export CELLS_GRPC_PORT=54545; ` + os.Args[0] + ` start

  2. Working Directories 

  - CELLS_WORKING_DIR: replace the whole standard application dir
  - CELLS_DATA_DIR: replace the location for storing default datasources (default CELLS_WORKING_DIR/data)
  - CELLS_LOG_DIR: replace the location for storing logs (default CELLS_WORKING_DIR/logs)
  - CELLS_SERVICES_DIR: replace location for services-specific data (default CELLS_WORKING_DIR/services)

  3. Timeouts, limits, proxies

  - CELLS_SQL_DEFAULT_CONN, CELLS_SQL_LONG_CONN: timeouts used for SQL queries. Use a golang duration (10s, 1m, etc). Defaults are respectively 30 seconds and 10 minutes.
  - CELLS_CACHES_HARD_LIMIT: maximum memory limit used by internal caches (in MB, default is 8). This is a per/cache limit, not global.
  - CELLS_UPDATE_HTTP_PROXY: if your server uses a client proxy to access outside world, this can be set to query update server.
  - HTTP_PROXY, HTTPS_PROXY, NO_PROXY: golang-specific environment variables to configure a client proxy for all external http calls.

  4. Other environment variables (development or advanced fine-tuning)

` + runtime.DocRegisteredEnvVariables("CELLS_SQL_DEFAULT_CONN", "CELLS_SQL_LONG_CONN", "CELLS_CACHES_HARD_LIMIT", "CELLS_UPDATE_HTTP_PROXY") + `

`,
	PreRunE: func(cmd *cobra.Command, args []string) error {
		bindViperFlags(cmd.Flags(), map[string]string{
			runtime.KeyFork: runtime.KeyForkLegacy,
		})

		runtime.SetArgs(args)
		initLogLevel()
		handleSignals(args)

		return nil
	},
	RunE: func(cmd *cobra.Command, args []string) error {

		ctx, cancel := context.WithCancel(cmd.Context())
		defer cancel()

		managerLogger := log.Logger(servicecontext.WithServiceName(ctx, "pydio.server.manager"))

		if needs, gU := runtime.NeedsGrpcDiscoveryConn(); needs {
			u, err := url.Parse(gU)
			if err != nil {
				return err
			}
			discoveryConn, err := grpc.Dial(u.Host, grpc.WithTransportCredentials(insecure.NewCredentials()))
			if err != nil {
				return err
			}
			ctx = clientcontext.WithClientConn(ctx, discoveryConn)
		}

		configFile := filepath.Join(runtime.ApplicationWorkingDir(), runtime.DefaultConfigFileName)
		if runtime.ConfigIsLocalFile() && !filex.Exists(configFile) {
			return triggerInstall(
				"We cannot find a configuration file ... "+configFile,
				"Do you want to create one now",
				cmd, args)
		}

		isNew, keyring, er := initConfig(ctx, true)
		if er != nil {
			return er
		}
		if isNew && runtime.ConfigIsLocalFile() {
			return triggerInstall(
				"Oops, the configuration is not right ... "+configFile,
				"Do you want to reset the initial configuration", cmd, args)
		}

		ctx = servicecontext.WithKeyring(ctx, keyring)
		for _, cc := range configChecks {
			if e := cc(ctx); e != nil {
				return e
			}
		}

		reg, err := registry.OpenRegistry(ctx, runtime.RegistryURL())
		if err != nil {
			return err
		}
		ctx = servercontext.WithRegistry(ctx, reg)

		broker.Register(broker.NewBroker(runtime.BrokerURL(), broker.WithContext(ctx)))

		if !runtime.IsFork() {
			data := []runtime.InfoGroup{binaryInfo()}
			data = append(data, runtime.Describe()...)
			data = append(data, buildInfo())
			for _, group := range data {
				cmd.Println(group.Name + ":")
				for _, pair := range group.Pairs {
					cmd.Println("  " + pair.Key + ":\t" + pair.Value)
				}
				cmd.Println("")
			}
		}

		// Starting discovery server containing registry, broker, config and log
		var discovery manager.Manager
		if !runtime.IsGrpcScheme(runtime.RegistryURL()) || runtime.LogLevel() == "debug" {
			if discovery, err = startDiscoveryServer(ctx, reg, managerLogger); err != nil {
				return err
			}
		}

		clientgrpc.WarnMissingConnInContext = true
		conn, err := grpc.Dial("cells:///", clientgrpc.DialOptionsForRegistry(reg)...)
		if err != nil {
			return err
		}
		ctx = clientcontext.WithClientConn(ctx, conn)
		ctx = nodescontext.WithSourcesPool(ctx, nodes.NewPool(ctx, reg))

		m := manager.NewManager(ctx, reg, "mem:///?cache=plugins&byname=true", "main", managerLogger)
		if err := m.Init(ctx); err != nil {
			return err
		}

		runtime.InitGlobalConnConsumers(ctx, "main")
		go initLogLevelListener(ctx)

		go m.WatchServicesConfigs()
		go m.WatchBroker(ctx, broker.Default())

		if replaced := config.EnvOverrideDefaultBind(); replaced {

			if ss, e := config.LoadSites(true); e == nil && len(ss) > 0 && !runtime.IsFork() {
				fmt.Println("*****************************************************************")
				fmt.Println("*  Dynamic bind flag detected, overriding any configured sites  *")
				fmt.Println("*****************************************************************")
			}
		}

		if os.Args[1] == "daemon" {
			msg := "| Starting daemon, use '" + os.Args[0] + " ctl' to control services |"
			line := strings.Repeat("-", len(msg))
			cmd.Println(line)
			cmd.Println(msg)
			cmd.Println(line)
			m.SetServeOptions(
				server.WithGrpcBindAddress(runtime.GrpcBindAddress()),
				server.WithHttpBindAddress(runtime.HttpBindAddress()),
			)
		} else {
			select {
			case <-ctx.Done():
				return nil
			default:
			}
			m.ServeAll(
				server.WithGrpcBindAddress(runtime.GrpcBindAddress()),
				server.WithHttpBindAddress(runtime.HttpBindAddress()),
				server.WithErrorCallback(func(err error) {
					managerLogger.Error(promptui.IconBad + "There was an error while starting:" + err.Error())
				}),
			)
		}

		select {
		case <-ctx.Done():
		case <-reg.Done():
		}

		reg.Close()
		m.StopAll()
		if discovery != nil {
			managerLogger.Info("Stopping discovery services now")
			discovery.StopAll()
		}

		return nil
	},
}

StartCmd represents the start command

View Source
var TestExternalGrpc = &cobra.Command{
	Use:    "grpc",
	Short:  "Sample GRPC request sent to web-facing interface",
	Hidden: true,
	RunE: func(cmd *cobra.Command, args []string) error {

		creds, err := loadTLSCredentials()
		if err != nil {
			return err
		}
		conn, err := grpc.Dial(extAddr, grpc.WithTransportCredentials(creds))
		if err != nil {
			return err
		}
		cli := tree.NewNodeProviderClient(conn)
		md := metadata.MD{}
		md.Set("x-pydio-bearer", extToken)
		og := metadata.NewOutgoingContext(context.Background(), md)
		stream, e := cli.ListNodes(og, &tree.ListNodesRequest{Node: &tree.Node{Path: "common-files"}})
		if e != nil {
			return e
		}
		for {
			rsp, er := stream.Recv()
			if er != nil {
				if er != io.EOF {
					return er
				}
				break
			}
			fmt.Println(rsp.GetNode().GetPath(), rsp.GetNode().GetType(), rsp.GetNode().GetSize())
		}
		return nil
	},
}
View Source
var ToolsCmd = &cobra.Command{
	Use:    "tools",
	Short:  "Additional tools",
	Hidden: true,
	Long: `
DESCRIPTION

  Various commands that do not require a running Cells instance.
`,
	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
		bindViperFlags(cmd.Flags())
		_, _, er := initConfig(cmd.Context(), false)
		return er
	},
	Run: func(cmd *cobra.Command, args []string) {
		cmd.Help()
	},
}

ToolsCmd are tools that do not need a running Cells instance

View Source
var UserCmd = &cobra.Command{
	Use:   "user",
	Short: "Manage users",
	Long: `
DESCRIPTION

  Manage users from the command line by calling the dedicated services.
`,
	Run: func(cmd *cobra.Command, args []string) {
		cmd.Help()
	},
}

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func RegisterAdditionalPrompt

func RegisterAdditionalPrompt(step CellsCliPromptStep)

func RegisterConfigChecker added in v4.0.1

func RegisterConfigChecker(f func(ctx context.Context) error)

Types

type CellsCliPromptStep

type CellsCliPromptStep struct {
	Step   string
	Prompt func(*install.InstallConfig) error
}

type NiInstallConfig

type NiInstallConfig struct {
	install.InstallConfig `yaml:",inline"`
	ProxyConfigs          []*install.ProxyConfig `json:"proxyConfigs" yaml:"proxyconfigs"`
	CustomConfigs         map[string]interface{} `json:"customConfigs" yaml:"customconfigs"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL