-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·44 lines (35 loc) · 1.59 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·44 lines (35 loc) · 1.59 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
#!/bin/bash
set -e
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${BLUE}==== File Deduplication System Setup ====${NC}"
# Check if dbstrap is installed
if ! command -v dbstrap &> /dev/null; then
echo -e "${RED}dbstrap is not installed. Please install it first.${NC}"
echo "You can install it with: go install github.com/jackc/dbstrap@latest"
exit 1
fi
# Set environment variables
export FILEDEDUP_USER_PASSWORD=${FILEDEDUP_USER_PASSWORD:-pwd}
export DATABASE_URL="postgres://postgres:${POSTGRES_PASSWORD:-pwd}@localhost:5432/postgres?sslmode=disable"
echo -e "${BLUE}Setting up database...${NC}"
echo "Using DATABASE_URL: $DATABASE_URL"
echo "FILEDEDUP_USER_PASSWORD is set (not shown for security)"
# Run dbstrap to set up the database
echo -e "${BLUE}Running dbstrap...${NC}"
dbstrap run --config=bootstrap.yaml
# Update DATABASE_URL to point to the filededup database
export DATABASE_URL="postgres://filededup:${FILEDEDUP_USER_PASSWORD}@localhost:5432/filededup?sslmode=disable"
# Initialize schema if not already done
echo -e "${BLUE}Initializing database schema...${NC}"
psql -h localhost -d filededup -U filededup -f pkg/record/recorddb/schema.sql || {
echo -e "${RED}Failed to initialize schema. This is normal if tables already exist.${NC}"
}
echo -e "${GREEN}Setup complete!${NC}"
echo -e "${BLUE}To run the server:${NC}"
echo "DATABASE_URL=\"$DATABASE_URL\" go run ./cmd/server"
echo -e "${BLUE}To run the agent:${NC}"
echo "go run ./cmd/agent -dir \"/path/to/scan\" -server \"http://localhost:8080\" -machine-id \"my-machine\""