Files

108 lines
3.9 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# =============================================================
# Dental Manager — fresh-machine install (README Steps 4–14, 16)
# Run in a terminal: bash install-all.sh
# It asks for your sudo password once at the start.
# Safe to re-run: every step skips what's already done.
# =============================================================
set -e
cd "$(dirname "$0")"
PROJECT_DIR="$(pwd)"
step() { echo ""; echo "=============================="; echo " $1"; echo "=============================="; }
sudo -v # ask for password up front
# keep sudo alive while the script runs
while true; do sudo -n true; sleep 50; kill -0 "$$" || exit; done 2>/dev/null &
step "Base tools (curl, wget, git)"
sudo apt-get update
sudo apt-get install -y curl wget ca-certificates git
step "STEP 4 — Node.js 20"
if command -v node >/dev/null && node -v | grep -q '^v2[0-9]'; then
echo "Node already installed: $(node -v)"
else
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
fi
node -v; npm -v
step "STEP 5 — Python (+ venv, pip)"
sudo apt-get install -y python3 python3-pip python3-venv
python3 --version
step "STEP 6 — Google Chrome"
if command -v google-chrome >/dev/null; then
echo "Chrome already installed"
else
wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -O /tmp/google-chrome-stable.deb
sudo apt-get install -y /tmp/google-chrome-stable.deb
fi
google-chrome --version
step "STEP 7 — PostgreSQL"
sudo apt-get install -y postgresql postgresql-contrib
sudo systemctl enable postgresql
sudo systemctl start postgresql
sudo -u postgres psql -tc "SELECT 1 FROM pg_database WHERE datname='dentalapp'" | grep -q 1 \
|| sudo -u postgres psql -c "CREATE DATABASE dentalapp OWNER postgres;"
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'mypassword';"
sudo sed -i 's/scram-sha-256/md5/g' /etc/postgresql/*/main/pg_hba.conf
sudo systemctl restart postgresql
PGPASSWORD=mypassword psql -U postgres -d dentalapp -h 127.0.0.1 -c 'SELECT 1' >/dev/null && echo "✓ PostgreSQL login works"
step "STEP 8 — Redis"
sudo apt-get install -y redis-server
sudo systemctl enable redis-server
sudo systemctl start redis-server
redis-cli ping
step "STEP 9 — rclone"
bash scripts/install-rclone.sh
step "STEP 10 — Node.js dependencies"
npm install
step "STEP 11 — Python dependencies (venvs)"
npm run setup:python
step "STEP 12 — .env files (only the missing ones; existing ones are kept)"
for f in packages/db/prisma/.env apps/Frontend/.env apps/Backend/.env \
apps/PatientDataExtractorService/.env apps/SeleniumService/.env apps/PaymentOCRService/.env; do
if [ -f "$f" ]; then echo "keep $f"
else cp "$f.example" "$f" && echo "created $f"; fi
done
step "STEP 13 — Database (migrate, generate, seed)"
npm run db:migrate
npm run db:generate
npm run db:seed
step "STEP 14 — nginx"
sudo apt-get install -y nginx
CERT=$(grep -m1 -oP 'ssl_certificate\s+\K\S+(?=;)' nginx.conf)
if sudo test -f "$CERT"; then
sudo cp nginx.conf /etc/nginx/sites-available/dental-app
sudo ln -sf /etc/nginx/sites-available/dental-app /etc/nginx/sites-enabled/dental-app
sudo rm -f /etc/nginx/sites-enabled/default
sudo nginx -t && sudo systemctl reload nginx
echo "✓ nginx configured"
else
echo "⚠ Skipped enabling the dental-app nginx site: certificate not found at"
echo " $CERT"
echo " Do the README's 'LAN HTTPS Setup' (certbot) first, then re-run this script."
fi
step "STEP 16 — Desktop shortcuts"
bash setup-desktop-shortcut.sh
echo ""
echo "============================================"
echo " Done. To run the app (Step 15):"
echo " Terminal 1: cd $PROJECT_DIR && npm run dev"
echo " Terminal 2: cd $PROJECT_DIR/apps/SeleniumService && .venv/bin/python3 agent.py"
echo " ...or double-click the 'Dental App' desktop shortcut."
echo "============================================"