This repository has no description
1#!/bin/bash
2# inky_setup.sh - auto setup the inky server
3
4# Check if running as root
5if [ "$EUID" -ne 0 ]; then
6 echo "Please run as root or with sudo"
7 exit 1
8fi
9
10echo "Setting up Inky camera server from GitHub repository..."
11
12# Update system packages and install dependencies
13echo "Updating package lists and installing dependencies..."
14apt update
15apt install -y python3-picamera2 python3-websockets python3-rpi.gpio git
16
17# Create directory for storing photos
18echo "Creating photos directory..."
19mkdir -p /home/ink/photos
20chown ink:ink /home/ink/photos
21
22# Clone the repository
23echo "Cloning repository from GitHub..."
24cd /home/ink
25if [ -d "/home/ink/inky" ]; then
26 read -p "Repository already exists. Would you like to update it? (y/n) " -n 1 -r
27 echo
28 if [[ $REPLY =~ ^[Yy]$ ]]; then
29 cd /home/ink/inky
30 git pull
31 # Just restart the service since it's an update
32 echo "Restarting camera service..."
33 systemctl restart camera.service
34 fi
35else
36 git clone https://github.com/taciturnaxolotl/inky.git
37
38 chown -R ink:ink /home/ink/inky
39
40 # Copy camera_server.py to user's home directory
41 echo "Setting up camera server..."
42 cp /home/ink/inky/src/camera_server.py /home/ink/
43 chown ink:ink /home/ink/camera_server.py
44 chmod +x /home/ink/camera_server.py
45
46 # Copy and set up systemd service
47 echo "Setting up systemd service..."
48 cp /home/ink/inky/src/camera.service /etc/systemd/system/
49
50 # Test the camera
51 echo "Testing camera..."
52 if command -v rpicam-still &> /dev/null; then
53 mkdir -p /tmp/camera_test
54 if rpicam-still -o /tmp/camera_test/test.jpg; then
55 echo "Camera test successful!"
56 else
57 echo "Camera test failed. Please check your camera connection."
58 fi
59 else
60 echo "rpicam-still not found. Please make sure the camera is properly enabled."
61 fi
62
63 # Enable and start the service
64 echo "Enabling and starting camera service..."
65 systemctl daemon-reload
66 systemctl enable camera.service
67 systemctl start camera.service
68fi
69
70echo "Setup complete!"
71echo "Camera server should now be running."
72echo "You can access the web interface at: http://inky.local"
73echo "Check service status with: sudo systemctl status camera"