Diferencia entre revisiones de «Administración por línea de comando»

De MoodleDocs
m (tidy up)
m (tidy up)
Línea 1: Línea 1:
{{Pendiente de traducir}}
{{Pendiente de traducir}}
{{Instalación}}
{{Instalación}}
Si Usted tiene acceso de ''shell'' a su servidor web, Usted puede encontrar varios ''scripts'' CLI (''CLI = Command Line Interfase'') útiles para la administración de Moodle. Las herramientas de CLI del núcleo de Moodle están localizadas en la carpeta <code>admin/cli/*</code>. Otros plugins proporcionan su funcionalidad CLI mediante scripts en sus propias carpetas cli. Por ejemplo, el script de sincronización enrol_db está localizado en <code>enrol/db/cli/</code>.
Para evitar problemas con el control de acceso, Usted debería de correr los scripts como el propietario del proceso del servidor web. Es especialmente importante par la instalación y actualización por CLI, dado que crean archivos nuevos en el directorio moodledata y el servidor web tiene que tener acceso de escritura a ellos. En las distribuciones Linux, el usuario que corre el servidor web usualmente es apache o wwrun o httpd o algo similar. Como 'root'' Usted probablemente querrá ejecutar los scripts CLI de Moodle de esta manera:
    $ cd /path/to/your/moodle/dir
    $ sudo -u apache /usr/bin/php admin/cli/somescript.php --params
La mayoría de los scripts aceptan el parámetro común --help (o -h) para mostrarle la información  completa respecto al uso, por ejemplo:
    $ sudo -u apache /usr/bin/php admin/cli/install.php --help
== Actualización por línea de comando ==
Moodle can be upgraded from the command line. As with the installation script, there is either interactive or non-interactive mode of the upgrade. The script itself does not put the site into the maintenance mode, you have to do it on your own. Also, the script does not backup any data (if you read this page, you probably have some own scripts to backup your moodledata and the database, right?)
    $ sudo -u apache /usr/bin/php admin/cli/upgrade.php
Upgrading via command line is a very comfortable way of Moodle upgrade if you use Git checkout of the Moodle source code (see [[Git for Administrators]]). See the following procedure how to upgrade your site within several seconds to the most recent version while preserving your eventual local customizations tracked in git repository:
    $ cd /var/www/sites/moodle/htdocs/
    $ sudo -u apache /usr/bin/php admin/cli/maintenance.php --enable
    $ git pull
    $ sudo -u apache /usr/bin/php admin/cli/upgrade.php
    $ sudo -u apache /usr/bin/php admin/cli/maintenance.php --disable
== Instalación por línea de comando ==
Since version 2.0, Moodle can be installed from the command line. There are two modes of installation. In interactive mode, the install script asks you for all data needed to properly set up new Moodle site. In non-interactive mode, you must provide all required data as the script parameters and then the new site is installed silently. The parameters can be passed in the interactive mode, too. The provided values are then used as the default values during the interactive session.
    $ sudo -u apache /usr/bin/php admin/cli/install.php --lang=cs
== Modo de mantenimiento ==
To switch your site into the maintenance mode via CLI, you can use
    $ sudo -u apache /usr/bin/php admin/cli/maintenance.php --enable
To turn the maintenance mode off, just execute the same script with --disable parameter.
== Modo fuera de línea (''Offline'') ==
In some situations, you may want to switch your Moodle site into offline mode so that it is not accessible via the web but you can not stop the web server completely (typically because there are other web pages and applications running there). If a file called <code>climaintenance.html</code> exists in the root folder of moodledata directory, Moodle will automatically display the contents of that file instead of any other page.
    $ cd /var/www/sites/moodle/moodledata/
    $ echo '&lt;h1&gt;Sorry, maintenance in progress&lt;/h1&gt;' &gt; climaintenance.html
You can prepare a nice formatted HTML page to inform your users about the server being down and keep in the moodledata directory under a name like <code>climaintenance.off</code> and rename it to the <code>climaintenance.html</code> if needed.
== Custom site defaults ==
During the install and upgrade via CLI, Moodle sets the administration variables to the default values. You can use different defaults. See MDL-17850 for details. Shortly, all you need to do is to add a file <code>local/defaults.php</code> into your Moodle installation. The format of the file is like
<code php>
<?php
$defaults['pluginname']['settingname'] = 'settingvalue'; // for plugins
$defaults['moodle']['settingname'] = 'settingvalue';    // for core settings
</code>
These defaults are used during install, upgrade and are also displayed as defaults at the Site administration pages.
== Reiniciar contrasseña de usuario ==
If you happen to forget your admin password (or you want to set a password for any other user of your Moodle system), you can use reset_password.php script. The script sets the correctly salted password for the given user.
    $ sudo -u apache /usr/bin/php admin/cli/reset_password.php
== MySQL storage engine conversion ==
If you run your Moodle site with MySQL database backend and use the default MyISAM as the storage engine for your tables, you may want to convert them to use some more reliable engine like InnoDB (actually, you should want to switch to PostgreSQL ;-) anyway).
    $ sudo -u apache /usr/bin/php admin/cli/mysql_engine.php --engine=InnoDB
== Correr cron mediante línea de comando ==
In versions 1.x, you could execute admin/cron.php either from command line or via the web. Since Moodle 2.0, only admin/cli/cron.php script can be run via command line.
==Database transfer==
A command line script for [[Database transfer]] may be found in ''admin/tool/dbtransfer/cli/migrate.php''.
==Actualizar imágenes de usuario mediante línea de comando==
  http://moodle.org/pluginfile.php/143/mod_forum/attachment/926929/updatepics.php
Tested for 2.3.1+
Place this file in /admin/cli/updatepics.php
How to use:
Run with "dir" option to specify which directory contains the files.
  .../admin/cli/updatepics.php --dir=PATH_TO_DIR
* File names must be identical to usernames
==Gestionar Módulos y bloques mediante línea de comando==
Here are two scripts to help you manage your plugins.
  http://tracker.moodle.org/browse/MDL-35736
How to use "manage_blocks.php":
place in /admin/cli
hide:
../admin/cli/manage_blocks.php --name=tag_youtube --hide
show:
../admin/cli/manage_blocks.php --name=tag_youtube --show
delete:
../admin/cli/manage_blocks.php --name=tag_youtube --delete
protect:
../admin/cli/manage_blocks.php --name=tag_youtube --protect
unprotect:
../admin/cli/manage_blocks.php --name=tag_youtube --unprotect
(obviously - replace "tag_youtube" with the blockthat you want to remove...)
How to use "manage_mods.php":
hide:
../admin/cli/manage_blocks.php --name=game --hide
show:
../admin/cli/manage_blocks.php --name=game --show
delete:
../admin/cli/manage_blocks.php --name=game --delete
*Important!
this script does not delete the relevant folder in /moodle/mod or /moodle/blocks
you have to delete it yourself !
==Update language pack via CLI==
  http://tracker.moodle.org/browse/MDL-35735
Place attached file in /admin/cli
and simply run it, without any command-line arguments :)
==ReSort course list via CLI==
  http://tracker.moodle.org/browse/MDL-36237
Place attached file in /admin/cli
and simply run it, without any command-line arguments :)
I import courses every night from an external system, and run this script afterwards
==Purge caches via CLI==
You can purge caches using this script:
  php admin/cli/purge_caches.php
Vea [https://docs.moodle.org/25/en/Administration_via_command_line https://docs.moodle.org/25/en/Administration_via_command_line]
Vea [https://docs.moodle.org/25/en/Administration_via_command_line https://docs.moodle.org/25/en/Administration_via_command_line]
[[fr:Administration en ligne de commande]]
[[de:Administration über Kommandozeile]]
[[ja:コマンドライン経由の管理]]
[[en:Administration via command line]]
[[en:Administration via command line]]

Revisión del 15:46 23 sep 2013

Nota: Pendiente de Traducir. ¡Anímese a traducir esta página!.     ( y otras páginas pendientes)

Si Usted tiene acceso de shell a su servidor web, Usted puede encontrar varios scripts CLI (CLI = Command Line Interfase) útiles para la administración de Moodle. Las herramientas de CLI del núcleo de Moodle están localizadas en la carpeta admin/cli/*. Otros plugins proporcionan su funcionalidad CLI mediante scripts en sus propias carpetas cli. Por ejemplo, el script de sincronización enrol_db está localizado en enrol/db/cli/.

Para evitar problemas con el control de acceso, Usted debería de correr los scripts como el propietario del proceso del servidor web. Es especialmente importante par la instalación y actualización por CLI, dado que crean archivos nuevos en el directorio moodledata y el servidor web tiene que tener acceso de escritura a ellos. En las distribuciones Linux, el usuario que corre el servidor web usualmente es apache o wwrun o httpd o algo similar. Como 'root Usted probablemente querrá ejecutar los scripts CLI de Moodle de esta manera:

   $ cd /path/to/your/moodle/dir
   $ sudo -u apache /usr/bin/php admin/cli/somescript.php --params

La mayoría de los scripts aceptan el parámetro común --help (o -h) para mostrarle la información completa respecto al uso, por ejemplo:

   $ sudo -u apache /usr/bin/php admin/cli/install.php --help

Actualización por línea de comando

Moodle can be upgraded from the command line. As with the installation script, there is either interactive or non-interactive mode of the upgrade. The script itself does not put the site into the maintenance mode, you have to do it on your own. Also, the script does not backup any data (if you read this page, you probably have some own scripts to backup your moodledata and the database, right?)

   $ sudo -u apache /usr/bin/php admin/cli/upgrade.php

Upgrading via command line is a very comfortable way of Moodle upgrade if you use Git checkout of the Moodle source code (see Git for Administrators). See the following procedure how to upgrade your site within several seconds to the most recent version while preserving your eventual local customizations tracked in git repository:

   $ cd /var/www/sites/moodle/htdocs/
   $ sudo -u apache /usr/bin/php admin/cli/maintenance.php --enable
   $ git pull
   $ sudo -u apache /usr/bin/php admin/cli/upgrade.php
   $ sudo -u apache /usr/bin/php admin/cli/maintenance.php --disable

Instalación por línea de comando

Since version 2.0, Moodle can be installed from the command line. There are two modes of installation. In interactive mode, the install script asks you for all data needed to properly set up new Moodle site. In non-interactive mode, you must provide all required data as the script parameters and then the new site is installed silently. The parameters can be passed in the interactive mode, too. The provided values are then used as the default values during the interactive session.

   $ sudo -u apache /usr/bin/php admin/cli/install.php --lang=cs

Modo de mantenimiento

To switch your site into the maintenance mode via CLI, you can use

   $ sudo -u apache /usr/bin/php admin/cli/maintenance.php --enable

To turn the maintenance mode off, just execute the same script with --disable parameter.

Modo fuera de línea (Offline)

In some situations, you may want to switch your Moodle site into offline mode so that it is not accessible via the web but you can not stop the web server completely (typically because there are other web pages and applications running there). If a file called climaintenance.html exists in the root folder of moodledata directory, Moodle will automatically display the contents of that file instead of any other page.

   $ cd /var/www/sites/moodle/moodledata/
   $ echo '<h1>Sorry, maintenance in progress</h1>' > climaintenance.html

You can prepare a nice formatted HTML page to inform your users about the server being down and keep in the moodledata directory under a name like climaintenance.off and rename it to the climaintenance.html if needed.

Custom site defaults

During the install and upgrade via CLI, Moodle sets the administration variables to the default values. You can use different defaults. See MDL-17850 for details. Shortly, all you need to do is to add a file local/defaults.php into your Moodle installation. The format of the file is like

<?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 at the Site administration pages.

Reiniciar contrasseña de usuario

If you happen to forget your admin password (or you want to set a password for any other user of your Moodle system), you can use reset_password.php script. The script sets the correctly salted password for the given user.

   $ sudo -u apache /usr/bin/php admin/cli/reset_password.php

MySQL storage engine conversion

If you run your Moodle site with MySQL database backend and use the default MyISAM as the storage engine for your tables, you may want to convert them to use some more reliable engine like InnoDB (actually, you should want to switch to PostgreSQL ;-) anyway).

   $ sudo -u apache /usr/bin/php admin/cli/mysql_engine.php --engine=InnoDB

Correr cron mediante línea de comando

In versions 1.x, you could execute admin/cron.php either from command line or via the web. Since Moodle 2.0, only admin/cli/cron.php script can be run via command line.

Database transfer

A command line script for Database transfer may be found in admin/tool/dbtransfer/cli/migrate.php.

Actualizar imágenes de usuario mediante línea de comando

  http://moodle.org/pluginfile.php/143/mod_forum/attachment/926929/updatepics.php 

Tested for 2.3.1+

Place this file in /admin/cli/updatepics.php

How to use: Run with "dir" option to specify which directory contains the files.

  .../admin/cli/updatepics.php --dir=PATH_TO_DIR
  • File names must be identical to usernames

Gestionar Módulos y bloques mediante línea de comando

Here are two scripts to help you manage your plugins.

  http://tracker.moodle.org/browse/MDL-35736

How to use "manage_blocks.php": place in /admin/cli

hide: ../admin/cli/manage_blocks.php --name=tag_youtube --hide

show: ../admin/cli/manage_blocks.php --name=tag_youtube --show

delete: ../admin/cli/manage_blocks.php --name=tag_youtube --delete

protect: ../admin/cli/manage_blocks.php --name=tag_youtube --protect

unprotect: ../admin/cli/manage_blocks.php --name=tag_youtube --unprotect

(obviously - replace "tag_youtube" with the blockthat you want to remove...)

How to use "manage_mods.php":

hide: ../admin/cli/manage_blocks.php --name=game --hide

show: ../admin/cli/manage_blocks.php --name=game --show

delete: ../admin/cli/manage_blocks.php --name=game --delete

  • Important!

this script does not delete the relevant folder in /moodle/mod or /moodle/blocks

you have to delete it yourself !

Update language pack via CLI

 http://tracker.moodle.org/browse/MDL-35735

Place attached file in /admin/cli and simply run it, without any command-line arguments :)

ReSort course list via CLI

 http://tracker.moodle.org/browse/MDL-36237

Place attached file in /admin/cli and simply run it, without any command-line arguments :)

I import courses every night from an external system, and run this script afterwards

Purge caches via CLI

You can purge caches using this script:

 php admin/cli/purge_caches.php


Vea https://docs.moodle.org/25/en/Administration_via_command_line