#!/bin/bash # PostgreSQL Ubuntu Server Setup Script for Church Song Lyric System # Configured for PostgreSQL on port 5100 set -e echo "==========================================" echo "Church Song Lyric - PostgreSQL Ubuntu Setup" echo "==========================================" echo "" RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' if [ "$EUID" -eq 0 ]; then echo -e "${RED}Please do not run as root. Run as regular user with sudo privileges.${NC}" exit 1 fi # Get configuration echo -e "${YELLOW}Please provide the following information:${NC}" read -p "Enter your server IP [192.168.10.130]: " SERVER_IP SERVER_IP=${SERVER_IP:-192.168.10.130} read -p "Enter PostgreSQL password for songlyric_user: " -s DB_PASSWORD echo "" read -p "Enter the installation directory [/var/www/church-songlyric]: " INSTALL_DIR INSTALL_DIR=${INSTALL_DIR:-/var/www/church-songlyric} echo "" echo -e "${GREEN}Server IP: $SERVER_IP${NC}" echo -e "${GREEN}Installation directory: $INSTALL_DIR${NC}" echo "" read -p "Continue with installation? (y/n): " -n 1 -r echo if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1 fi echo "" echo "Step 1: Updating system packages..." sudo apt update sudo apt upgrade -y echo "" echo "Step 2: Installing PostgreSQL..." sudo apt install -y postgresql postgresql-contrib libpq-dev sudo systemctl start postgresql sudo systemctl enable postgresql echo "" echo "Step 3: Creating PostgreSQL database and user..." sudo -u postgres psql < .env < .env.production < /dev/null < /dev/null <