-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·124 lines (105 loc) · 4.21 KB
/
start.sh
File metadata and controls
executable file
·124 lines (105 loc) · 4.21 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
116
117
118
119
120
121
122
123
#!/bin/bash
#
# 🐷 $oink ↔ 🌙 $midoink Bridge
# One-tap install and start
#
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo ""
echo -e "${BLUE}╔════════════════════════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ 🐷 \$oink ↔ 🌙 \$midoink Bridge Installer ║${NC}"
echo -e "${BLUE}║ Cardano ↔ Midnight (1:1 Peg) ║${NC}"
echo -e "${BLUE}╚════════════════════════════════════════════════════════════════╝${NC}"
echo ""
# Check for Docker
if ! command -v docker &> /dev/null; then
echo -e "${RED}❌ Docker not found. Please install Docker first.${NC}"
echo " https://docs.docker.com/get-docker/"
exit 1
fi
# Check for Docker Compose
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
echo -e "${RED}❌ Docker Compose not found. Please install Docker Compose.${NC}"
exit 1
fi
echo -e "${GREEN}✅ Docker found${NC}"
# Determine compose command
if docker compose version &> /dev/null; then
COMPOSE="docker compose"
else
COMPOSE="docker-compose"
fi
# Parse arguments
ACTION=${1:-start}
case $ACTION in
start|up)
echo -e "${YELLOW}🚀 Building and starting bridge...${NC}"
$COMPOSE up -d --build
echo ""
echo -e "${GREEN}✅ Bridge is starting...${NC}"
echo ""
# Wait for health check
echo -e "${YELLOW}⏳ Waiting for bridge to be healthy...${NC}"
for i in {1..30}; do
if curl -s http://localhost:3008/health > /dev/null 2>&1; then
echo ""
echo -e "${GREEN}✅ Bridge is healthy!${NC}"
break
fi
echo -n "."
sleep 1
done
echo ""
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
echo -e "${GREEN}🌉 Bridge running at: http://localhost:3008${NC}"
echo ""
echo " Endpoints:"
echo " • GET /health - Health check"
echo " • GET /status - Bridge status"
echo " • POST /wrap/initiate - Start wrap (oink → midoink)"
echo " • POST /wrap/complete - Complete wrap"
echo " • POST /unwrap/initiate - Start unwrap (midoink → oink)"
echo " • POST /unwrap/complete - Complete unwrap"
echo ""
echo " Quick test:"
echo " curl http://localhost:3008/health"
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
;;
stop|down)
echo -e "${YELLOW}🛑 Stopping bridge...${NC}"
$COMPOSE down
echo -e "${GREEN}✅ Bridge stopped${NC}"
;;
restart)
echo -e "${YELLOW}🔄 Restarting bridge...${NC}"
$COMPOSE restart
echo -e "${GREEN}✅ Bridge restarted${NC}"
;;
logs)
$COMPOSE logs -f bridge
;;
status)
echo -e "${YELLOW}📊 Bridge Status:${NC}"
curl -s http://localhost:3008/status | jq . 2>/dev/null || curl -s http://localhost:3008/status
;;
test)
echo -e "${YELLOW}🧪 Running simulation test...${NC}"
npm run simulate
;;
*)
echo "Usage: ./start.sh [command]"
echo ""
echo "Commands:"
echo " start - Build and start the bridge (default)"
echo " stop - Stop the bridge"
echo " restart - Restart the bridge"
echo " logs - View bridge logs"
echo " status - Check bridge status"
echo " test - Run simulation test"
;;
esac