#!/bin/bash set -euo pipefail apt-get update apt-get install -y apache2 apache2-mod_php8.3 php8.3-mysqlnd-mysqli mariadb-server mkdir -p /mnt/additional mountpoint -q /mnt/additional || mount -o ro /dev/sr0 /mnt/additional systemctl enable --now mysqld for attempt in $(seq 1 30); do mariadb-admin ping --silent && break; sleep 1; done mariadb <<'EOF' CREATE DATABASE webdb; CREATE USER 'web'@'localhost' IDENTIFIED BY 'P@ssw0rd'; GRANT ALL PRIVILEGES ON webdb.* TO 'web'@'localhost'; EOF mariadb webdb < /mnt/additional/web/dump.sql cp /mnt/additional/web/index.php /mnt/additional/web/logo.png /var/www/html/ sed -i -e 's/\$username = "user";/\$username = "web";/' \ -e 's/\$password = "password";/\$password = "P@ssw0rd";/' \ -e 's/\$dbname = "db";/\$dbname = "webdb";/' /var/www/html/index.php chmod 644 /var/www/html/index.php /var/www/html/logo.png cat > /etc/httpd2/conf/extra-enabled/kim2027-index.conf <<'EOF' DirectoryIndex disabled DirectoryIndex index.php ServerName hq-srv.au-team.irpo EOF systemctl enable --now httpd2 systemctl restart httpd2 curl --fail http://127.0.0.1/index.php | grep DemoTest mariadb -e 'SELECT * FROM webdb.employees'