#!/bin/bash LOG_FILE="$(dirname "$(dirname "$0")")/setup.log" # Log function log() { echo "$1" | tee -a "$LOG_FILE" } # Function to prompt for yes/no input prompt_yes_no() { while true; do read -r -p "$1 (y/n): " REPLY case "$REPLY" in [Yy]* ) return 0 ;; [Nn]* ) return 1 ;; * ) log "Please answer yes or no." ;; esac done } # Function to install MariaDB install_mariadb() { if command -v apt &>/dev/null; then apt update && apt install -y mariadb-server elif command -v yum &>/dev/null; then yum install -y mariadb-server else log "Unsupported package manager. Please install MariaDB manually." exit 1 fi log "MariaDB installed successfully." } # Function to secure MariaDB installation secure_mariadb() { log "Securing MariaDB installation..." mariadb-secure-installation } # Function to create a database and user create_database_user() { log "Please enter the MariaDB root password:" read -r -s ROOT_PASSWORD log "Please enter the name of the new database:" read -r DB_NAME log "Please enter the username for the new database user:" read -r DB_USER log "Please enter the password for the new database user:" read -r -s DB_PASSWORD log "Please enter the host for the new database user (e.g., localhost, %, specific IP):" read -r DB_HOST mysql -u root -p"$ROOT_PASSWORD" <