#!/bin/bash # LittleShop Production Configuration Script # Configures bot tokens, payment gateway, and all production settings set -e # Colors for output GREEN='\033[0;32m' BLUE='\033[0;34m' YELLOW='\033[1;33m' RED='\033[0;31m' NC='\033[0m' echo -e "${BLUE}================================================${NC}" echo -e "${BLUE}LittleShop Production Configuration${NC}" echo -e "${BLUE}================================================${NC}" echo "" # Configuration variables DEPLOY_DIR="/root/LittleShop" TELEBOT_DIR="/root/TeleBot" # Telegram Bot Token (from appsettings) TELEGRAM_BOT_TOKEN="8496279616:AAE7kV_riICbWxn6-MPFqcrWx7K8b4_NKq0" # BTCPay Server (from existing config) BTCPAY_URL="https://thebankofdebbie.giize.com" BTCPAY_API_KEY="db920209c0101efdbd1c6b6d1c99a48e3ba9d0de" BTCPAY_STORE_ID="CvdvHoncGLM7TdMYRAG6Z15YuxQfxeMWRYwi9gvPhh5R" # WebPush VAPID Keys (from existing config) VAPID_PUBLIC="BMc6fFJZ8oIQKQzcl3kMnP9tTsjrm3oI_VxLt3lAGYUMWGInzDKn7jqclEoZzjvXy1QXGFb3dIun8mVBwh-QuS4" VAPID_PRIVATE="dYuuagbz2CzCnPDFUpO_qkGLBgnN3MEFZQnjXNkc1MY" # Production URLs LITTLESHOP_URL="https://srv1002428.hstgr.cloud:8080" TELEBOT_WEBHOOK_URL="$LITTLESHOP_URL/api/webhook" echo -e "${GREEN}Step 1: Backing up existing configuration...${NC}" if [ -f "$DEPLOY_DIR/appsettings.Hostinger.json" ]; then cp "$DEPLOY_DIR/appsettings.Hostinger.json" "$DEPLOY_DIR/appsettings.Hostinger.json.backup.$(date +%Y%m%d-%H%M%S)" echo "✓ Backup created" fi echo "" echo -e "${GREEN}Step 2: Configuring LittleShop API...${NC}" # Create production appsettings for LittleShop cat > "$DEPLOY_DIR/appsettings.Hostinger.json" << EOF { "ConnectionStrings": { "DefaultConnection": "Data Source=/app/data/littleshop.db" }, "Jwt": { "Key": "YourSuperSecretKeyThatIsAtLeast32CharactersLong!", "Issuer": "LittleShop", "Audience": "LittleShop", "ExpiryInHours": 24 }, "BTCPayServer": { "BaseUrl": "$BTCPAY_URL", "ApiKey": "$BTCPAY_API_KEY", "StoreId": "$BTCPAY_STORE_ID", "WebhookSecret": "your-webhook-secret-here" }, "RoyalMail": { "ClientId": "", "ClientSecret": "", "BaseUrl": "https://api.royalmail.net/", "SenderAddress1": "SilverLabs Ltd, 123 Business Street", "SenderCity": "London", "SenderPostCode": "SW1A 1AA", "SenderCountry": "United Kingdom" }, "WebPush": { "VapidPublicKey": "$VAPID_PUBLIC", "VapidPrivateKey": "$VAPID_PRIVATE", "Subject": "mailto:admin@littleshop.local" }, "TeleBot": { "ApiUrl": "http://localhost:5010", "Enabled": true }, "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning", "BTCPayServer": "Debug" } }, "AllowedHosts": "*", "Kestrel": { "Endpoints": { "Http": { "Url": "http://0.0.0.0:8080" } } } } EOF echo "✓ LittleShop configuration updated" echo " - Database: /app/data/littleshop.db" echo " - BTCPay Server: $BTCPAY_URL" echo " - API Port: 8080" echo "" echo -e "${GREEN}Step 3: Configuring TeleBot...${NC}" # Create TeleBot directory if it doesn't exist mkdir -p "$TELEBOT_DIR" # Create production appsettings for TeleBot cat > "$TELEBOT_DIR/appsettings.json" << EOF { "BotInfo": { "Name": "LittleShop TeleBot", "Description": "Privacy-focused e-commerce Telegram bot", "Version": "1.0.0" }, "BotManager": { "ApiKey": "", "Comment": "This will be populated after first registration with admin panel" }, "Telegram": { "BotToken": "$TELEGRAM_BOT_TOKEN", "AdminChatId": "123456789", "WebhookUrl": "$TELEBOT_WEBHOOK_URL", "UseWebhook": false, "Comment": "Bot token configured for production" }, "Webhook": { "Secret": "", "Comment": "Optional secret key for webhook authentication" }, "LittleShop": { "ApiUrl": "http://localhost:8080", "OnionUrl": "", "Username": "admin", "Password": "admin", "UseTor": false, "Comment": "Internal communication on localhost" }, "Privacy": { "Mode": "strict", "DataRetentionHours": 24, "SessionTimeoutMinutes": 30, "EnableAnalytics": false, "RequirePGPForShipping": false, "EphemeralByDefault": true, "EnableTor": false, "TorSocksPort": 9050, "TorControlPort": 9051, "OnionServiceDirectory": "/var/lib/tor/telebot/" }, "Redis": { "ConnectionString": "localhost:6379", "InstanceName": "TeleBot", "Enabled": false }, "Database": { "ConnectionString": "Filename=/app/data/telebot.db;Password=;", "EncryptionKey": "CHANGE_THIS_KEY_IN_PRODUCTION" }, "Features": { "EnableVoiceSearch": false, "EnableQRCodes": true, "EnablePGPEncryption": false, "EnableDisappearingMessages": true, "EnableOrderMixing": false, "MixingDelayMinSeconds": 60, "MixingDelayMaxSeconds": 300 }, "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "System": "Warning" }, "PrivacyMode": true }, "Hangfire": { "Enabled": false, "DatabasePath": "hangfire.db" }, "Cryptocurrencies": [ "BTC", "ETH", "LTC", "DOGE" ], "Kestrel": { "Endpoints": { "Http": { "Url": "http://0.0.0.0:5010" } } } } EOF echo "✓ TeleBot configuration created" echo " - Telegram Bot Token: ${TELEGRAM_BOT_TOKEN:0:20}..." echo " - LittleShop API: http://localhost:8080" echo " - TeleBot Port: 5010" echo "" echo -e "${GREEN}Step 4: Setting permissions...${NC}" chmod 600 "$DEPLOY_DIR/appsettings.Hostinger.json" if [ -f "$TELEBOT_DIR/appsettings.json" ]; then chmod 600 "$TELEBOT_DIR/appsettings.json" fi echo "✓ Permissions set (600 for security)" echo "" echo -e "${GREEN}Step 5: Checking services...${NC}" # Check if services are running if systemctl is-active --quiet littleshop 2>/dev/null; then echo " LittleShop service: Running" RESTART_LITTLESHOP=true else echo " LittleShop service: Not running" RESTART_LITTLESHOP=false fi if systemctl is-active --quiet telebot 2>/dev/null; then echo " TeleBot service: Running" RESTART_TELEBOT=true else echo " TeleBot service: Not running" RESTART_TELEBOT=false fi echo "" echo -e "${BLUE}================================================${NC}" echo -e "${BLUE}Configuration Summary${NC}" echo -e "${BLUE}================================================${NC}" echo "" echo -e "${GREEN}✓ Configuration files updated${NC}" echo "" echo "LittleShop API:" echo " - Database: /app/data/littleshop.db" echo " - BTCPay Server: $BTCPAY_URL" echo " - Port: 8080" echo "" echo "TeleBot:" echo " - Bot Token: Configured" echo " - API Connection: http://localhost:8080" echo " - Port: 5010" echo "" echo "Payment Gateway:" echo " - Provider: BTCPay Server" echo " - Store ID: $BTCPAY_STORE_ID" echo "" echo -e "${YELLOW}================================================${NC}" echo -e "${YELLOW}Next Steps:${NC}" echo -e "${YELLOW}================================================${NC}" echo "" echo "1. Restart services to apply configuration:" if [ "$RESTART_LITTLESHOP" = true ]; then echo " systemctl restart littleshop" else echo " systemctl start littleshop" fi if [ "$RESTART_TELEBOT" = true ]; then echo " systemctl restart telebot" else echo " systemctl start telebot" fi echo "" echo "2. Register bot in admin panel:" echo " - Login to: $LITTLESHOP_URL/Admin" echo " - Username: admin" echo " - Password: admin" echo " - Go to: Bots > Create New Bot" echo " - Enter bot token and save" echo "" echo "3. Test end-to-end transaction:" echo " - Open Telegram and find your bot" echo " - Send /start" echo " - Browse products and create an order" echo " - Verify payment address is generated" echo "" echo -e "${GREEN}Configuration complete!${NC}" echo "" # Ask if user wants to restart services now read -p "Restart services now? (y/n): " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then echo "" echo "Restarting services..." if [ "$RESTART_LITTLESHOP" = true ]; then systemctl restart littleshop echo "✓ LittleShop restarted" else systemctl start littleshop echo "✓ LittleShop started" fi sleep 2 if [ "$RESTART_TELEBOT" = true ]; then systemctl restart telebot echo "✓ TeleBot restarted" else systemctl start telebot echo "✓ TeleBot started" fi echo "" echo "Checking service status..." sleep 3 if systemctl is-active --quiet littleshop; then echo -e "${GREEN}✓ LittleShop is running${NC}" else echo -e "${RED}✗ LittleShop failed to start${NC}" echo "Check logs: journalctl -u littleshop -n 50" fi if systemctl is-active --quiet telebot; then echo -e "${GREEN}✓ TeleBot is running${NC}" else echo -e "${RED}✗ TeleBot failed to start${NC}" echo "Check logs: journalctl -u telebot -n 50" fi else echo "" echo "Services not restarted. Remember to restart manually." fi echo "" echo -e "${GREEN}Done!${NC}"