SugarCli is a command line tool to install and manage SugarCRM installations.
Get the phar archive at http://apt.inetprocess.fr/pub/sugarcli.phar
. Allow the execution and run it.
wget 'http://apt.inetprocess.fr/pub/sugarcli.phar'
chmod +x ./sugarcli.phar
./sugarcli.phar
Or clone this git repository and use ./bin/sugarcli
.
Clone the git repository and run php -dphar.readonly=0 bin/compile
.
It will build the sugarcli.phar
at the top of the git project.
You can save some configurations options in different location. The latter one will override the previous one:
/etc/sugarclirc
$HOME/.sugarclirc
./.sugarclirc
Command line parameters will override these configurations.
---
sugarcrm:
path: path/to/sugar
url: http://external.url
./sugarcli.phar --help
: This will give you the help and list of available commands.
Copy the file phpunit.xml.dist
to phpunit.xml
and edit the environment variables.
Run the full test suite with bin/phpunit
or exclude groups to avoid required external resources bin/phpunit --exclude-group inventory,sugarcrm-db
Available groups:
- inventory
- sugarcrm-db
- sugarcrm-path
- sugarcrm-url
- Clean language files
- Install a SugarCRM
- Manage
fields_meta_data
andrelationships
tables - Inventory
- User Management
- System
- Logic Hooks
- Vardefs Extractor
- Code Generator
The main command is ./sugarcli.phar clean:langfiles
--no-sort Do not sort the files contents. It will still remove duplicates. Useful for testing.
-t, --test Try to rewrite the files without modifying the contents. Imply --no-sort.
-p, --path=PATH Path to SugarCRM installation.
./sugarcli.phar clean:langfiles --test path/to/sugar
This will parse the custom languages files from sugar. It should return the files as is.
./sugarcli.phar clean:langfiles --no-sort path/to/sugar
This will clean the lang files by removing unecessary whitespaces and remove duplicates in variables definitions.
./sugarcli.phar clean:langfiles path/to/sugar
This will clean and sort the language files. All defined variables will be sorted by name.
The main command is ./sugarcli.phar install
Subcommands are :
./sugarcli.phar install:config:get
./sugarcli.phar install:check
./sugarcli.phar install:run
./sugarcli.phar install:config:get
will create a config_si.php
in the current directory.
This provides default settings for the installer. You will need to complete some require parameters like db information, usernames and passwords. Required fields are in the form <VALUE>
.
-c, --config=CONFIG Write to this file instead of config_si.php. [default: "config_si.php"]
-f, --force Overwrite existing file
-p, --path=PATH Path to SugarCRM installation.
./sugarcli.phar install:run [-f|--force] [-s|--source[="..."]] [-c|--config[="..."]] path url
You need to specify an installation path and the public url for your sugar installation.
The installer will extract a SugarCRM installation package named sugar.zip or specified with the --source
option.
It will use the --config
option to use for the installation.
-f, --force Force installer to remove target directory if present.
-s, --source=SOURCE Path to SugarCRM installation package. [default: "sugar.zip"]
-c, --config=CONFIG PHP file to use as configuration for the installation. [default: "config_si.php"]
-p, --path=PATH Path to SugarCRM installation.
./sugarcli.phar install:config:get
nano config_si.php
./sugarcli.phar install:run -v ~/www/sugar7 http://myserver.example.org/sugar7 --source ~/sugar_package/SugarPro-Full-7.2.2.1.zip
Use -v
or -vv
to add more verbose output.
Two groups of commands are available to export and sync the content of the fields_meta_data table (custom fields from studio) and relationships (default and custom relationships).
The first has metadata
as a prefix and the second has rels
By default the metadata definition file will be <sugar_path>/../db/fields_meta_data.yaml
and the relationships will be <sugar_path>/../db/relationships.yaml
.
You can override it with the --metadata-file
parameter for all the metadata
sub-commands and --file
parameter for all the rels
subcommands.
The main command are then ./sugarcli.phar metadata
and ./sugarcli.phar rels
Subcommands are :
./sugarcli.phar metadata:loadfromfile
./sugarcli.phar metadata:dumptofile
./sugarcli.phar metadata:status
./sugarcli.phar rels:loadfromfile
./sugarcli.phar rels:dumptofile
./sugarcli.phar rels:status
The following explanations are made for metadata
but are similar for rels
sugarcli {type}:loadfromfile
Load fields defined in the meta data file to update the database.
-s, --sql Print the sql queries that would have been executed.
-f, --force Really execute the SQL queries to modify the database.
-a, --add Add new fields from the file to the DB.
-d, --del Delete fields not present in the metadata file from the DB.
-u, --update Update the DB for modified fields in metadata file.
-p, --path=PATH Path to SugarCRM installation.
-m, --metadata-file=METADATA-FILE Path to the metadata file. (default: "<sugar_path>/../db/fields_meta_data.yaml")
-s, --sql Print the sql queries that would have been executed.
-f, --force Really execute the SQL queries to modify the database.
-a, --add Add new fields from the file to the DB.
-d, --del Delete fields not present in the relationships file from the DB.
-u, --update Update the DB for modified fields in relationships file.
-p, --path=PATH Path to SugarCRM installation.
--file=FILE Path to the rels file. (default: "<sugar_path>/../db/relationships.yaml")
sugarcli {type}:dump
You can dump the current DB fields_meta_data (or relationships) contents into the definition file.
You can also use the --add
, --del
, --update
flags to only add, delete or update fields (or relationships).
The fields specified after the command line will allow you to act only on specific fields (or relationships).
-a, --add Add new fields from the DB to the definition file.
-d, --del Delete fields not present in the DB from the metadata file.
-u, --update Update the metadata file for modified fields in the DB.
-p, --path=PATH Path to SugarCRM installation.
-m, --metadata-file=METADATA-FILE Path to the metadata file. (default: "<sugar_path>/../db/fields_meta_data.yaml")
-a, --add Add new relationships from the DB to the definition file.
-d, --del Delete relationships not present in the DB
-u, --update Update the relationships in the DB.
-p, --path=PATH Path to SugarCRM installation.
--file=FILE Path to the rels file. (default: "<sugar_path>/../db/relationships.yaml")
sugarcli {type}:status -p path/to/sugar
This will show which fields are differing between the definition file and the database.
-p, --path=PATH Path to SugarCRM installation.
-m, --metadata-file=METADATA-FILE Path to the metadata file. (default: "<sugar_path>/../db/fields_meta_data.yaml")
-p, --path=PATH Path to SugarCRM installation.
--file=FILE Path to the rels file. (default: "<sugar_path>/../db/relationships.yaml")
The main command is ./sugarcli.phar inventory
Subcommands are :
./sugarcli.phar inventory:facter
./sugarcli.phar inventory:agent
./sugarcli.phar inventory:facter --path <sugracrm_path> --format yml
will give you a yaml file with various information about
the system and the sugarcrm instance.
-F, --custom-fact=CUSTOM-FACT Add or override facts. Format: path.to.fact:value (multiple values allowed)
-f, --format=FORMAT Specify the output format. (json|yml|xml). [default: "yml"]
-p, --path=PATH Path to SugarCRM installation.
./sugarcli.phar inventory:agent --path <sugarcrm_path> --account-name 'Name of client' <inventory_url> <username> <password>
This will send all the gathered facts to the inventory server.
-F, --custom-fact=CUSTOM-FACT Add or override facts. Format: path.to.fact:value (multiple values allowed)
-p, --path=PATH Path to SugarCRM installation.
-a, --account-name=ACCOUNT-NAME Name of the account.
The main command is ./sugarcli.phar user
Subcommands are :
./sugarcli.phar user:update
./sugarcli.phar user:create
./sugarcli.phar user:list
./sugarcli.phar user:update --path <sugarcrm_path> --first-name=Admin --last-name='Test' myNewLogin
will update the user
myNewLogin and set the first and last name.
-c, --create Create the user instead of updating it. Optional if called with users:create.
-f, --first-name=FIRST-NAME First name of the user.
-l, --last-name=LAST-NAME Last name of the user.
-P, --password=PASSWORD Password of the user [UNSAFE].
--ask-password Ask for user password.
-a, --admin=ADMIN Make the user administrator. [yes/no]
-A, --active=ACTIVE Make the user active. [yes/no]
-p, --path=PATH Path to SugarCRM installation.
./sugarcli.phar user:create --path <sugarcrm_path> --password=mypasword --admin=yes myNewLogin
will create a new admin user
with login myNewLogin and password mypasword.
-c, --create Create the user instead of updating it. Optional if called with users:create.
-f, --first-name=FIRST-NAME First name of the user.
-l, --last-name=LAST-NAME Last name of the user.
-P, --password=PASSWORD Password of the user [UNSAFE].
--ask-password Ask for user password.
-a, --admin=ADMIN Make the user administrator. [yes/no]
-A, --active=ACTIVE Make the user active. [yes/no]
-p, --path=PATH Path to SugarCRM installation.
./sugarcli.phar user:list --path <sugarcrm_path>
will give you a nice output of the users.
You can also limit the result to a specific username (--username
) and change the output format (--format
) to json, yml or xml.
-u, --username=USERNAME Login of the user.
-f, --format=FORMAT Output format. (text|json|yml|xml) [default: "text"]
-F, --fields=FIELDS List of comma separated field name. [default: "id,user_name,is_admin,status,first_name,last_name"]
-l, --lang=LANG Lang for display. [default: "en_us"]
-p, --path=PATH Path to SugarCRM installation.
The main command is ./sugarcli.phar system
Subcommands are:
./sugarcli.phar system:quickrepair
./sugarcli.phar system:quickrepair --path <sugarcrm_path>
will do a basic Quick Repair & Rebuild of your SugarCRM instance.
You can also use --database
to see if Vardefs are synchronized with the Database.
If they are not in sync you can run the queries by adding --force
.
Finally, if you want to have the full output from SugarCRM, add the verbose (--verbose
) option.
-d, --database Manage database changes.
-f, --force Really execute the SQL queries (displayed by using -v).
-p, --path=PATH Path to SugarCRM installation.
The command ./sugarcli.phar system:quickrepair --database
has that type of output:
Reparation:
- Repair Done.
Database Messages:
Database tables are synced with vardefs
The main command is ./sugarcli.phar hooks
Subcommands are:
./sugarcli.phar hooks:list
./sugarcli.phar hooks:list --path <sugarcrm_path> --module <module>
will generate of list of hooks for the specified module.
That command lists the hooks with, for each, its Weight, description, the file where the class is defined, the method called, and where it's defined.
You can also use --compact
to have the basic informations about hooks (Weight / Description / Method).
-m, --module=MODULE Module's name.
--compact Activate compact mode
-p, --path=PATH Path to SugarCRM installation.
The command ./sugarcli.phar hooks:list --module Contacts --compact
gives that type of output, for a module with no Hooks:
+-----------+-------------+--------+
| Hooks definition for Contacts |
+-----------+-------------+--------+
| Weight | Description | Method |
+-----------+-------------+--------+
| No Hooks for that module |
+-----------+-------------+--------+
./sugarcli.phar extract:fields --path <sugarcrm_path> --module <module>
will extract all the fields defined for a module, with theirs parameters (Label, content of dropdowns, dbType, etc ...) and write 2 csv files containing the data.
-m, --module=MODULE Module's name.
--lang=LANG SugarCRM Language [default: "fr_FR"]
-p, --path=PATH Path to SugarCRM installation.
The main command is ./sugarcli.phar code
Subcommands are:
./sugarcli.phar code:execute:file
./sugracli.phar code:execute:file --path <sugarcrm_path> [--user-id='1'] <test.php>
will execute the file test.php
by loading
first the sugarcrm environment. So the script can directly use the classes and db from sugar.
You can also set the user_id from the command line to have another one than the default administrator.