Skip to main content

CLI

This page describes the CLI commands that are included in mosparo.

Maintenance​

Database cleanup​

One of the main features of mosparo is to ensure that the form data is removed from mosparo after two weeks. To clean the database after two weeks, mosparo executes the cleanup process every 6 hours automatically when a form is loaded. If you prefer to execute the cleanup at a specified time, you can use this command and set up a cron job.

This command uses a slight delay when executed. The idea behind this command is to make sure that the command is only executed once, especially in a multi-node setup where multiple nodes may execute the command at the same time.

./bin/console mosparo:cleanup-database

Arguments​

This command does not offer any arguments.

Use case​

Use this command in a cron job to execute this functionality automatically.

GeoIP2 database download​

This command can be used to download the latest GeoIP2 database from the MaxMind servers automatically.

./bin/console mosparo:geoip2:download-database

Arguments​

This command does not offer any arguments.

Use case​

Use this command in a cron job to execute this functionality automatically.

Health​

The health command checks the health of the mosparo installation.

./bin/console mosparo:health

Arguments​

This command does not offer any arguments.

Use case​

This command is used as the Docker Healthcheck to detect the health of the container automatically.

Update​

The update command is an interactive command to update mosparo to the latest version automatically.

./bin/console mosparo:self-update

Arguments​

This command does not offer any arguments.

Use case​

Use this command to update your mosparo installation.

Finalize update​

The finalize-update command can be executed after updating mosparo. The command executes the same steps as in the frontend when the user opens the web interface after an update.

The command will:

  • Update the database
  • Clear the cache
  • Check for other upgrade steps, for example to recalculate the prepared rule items
./bin/console mosparo:finalize-update

Arguments​

ArgumentRequiredDescription
--forceOptionalFinalizes the update although the installed version is already the current version.
--wait-for-databaseOptionalWaits for the given number of seconds until the database is available, which is useful if mosparo and the database are started at the same time. 0 does not wait at all. Default: 0

Use case​

Use this command to finalize an update of your mosparo installation.

Refresh frontend resources​

Refreshes the frontend resources of all projects. The frontend resources contain the project designs and are built from the assets of the installed version, so they must be refreshed after an update. The update in the administration interface does that on its own. An installation that is updated by replacing the files, for example by starting a new container image, never runs that update, and this command refreshes the resources instead.

./bin/console mosparo:refresh-frontend-resources

Arguments​

This command does not offer any arguments.

Use case​

Use this command to refresh the frontend resources of all projects of your mosparo installation after an update.

User​

Create a user​

The command creates a user without the setup wizard or the administration interface so that an installation can be prepared in an automated deployment.

./bin/console mosparo:user:create [--password PASSWORD] [--password-from-stdin] [--role ROLE] [--update] [--] <email>

Arguments​

ArgumentRequiredDescription
emailRequiredThe email address of the user, which is also the username.
--passwordOptionalThe password of the user. The command asks for the password if it is needed and neither this option nor --password-from-stdin is used.
--password-from-stdinOptionalRead the password from the standard input instead of the --password option.
--roleOptionalThe role of the user, usable multiple times. Every user gets ROLE_USER. Without this option, a new user gets only ROLE_USER, and --update keeps the existing roles.
--updateOptionalUpdate an existing user instead of stopping with an error. The password is changed if --password or --password-from-stdin is used, and the roles if --role is used. Without any of these options, the command asks for a new password.

Use case​

Use this command to create or update a user, for example, in any automation.

Project​

Create a project​

The command creates a project so that an installation can be prepared in an automated deployment. The UUID and the keys are generated if they are not given, which is why the command prints them.

./bin/console mosparo:project:create [--owner OWNER] [--host HOST] [--description DESCRIPTION] [--uuid UUID] [--public-key PUBLIC-KEY] [--private-key PRIVATE-KEY] [--private-key-from-stdin] [--update] [--] <name>

Arguments​

ArgumentRequiredDescription
nameRequiredThe name of the project.
--ownerOptionalThe email address of the user who becomes the owner of the project.
--hostOptionalA host that is allowed to use the project, usable multiple times.
--descriptionOptionalThe description of the project.
--uuidOptionalThe UUID of the project. A random UUID is generated if the option is not used.
--public-keyOptionalThe public key of the project, to be used together with --private-key or --private-key-from-stdin. Both keys are generated if the options are not used.
--private-keyOptionalThe private key of the project, to be used together with --public-key. Visible in the process list; prefer --private-key-from-stdin.
--private-key-from-stdinOptionalRead the private key from the standard input instead of the --private-key option, to be used together with --public-key.
--updateOptionalSet the name, the description, the hosts, and the keys of the project with the given UUID instead of stopping with an error. Requires --uuid.

Use case​

Use this command to create or update a project, for example, as part of any automation.

Import project settings​

With the import command, you can import the settings from a previously exported project into a project. You can use this command to make a backup of the settings.

