#!/bin/bash # Dealspace Installation Script # Run as root on Shannon (82.24.174.112) set -e INSTALL_DIR=/opt/dealspace SERVICE_USER=johan echo "=== Dealspace Installation ===" # Create user if missing if ! id "$SERVICE_USER" &>/dev/null; then echo "Creating user $SERVICE_USER..." useradd -r -s /bin/bash -d /home/$SERVICE_USER -m $SERVICE_USER fi # Create directory structure echo "Creating directories..." mkdir -p $INSTALL_DIR/{bin,data,store,logs,backups,migrations} # Generate MASTER_KEY if .env doesn't exist if [ ! -f "$INSTALL_DIR/.env" ]; then echo "Creating .env with new MASTER_KEY..." MASTER_KEY=$(openssl rand -hex 32) cat > $INSTALL_DIR/.env < $CRON_TMP <> $INSTALL_DIR/logs/backup.log 2>&1 # Dealspace healthcheck - every 5 minutes */5 * * * * $INSTALL_DIR/healthcheck.sh CRONEOF crontab -u $SERVICE_USER $CRON_TMP rm $CRON_TMP echo "" echo "=== Installation Complete ===" echo "" echo "Next steps:" echo " 1. Edit $INSTALL_DIR/.env with SMTP and Fireworks credentials" echo " 2. Deploy the binary: make deploy" echo " 3. Start the service: systemctl start dealspace" echo " 4. Check status: systemctl status dealspace" echo " 5. View logs: journalctl -u dealspace -f" echo "" echo "Cron jobs installed:" echo " - Daily backup at 3 AM" echo " - Healthcheck every 5 minutes"