Skip to content

Latest commit

 

History

History
116 lines (87 loc) · 4.11 KB

README.md

File metadata and controls

116 lines (87 loc) · 4.11 KB

PHP-CLI SHELL for PATCHMANAGER

New release will be only available on https://github.com/Renji-FR/PhpCliShell

This repository is the addon for PHP-CLI SHELL about PATCHMANAGER service.
You have to use base PHP-CLI SHELL project that is here: https://github.com/cloudwatt/php-cli-shell_base

REQUIREMENTS

PATCHMANAGER

  • Import profiles which are in addons/dcim/ressources
    • formats: ressources/dcim/formats
    • Reports: ressources/dcim/reports
    • Searches: ressources/dcim/searches

/!\ Do not rename custom profiles
/!\ Version 2.0 add new profiles!

INSTALLATION

APT PHP

Ubuntu only, you can get last PHP version from this PPA:
https://launchpad.net/~ondrej/+archive/ubuntu/php

  • add-apt-repository ppa:ondrej/php
  • apt update

You have to install a PHP version >= 7.1:

  • apt install php7.3-cli php7.3-mbstring php7.3-readline php7.3-soap php7.3-curl

For MacOS users which use PHP 7.3, there is an issue with PCRE. You have to add this configuration in your php.ini:

pcre.jit=0

To locate your php.ini, use this command: php -i | grep "Configuration File"

USE PHAR

Download last PHAR release and its key from releases

wizard

Print wizard help:
$ php php-cli-shell.phar --help

Create PATCHMANAGER configuration with command:
$ php php-cli-shell.phar configuration:application:factory dcim
For more informations about configuration file, see 'CONFIGURATION FILE' section

Create PATCHMANAGER launcher with command:
$ php php-cli-shell.phar launcher:application:factory dcim

The PHAR contains all PHP-CLI SHELL components (Base, DCIM, IPAM and Firewall)

USE SOURCE

REPOSITORIES

CONFIGURATION FILE

  • mv configurations/dcim.json.example configurations/dcim.json
  • vim configurations/dcim.json
    • servers field contains all PatchManager server which must be identified by custom key [DCIM_SERVER_KEY]
      server key must be unique and you will use it on next steps. You have an example in config file
    • userAttrs section contains all custom attributes which must be created in your PatchManager
      If you have a serial number custom attribute, change [PM_ATTR_SN] with the name of this attribute otherwise leave false
    • preferences section contains all options about PatchManager
      CSV delimiter option must be identical between PHP-CLI configuration and PatchManager user preferences
  • Optionnal
    • You can create user configuration files to overwrite some configurations
      These files will be ignored for commits, so your user config files can not be overwrited by a futur release
    • mv configurations/dcim.user.json.example configurations/dcim.user.json
    • vim configurations/dcim.user.json
      Change configuration like browserCmd or DCIM preferences
    • All *.user.json files are ignored by .gitignore

PHP LAUNCHER FILE

  • mv dcim.php.example patchmanager.php
  • vim patchmanager.php
    • Change [DCIM_SERVER_KEY] with the key of your PatchManager server in configuration file

EXECUTION

CREDENTIALS FILE

/!\ For security reason, you can use a read only account!
Change informations which are between []

  • vim credentialsFile
    • read -sr USER_PASSWORD_INPUT
    • export DCIM_[DCIM_SERVER_KEY]_LOGIN=[YourLoginHere]
    • export DCIM_[DCIM_SERVER_KEY]_PASSWORD=$USER_PASSWORD_INPUT
      Change [DCIM_SERVER_KEY] with the key of your PatchManager server in configuration file

SHELL

Launch PHP-CLI Shell for PatchManager service

  • source credentialsFile
  • php patchmanager.php

COMMAND

Get command result in order to handle with your OS shell.
/!\ The result is JSON so you can use JQ https://stedolan.github.io/jq/
Change informations which are between []

  • source credentialsFile
  • php patchmanager.php "[myCommandHere]"