Skip to content

Conversation

EEJoshua
Copy link
Contributor

πŸ›‘ New scripts must first be submitted to ProxmoxVED for testing.
PRs for new scripts that skip this process will be closed.


✍️ Description

Install script for moodle

πŸ”— Related PR / Issue

Link: #

βœ… Prerequisites (X in brackets)

  • Self-review completed – Code follows project standards.
  • Tested thoroughly – Changes work as expected.
  • No breaking changes – Existing functionality remains intact.
  • No security risks – No hardcoded secrets, unnecessary privilege escalations, or permission issues.

πŸ› οΈ Type of Change (X in brackets)

  • 🐞 Bug fix – Resolves an issue without breaking functionality.
  • ✨ New feature – Adds new, non-breaking functionality.
  • πŸ’₯ Breaking change – Alters existing functionality in a way that may require updates.
  • πŸ†• New script – A fully functional and tested script or script set.
  • 🌍 Website update – Changes to website-related JSON files or metadata.
  • πŸ”§ Refactoring / Code Cleanup – Improves readability or maintainability without changing functionality.
  • πŸ“ Documentation update – Changes to README, AppName.md, CONTRIBUTING.md, or other docs.

πŸ” Code & Security Review (X in brackets)

  • Follows Code_Audit.md & CONTRIBUTING.md guidelines
  • Uses correct script structure (AppName.sh, AppName-install.sh, AppName.json)
  • No hardcoded credentials

πŸ“‹ Additional Information (optional)

@EEJoshua EEJoshua requested review from a team as code owners August 18, 2025 20:54
Copy link
Member

@MickLesk MickLesk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First quick review

"password": null
},
"notes": [
"Database and Admin credentials are saved in ~/moodle.creds",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notes need an Type and must be seperate. Checkout the json-editor on our Site:
https://community-scripts.github.io/ProxmoxVE/json-editor

msg_info "Installing Web & DB stack"
$STD apt-get install -y apache2 mariadb-server git unzip \
php libapache2-mod-php \
php-mysql php-zip php-xml php-gd php-curl \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have seperate functions for PHP, mariadb and co. Checkout other Scripts or our tools.func in misc

Comment on lines +38 to +58
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}"

msg_info "Setting permissions and data directory"
install -d -m 0770 -o www-data -g www-data /var/moodledata
Copy link
Member

Choose a reason for hiding this comment

The 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"....

Comment on lines 64 to 81
msg_info "PHP tuning (CLI and Apache)"
PHPVER="$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')" || true
if [[ -z "$PHPVER" ]]; then
PHPVER="$(ls -1d /etc/php/* 2>/dev/null | awk -F'/' '{print $4}' | head -n1)"
fi
if [[ -z "$PHPVER" ]]; then
msg_error "Unable to determine PHP version path under /etc/php"
exit 1
fi
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this is not needed with setup_php function

Comment on lines +28 to +29
MARIADB_VERSION="latest"
export MARIADB_VERSION
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MARIADB_VERSION="latest"
export MARIADB_VERSION

MARIADB_VERSION="latest"
export MARIADB_VERSION
setup_mariadb
msg_ok "MariaDB ready"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
msg_ok "MariaDB ready"

setup_php
msg_ok "PHP ready"

msg_info "Install MariaDB"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
msg_info "Install MariaDB"

Comment on lines +16 to +25
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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"
PHP_VERSION="8.2" PHP_APACHE="YES" PHP_MODULE="mysql,soap,ldap" PHP_MEMORY_LIMIT="256M" setup_php

Comment on lines +48 to +65
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}"
Copy link
Member

@tremor021 tremor021 Aug 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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}"

Dont use git clone, use fetch_and_deploy_gh_release function

@@ -0,0 +1,56 @@
#!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func)

Comment on lines +30 to +38

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}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use git

"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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"logo": "https://moodle.org/theme/image.php/moodleorg/core/1720531200/moodle-logo",
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/moodle.webp",

},
"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." },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{ "type": "warning", "text": "Moodle requires PHP settings: max_input_vars >= 5000 and memory_limit >= 256M. These are applied automatically." },

Not needed

{ "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." },
{ "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)." }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{ "type": "info", "text": "Supports MariaDB as the database backend (configured by the script)." }

Not needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants