#!/bin/bash # Prepare LittleShop deployment package for manual upload # This creates a complete deployment package that can be uploaded and extracted on the server set -e # Colors GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' echo -e "${GREEN}═══════════════════════════════════════════════════${NC}" echo -e "${GREEN} Preparing LittleShop Deployment Package${NC}" echo -e "${GREEN}═══════════════════════════════════════════════════${NC}" echo "" # Clean previous deployment package rm -rf deployment-package mkdir -p deployment-package echo -e "${YELLOW}📦 Copying deployment files...${NC}" # Copy published applications cp -r publish/littleshop deployment-package/ cp -r publish/telebot deployment-package/ # Copy Docker files cp docker-compose.prod.yml deployment-package/docker-compose.yml cp Dockerfile deployment-package/ cp .env.production.template deployment-package/.env.template # Create deployment script cat > deployment-package/deploy.sh << 'DEPLOY_SCRIPT' #!/bin/bash # LittleShop Server Deployment Script # Run this on the target server after extracting the package set -e GREEN='\033[0;32m' YELLOW='\033[1;33m' RED='\033[0;31m' NC='\033[0m' echo -e "${GREEN}Starting LittleShop deployment...${NC}" # Create directories mkdir -p /opt/littleshop mkdir -p /opt/telebot mkdir -p /var/lib/littleshop mkdir -p /var/log/littleshop # Copy applications echo -e "${YELLOW}Installing applications...${NC}" cp -r littleshop/* /opt/littleshop/ cp -r telebot/* /opt/telebot/ # Set permissions chmod +x /opt/littleshop/LittleShop chmod +x /opt/telebot/TeleBot # Setup environment if not exists if [ ! -f /opt/littleshop/.env ]; then echo -e "${YELLOW}Setting up environment configuration...${NC}" cp .env.template /opt/littleshop/.env # Add BTCPay configuration cat >> /opt/littleshop/.env << 'EOF' # BTCPay Server Configuration BTCPAY_SERVER_URL=https://thebankofdebbie.giize.com BTCPAY_STORE_ID=CvdvHoncGLM7TdMYRAG6Z15YuxQfxeMWRYwi9gvPhh5R BTCPAY_API_KEY=3ff1f1e8c488ab9bb19b0c979c8fa2f1bf5e8dc5 BTCPAY_WEBHOOK_SECRET=generate-a-secure-webhook-secret # Web Push VAPID Keys WEBPUSH_VAPID_PUBLIC_KEY=BMc6fFJZ8oIQKQzcl3kMnP9tTsjrm3oI_VxLt3lAGYUMWGInzDKn7jqclEoZzjvXy1QXGFb3dIun8mVBwh-QuS4 WEBPUSH_VAPID_PRIVATE_KEY=sX5KHgb5LRd-FV8XYTWN6p8TpMZcQ2y3mcKwKe50NeE # TeleBot Configuration TELEBOT_API_URL=http://localhost:8081 TELEBOT_API_KEY=your-telebot-api-key EOF echo -e "${RED}⚠️ Please edit /opt/littleshop/.env to set proper values${NC}" fi # Create systemd service for LittleShop echo -e "${YELLOW}Creating systemd services...${NC}" cat > /etc/systemd/system/littleshop.service << 'SERVICE' [Unit] Description=LittleShop E-Commerce API After=network.target [Service] Type=simple User=www-data WorkingDirectory=/opt/littleshop ExecStart=/opt/littleshop/LittleShop Restart=on-failure RestartSec=10 Environment="ASPNETCORE_URLS=http://localhost:8080" Environment="ASPNETCORE_ENVIRONMENT=Production" EnvironmentFile=/opt/littleshop/.env [Install] WantedBy=multi-user.target SERVICE # Create systemd service for TeleBot cat > /etc/systemd/system/telebot.service << 'SERVICE' [Unit] Description=LittleShop TeleBot Service After=network.target littleshop.service [Service] Type=simple User=www-data WorkingDirectory=/opt/telebot ExecStart=/opt/telebot/TeleBot Restart=on-failure RestartSec=10 Environment="ASPNETCORE_URLS=http://localhost:8081" Environment="ASPNETCORE_ENVIRONMENT=Production" EnvironmentFile=/opt/littleshop/.env [Install] WantedBy=multi-user.target SERVICE # Setup nginx configuration echo -e "${YELLOW}Configuring nginx...${NC}" cat > /etc/nginx/sites-available/littleshop << 'NGINX' server { listen 80; server_name littleshop.silverlabs.uk; client_max_body_size 50M; location / { proxy_pass http://localhost:8080; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection keep-alive; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } location /telebot { rewrite ^/telebot(.*)$ $1 break; proxy_pass http://localhost:8081; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection keep-alive; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } } NGINX ln -sf /etc/nginx/sites-available/littleshop /etc/nginx/sites-enabled/ # Reload systemd and start services echo -e "${YELLOW}Starting services...${NC}" systemctl daemon-reload systemctl enable littleshop systemctl enable telebot systemctl restart littleshop systemctl restart telebot nginx -t && systemctl reload nginx # Wait for services to start sleep 5 # Check service status echo -e "${GREEN}Checking service status...${NC}" systemctl status littleshop --no-pager || true systemctl status telebot --no-pager || true # Test API endpoint if curl -f -s http://localhost:8080/api/push/vapid-key > /dev/null; then echo -e "${GREEN}✅ LittleShop API is running${NC}" else echo -e "${RED}⚠️ LittleShop API health check failed${NC}" fi echo -e "${GREEN}═══════════════════════════════════════════════════${NC}" echo -e "${GREEN} Deployment Complete!${NC}" echo -e "${GREEN}═══════════════════════════════════════════════════${NC}" echo "" echo "Next steps:" echo "1. Edit /opt/littleshop/.env with proper configuration" echo "2. Restart services: systemctl restart littleshop telebot" echo "3. Configure BTCPay webhook: https://littleshop.silverlabs.uk/api/orders/payments/webhook" echo "4. Test the application: https://littleshop.silverlabs.uk" DEPLOY_SCRIPT chmod +x deployment-package/deploy.sh # Create README cat > deployment-package/README.md << 'README' # LittleShop Deployment Package ## Contents - `littleshop/` - Main application - `telebot/` - Telegram bot service - `docker-compose.yml` - Docker configuration (optional) - `deploy.sh` - Automated deployment script - `.env.template` - Environment configuration template ## Deployment Instructions ### Option 1: Using systemd (Recommended) 1. Upload and extract this package on the server 2. Run `sudo ./deploy.sh` 3. Edit `/opt/littleshop/.env` with your configuration 4. Restart services: `sudo systemctl restart littleshop telebot` ### Option 2: Using Docker 1. Upload and extract this package on the server 2. Copy `.env.template` to `.env` and configure 3. Run `docker-compose up -d` ## Configuration Required - BTCPay webhook secret - TeleBot API credentials - Database connection (if not using SQLite) ## Service Management ```bash # Check status systemctl status littleshop systemctl status telebot # View logs journalctl -u littleshop -f journalctl -u telebot -f # Restart services systemctl restart littleshop systemctl restart telebot ``` ## URLs - API: http://localhost:8080 - Admin: http://localhost:8080/admin - TeleBot: http://localhost:8081 README # Create the deployment archive echo -e "${YELLOW}📦 Creating deployment archive...${NC}" tar -czf littleshop-deployment-$(date +%Y%m%d-%H%M%S).tar.gz deployment-package/ echo -e "${GREEN}✅ Deployment package created!${NC}" echo "" echo "📦 Package: littleshop-deployment-*.tar.gz" echo "" echo "Upload instructions:" echo "1. Upload the tar.gz file to the server" echo "2. Extract: tar -xzf littleshop-deployment-*.tar.gz" echo "3. Run: cd deployment-package && sudo ./deploy.sh" echo "" echo "Manual upload command:" echo "scp -P 2255 littleshop-deployment-*.tar.gz root@srv1002428.hstgr.cloud:/tmp/"