- 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
104 lines
2.8 KiB
Bash
Executable File
104 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# MariaDB Installation and Setup Script
|
|
# This script installs MariaDB, creates database, table, and sets up authentication
|
|
|
|
echo "Starting MariaDB installation and setup..."
|
|
|
|
# Update package list
|
|
sudo apt update
|
|
|
|
# Install MariaDB server and client
|
|
echo "Installing MariaDB..."
|
|
sudo apt install -y mariadb-server mariadb-client
|
|
|
|
# Start and enable MariaDB service
|
|
sudo systemctl start mariadb
|
|
sudo systemctl enable mariadb
|
|
|
|
# Secure MariaDB installation
|
|
echo "Securing MariaDB installation..."
|
|
sudo mysql_secure_installation
|
|
|
|
# Create database and user
|
|
echo "Creating database and user..."
|
|
|
|
# Connect to MariaDB and execute commands
|
|
sudo mysql -e "CREATE DATABASE IF NOT EXISTS webform_users;"
|
|
sudo mysql -e "CREATE TABLE IF NOT EXISTS webform_users.users (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
username VARCHAR(50) NOT NULL UNIQUE,
|
|
password VARCHAR(255) NOT NULL,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);"
|
|
|
|
# Insert admin user with hashed password
|
|
# Note: In a real scenario, you'd want to generate a secure password
|
|
ADMIN_PASSWORD="admin123"
|
|
HASHED_PASSWORD=$(sudo mysql -e "SELECT PASSWORD('$ADMIN_PASSWORD');" | tail -n +2 | head -n 1)
|
|
|
|
if [ -n "$HASHED_PASSWORD" ]; then
|
|
sudo mysql -e "INSERT INTO webform_users.users (username, password) VALUES ('admin', '$HASHED_PASSWORD');"
|
|
echo "Admin user created successfully"
|
|
else
|
|
echo "Error creating admin user"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Database setup completed successfully!"
|
|
|
|
# Create a simple login.php file for demonstration
|
|
echo "Creating login.php file..."
|
|
|
|
cat > login.php << 'EOF'
|
|
<?php
|
|
// Database configuration
|
|
$host = 'localhost';
|
|
$dbname = 'webform_users';
|
|
$username = 'root';
|
|
$password = ''; // You should use a proper password here
|
|
|
|
try {
|
|
$pdo = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
|
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
} catch(PDOException $e) {
|
|
die("Connection failed: " . $e->getMessage());
|
|
}
|
|
|
|
// Handle login
|
|
if ($_POST) {
|
|
$user = $_POST['username'];
|
|
$pass = $_POST['password'];
|
|
|
|
$stmt = $pdo->prepare("SELECT username, password FROM users WHERE username = ?");
|
|
$stmt->execute([$user]);
|
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if ($result && password_verify($pass, $result['password'])) {
|
|
echo "Login successful!";
|
|
// Start session, redirect, etc.
|
|
} else {
|
|
echo "Invalid username or password!";
|
|
}
|
|
}
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Login</title>
|
|
</head>
|
|
<body>
|
|
<h2>Login</h2>
|
|
<form method="post">
|
|
<label>Username:</label>
|
|
<input type="text" name="username" required><br><br>
|
|
<label>Password:</label>
|
|
<input type="password" name="password" required><br><br>
|
|
<input type="submit" value="Login">
|
|
</form>
|
|
</body>
|
|
</html>
|
|
EOF
|
|
|
|
echo "Installation complete! Please review and modify the login.php file as needed." |