diff --git a/provision-turnkey.sh b/provision-turnkey.sh new file mode 100644 index 0000000..1bd8732 --- /dev/null +++ b/provision-turnkey.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# TurnKey NodeJS Provisioning Script for Connect-5 +# Run this script on your TurnKey NodeJS appliance to set up PostgreSQL and prepare for deployment. + +set -e + +# Colors +GREEN='\033[0;32m' +BLUE='\033[0;34m' +RED='\033[0;31m' +NC='\033[0m' + +echo -e "${BLUE}╔══════════════════════════════════════════════╗${NC}" +echo -e "${BLUE}║ Connect-5 TurnKey Provisioning Script ║${NC}" +echo -e "${BLUE}╚══════════════════════════════════════════════╝${NC}" +echo "" + +# Check if running as root +if [ "$EUID" -ne 0 ]; then + echo -e "${RED}❌ Please run as root${NC}" + exit 1 +fi + +# 1. Update and Install PostgreSQL +echo -e "${BLUE}📦 Updating system and installing PostgreSQL...${NC}" +apt-get update +apt-get install -y postgresql postgresql-contrib git + +# 2. Start PostgreSQL +echo -e "${BLUE}🚀 Starting PostgreSQL service...${NC}" +systemctl start postgresql +systemctl enable postgresql + +# 3. Configure Database +echo -e "${BLUE}🔐 Configuring Database...${NC}" +echo "Please enter a password for the 'postgres' database user:" +read -s -p "Password: " DB_PASSWORD +echo "" + +# Switch to postgres user to run commands +su - postgres <