#!/bin/bash # Setup script for PostgreSQL database and user set -e # Exit on error # Configuration PG_HOST="${1:-localhost}" PG_ADMIN_USER="postgres" PG_ADMIN_PASS="Lkxdjfhl1d" DB_NAME="smart_monitoring" DB_USER="smart_logger" DB_PASS="${2:-change_me_123}" # Pass as second argument or use default echo "PostgreSQL Setup for Smart Logger" echo "==================================" echo "Host: $PG_HOST" echo "Database: $DB_NAME" echo "User: $DB_USER" echo "" # Check if psql is installed if ! command -v psql &> /dev/null; then echo "ERROR: psql is not installed" echo "Install with: sudo pacman -S postgresql" exit 1 fi echo "Step 1: Creating database..." PGPASSWORD="$PG_ADMIN_PASS" psql -h "$PG_HOST" -U "$PG_ADMIN_USER" -d postgres <