Note: This documentation is for Moodle 2.7. For up-to-date documentation see Administration via command line.

Administration via command line

From MoodleDocs

Template:Moodle 2.0 Some large scale deployments or special distributions may prefer command line environment when installing or upgrading Moodle. All command line tools are located in admin/cli/*

Support for custom site defaults

Sites now may have different defaults - MDL-17850, all you need to do is to add local/defaults.php file to your installation. The internal format is:

<?php $defaults['pluginname']['settingname'] = 'settingvalue'; //for plugins $defaults['moodle']['settingname'] = 'settingvalue'; //for core settings

These defaults are used during install, upgrade and are also displayed as defaults in admin configuration forms.

Installation

Advanced cli installation script.

   Command line Moodle installer, creates config.php and initializes database.
   Please note you must execute this script with the same uid as apache
   or use chmod/chown after installation.
   
   Site defaults may be changed via local/defaults.php.
   
   Options:
   --chmod=OCTAL-MODE    Permissions of new directories created within dataroot.
                         Default is 2777. You may want to change it to 2770
                         or 2750 or 750. See chmod man page for details.
   --lang=CODE           Installation and default site language.
   --wwwroot=URL         Web address for the Moodle site,
                         required in non-interactive mode.
   --dataroot=DIR        Location of the moodle data folder,
                         must not be web accessible. Default is moodledata
                         in the parent directory.
   --dbtype=TYPE         Database type. Default is mysqli
   --dbhost=HOST         Database host. Default is localhost
   --dbname=NAME         Database name. Default is moodle
   --dbuser=USERNAME     Database user. Default is root
   --dbpass=PASSWORD     Database password. Default is blank
   --dbsocket            Use database sockets. Available for some databases only.
   --prefix=STRING       Table prefix for above database tables. Default is mdl_
   --fullname=STRING     The fullname of the site
   --shortname=STRING    The shortname of the site
   --adminuser=USERNAME  Username for the moodle admin account. Default is admin
   --adminpass=PASSWORD  Password for the moodle admin account,
                         required in non-interactive mode.
   --non-interactive     No interactive questions, installation fails if any
                         problem encountered.
   --agree-license       Indicates agreement with software license,
                         required in non-interactive mode.
   -h, --help            Print out this help
   
   Example:
   $sudo -u www-data /usr/bin/php admin/cli/install.php --lang=cs

Upgrades

Command line Moodle upgrade.
Please note you must execute this script with the same uid as apache!
Site defaults may be changed via local/defaults.php.
Options:
--non-interactive     No interactive questions or confirmations
-h, --help            Print out this help
Example: $sudo -u wwwrun /usr/bin/php admin/cli/upgrade.php

Reset passwords

Reset local user passwords, useful especially for admin acounts.
There are no security checks here because anybody who is able to
execute this file may execute any PHP too.
Options:
-h, --help            Print out this help
Example: $/usr/bin/php admin/cli/reset_password.php

Customize new site

Not implemented yet. Idea is to create a script that customizes freshly installed site.

TODO

Finish help localizations.