Redesign as VM webshop with NetBox virtualization integration

- Split single-page into 3 pages:
  - index.php: product catalog with VM size cards
  - create.php: order form (name, domain, description)
  - requests.php: request history with pagination
- Rewrite NetBox integration to create Virtual Machines
  (/virtualization/virtual-machines/) instead of DCIM devices
- Add netbox_integration/netbox_api.php: NetBoxClient with
  createVirtualMachine(), findCluster(), findTag(), getList()
- Generate new sleek product-card images (420x280) with
  aligned spec boxes (vcpus/ram/disk)
- Add webshop CSS: product cards, nav links, hero section,
  order layout, responsive grid
- Update redirects: send.php -> requests.php, cancel.php -> requests.php
- Update E2E test for new page structure
- Add .gitignore, deploy-local.sh, setup_database.sql to repo
This commit is contained in:
alex
2026-05-09 23:49:02 +02:00
parent c568ac09bb
commit d629689473
26 changed files with 2471 additions and 603 deletions

72
deploy-local.sh Executable file
View File

@@ -0,0 +1,72 @@
#!/usr/bin/env bash
set -euo pipefail
APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DB_NAME="${PHPSITE_DB_NAME:-phpsite}"
DB_USER="${PHPSITE_DB_USER:-phpsite_app}"
DB_PASS="${PHPSITE_DB_PASS:-phpsite_local_password}"
ADMIN_USER="${PHPSITE_ADMIN_USER:-admin}"
ADMIN_PASS="${PHPSITE_ADMIN_PASS:-admin123}"
NGINX_SITE="/etc/nginx/sites-available/phpsite"
NGINX_ENABLED="/etc/nginx/sites-enabled/phpsite"
require_cmd() {
command -v "$1" >/dev/null 2>&1 || {
echo "Missing required command: $1" >&2
exit 1
}
}
require_cmd php
require_cmd mysql
require_cmd nginx
require_cmd curl
sudo systemctl enable --now mariadb
sudo systemctl enable --now php8.3-fpm
sudo mysql <<SQL
CREATE DATABASE IF NOT EXISTS \`${DB_NAME}\` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER IF NOT EXISTS '${DB_USER}'@'localhost' IDENTIFIED BY '${DB_PASS}';
ALTER USER '${DB_USER}'@'localhost' IDENTIFIED BY '${DB_PASS}';
GRANT ALL PRIVILEGES ON \`${DB_NAME}\`.* TO '${DB_USER}'@'localhost';
FLUSH PRIVILEGES;
SQL
mysql --protocol=TCP -h 127.0.0.1 -u"${DB_USER}" -p"${DB_PASS}" "${DB_NAME}" < "${APP_DIR}/setup_database.sql"
ADMIN_HASH="$(php -r 'echo password_hash(getenv("PHPSITE_ADMIN_PASS") ?: "admin123", PASSWORD_DEFAULT);')"
mysql --protocol=TCP -h 127.0.0.1 -u"${DB_USER}" -p"${DB_PASS}" "${DB_NAME}" <<SQL
INSERT INTO users (username, password_hash)
VALUES ('${ADMIN_USER}', '${ADMIN_HASH}')
ON DUPLICATE KEY UPDATE password_hash = VALUES(password_hash);
SQL
umask 077
cat > "${APP_DIR}/config.local.php" <<PHP
<?php
return [
'db_host' => '127.0.0.1',
'db_name' => '${DB_NAME}',
'db_user' => '${DB_USER}',
'db_pass' => '${DB_PASS}',
];
PHP
sudo chgrp www-data "${APP_DIR}/config.local.php"
chmod 0640 "${APP_DIR}/config.local.php"
sudo install -d -m 0755 /home/alex/sites
sudo ln -sfn /home/alex/sites/phpsite.conf "${NGINX_SITE}"
sudo ln -sfn "${NGINX_SITE}" "${NGINX_ENABLED}"
sudo rm -f /etc/nginx/sites-enabled/default
if systemctl is-active --quiet apache2; then
sudo systemctl disable --now apache2
fi
sudo nginx -t
sudo systemctl enable --now nginx
sudo systemctl reload nginx
echo "phpsite deployed at http://127.0.0.1/ and http://127.0.0.1:8000/"
echo "local login: ${ADMIN_USER} / ${ADMIN_PASS}"