Moodle

Installation per Kommandozeile

cd /var/www/html/moodle
sudo -u apache /usr/bin/php /var/www/html/moodle/admin/cli/install.php \
    --chmod=2750 \
    --lang=en \
    --wwwroot=https://learning.example.com \
    --dataroot=/data \
    --dbtype=mariadb \
    --dbhost=localhost \
    --dbname=moodle \
    --dbuser=moodle \
    --dbpass=linuxfabrik \
    --dbport=3306 \
    --dbsocket=/var/lib/mysql/mysql.sock \
    --prefix=mdl_ \
    --fullname='Full Site Name' \
    --shortname='ShortName' \
    --summary='The summary to be displayed on the front page' \
    --adminuser=moodle-admin \
    --adminpass=linuxfabrik \
    --adminemail=admin@example.com \
    --sitepreset=sitepreset \
    --supportemail=support@example.com \
    --upgradekey= \
    --non-interactive \
    --agree-license

Moodle install.php Cheat Sheet:

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
--dbport=NUMBER       Use database port.
--dbsocket=PATH       Use database socket, 1 means default. 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
--summary=STRING      The summary to be displayed on the front page
--adminuser=USERNAME  Username for the moodle admin account. Default is admin
--adminpass=PASSWORD  Password for the moodle admin account,
                      required in non-interactive mode.
--adminemail=STRING   Email address for the moodle admin account.
--sitepreset=STRING   Admin site preset to be applied during the installation process.
--supportemail=STRING Email address for support and help.
--upgradekey=STRING   The upgrade key to be set in the config.php, leave empty to not set it.
--non-interactive     No interactive questions, installation fails if any
                      problem encountered.
--agree-license       Indicates agreement with software license,
                      required in non-interactive mode.
--allow-unstable      Install even if the version is not marked as stable yet,
                      required in non-interactive mode.
--skip-database       Stop the installation before installing the database.
-h, --help            Print out this help

Example:
$sudo -u www-data /usr/bin/php admin/cli/install.php --lang=cs

Moodle auf der Kommandozeile konfigurieren

Das Tool verarbeitet Key/Value-Paare.

Alle Einstellungen auslesen:

sudo -u apache php /var/www/html/moodle/admin/cli/cfg.php

Updates und Upgrades

Siehe auch https://docs.moodle.org/404/en/Administration_via_command_line.

Neue Version der PHP-Dateien ins /var/www/html/moodle kopieren, z.B. per LFOps-Rolle. Dann:

sudo -u apache php /var/www/html/moodle/admin/cli/maintenance.php --enable
sudo -u apache php /var/www/html/moodle/admin/cli/upgrade.php --non-interactive
sudo -u apache php /var/www/html/moodle/admin/cli/maintenance.php --disable

Moosh

Die Administrationsmöglichkeiten mit Moodle-Bordmitteln auf der Kommandozeile sind (zumindest bis Version 4.1 LTS) sehr beschränkt. Beispielsweise ist das Anlegen von Benutzern nicht möglich. Hier hilft Moosh.

cd /var/www/html/moodle
sudo -u apache php /opt/moosh/moosh.php --user=moodle-admin --list-commands

Bemerkung

Die Reihenfolge der Parameter und Argumente ist wichtig:

