-
-
Notifications
You must be signed in to change notification settings - Fork 99
Moodle #813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Moodle #813
Changes from all commits
e026e6e
4831c9d
2aedfcd
d46bfa6
6d88557
df3e81b
d72b56c
4b5cf6a
9a96648
3f06a86
0bf1ddd
1043708
e5f1adc
317c6f6
613ffce
b675ca8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env bash | ||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) | ||
# Copyright (c) 2021-2025 community-scripts ORG | ||
# Author: EEJoshua | ||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE | ||
# Source: https://moodle.org/ | ||
|
||
APP="Moodle" | ||
var_tags="${var_tags:-lms;php}" | ||
var_cpu="${var_cpu:-2}" | ||
var_ram="${var_ram:-4096}" | ||
var_disk="${var_disk:-8}" | ||
var_os="${var_os:-debian}" | ||
var_version="${var_version:-12}" | ||
var_unprivileged="${var_unprivileged:-1}" | ||
|
||
header_info "$APP" | ||
variables | ||
color | ||
catch_errors | ||
|
||
function update_script() { | ||
header_info | ||
check_container_storage | ||
check_container_resources | ||
if [[ ! -f /var/www/moodle/version.php ]]; then | ||
msg_error "No ${APP} Installation Found!" | ||
exit | ||
fi | ||
|
||
msg_info "Preparing repository" | ||
$STD git config --system --add safe.directory /var/www/moodle || true | ||
|
||
BRANCH="$(runuser -u www-data -- git -C /var/www/moodle rev-parse --abbrev-ref HEAD 2>/dev/null || echo 'MOODLE_500_STABLE')" | ||
msg_info "Updating $APP (${BRANCH})" | ||
$STD runuser -u www-data -- git -C /var/www/moodle fetch --all --prune | ||
$STD runuser -u www-data -- git -C /var/www/moodle checkout -B "${BRANCH}" "origin/${BRANCH}" | ||
$STD runuser -u www-data -- git -C /var/www/moodle reset --hard "origin/${BRANCH}" | ||
Comment on lines
+30
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't use git |
||
$STD runuser -u www-data -- /usr/bin/php /var/www/moodle/admin/cli/maintenance.php --enable | ||
$STD runuser -u www-data -- /usr/bin/php /var/www/moodle/admin/cli/upgrade.php --non-interactive | ||
$STD runuser -u www-data -- /usr/bin/php /var/www/moodle/admin/cli/purge_caches.php | ||
$STD runuser -u www-data -- /usr/bin/php /var/www/moodle/admin/cli/maintenance.php --disable | ||
msg_ok "Update Successful" | ||
exit | ||
} | ||
|
||
start | ||
build_container | ||
|
||
description | ||
|
||
msg_ok "Completed Successfully!\n" | ||
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" | ||
echo -e "${INFO}${YW} Access it using the following URL:${CL}" | ||
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:80${CL}" | ||
echo -e "${INFO}${YW} Database and Admin credentials are saved in ~/moodle.creds${CL} inside the LXC" |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,39 @@ | ||||||
{ | ||||||
"name": "Moodle", | ||||||
"slug": "moodle", | ||||||
"categories": [ | ||||||
11 | ||||||
], | ||||||
"date_created": "2025-08-18", | ||||||
"type": "ct", | ||||||
"updateable": true, | ||||||
"privileged": false, | ||||||
"interface_port": 80, | ||||||
"documentation": "https://docs.moodle.org/500/en/Main_page", | ||||||
"website": "https://moodle.org/", | ||||||
"logo": "https://moodle.org/theme/image.php/moodleorg/core/1720531200/moodle-logo", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"description": "Moodle is the worldβs most popular open-source learning management system (LMS). The community edition of Moodle allows educators to create flexible, customizable online learning platforms with extensive plugin support, user management, and activity tracking.", | ||||||
"install_methods": [ | ||||||
{ | ||||||
"type": "default", | ||||||
"script": "ct/moodle.sh", | ||||||
"resources": { | ||||||
"cpu": 2, | ||||||
"ram": 4096, | ||||||
"hdd": 8, | ||||||
"os": "debian", | ||||||
"version": "12" | ||||||
} | ||||||
} | ||||||
], | ||||||
"default_credentials": { | ||||||
"username": null, | ||||||
"password": null | ||||||
}, | ||||||
"notes": [ | ||||||
{ "type": "info", "text": "Database and Admin credentials are saved in ~/moodle.creds" }, | ||||||
{ "type": "warning", "text": "Moodle requires PHP settings: max_input_vars >= 5000 and memory_limit >= 256M. These are applied automatically." }, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Not needed |
||||||
{ "type": "info", "text": "Default data directory: /var/moodledata (writeable by www-data)." }, | ||||||
{ "type": "info", "text": "Supports MariaDB as the database backend (configured by the script)." } | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Not needed |
||||||
] | ||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,156 @@ | ||||||||||||||||||||||||||||||||||||||
#!/usr/bin/env bash | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
# Copyright (c) 2021-2025 community-scripts ORG | ||||||||||||||||||||||||||||||||||||||
# Author: EEJoshua | ||||||||||||||||||||||||||||||||||||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE | ||||||||||||||||||||||||||||||||||||||
# Source: https://docs.moodle.org/500/en/Git_for_Administrators | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" | ||||||||||||||||||||||||||||||||||||||
color | ||||||||||||||||||||||||||||||||||||||
verb_ip6 | ||||||||||||||||||||||||||||||||||||||
catch_errors | ||||||||||||||||||||||||||||||||||||||
setting_up_container | ||||||||||||||||||||||||||||||||||||||
network_check | ||||||||||||||||||||||||||||||||||||||
update_os | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
msg_info "Install PHP (Apache) + required modules" | ||||||||||||||||||||||||||||||||||||||
$STD apt-get install -y git | ||||||||||||||||||||||||||||||||||||||
PHP_VERSION="8.2" | ||||||||||||||||||||||||||||||||||||||
PHP_APACHE="YES" | ||||||||||||||||||||||||||||||||||||||
PHP_FPM="NO" | ||||||||||||||||||||||||||||||||||||||
PHP_MODULE="bcmath,curl,gd,intl,mbstring,opcache,readline,xml,zip,mysql,soap,ldap" | ||||||||||||||||||||||||||||||||||||||
PHP_MEMORY_LIMIT="256M" | ||||||||||||||||||||||||||||||||||||||
export PHP_VERSION PHP_APACHE PHP_FPM PHP_MODULE PHP_MEMORY_LIMIT | ||||||||||||||||||||||||||||||||||||||
setup_php | ||||||||||||||||||||||||||||||||||||||
msg_ok "PHP ready" | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+16
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
msg_info "Install MariaDB" | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||
MARIADB_VERSION="latest" | ||||||||||||||||||||||||||||||||||||||
export MARIADB_VERSION | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+28
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||
setup_mariadb | ||||||||||||||||||||||||||||||||||||||
msg_ok "MariaDB ready" | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
msg_info "Create Moodle database" | ||||||||||||||||||||||||||||||||||||||
DB_NAME="moodle" | ||||||||||||||||||||||||||||||||||||||
DB_USER="moodleuser" | ||||||||||||||||||||||||||||||||||||||
DB_PASS="$(openssl rand -base64 24 | tr -dc 'A-Za-z0-9' | head -c24)" | ||||||||||||||||||||||||||||||||||||||
$STD mariadb -u root -e "CREATE DATABASE \`${DB_NAME}\` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" | ||||||||||||||||||||||||||||||||||||||
$STD mariadb -u root -e "CREATE USER '${DB_USER}'@'localhost' IDENTIFIED BY '${DB_PASS}';" | ||||||||||||||||||||||||||||||||||||||
$STD mariadb -u root -e "GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON \`${DB_NAME}\`.* TO '${DB_USER}'@'localhost'; FLUSH PRIVILEGES;" | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
echo "Moodle DB Credentials" | ||||||||||||||||||||||||||||||||||||||
echo "DB Name: ${DB_NAME}" | ||||||||||||||||||||||||||||||||||||||
echo "DB User: ${DB_USER}" | ||||||||||||||||||||||||||||||||||||||
echo "DB Pass: ${DB_PASS}" | ||||||||||||||||||||||||||||||||||||||
} >>~/"moodle.creds" | ||||||||||||||||||||||||||||||||||||||
msg_ok "Database ready" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
msg_ok "Selecting Moodle branch" | ||||||||||||||||||||||||||||||||||||||
REMOTE_BRANCHES="$(git ls-remote --heads https://github.com/moodle/moodle.git 'MOODLE_*_STABLE' | awk -F'refs/heads/' '{print $2}' | sort -V)" | ||||||||||||||||||||||||||||||||||||||
echo "Available stable branches:" | ||||||||||||||||||||||||||||||||||||||
echo "${REMOTE_BRANCHES}" | ||||||||||||||||||||||||||||||||||||||
echo -n "Enter branch to install [default MOODLE_500_STABLE]: " | ||||||||||||||||||||||||||||||||||||||
read -r MOODLE_BRANCH | ||||||||||||||||||||||||||||||||||||||
MOODLE_BRANCH="${MOODLE_BRANCH:-MOODLE_500_STABLE}" | ||||||||||||||||||||||||||||||||||||||
if ! echo "${REMOTE_BRANCHES}" | grep -qx "${MOODLE_BRANCH}"; then | ||||||||||||||||||||||||||||||||||||||
msg_error "Branch ${MOODLE_BRANCH} not found among remotes" | ||||||||||||||||||||||||||||||||||||||
exit 1 | ||||||||||||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||||||||||||
msg_ok "Selected ${MOODLE_BRANCH}" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
msg_info "Cloning Moodle (shallow)" | ||||||||||||||||||||||||||||||||||||||
install -d -m 0755 /var/www | ||||||||||||||||||||||||||||||||||||||
$STD rm -rf /var/www/moodle | ||||||||||||||||||||||||||||||||||||||
$STD git clone --depth 1 --branch "${MOODLE_BRANCH}" https://github.com/moodle/moodle.git /var/www/moodle | ||||||||||||||||||||||||||||||||||||||
msg_ok "Cloned Moodle ${MOODLE_BRANCH}" | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+48
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Dont use git clone, use |
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
msg_info "Setting permissions and data directory" | ||||||||||||||||||||||||||||||||||||||
install -d -m 0770 -o www-data -g www-data /var/moodledata | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+48
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why so much effort? Just use function "fetch_and_deploy_gh_release "moodle".... |
||||||||||||||||||||||||||||||||||||||
$STD chown -R www-data:www-data /var/www/moodle | ||||||||||||||||||||||||||||||||||||||
$STD find /var/www/moodle -type d -exec chmod 02775 {} \; | ||||||||||||||||||||||||||||||||||||||
$STD find /var/www/moodle -type f -exec chmod 0644 {} \; | ||||||||||||||||||||||||||||||||||||||
msg_ok "Permissions set" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
msg_info "Configuring Apache" | ||||||||||||||||||||||||||||||||||||||
cat >/etc/apache2/sites-available/moodle.conf <<'EOF' | ||||||||||||||||||||||||||||||||||||||
<VirtualHost *:80> | ||||||||||||||||||||||||||||||||||||||
ServerName _ | ||||||||||||||||||||||||||||||||||||||
DocumentRoot /var/www/moodle | ||||||||||||||||||||||||||||||||||||||
<Directory /var/www/moodle> | ||||||||||||||||||||||||||||||||||||||
AllowOverride All | ||||||||||||||||||||||||||||||||||||||
Require all granted | ||||||||||||||||||||||||||||||||||||||
</Directory> | ||||||||||||||||||||||||||||||||||||||
ErrorLog ${APACHE_LOG_DIR}/moodle_error.log | ||||||||||||||||||||||||||||||||||||||
CustomLog ${APACHE_LOG_DIR}/moodle_access.log combined | ||||||||||||||||||||||||||||||||||||||
</VirtualHost> | ||||||||||||||||||||||||||||||||||||||
EOF | ||||||||||||||||||||||||||||||||||||||
$STD a2enmod rewrite | ||||||||||||||||||||||||||||||||||||||
$STD a2dissite 000-default.conf | ||||||||||||||||||||||||||||||||||||||
$STD a2ensite moodle.conf | ||||||||||||||||||||||||||||||||||||||
$STD systemctl reload apache2 | ||||||||||||||||||||||||||||||||||||||
msg_ok "Apache configured" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
msg_info "Apply PHP tunables" | ||||||||||||||||||||||||||||||||||||||
PHPVER="$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')" 2>/dev/null || true | ||||||||||||||||||||||||||||||||||||||
[[ -z "$PHPVER" ]] && PHPVER="$(ls -1d /etc/php/* 2>/dev/null | awk -F'/' '{print $4}' | head -n1)" | ||||||||||||||||||||||||||||||||||||||
for sapi in apache2 cli; do | ||||||||||||||||||||||||||||||||||||||
install -d -m 0755 "/etc/php/${PHPVER}/${sapi}/conf.d" | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
echo "max_input_vars=5000" | ||||||||||||||||||||||||||||||||||||||
echo "memory_limit=256M" | ||||||||||||||||||||||||||||||||||||||
} >"/etc/php/${PHPVER}/${sapi}/conf.d/99-moodle.ini" | ||||||||||||||||||||||||||||||||||||||
done | ||||||||||||||||||||||||||||||||||||||
$STD systemctl reload apache2 | ||||||||||||||||||||||||||||||||||||||
msg_ok "PHP tuned" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
msg_info "Run Moodle CLI installer" | ||||||||||||||||||||||||||||||||||||||
IPV4="$(hostname -I | awk '{print $1}')" | ||||||||||||||||||||||||||||||||||||||
WWWROOT="http://${IPV4}" | ||||||||||||||||||||||||||||||||||||||
DEFAULT_ADMIN_EMAIL="admin@example.com" | ||||||||||||||||||||||||||||||||||||||
ADMIN_EMAIL="${MOODLE_ADMIN_EMAIL:-$DEFAULT_ADMIN_EMAIL}" | ||||||||||||||||||||||||||||||||||||||
ADMIN_USER="admin" | ||||||||||||||||||||||||||||||||||||||
ADMIN_PASS="$(openssl rand -base64 24 | tr -dc 'A-Za-z0-9' | head -c20)" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
msg_info "Running non-interactive Moodle CLI installer (MariaDB driver)" | ||||||||||||||||||||||||||||||||||||||
$STD runuser -u www-data -- /usr/bin/php /var/www/moodle/admin/cli/install.php \ | ||||||||||||||||||||||||||||||||||||||
--chmod=2775 \ | ||||||||||||||||||||||||||||||||||||||
--lang=en \ | ||||||||||||||||||||||||||||||||||||||
--wwwroot="${WWWROOT}" \ | ||||||||||||||||||||||||||||||||||||||
--dataroot="/var/moodledata" \ | ||||||||||||||||||||||||||||||||||||||
--dbtype="mariadb" \ | ||||||||||||||||||||||||||||||||||||||
--dbhost="localhost" \ | ||||||||||||||||||||||||||||||||||||||
--dbname="${DB_NAME}" \ | ||||||||||||||||||||||||||||||||||||||
--dbuser="${DB_USER}" \ | ||||||||||||||||||||||||||||||||||||||
--dbpass="${DB_PASS}" \ | ||||||||||||||||||||||||||||||||||||||
--dbport="" \ | ||||||||||||||||||||||||||||||||||||||
--fullname="Moodle Site" \ | ||||||||||||||||||||||||||||||||||||||
--shortname="Moodle" \ | ||||||||||||||||||||||||||||||||||||||
--summary="Self-hosted Moodle (${MOODLE_BRANCH})" \ | ||||||||||||||||||||||||||||||||||||||
--adminuser="${ADMIN_USER}" \ | ||||||||||||||||||||||||||||||||||||||
--adminpass="${ADMIN_PASS}" \ | ||||||||||||||||||||||||||||||||||||||
--adminemail="${ADMIN_EMAIL}" \ | ||||||||||||||||||||||||||||||||||||||
--agree-license \ | ||||||||||||||||||||||||||||||||||||||
--non-interactive | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
echo "" | ||||||||||||||||||||||||||||||||||||||
echo "Moodle Admin Credentials" | ||||||||||||||||||||||||||||||||||||||
echo "User: ${ADMIN_USER}" | ||||||||||||||||||||||||||||||||||||||
echo "Pass: ${ADMIN_PASS}" | ||||||||||||||||||||||||||||||||||||||
echo "Email: ${ADMIN_EMAIL}" | ||||||||||||||||||||||||||||||||||||||
echo "URL : ${WWWROOT}" | ||||||||||||||||||||||||||||||||||||||
echo "Branch: ${MOODLE_BRANCH}" | ||||||||||||||||||||||||||||||||||||||
} >>~/"moodle.creds" | ||||||||||||||||||||||||||||||||||||||
msg_ok "CLI installer completed" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
msg_info "Enabling cron" | ||||||||||||||||||||||||||||||||||||||
echo '* * * * * www-data /usr/bin/php -f /var/www/moodle/admin/cli/cron.php >/dev/null 2>&1' >/etc/cron.d/moodle | ||||||||||||||||||||||||||||||||||||||
$STD chmod 0644 /etc/cron.d/moodle | ||||||||||||||||||||||||||||||||||||||
msg_ok "Cron enabled" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
motd_ssh | ||||||||||||||||||||||||||||||||||||||
customize | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
msg_info "Cleaning up" | ||||||||||||||||||||||||||||||||||||||
$STD apt-get -y autoremove | ||||||||||||||||||||||||||||||||||||||
$STD apt-get -y autoclean | ||||||||||||||||||||||||||||||||||||||
msg_ok "Cleaned" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.