-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·150 lines (120 loc) · 3.21 KB
/
setup.sh
File metadata and controls
executable file
·150 lines (120 loc) · 3.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
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
#!/bin/bash
# Lambda@Home Quick Setup Script
# This script sets up Lambda@Home for end users
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
main() {
print_status "Lambda@Home Quick Setup"
echo
# Check prerequisites
print_status "Checking prerequisites..."
if ! command_exists docker; then
print_error "Docker is required but not installed."
print_error "Please install Docker from https://docs.docker.com/get-docker/"
exit 1
fi
if ! docker info >/dev/null 2>&1; then
print_error "Docker daemon is not running."
print_error "Please start Docker and try again."
exit 1
fi
if ! command_exists cargo; then
print_error "Rust/Cargo is required but not installed."
print_error "Please install Rust from https://rustup.rs/"
exit 1
fi
print_success "All prerequisites are met!"
# Get current directory
CURRENT_DIR=$(pwd)
print_status "Setting up Lambda@Home in: $CURRENT_DIR"
# Create necessary directories
print_status "Creating directory structure..."
mkdir -p data/cache
mkdir -p data/zips
mkdir -p config
mkdir -p functions
print_success "Created directory structure"
# Create default config if it doesn't exist
if [[ ! -f "config/config.toml" ]]; then
cat > config/config.toml << 'EOF'
[server]
bind = "127.0.0.1"
port_user_api = 9000
port_runtime_api = 9001
[data]
dir = "data"
db_url = "sqlite://data/lhome.db"
[docker]
host = ""
[defaults]
memory_mb = 512
timeout_ms = 3000
tmp_mb = 512
[idle]
soft_ms = 45000 # stop container
hard_ms = 300000 # rm container
[limits]
max_global_concurrency = 256
EOF
print_success "Created default configuration"
fi
# Create .gitignore for data directory
cat > data/.gitignore << 'EOF'
# Lambda@Home data directory
*.db
*.db-journal
*.db-wal
*.db-shm
cache/*
zips/*
*.log
*.tmp
*.temp
EOF
print_success "Created .gitignore for data directory"
# Set permissions
chmod 755 data
chmod 755 data/cache
chmod 755 data/zips
chmod 755 config
chmod 755 functions
print_success "Set directory permissions"
# Final instructions
echo
print_success "Lambda@Home setup completed!"
echo
print_status "Next steps:"
echo " 1. Build the project: cargo build --release"
echo " 2. Run Lambda@Home: cargo run"
echo " 3. Or run the release binary: ./target/release/lambda-at-home-server"
echo
print_status "Lambda@Home will be available at:"
echo " - User API: http://127.0.0.1:9000"
echo " - Runtime API: http://127.0.0.1:9001"
echo
print_status "The database will be created automatically on first run."
echo
print_warning "Make sure Docker is running before starting Lambda@Home!"
}
main "$@"