Paulhayes commited on
Commit
7a84ad7
Β·
verified Β·
1 Parent(s): 6947c37

Create install_pi.sh

Browse files
Files changed (1) hide show
  1. install_pi.sh +98 -0
install_pi.sh ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Hive AI Tutor - Raspberry Pi Installation Script
3
+
4
+ set -e
5
+
6
+ echo "🐝 Hive AI Tutor - Raspberry Pi Installation"
7
+ echo "==========================================="
8
+
9
+ # Check if running on Raspberry Pi
10
+ if ! grep -q "Raspberry Pi" /proc/cpuinfo 2>/dev/null; then
11
+ echo "⚠️ Warning: This doesn't appear to be a Raspberry Pi"
12
+ read -p "Continue anyway? (y/N) " -n 1 -r
13
+ echo
14
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
15
+ exit 1
16
+ fi
17
+ fi
18
+
19
+ # Check disk space
20
+ DISK_FREE=$(df . | tail -1 | awk '{print $4}')
21
+ if [ "$DISK_FREE" -lt 16000000 ]; then
22
+ echo "❌ Error: Less than 16GB free disk space available"
23
+ echo " Please free up some space and try again"
24
+ exit 1
25
+ fi
26
+
27
+ # Install system dependencies
28
+ echo "πŸ“¦ Installing system dependencies..."
29
+ sudo apt-get update
30
+ sudo apt-get install -y python3-pip python3-venv python3-dev \
31
+ libportaudio2 libportaudiocpp0 portaudio19-dev \
32
+ ffmpeg libsndfile1
33
+
34
+ # Create hive user (optional, comment out to use current user)
35
+ # echo "πŸ‘€ Creating hive user..."
36
+ # sudo useradd -r -s /bin/bash -d /home/hive -m hive || true
37
+
38
+ # Set installation directory
39
+ INSTALL_DIR="$HOME/hive"
40
+ DATA_DIR="$HOME/hive_data"
41
+
42
+ echo "πŸ“ Creating directories..."
43
+ mkdir -p "$INSTALL_DIR"
44
+ mkdir -p "$DATA_DIR"
45
+
46
+ # Copy files
47
+ echo "πŸ“‹ Copying application files..."
48
+ cp app.py "$INSTALL_DIR/"
49
+ cp requirements.txt "$INSTALL_DIR/"
50
+
51
+ # Create virtual environment
52
+ echo "🐍 Creating virtual environment..."
53
+ cd "$INSTALL_DIR"
54
+ python3 -m venv hive_env
55
+
56
+ # Activate virtual environment
57
+ source hive_env/bin/activate
58
+
59
+ # Upgrade pip
60
+ echo "⬆️ Upgrading pip..."
61
+ pip install --upgrade pip
62
+
63
+ # Install Python dependencies (this will take a while)
64
+ echo "πŸ“¦ Installing Python dependencies (this may take 10-30 minutes)..."
65
+ pip install -r requirements.txt
66
+
67
+ # Create systemd service
68
+ echo "βš™οΈ Setting up systemd service..."
69
+ SERVICE_FILE="/etc/systemd/system/hive.service"
70
+
71
+ # Substitute current user in service file
72
+ sed "s/User=pi/User=$USER/g; s/Group=pi/Group=$USER/g; s|/home/pi/|$HOME/|g" hive.service | sudo tee "$SERVICE_FILE" > /dev/null
73
+
74
+ # Reload systemd
75
+ sudo systemctl daemon-reload
76
+
77
+ # Enable service
78
+ sudo systemctl enable hive.service
79
+
80
+ echo ""
81
+ echo "βœ… Installation complete!"
82
+ echo ""
83
+ echo "To start Hive:"
84
+ echo " sudo systemctl start hive.service"
85
+ echo ""
86
+ echo "To check status:"
87
+ echo " sudo systemctl status hive.service"
88
+ echo ""
89
+ echo "To view logs:"
90
+ echo " journalctl -u hive.service -f"
91
+ echo ""
92
+ echo "To access the UI:"
93
+ echo " Open browser to http://localhost:7860"
94
+ echo " Or http://$(hostname -I | awk '{print $1}'):7860 from another device"
95
+ echo ""
96
+ echo "Data directory: $DATA_DIR"
97
+ echo "Installation directory: $INSTALL_DIR"
98
+ echo ""