./bin/console mosparo:import [--generalSettings|--no-generalSettings] [--designSettings|--no-designSettings] [--securitySettings|--no-securitySettings] [--translations|--no-translations] [--submissionRules|--no-submissionRules] [--fieldRules|--no-fieldRules] [--handlingExistingFieldRules HANDLINGEXISTINGFIELDRULES] [--rulePackages|--no-rulePackages] [-f|--force] [--] <projectId> <filePath>

Arguments​

ArgumentRequiredDescription
projectIdRequiredThe project ID of the project into which you want to import the settings. You can find the ID of a project in the project list in mosparo.
filePathRequiredThe location of the file you want to import.
--generalSettingsOptionalImport the general settings of a project.
--no-generalSettingsOptionalDo not import the general settings of a project.
--designSettingsOptionalImport the design settings of a project.
--no-designSettingsOptionalDo not import the design settings of a project.
--securitySettingsOptionalImport the security settings of a project.
--no-securitySettingsOptionalDo not import the security settings of a project.
--translationsOptionalImport the translations of a project.
--no-translationsOptionalDo not import the translations of a project.
--submissionRulesOptionalImport the submission rules of a project.
--no-submissionRulesOptionalDo not import the submission rules of a project.
--fieldRulesOptionalImport the field rules of a project.
--no-fieldRulesOptionalDo not import the field rules of a project.
--handlingExistingFieldRulesOptionalDefines how mosparo should handle existing field rules. Use override, to override a field rule that already exists. Use append to append the rule items if a field rule already exists. Use add to add an existing field rule as a new field rule.
--rulePackagesOptionalImport the rule packages of a project.
--no-rulePackagesOptionalDo not import the rule packages of a project.
--forceOptionalIf force is set, the command will execute all changes without asking. Otherwise, the command will be executed interactively, and you need to tell the command which changes to apply.

Use case​

Use this command to import the settings, rules, and rule packages from a file into a project.

Export project settings​

With the export command, you can export the settings of a project. You can later import the settings into a different project in the same or a different mosparo installation.

mosparo will not export any sensitive data, such as submitted form data or the UUID, public or private key of a project.

./bin/console mosparo:export [--generalSettings|--no-generalSettings] [--designSettings|--no-designSettings] [--securitySettings|--no-securitySettings] [--translations|--no-translations] [--submissionRules|--no-submissionRules] [--fieldRules|--no-fieldRules] [--rulePackages|--no-rulePackages] [--] <projectId> [<filePath>]

Arguments​

ArgumentRequiredDescription
projectIdRequiredThe project ID of the project you want to export. You can find the ID of a project in the project list in mosparo.
filePathOptionalThe location where the command should store the export file.
--generalSettingsOptionalExport the general settings of a project.
--no-generalSettingsOptionalDo not export the general settings of a project.
--designSettingsOptionalExport the design settings of a project.
--no-designSettingsOptionalDo not export the design settings of a project.
--securitySettingsOptionalExport the security settings of a project.
--no-securitySettingsOptionalDo not export the security settings of a project.
--translationsOptionalExport the translations of a project.
--no-translationsOptionalDo not export the translations of a project.
--submissionRulesOptionalExport the submission rules of a project.
--no-submissionRulesOptionalDo not export the submission rules of a project.
--fieldRulesOptionalExport the field rules of a project.
--no-fieldRulesOptionalDo not export the field rules of a project.
--rulePackagesOptionalExport the rule packages of a project.
--no-rulePackagesOptionalDo not export the rule packages of a project.

Use case​

Use this command to export the settings, rules, and rule packages of a project into a file.

Rule packages​

Import rule package​

With the rule package import command, you can import a rule package from a local file or via standard input (stdin).

./bin/console mosparo:rule-package:import [-f|--file FILE] [-i|--input] [-s|--hash HASH] [--] <projectId> <rulePackageId>

Arguments​

ArgumentRequiredDescription
projectIdRequiredThe project ID of the project into which you want to import the rule package. You can find the ID of a project in the project list in mosparo.
rulePackageIdRequiredThe rule package ID of the rule package into which you want to import the rule package. This rule package needs to be of the correct type.
-f / --fileOptionalThe path to the rule pacakge file.
-i / --inputOptionalWith this option, you can tell the command to read the package content from the standard input.
-s / --hashOptionalSpecify the SHA256 hash of the content of the rule package.

At least one of -f/--file or -i/--input is required.

Use case​

Use this command to import a locally generated or stored rule package.

Refresh rule packages​

Refreshes all automatic rule packages. Packages that are hosted on a URL are downloaded and cached in mosparo. Packages, which are loaded from a specified file path, are directly loaded and cached in mosparo.

./bin/console mosparo:rule-package:refresh

Arguments​

This command does not offer any arguments.

Use case​

Use this command in a cron job to execute this functionality automatically.