CoreInto

Command line

Everything in CoreInto can be done from the admin area. For hosting accounts with shell access (SSH), cli.php adds a few commands that are useful when the admin area cannot be reached, when a server task should run from a script, or when an import is large.

CoreInto developer guide: Command line overview with the main sections of the article

Everything in CoreInto can be done from the admin area. For hosting accounts with shell access (SSH), cli.php adds a few commands that are useful when the admin area cannot be reached, when a server task should run from a script, or when an import is large. A second script, tools/release.php, is for the people who publish CoreInto releases, not for a site. A third, tools/lang.php, works on translation files and is described in Languages. Neither can be run from a browser: both answer "403 Forbidden" over the web, and .htaccess refuses to serve cli.php.

Running the commands

Open a shell on the server, go to CoreInto's folder, and run php cli.php followed by the command:

cd /home/USER/public_html
php cli.php version

If php on the command line is an old version, use the full path to PHP 8.1 or newer, for example /usr/local/bin/php82 cli.php version. The hosting control panel usually shows which path to use for cron jobs; the same path works here.

Every command except version connects to the database named in configuration.php and needs the encryption key from that file, so run the commands on the server where CoreInto is installed. Errors are printed and the command exits with code 1. Running php cli.php with no command prints the list of commands and exits with code 2.

usage: php cli.php migrate | create-admin NAME [EMAIL] | reset-admin NAME | run-task NAME | pipe-ticket [DEPARTMENT] | import-whmcs ... | version

The commands

version

php cli.php version

Prints the version of the CoreInto files, for example 0.21.1-dev. It does not touch the database, so it works before installation and while a database update is pending. The same version is shown on the dashboard under System Information.

migrate

php cli.php migrate

Brings the database up to date with the files: applies every numbered file in app/migrations/ that has not been applied yet, in order, printing each one, and ends with "the database is up to date". It also creates the three standard administrator roles if the roles table is empty.

Use it after uploading a new version when you prefer the command line to the Database Update page in the admin area (both do the same thing; the page needs the "Update CoreInto" permission). Back up the database first. If a change fails, nothing after it is applied; the error is printed.

create-admin

php cli.php create-admin NAME [EMAIL]

Adds an administrator with the Full Administrator role (role 1) and prints a random 20-character password:

Administrator maria created.
Password: 9kQ2...
You will be asked to choose a new password at the first sign-in.

NAME is the username: 2 to 64 letters, digits, dots, dashes or underscores, and not yet taken. EMAIL is optional; add it so the administrator can receive staff notices and reset links, or set it later under Settings > Administrators. The first and last name are left empty. The database is brought up to date first, as with migrate.

Use it when nobody can sign in any more, for example after the only full administrator left the company, or to make the first administrator on a copy restored from a backup.

reset-admin

php cli.php reset-admin NAME

Gives the administrator NAME a new random password and prints it. It also:

  • turns off two-step sign-in for that administrator (the authenticator app and the recovery codes stop working; they can set it up again under My Account);
  • enables the account if it was disabled;
  • ends every session of that administrator;
  • marks the account "Ask for a new password at the next sign-in".
New password for maria: Xo7p...
Two-step sign-in was turned off; turn it on again under My Account.

Use it when an administrator is locked out: password forgotten and "Staff may reset a forgotten password by email" is off or the email does not arrive, or phone and recovery codes both lost and no other administrator can turn two-step sign-in off for them. Unknown names answer "there is no administrator NAME".

run-task

php cli.php run-task NAME

Runs one automation task now, whatever its schedule and whether or not it is turned off on Utilities > Automation Status, and prints its result line:

php cli.php run-task create-invoices
create-invoices: 3 invoices created

NAME is the task name as shown in small type on Automation Status, for example jobs, create-invoices, invoice-reminders, suspensions, domain-sync, ticket-mail, backup or prune. Automation lists them all. A task that is not built in this version, or does not exist, answers "there is no task called NAME, or it is not built yet". If a cron run holds the task at that moment, the answer is "another run is busy with it". The run is recorded on Automation Status with the runner "command line", and the task's next due time moves forward as after any run.

Use it to try a task right after changing its settings, to catch up after the cron job was down (run-task jobs sends waiting email at once), or to run a task from your own scripts.

pipe-ticket

php cli.php pipe-ticket [DEPARTMENT_ID]

Reads one raw email from standard input and turns it into a support ticket or a reply, exactly as the ticket-mail task does for department mailboxes. It prints what happened, for example Ticket opened, Ticket reply, Ticket reply by staff, Blocked: spam filter (subject), Refused: ... or Ignored: automatic message, and writes the same to the Ticket Mail Import Log.

This is for mail servers that can pipe (forward) incoming email to a program instead of a mailbox. In the control panel's email forwarder or filter for support@example.com, set the destination to:

|/usr/local/bin/php /home/USER/public_html/cli.php pipe-ticket

