-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·115 lines (103 loc) · 2.97 KB
/
setup.sh
File metadata and controls
executable file
·115 lines (103 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
# DefiPrice Markets - Quick Setup Script
# This script automates the initial setup process
set -e
echo "🚀 DefiPrice Markets - Setup Script"
echo "===================================="
echo ""
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Check Node.js version
echo "📦 Checking Node.js version..."
NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
if [ "$NODE_VERSION" -lt 20 ]; then
echo -e "${RED}❌ Node.js 20+ is required. Current version: $(node -v)${NC}"
exit 1
fi
echo -e "${GREEN}✅ Node.js $(node -v) detected${NC}"
echo ""
# Check if .env exists
if [ -f ".env" ]; then
echo -e "${YELLOW}⚠️ .env file already exists. Skipping environment setup.${NC}"
else
echo "📝 Creating .env file from template..."
cp .env.example .env
echo -e "${GREEN}✅ Created .env file${NC}"
echo -e "${YELLOW}⚠️ Please edit .env with your configuration before continuing!${NC}"
echo ""
read -p "Press Enter when you've updated .env file..."
echo ""
fi
# Install bot dependencies
echo "📦 Installing bot dependencies..."
cd bot
if [ -d "node_modules" ]; then
echo -e "${YELLOW}⚠️ node_modules exists. Skipping install.${NC}"
else
npm install
echo -e "${GREEN}✅ Bot dependencies installed${NC}"
fi
cd ..
echo ""
# Install dashboard dependencies
echo "📦 Installing dashboard dependencies..."
cd dashboard
if [ -d "node_modules" ]; then
echo -e "${YELLOW}⚠️ node_modules exists. Skipping install.${NC}"
else
npm install
echo -e "${GREEN}✅ Dashboard dependencies installed${NC}"
fi
cd ..
echo ""
# Build bot
echo "🔨 Building bot..."
cd bot
npm run build
echo -e "${GREEN}✅ Bot built successfully${NC}"
cd ..
echo ""
# Prompt for schema registration
echo "📋 Schema Registration"
echo "====================="
echo ""
echo "Before starting the bot, you need to register the Somnia schema."
echo ""
read -p "Do you want to register the schema now? (y/n) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "🔧 Registering schema..."
cd bot
node dist/scripts/register-schema.js
cd ..
echo ""
echo -e "${YELLOW}⚠️ Update SOMNIA_SCHEMA_ID in .env with the returned schema ID${NC}"
echo ""
read -p "Press Enter when you've updated .env file..."
echo ""
fi
# Setup complete
echo "✨ Setup Complete!"
echo "================="
echo ""
echo "Next steps:"
echo ""
echo "1. Start the bot:"
echo " ${GREEN}cd bot && npm run dev${NC}"
echo " or for production:"
echo " ${GREEN}pm2 start ecosystem.config.js${NC}"
echo ""
echo "2. Start the dashboard (in a new terminal):"
echo " ${GREEN}cd dashboard && npm run dev${NC}"
echo " or for production:"
echo " ${GREEN}cd dashboard && npm run build && npm start${NC}"
echo ""
echo "3. Or use Docker:"
echo " ${GREEN}docker-compose up -d${NC}"
echo ""
echo "📖 For detailed instructions, see README.md and DEPLOYMENT.md"
echo ""
echo -e "${GREEN}Happy trading! 🚀${NC}"