forked from maybe-finance/maybe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
165 lines (145 loc) Β· 4.53 KB
/
setup.sh
File metadata and controls
165 lines (145 loc) Β· 4.53 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/bash
# Colors for better output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
clear
echo "================================================"
echo " ποΈ FinKey Personal Finance Setup ποΈ"
echo "================================================"
echo ""
echo "Welcome to FinKey - Your Personal Finance Command Center!"
echo "This script will set up everything you need to get started."
echo ""
# Function to print colored output
print_status() {
echo -e "${GREEN}β
$1${NC}"
}
print_error() {
echo -e "${RED}β $1${NC}"
}
print_warning() {
echo -e "${YELLOW}β οΈ $1${NC}"
}
print_info() {
echo -e "${BLUE}βΉοΈ $1${NC}"
}
# Check if Docker is installed
echo "[1/4] Checking Docker installation..."
if ! command -v docker &> /dev/null; then
print_error "Docker not found!"
echo ""
echo "Please install Docker first:"
echo "β’ macOS: https://docs.docker.com/docker-for-mac/install/"
echo "β’ Linux: https://docs.docker.com/engine/install/"
echo ""
echo "After installation, restart this script."
exit 1
fi
print_status "Docker found!"
# Check if Docker Compose is available
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
print_error "Docker Compose not found!"
echo ""
echo "Please install Docker Compose:"
echo "β’ https://docs.docker.com/compose/install/"
exit 1
fi
print_status "Docker Compose found!"
# Check if Docker daemon is running
echo ""
echo "[2/4] Checking if Docker is running..."
if ! docker ps &> /dev/null; then
print_error "Docker daemon is not running!"
echo ""
echo "Please start Docker and try again:"
echo "β’ macOS: Open Docker Desktop from Applications"
echo "β’ Linux: sudo systemctl start docker"
exit 1
fi
print_status "Docker is running!"
# Setup environment file
echo ""
echo "[3/4] Setting up configuration..."
if [ ! -f ".env" ]; then
if [ -f ".env.example" ]; then
cp ".env.example" ".env"
print_status "Configuration file created (.env from .env.example)"
else
print_warning ".env.example not found, creating basic .env"
cat > .env << EOL
SELF_HOSTED=true
PORT=3000
EOL
fi
else
print_info "Configuration file already exists"
fi
# Make sure we have proper permissions on the setup script
chmod +x "$0"
# Start the application
echo ""
echo "[4/4] Starting FinKey..."
echo ""
echo "β³ This may take 5-10 minutes on first run while Docker downloads and builds everything..."
echo " You can safely minimize this terminal and check back later."
echo ""
# Use docker-compose or docker compose based on what's available
if command -v docker-compose &> /dev/null; then
COMPOSE_CMD="docker-compose"
else
COMPOSE_CMD="docker compose"
fi
$COMPOSE_CMD up -d --build
if [ $? -ne 0 ]; then
echo ""
print_error "Failed to start FinKey containers."
echo ""
echo "Common solutions:"
echo "β’ Make sure Docker is running properly"
echo "β’ Check if ports 3000, 5432, or 6379 are already in use"
echo "β’ Try: $COMPOSE_CMD down, then run this script again"
exit 1
fi
# Wait a moment and check container status
echo ""
echo "Waiting for services to start..."
sleep 15
echo ""
echo "π Container Status:"
$COMPOSE_CMD ps
echo ""
echo "================================================"
echo " π FinKey Setup Complete! π"
echo "================================================"
echo ""
echo "π Access your FinKey instance at: http://localhost:3000"
echo ""
echo "π‘ Important Notes:"
echo " β’ First startup may take 1-2 minutes to initialize database"
echo " β’ If you see connection errors, wait a bit longer and refresh"
echo " β’ Default port is 3000 (change in .env file if needed)"
echo ""
echo "π Useful Commands:"
echo " β’ Check status: $COMPOSE_CMD ps"
echo " β’ View logs: $COMPOSE_CMD logs"
echo " β’ Stop FinKey: $COMPOSE_CMD down"
echo " β’ Restart: $COMPOSE_CMD restart"
echo ""
echo "π§ Need help? Check the documentation in the docs/ folder"
echo ""
# Try to open browser (works on macOS and some Linux distributions)
if command -v open &> /dev/null; then
echo "Opening http://localhost:3000 in your default browser..."
open http://localhost:3000
elif command -v xdg-open &> /dev/null; then
echo "Opening http://localhost:3000 in your default browser..."
xdg-open http://localhost:3000
else
echo "Manual step: Open http://localhost:3000 in your browser"
fi
echo ""
echo "Setup complete! Press Enter to exit..."
read -r