Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 21 additions & 34 deletions simplerisk-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -515,43 +515,30 @@ setup_ubuntu_debian(){
print_status 'Updating current packages (this may take a bit)...'
run_cmd apt-get dist-upgrade -qq --assume-yes

if [ "${OS}" = "${UBUNTU_OSVAR}" ]; then
print_status 'Installing lamp-server...'
run_cmd apt-get install -y 'lamp-server^'
print_status 'Installing cron...'
run_cmd apt-get install -y cron

# lamp-server^ installs whatever PHP version Ubuntu's own archive
# defaults to for this release (e.g. 8.1 on 22.04), which can be
# older than SimpleRisk's Composer platform requirement. Install the
# pinned Sury version from the repo added above and switch Apache's
# active PHP module to it, without touching the MySQL/Apache
# packages lamp-server^ already installed.
print_status "Installing PHP ${apt_php_version} from Ondrej's repository..."
run_cmd apt-get install -y "php${apt_php_version}" "php${apt_php_version}-mysql" "libapache2-mod-php${apt_php_version}"
for old_mod_file in /etc/apache2/mods-enabled/php*.load; do
[ -e "${old_mod_file}" ] || continue
old_mod=$(basename "${old_mod_file}" .load)
[ "${old_mod}" = "php${apt_php_version}" ] && continue
run_cmd a2dismod "${old_mod}"
done
run_cmd a2enmod "php${apt_php_version}"
else
print_status 'Installing Apache...'
run_cmd apt-get install -y apache2
# Both OSes install the same explicit package set - Ubuntu previously
# used the lamp-server^ "task" metapackage instead, but that pulls in a
# large set of packages beyond the actual LAMP stack (CGI/Perl libraries,
# etc.) that SimpleRisk has no use for, and still needed the Sury PHP
# package installed and its Apache module swapped in afterward to
# override whatever older PHP lamp-server^ had already defaulted to.
# Installing the same explicit packages Debian already uses (now that
# Ubuntu gets the same Sury repo added above) gets the pinned PHP
# version directly, with nothing to swap out.
print_status 'Installing Apache...'
run_cmd apt-get install -y apache2

print_status 'Installing MySQL...'
run_cmd apt-get install -y mysql-server
print_status 'Installing MySQL...'
run_cmd apt-get install -y mysql-server

print_status 'Installing PHP...'
run_cmd apt-get install -y "php${apt_php_version:-}" "php${apt_php_version:-}-mysql" "libapache2-mod-php${apt_php_version:-}"
print_status 'Installing PHP...'
run_cmd apt-get install -y "php${apt_php_version:-}" "php${apt_php_version:-}-mysql" "libapache2-mod-php${apt_php_version:-}"

if [ "${OS}" = "${DEBIAN_OSVAR}" ]; then
if [ "${VER}" = '12' ] || [ "${VER}" = '13' ]; then
print_status 'Installing crontab'
run_cmd apt-get install -y cron
fi
fi
if [ "${OS}" = "${UBUNTU_OSVAR}" ]; then
print_status 'Installing cron...'
run_cmd apt-get install -y cron
elif [ "${VER}" = '12' ] || [ "${VER}" = '13' ]; then
print_status 'Installing crontab'
run_cmd apt-get install -y cron
fi

print_status 'Installing PHP development libraries...'
Expand Down
28 changes: 17 additions & 11 deletions tests/dockerfiles/Dockerfile.ubuntu-22.04
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,30 @@ RUN apt-get update && \

# MySQL uses native AIO by default, which fails on Docker's overlayfs storage
# driver during the post-install data directory initialisation. Pre-creating
# this config disables AIO so that `lamp-server^` installs cleanly.
# this config disables AIO so that mysql-server installs cleanly.
RUN mkdir -p /etc/mysql/conf.d && \
printf '[mysqld]\ninnodb_use_native_aio=0\n' > /etc/mysql/conf.d/docker.cnf

# DENY all service operations during the lamp-server^ pre-install below.
# This is the standard Docker pattern: MySQL's post-install script tries to
# start mysqld for initialization and then shut it down — the shutdown step
# times out inside Docker's overlayfs because the process can't be signalled
# cleanly. By denying service actions here, dpkg skips start/stop but still
# initialises the data directory via mysqld --initialize, which is sufficient.
# DENY all service operations during the apache2/mysql-server pre-install
# below. This is the standard Docker pattern: MySQL's post-install script
# tries to start mysqld for initialization and then shut it down — the
# shutdown step times out inside Docker's overlayfs because the process
# can't be signalled cleanly. By denying service actions here, dpkg skips
# start/stop but still initialises the data directory via mysqld
# --initialize, which is sufficient.
RUN printf '#!/bin/sh\nexit 101\n' > /usr/sbin/policy-rc.d && \
chmod +x /usr/sbin/policy-rc.d

# Pre-install lamp-server^ so that when the setup script calls
# `apt-get install -y lamp-server^` during the test run, all packages are
# already present and dpkg has nothing to reconfigure.
# Pre-install the same explicit packages simplerisk-setup.sh installs
# (apache2, mysql-server - PHP comes from the Sury repo the script adds
# itself, not from Ubuntu's own archive) so the test run has nothing left
# to fetch. Deliberately not the lamp-server^ metapackage: it pulls in a
# large set of packages beyond the actual LAMP stack (CGI/Perl libraries,
# etc.) the script has no use for, and installs whatever PHP version
# Ubuntu's own archive defaults to, which the script immediately overrides
# via Sury anyway.
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y lamp-server^ && \
DEBIAN_FRONTEND=noninteractive apt-get install -y apache2 mysql-server && \
rm -rf /var/lib/apt/lists/*

# Switch back to ALLOW so the setup script can start/stop services normally
Expand Down
14 changes: 9 additions & 5 deletions tests/dockerfiles/Dockerfile.ubuntu-24.04
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ RUN apt-get update && \
RUN mkdir -p /etc/mysql/conf.d && \
printf '[mysqld]\ninnodb_use_native_aio=0\n' > /etc/mysql/conf.d/docker.cnf

# DENY all service operations during the lamp-server^ pre-install below.
# MySQL's post-install shutdown times out inside Docker; denying start/stop
# lets dpkg initialise the data directory without triggering the timeout.
# DENY all service operations during the apache2/mysql-server pre-install
# below. MySQL's post-install shutdown times out inside Docker; denying
# start/stop lets dpkg initialise the data directory without triggering
# the timeout.
RUN printf '#!/bin/sh\nexit 101\n' > /usr/sbin/policy-rc.d && \
chmod +x /usr/sbin/policy-rc.d

# Pre-install lamp-server^ so packages are already present for the test run.
# Pre-install the same explicit packages simplerisk-setup.sh installs
# (apache2, mysql-server - PHP comes from the Sury repo the script adds
# itself). Deliberately not the lamp-server^ metapackage: see
# Dockerfile.ubuntu-22.04 for why.
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y lamp-server^ && \
DEBIAN_FRONTEND=noninteractive apt-get install -y apache2 mysql-server && \
rm -rf /var/lib/apt/lists/*

# Switch back to ALLOW so the setup script can start/stop services normally.
Expand Down
14 changes: 9 additions & 5 deletions tests/dockerfiles/Dockerfile.ubuntu-26.04
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ RUN apt-get update && \
RUN mkdir -p /etc/mysql/conf.d && \
printf '[mysqld]\ninnodb_use_native_aio=0\n' > /etc/mysql/conf.d/docker.cnf

# DENY all service operations during the lamp-server^ pre-install below.
# MySQL's post-install shutdown times out inside Docker; denying start/stop
# lets dpkg initialise the data directory without triggering the timeout.
# DENY all service operations during the apache2/mysql-server pre-install
# below. MySQL's post-install shutdown times out inside Docker; denying
# start/stop lets dpkg initialise the data directory without triggering
# the timeout.
RUN printf '#!/bin/sh\nexit 101\n' > /usr/sbin/policy-rc.d && \
chmod +x /usr/sbin/policy-rc.d

# Pre-install lamp-server^ so packages are already present for the test run.
# Pre-install the same explicit packages simplerisk-setup.sh installs
# (apache2, mysql-server - PHP comes from the Sury repo the script adds
# itself). Deliberately not the lamp-server^ metapackage: see
# Dockerfile.ubuntu-22.04 for why.
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y lamp-server^ && \
DEBIAN_FRONTEND=noninteractive apt-get install -y apache2 mysql-server && \
rm -rf /var/lib/apt/lists/*

# Switch back to ALLOW so the setup script can start/stop services normally.
Expand Down
Loading