#!/bin/bash # QR Inventory Management System - Quick Setup Script for Debian 13 # This script automates the setup process set -e # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color # Function to print colored output print_status() { echo -e "${GREEN}[INFO]${NC} $1" } print_warning() { echo -e "${YELLOW}[WARNING]${NC} $1" } print_error() { echo -e "${RED}[ERROR]${NC} $1" } # Check if running as root if [[ $EUID -eq 0 ]]; then print_error "This script should not be run as root. Please run as a regular user." exit 1 fi # Update system print_status "Updating system packages..." sudo apt update sudo apt upgrade -y # Install Node.js print_status "Installing Node.js 18 LTS..." curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt-get install -y nodejs # Verify Node.js installation if ! command -v node &> /dev/null; then print_error "Node.js installation failed" exit 1 fi print_status "Node.js $(node --version) installed successfully" # Install Git print_status "Installing Git..." sudo apt install git -y # Install build tools print_status "Installing build tools..." sudo apt install build-essential -y # Install project dependencies with legacy peer deps to handle React 19 compatibility print_status "Installing project dependencies..." npm install --legacy-peer-deps # Create .env file if it doesn't exist if [ ! -f .env ]; then print_status "Creating .env file..." cat > .env << EOF # Database Configuration DATABASE_URL="file:./db/custom.db" # Application Configuration NODE_ENV="development" PORT=3000 HOSTNAME="0.0.0.0" EOF print_status ".env file created with default settings" else print_warning ".env file already exists, skipping creation" fi # Create database directory print_status "Setting up database..." mkdir -p db # Generate Prisma client print_status "Generating Prisma client..." npm run db:generate # Push database schema print_status "Setting up database schema..." npm run db:push # Build the application print_status "Building the application..." npm run build print_status "Setup completed successfully!" print_status "You can now run the application with:" echo -e "${GREEN}npm start${NC} (for production)" echo -e "${GREEN}npm run dev${NC} (for development)" print_status "The application will be available at http://localhost:3000" # Ask if user wants to run the application now read -p "Do you want to start the application now? (y/n): " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then print_status "Starting the application..." npm start fi