-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup-pi.sh
More file actions
executable file
·123 lines (104 loc) · 3 KB
/
Copy pathsetup-pi.sh
File metadata and controls
executable file
·123 lines (104 loc) · 3 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
# Raspberry Pi Docker Setup Script for Amazon Price Monitor
# Run this script on your Raspberry Pi to set up the environment
set -e
echo "🚀 Setting up Amazon Price Monitor on Raspberry Pi..."
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if running on Raspberry Pi
if ! grep -q "Raspberry Pi" /proc/cpuinfo 2>/dev/null; then
print_warning "This script is designed for Raspberry Pi. Proceeding anyway..."
fi
# Update system
print_status "Updating system packages..."
sudo apt update && sudo apt upgrade -y
# Install Docker if not present
if ! command -v docker &> /dev/null; then
print_status "Installing Docker..."
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
rm get-docker.sh
print_status "Docker installed successfully!"
else
print_status "Docker is already installed"
fi
# Install Docker Compose if not present
if ! command -v docker-compose &> /dev/null; then
print_status "Installing Docker Compose..."
sudo apt install -y docker-compose
print_status "Docker Compose installed successfully!"
else
print_status "Docker Compose is already installed"
fi
# Create application directory
APP_DIR="$HOME/amazon-price-monitor"
if [ ! -d "$APP_DIR" ]; then
print_status "Creating application directory at $APP_DIR"
mkdir -p "$APP_DIR"
fi
cd "$APP_DIR"
# Create necessary directories
mkdir -p data logs
# Create sample configuration files if they don't exist
if [ ! -f "config.json" ]; then
print_status "Creating sample config.json..."
cat > config.json << 'EOF'
{
"products": [
{
"name": "Example Product",
"url": "https://www.amazon.com/dp/B0XXXXXXXX",
"target_price": 50.00
}
],
"check_interval_minutes": 120,
"email_notifications": {
"enabled": true
}
}
EOF
fi
if [ ! -f ".env" ]; then
print_status "Creating .env template..."
cat > .env << 'EOF'
# Email Configuration
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
SMTP_SENDER_EMAIL=your-email@gmail.com
SMTP_SENDER_PASSWORD=your-app-password
SMTP_RECIPIENT_EMAIL=recipient@gmail.com
# Application Configuration
LOG_LEVEL=INFO
EOF
fi
# Set proper permissions
chmod 600 .env
chmod 644 config.json
print_status "Setup completed successfully! 🎉"
echo
print_status "Next steps:"
echo "1. Edit the .env file with your email configuration"
echo "2. Edit config.json with your products to monitor"
echo "3. Run: docker-compose up -d"
echo "4. Monitor logs: docker-compose logs -f"
echo
print_warning "Don't forget to:"
echo "• Set up Gmail app password if using Gmail"
echo "• Add your actual product URLs to config.json"
echo "• Test with longer check intervals (2+ hours) to avoid being blocked"
echo
print_status "Application directory: $APP_DIR"