The exact way to write a pipe destination depends on the mail server; use the full path to both PHP and cli.php.

Which department the ticket goes to:

  1. A subject that contains [Ticket #MASK] adds a reply to that ticket, provided the sender is allowed to.
  2. Otherwise the department whose email address the mail was sent to.
  3. Otherwise the department given as DEPARTMENT_ID (the number in the address of the department's page under Settings > Support Departments).
  4. Otherwise the first department.

The mail goes through the same checks as collected mail: automatic replies, mail from a department's own address (a loop), spam filters, banned senders, the per-sender limit ("Most tickets by email per sender per 15 minutes") and departments that only take tickets from clients. An empty input answers "pipe the email into this command". The command needs a department to exist.

import-whmcs

php cli.php import-whmcs --db=NAME --user=USER [--host=localhost] [--port=3306] [--socket=PATH] [--wipe] [--no-emails]

Copies the records of a WHMCS database (versions 7.10 to 8.x) into this CoreInto, the same import as Utilities > Import Data, for cases where the database is large or the admin area times out. The import itself, what it copies and what it leaves out, is described in Import.

OptionMeaning
--db=NAMEThe WHMCS database name. Required.
--user=USERA database user who can read it. Required.
--host=HOSTIts host, default localhost.
--port=PORTIts port, default 3306.
--socket=PATHA Unix socket instead of host and port.
--wipeRemove the records of an earlier import first. Without it, the import refuses when CoreInto already has clients or invoices ("Import again with 'remove what is there' ticked"). Staff, settings and email templates are never removed.
--no-emailsDo not bring the email history over.

The command asks for the WHMCS database user's password without showing it on the screen. To run it from a script, put the password in the environment variable WHMCS_DB_PASS instead:

WHMCS_DB_PASS='secret' php cli.php import-whmcs --db=whmcs --user=whmcs --wipe

It brings this CoreInto's database up to date first, then prints what it found (WHMCS 8.1.3 (Example Hosting): 1200 clients, 3100 services, 900 domains, 25000 invoices), one line per step as it goes (... clients), a table of counts of what was copied, a comparison of counts and money totals between WHMCS and CoreInto (lines that differ are marked <- differs), and finally the notes you should read: things that could not be copied, such as passwords WHMCS kept encrypted with its own key, or downloads whose files must be uploaded again.

The WHMCS database must be reachable from the server CoreInto runs on. Nothing is written to it.

licence-set and licence-check

php cli.php licence-set CI-XXXXX-XXXXX-XXXXX-XXXXX
php cli.php licence-check

licence-set checks a CoreInto licence key with the licence server and saves it, as "Check and save" on Utilities > CoreInto Licence does: a working licence is kept when the new key cannot be checked or is not accepted. licence-check checks the saved key now. Both print the state, for example Licence: licensed, and end with an error code when the licence server could not be asked. See CoreInto licence.

tools/release.php

tools/release.php is used by whoever publishes releases of CoreInto, intoPanel and StackRegent. It is not needed on a site, and the tools folder is closed to the web. It is run from a checkout of the code on the publisher's own computer and refuses to run over the web.

A release is offered to licensed programs by the licence server (Add-ons > Licensing Releases) and installed only when its signature checks against the release key built into the program. The release private key stays on the publisher's computer.

keygen-product

php tools/release.php keygen-product --private=PATH --public=PATH

Makes a release key pair (ECDSA P-256) for a program. The private key is written to the first path, readable only by its owner; keep it offline and never upload it. Paste the public key into Licensing Settings > Release keys on the licence server, and build it into the program. The command refuses to overwrite an existing private key: a new pair would make every installed copy reject your releases.

sign-product

php tools/release.php sign-product --product=CODE --version=X.Y.Z --file=FILE --key=PRIVATE.pem

Prints the size, SHA-256 and signature of a release file for the product code (coreinto, intopanel or stackregent), to paste into Licensing Releases > Add Release. For CoreInto the file is the release zip made with git archive --prefix=coreinto/; see "For the publisher" in Backups and updates.

Frequently asked questions

What does "Command line" cover in CoreInto?

Everything in CoreInto can be done from the admin area. For hosting accounts with shell access (SSH), cli.php adds a few commands that are useful when the admin area cannot be reached, when a server task should run from a script, or when an import is large. Everything in CoreInto can be done from the admin area. For hosting accounts with shell access (SSH), cli.php adds a few commands that are useful when the admin area cannot be reached, when a server task should run from a script, or when an import is large. A second script, tools/release.php, is for the people who publish CoreInto releases, not for a site. A third, tools/lang.php, works on translation files and is described in Languages. Neither can be run from a browser: both answer &quot;403 Forbidden&quot; over the web, and .htaccess refuses to serve cli.php.

Where do I find more help?

Use the Help button on this site, browse the Developer guide on coreinto.com, or submit a ticket at https://system.coreinto.com/contact with your panel version and the steps you tried.

Submit a ticket