sudo -u apache php /opt/moosh/moosh.php `user-create --firstname=Linus --lastname=Löffel --city=Zurich --country=Switzerland linus
  1. moosh.php

  2. Das Kommando wie user-create

  3. Die Parameter wie --firstname=Linus --lastname=Löffel --city=Zurich --country=Switzerland

  4. Das Argument wie linus (oder der Plugin-Name)

Anderes Beispiel: sudo -u apache php /opt/moosh/moosh.php config-set objectclass inetorgperson auth_ldap - der letzte Parameter hier steht für das zu konfigurierende Modul.

Moosh Cheat Sheet:

activity-add
activity-config-set
activity-delete
activity-move
admin-login
admin-remove-orphaned-modules
apache-parse-extendedlog
apache-parse-missing-files
apache-parse-perflog
audit-passwords
auth-list
auth-manage
backup-info
badge-create
badge-delete
badge-delete-duplicates
base-path
block-add
block-manage
cache-add-mem-store
cache-add-redis-store
cache-clear
cache-config-get
cache-course-rebuild
cache-edit-mappings
cache-test
category-config-set
category-create
category-delete
category-export
category-import
category-list
category-move
category-resortcourses
category-sortordertofirst
chkdatadir
code-check
cohort-create
cohort-enrol
cohort-enrolfile
cohort-unenrol
config-get
config-plugin-export
config-plugin-import
config-plugins
config-set
context-rebuild
course-backup
course-cleanup
course-config-set
course-create
course-delete
course-enableselfenrol
course-enrol
course-enrolbyname
course-image-generate
course-info
course-last-visited
course-list
course-move
course-reset
course-restore
course-unenrol
data-stats
db-stats
debug-off
debug-on
delete-missingplugins
dev-langusage
dev-versionbump
download-moodle
event-fire
event-list
file-check
file-datacheck
file-dbcheck
file-delete
file-hash-delete
file-list
file-path
file-upload
filter-set
fontawesome-refreshcache
form-add
forum-newdiscussion
framework-import
generate-availability
generate-block
generate-cfg
generate-enrol
generate-filemanager
generate-files
generate-form
generate-gradeexport
generate-gradereport
generate-lang
generate-local
generate-messageoutput
generate-module
generate-moosh
generate-qtype
generate-userprofilefield
generate-ws
gradebook-export
gradebook-import
gradecategory-create
gradecategory-list
gradeitem-create
gradeitem-list
group-assigngrouping
group-create
group-delete
group-empty
group-list
group-memberadd
grouping-create
info
info-context
info-plugins
label-create
lang-compare
lang-stats
language-install
languages-update
log-analyse
maintenance-off
maintenance-on
module-config
module-copy
module-manage
module-reinstall
nagios-check
nginx-parse-extendedlog
perf-analyse
php-eval
plugin-download
plugin-install
plugin-list
plugin-uninstall
plugins-usage
question-delete
question-import
questionbank-import
questioncategory-create
quiz-delete-attempts
random-label
report-concurrency
restore-settings
role-create
role-delete
role-export
role-import
role-list
role-reset
role-update-capability
role-update-contextlevel
section-config-set
sql-cli
sql-dump
sql-run
string-replace-encoded
task-lock-check
theme-info
theme-settings-export
theme-settings-import
top
user-assign-system-role
user-create
user-delete
user-export
user-import-pictures
user-list
user-login
user-mod
user-online
user-unassign-system-role
userprofilefields-export
userprofilefields-import
webservice-call

Moodle, Moosh und LDAP

dnf -y install php-ldap

sudo -u apache php /opt/moosh/moosh.php auth-manage enable ldap

sudo -u apache php /opt/moosh/moosh.php config-get auth_ldap

# LDAP Server Settings
sudo -u apache php /opt/moosh/moosh.php config-set host_url ldap://ldap.example.com auth_ldap
sudo -u apache php /opt/moosh/moosh.php config-set bind_dn cn=admin,dc=example,dc=com auth_ldap
sudo -u apache php /opt/moosh/moosh.php config-set bind_pw linuxfabrik auth_ldap
sudo -u apache php /opt/moosh/moosh.php config-set contexts ou=users,dc=example,dc=com auth_ldap

# LDAP User Attribute Mappings
sudo -u apache php /opt/moosh/moosh.php config-set user_attribute uid auth_ldap
sudo -u apache php /opt/moosh/moosh.php config-set memberattribute member auth_ldap
sudo -u apache php /opt/moosh/moosh.php config-set objectclass inetOrgPerson auth_ldap

# LDAP User Login and Password Handling
sudo -u apache php /opt/moosh/moosh.php config-set changepasswordurl "" auth_ldap
sudo -u apache php /opt/moosh/moosh.php config-set user_type "" auth_ldap

# Other Optional Settings
sudo -u apache php /opt/moosh/moosh.php config-set search_sub 1 auth_ldap
sudo -u apache php /opt/moosh/moosh.php config-set opt_deref 0 auth_ldap

Built on 2024-11-18