Nástroje pro příkazový řádek¶
Od GLPI verze 9.2.2 jsou nástroje pro příkazový řádek poskytovány jako podporované skripty a jsou k dispozici ve složce scripts (skripty) v archivu. V předchozích verzích se tyto skripty nacházely ve složce tools (nástroje) která není oficiální a proto není přítomná v instalačním archivu vydání.
Since GLPI 9.4.0, command line tools are being centralized in a console application (bin/console).
Calling php bin/console from GLPI directory displays the list of available commands.
Poznámka
Pokud je v systému nainstalované APCu PHP rozšíření, nemusí se podařit ho použít z příkazového řádku, protože ve výchozím nastavení je tato možnost vypnutá. Změnit je to možné nastavením volby apc.enable_cli na on v souboru s nastaveními APCu.
Varování
When using cli tools, please check the system user you are currently logged in with, and permissions on files and directories. With a wrong user, logs, cache and other files may be created with rights that would not allow your webserver to read or write on thos files!
Console options¶
For every console command, following options are available:
--config-dir=CONFIG-DIRpath of configuration directory to use, relative to current working directory (required only if a custom path is used)
-h,--helpzobrazí nápovědu k příkazu
--lang=LANGoutput language code (default value is existing GLPI „language“ configuration or „en_GB“)
-n,--no-interactiondisable command interactive questions
--no-pluginsdisable GLPI plugins during command execution
-q,--quietvypne výstup z příkazu
-v|vv|vvv,--verbose=VERBOSEverbosity level: 1 for normal output, 2 for more verbose output and 3 for debug
Additional install and update tools¶
Kontrola požadavků¶
Before installing or upgrading, requirements are automatically checked; but you can run them separately and see state for all of them using the php bin/console glpi:system:check_requirements command.
Zapnout/Vypnout režim údržby¶
GLPI provides a maintenance mode that can be activated prior to an update, and deactivated after all has been checked.
Just use the glpi:maintenance:enable and glpi:maintenance:disable commands.
Instalace¶
The php bin/console db:install has been made to install GLPI database in CLI mode.
Možné volby pro tento příkaz jsou:
-r,--reconfigureto enable overriding of any existing DB configuration file
-f,--forceto force execution of installation even if database is not empty
-L,--default-language=DEFAULT_LANGUAGEdefault language of GLPI (en_GB per default)
-H,--db-host=DB_HOSThost name (localhost per default)
-P,--db-port=DB_PORTdatabase port (default MySQL port if option is not defined)-d`,
--db-name=DB_NAMEjméno databáze
-u,--db-user=DB_USERjméno uživatele databáze
-p,--db-password=DB_PASSWORDdatabase user’s password (use it without value to be prompted for password)
If mandatory options are not specified in the command call, the console will ask for them.
Database connection parameters may be omitted if a configuration file already exists.
See also console options.
Nastavení připojení k databázi¶
Added in version 9.5.0.
The php bin/console db:configure has been made to define database connection parameters in CLI mode.
Možné volby pro tento příkaz jsou:
-r,--reconfigureto enable overriding of any existing DB configuration file
-H,--db-host=DB_HOSThost name (localhost per default)
-P,--db-port=DB_PORTdatabase port (default MySQL port if option is not defined)-d`,
--db-name=DB_NAMEjméno databáze
-u,--db-user=DB_USERjméno uživatele databáze
-p,--db-password=DB_PASSWORDdatabase user’s password (use it without value to be prompted for password)
If mandatory options are not specified in the command call, the console will ask for them.
See also console options.
Aktualizace¶
The php bin/console db:update has been made to update GLPI database in CLI mode from a previously installed version.
There is no required arguments, just run the command so it updates your database automatically.
Varování
Před jakýmkoli pokusem o aktualizaci nezapomeňte zazálohovat databázi!
Varování
Since GLPI 10.0.2, db:check_schema_integrity is executed before performing the update.
If an error is detected, the command will ask you if you want to continue (unless --no-interaction is used).
You can bypass this db:check_schema_integrity by using the option -s, --skip-db-checks.
Možné volby pro tento příkaz jsou:
-u,--allow-unstableallow update to an unstable version (use it with cautions)
-f,--forceforce execution of update from v-1 version of GLPI even if schema did not changed
-s,--skip-db-checksdo not check database schema integrity before performing the update
--enable-telemetryallow usage statistics sending to Telemetry service (https://telemetry.glpi-project.org)
--no-telemetrydisallow usage statistics sending to Telemetry service (https://telemetry.glpi-project.org)
See also console options.
Bezpečnostní klíč¶
Added in version 9.4.6.
Poznámka
GLPI key file is available for GLPI >= 9.4.6 but is not mandatory. As of GLPI 9.5, using the key file will be mandatory.
In order to store some sensitive data, GLPI relies on a homemade encryption/decryption tool, which uses a key to:
encrypt data before storing them in the database,
decrypt data that has been retrieved from the database.
The php bin/console glpi:security:change_key command allows to change the key, if it has been compromised for example. By default, command will:
generate a new key and and store it in the key file,
update all configured fields (for core and compatible plugins) to use the new key,
update all configuration entries listed (for core and compatible plugins) to use the new key.
Various tools¶
Kontrola databázového schematu¶
The php bin/console db:check_schema_integrity command can be used to check if your database schema differs from expected one.
Možné volby pro tento příkaz jsou:
--strict: Strict comparison of definitions
--check-all-migrations: Check tokens related to all databases migrations.
--check-innodb-migration: Check tokens related to migration from „MyISAM“ to „InnoDB“.
--check-timestamps-migration: Check tokens related to migration from „datetime“ to „timestamp“.
--check-utf8mb4-migration: Check tokens related to migration from „utf8“ to „utf8mb4“.
--check-dynamic-row-format-migration: Check tokens related to „DYNAMIC“ row format migration.
--check-unsigned-keys-migration: Check tokens related to migration from signed to unsigned integers in primary/foreign keys.
-p,--plugin: Plugin to check. If option is not used, checks will be done on GLPI core database tables.
If you have any diff, output will looks like :
$ php bin/console glpi:database:check_schema_integrity
Table schema differs for table "glpi_rulecriterias".
--- Original
+++ New
@@ @@
create table `glpi_rulecriterias` (
`id` int(11) not null auto_increment
`rules_id` int(11) not null default '0'
`criteria` varchar(255) default null
`condition` int(11) not null default '0'
- `pattern` text default null
+ `pattern` text
primary key (`id`)
Compared to the GLPI installation file:
a line that starts with
-means that something is missing in your databasea line that starts with
+means that there is something extra in your database
You can also have a message like Unknown table "glpi_tablename" has been found in database.,
this indicates that this table doesn’t exist in the installation file of the current GLPI schema:
either it’s a table that you have voluntarily created for your needs, you can ignore this message
either it’s an old GLPI table which is no longer useful, you can delete it (taking care to make a backup before)
LDAP synchronizace¶
The bin/console glpi:ldap:synchronize_users command can be used to synchronize users against LDAP server informations.
Možné volby pro tento příkaz jsou:
-c,--only-create-newonly create new users
-u,--only-update-existingonly update existing users
-s,--ldap-server-id[=LDAP-SERVER-ID]synchronize only users attached to this LDAP server (multiple values allowed)
-f,--ldap-filter[=LDAP-FILTER]filter to apply on LDAP search
--begin-date[=BEGIN-DATE]begin date to apply in „modifyTimestamp“ filter
--end-date[=END-DATE]end date to apply in „modifyTimestamp“ filter
-d,--deleted-user-strategy[=DELETED-USER-STRATEGY]force strategy used for deleted users:
0: Preserve
1: Put in trashbin
2: Withdraw dynamic authorizations and groups
3: Disable
4: Disable + Withdraw dynamic authorizations and groups
See http://php.net/manual/en/datetime.formats.php for supported date formats in --begin-date and --end-date options.
See also console options.
Task unlock¶
The php bin/console task:unlock command can be used to unlock stucked cron tasks.
Varování
Keep in mind that no task should be stucked except in case of a bug or a system failure (database failure during cron execution for example).
Možné volby pro tento příkaz jsou:
-a,--allunlock all tasks
-c,--cycle[=CYCLE]execution time (in cycles) from which the task is considered as stuck (delay = task frequency * cycle)
-d,--delay[=DELAY]execution time (in seconds) from which the task is considered as stuck (default: 1800)
-t,--task[=TASK]itemtype::nameof task to unlock (e.g:MailCollector::mailgate)
See also console options.
Suspend/Resume plugins execution¶
Added in version 11.0.
The php bin/console plugin:suspend_execution and the php bin/console plugin:resume_execution commands can be used
to suspend or resume the plugins execution.
Plugins tools¶
Added in version 9.5.
Some command line tolls are also available to manage plugins from command line:
glpi:plugin:install
glpi:plugin:activate
glpi:plugin:deactivate
In order to install MyGreatPlugin; you should end with something like:
$ ./bin/console glpi:plugin:install MyGreatPlugin
$ ./bin/console glpi:plugin:activate MyGreatPlugin
Each of those plugin commands can take a plugin name as argument, or the --all flag to be ran on all plugins.
Migration tools¶
From MyISAM to InnoDB¶
Added in version 9.3.0.
Since version 9.3.0, GLPI uses the InnoDB engine instead of previously used MyISAM engine.
The php bin/console glpi:migration:myisam_to_innodb command can be used to migrate exiting tables to InnoDB engine.
Missing timestamps builder¶
Added in version 9.1.0.
Prior to GLPI 9.1.0, fields corresponding to creation and modification dates were not existing.
The php bin/console glpi:migration:build_missing_timestamps command can be used to rebuild missing values using available logs.
Use timestamp data type¶
Added in version 9.5.0.
Many date fields were using the DATETIME type, but this does not allow to rely on timezones. Timezone support requires all fields to use TIMESTAMP data type, but this query can be very long and therefore is not included in the standard update process.
Using the glpi:migration:timestamps command will change those fields to the correct data type, but read documentation on timezones before.
Varování
Ensure to backup your database before!
Migrate Domains plugin¶
Added in version 9.5.0.
Domains in GLPI have evolved from a simple dropdown to a more complex object, including records management among others. Therefore, the Domains plugins feature are now included in core.
To migrate your plugin data; use the glpi:migration:domains_plugin_to_core command. Presence of the plugin is mandatory so checks can be run, you can use the --without-plugin switch but this is not recommended. If you were using an older version of the plugin than the one required, you can use the --update-plugin flag.
At the end, all domains types, domains and item relations will be migrated in core tables.
Migrate Racks plugin¶
Added in version 9.5.0.
Since GLPI 9.3.0, data center infrastructure management is available as a core feature. A migration script from Racks plugin was provided inside the scripts directory.
Since GLPI 9.5.0, this migration script has been refactored and moved inside the CLI console.
To migrate your plugin data; use the glpi:migration:racks_plugin_to_core command. Presence of the plugin is mandatory so checks can be run, you can use the --without-plugin switch but this is not recommended. If you were using an older version of the plugin than the one required, you can use the --update-plugin flag.
