this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: move to ink user and add setup scripts

+142 -92
-85
.github/workflows/image-generator.yaml
··· 1 - name: Raspberry Pi Camera Setup 2 - 3 - on: 4 - release: 5 - types: [published] 6 - branches: [main] 7 - 8 - jobs: 9 - build: 10 - runs-on: ubuntu-latest 11 - 12 - steps: 13 - - name: Checkout repository 14 - uses: actions/checkout@v3 15 - 16 - - name: Modify Raspberry Pi OS Image 17 - uses: dtcooper/rpi-image-modifier@v1 18 - id: create-image 19 - with: 20 - base-image-url: https://downloads.raspberrypi.org/raspios_lite_armhf_latest 21 - image-path: raspios-camera-ssh-usb.img 22 - compress-with-xz: true 23 - shrink: true 24 - mount-repository: true 25 - run: | 26 - # Set locale and timezone 27 - echo "en_US.UTF-8 UTF-8" > /etc/locale.gen 28 - locale-gen 29 - update-locale LANG=en_US.UTF-8 30 - ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime 31 - 32 - # Create inky user first 33 - useradd -m -s /bin/bash -G sudo,adm,dialout,cdrom,audio,video,plugdev,games,users,input,netdev,gpio,i2c,spi inky 34 - echo "inky:inkycamera" | chpasswd 35 - 36 - # Set hostname 37 - echo "inky" > /etc/hostname 38 - sed -i 's/raspberrypi/inky/' /etc/hosts 39 - 40 - # Now copy camera files since /home/inky exists 41 - cp -v /mounted-github-repo/src/camera_server.py /home/inky/camera_server.py 42 - cp -v /mounted-github-repo/src/camera.service /etc/systemd/system/camera.service 43 - 44 - # Set permissions 45 - chown -R inky:inky /home/inky 46 - 47 - # Configure SSH over USB 48 - echo "dtoverlay=dwc2" >> /boot/config.txt 49 - sed -i 's/rootwait/rootwait modules-load=dwc2,g_ether/' /boot/cmdline.txt 50 - touch /boot/ssh 51 - 52 - # Create setup script 53 - cat << 'EEOF' > /home/inky/setup.sh 54 - #!/bin/bash 55 - sudo systemctl daemon-reload 56 - sudo systemctl enable camera.service 57 - sudo systemctl start camera.service 58 - EEOF 59 - chmod +x /home/inky/setup.sh 60 - 61 - # Create and configure rc.local 62 - cat << 'EOF' > /etc/rc.local 63 - #!/bin/sh -e 64 - /home/inky/setup.sh 65 - exit 0 66 - EOF 67 - chmod +x /etc/rc.local 68 - 69 - # Install required packages 70 - apt-get update 71 - apt-get install -y python3-picamera2 python3-websockets 72 - apt-get clean 73 - 74 - - name: Upload image as artifact 75 - uses: actions/upload-artifact@v4 76 - with: 77 - name: raspberry-pi-camera-image 78 - path: ${{ steps.create-image.outputs.image-path }} 79 - 80 - - name: Upload Release Asset 81 - uses: softprops/action-gh-release@v1 82 - with: 83 - files: ${{ steps.create-image.outputs.image-path }} 84 - env: 85 - GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
+7 -3
README.md
··· 7 7 8 8 ## Setup 9 9 10 - Put raspberry pi os lite 64-bit onto an SD card using the Raspberry Pi Imager and in the configureation step make sure to 1) add your SSH key and 2) set the user:password to `inky:inkycamera`. Oh and also make sure to add your wifi creds so we can update and install packages. 10 + Put raspberry pi os lite 64-bit onto an SD card using the Raspberry Pi Imager and in the configureation step make sure to 1) add your SSH key and 2) set the user:password to `ink:inkycamera`. Oh and also make sure to add your wifi creds so we can update and install packages. 11 11 12 12 Next you need to configure network over usb so we can ssh in easily and be able to access the photo webserver. 13 13 ··· 27 27 28 28 now ssh in: 29 29 ```bash 30 - ssh ink@inkpress.local 30 + ssh ink@inky.local 31 31 # Default password: inkycamera 32 32 ``` 33 33 34 - The firmware instructions are in [`src/README.md`](src/README.md) 34 + The firmware instructions are in [`src/README.md`](src/README.md) or you can run the following to auto configure 35 + 36 + ```bash 37 + bash -c "$(curl -fsSL hack.club/crgqvn)" 38 + ``` 35 39 36 40 ## Build Notes 37 41
+66
configure-gadget.sh
··· 1 + #!/bin/bash 2 + # setup_gadget_mode.sh - Script to configure USB gadget mode on a Raspberry Pi SD card 3 + 4 + # Check if running as root 5 + if [ "$EUID" -ne 0 ]; then 6 + echo "Please run as root" 7 + exit 1 8 + fi 9 + 10 + # Check if SD card boot partition is provided 11 + if [ $# -lt 1 ]; then 12 + echo "Usage: $0 /path/to/sd_card_boot_partition" 13 + exit 1 14 + fi 15 + 16 + BOOT_PARTITION=$1 17 + 18 + # Verify the boot partition exists 19 + if [ ! -d "$BOOT_PARTITION" ]; then 20 + echo "Error: Boot partition not found at $BOOT_PARTITION" 21 + exit 1 22 + fi 23 + 24 + echo "Configuring USB gadget mode on $BOOT_PARTITION..." 25 + 26 + # Modify config.txt to enable dwc2 overlay 27 + CONFIG_FILE="$BOOT_PARTITION/config.txt" 28 + if [ -f "$CONFIG_FILE" ]; then 29 + if ! grep -q "dtoverlay=dwc2" "$CONFIG_FILE"; then 30 + echo "Adding dtoverlay=dwc2 to config.txt..." 31 + echo "dtoverlay=dwc2" >> "$CONFIG_FILE" 32 + else 33 + echo "dtoverlay=dwc2 already exists in config.txt" 34 + fi 35 + else 36 + echo "Error: config.txt not found in boot partition" 37 + exit 1 38 + fi 39 + 40 + # Modify cmdline.txt to load required modules 41 + CMDLINE_FILE="$BOOT_PARTITION/cmdline.txt" 42 + if [ -f "$CMDLINE_FILE" ]; then 43 + if ! grep -q "modules-load=dwc2,g_ether" "$CMDLINE_FILE"; then 44 + echo "Adding modules-load=dwc2,g_ether to cmdline.txt..." 45 + sed -i 's/$/ modules-load=dwc2,g_ether/' "$CMDLINE_FILE" 46 + else 47 + echo "modules-load=dwc2,g_ether already exists in cmdline.txt" 48 + fi 49 + else 50 + echo "Error: cmdline.txt not found in boot partition" 51 + exit 1 52 + fi 53 + 54 + # Create empty ssh file to enable SSH 55 + SSH_FILE="$BOOT_PARTITION/ssh" 56 + if [ ! -f "$SSH_FILE" ]; then 57 + echo "Creating empty ssh file to enable SSH..." 58 + touch "$SSH_FILE" 59 + else 60 + echo "SSH already enabled" 61 + fi 62 + 63 + echo "USB gadget mode configuration complete!" 64 + echo "Now you can insert the SD card into your Raspberry Pi and boot it." 65 + echo "After booting, you should be able to connect via: ssh ink@inky.local" 66 + echo "Default password: inkycamera"
+65
setup.sh
··· 1 + #!/bin/bash 2 + # inky_setup.sh - auto setup the inky server 3 + 4 + # Check if running as root 5 + if [ "$EUID" -ne 0 ]; then 6 + echo "Please run as root or with sudo" 7 + exit 1 8 + fi 9 + 10 + echo "Setting up Inky camera server from GitHub repository..." 11 + 12 + # Update system packages and install dependencies 13 + echo "Updating package lists and installing dependencies..." 14 + apt update 15 + apt install -y python3-picamera2 python3-websockets python3-rpi.gpio git 16 + 17 + # Create directory for storing photos 18 + echo "Creating photos directory..." 19 + mkdir -p /home/ink/photos 20 + chown ink:ink /home/ink/photos 21 + 22 + # Clone the repository 23 + echo "Cloning repository from GitHub..." 24 + cd /home/ink 25 + if [ -d "/home/ink/inky" ]; then 26 + cd /home/ink/inky 27 + git pull 28 + else 29 + git clone https://github.com/taciturnaxolotl/inky.git 30 + fi 31 + chown -R ink:ink /home/ink/inky 32 + 33 + # Copy camera_server.py to user's home directory 34 + echo "Setting up camera server..." 35 + cp /home/ink/inky/src/camera_server.py /home/ink/ 36 + chown ink:ink /home/ink/camera_server.py 37 + chmod +x /home/ink/camera_server.py 38 + 39 + # Copy and set up systemd service 40 + echo "Setting up systemd service..." 41 + cp /home/ink/inky/src/camera.service /etc/systemd/system/ 42 + 43 + # Test the camera 44 + echo "Testing camera..." 45 + if command -v rpicam-still &> /dev/null; then 46 + mkdir -p /tmp/camera_test 47 + if rpicam-still -o /tmp/camera_test/test.jpg; then 48 + echo "Camera test successful!" 49 + else 50 + echo "Camera test failed. Please check your camera connection." 51 + fi 52 + else 53 + echo "rpicam-still not found. Please make sure the camera is properly enabled." 54 + fi 55 + 56 + # Enable and start the service 57 + echo "Enabling and starting camera service..." 58 + systemctl daemon-reload 59 + systemctl enable camera.service 60 + systemctl start camera.service 61 + 62 + echo "Setup complete!" 63 + echo "Camera server should now be running." 64 + echo "You can access the web interface at: http://inky.local" 65 + echo "Check service status with: sudo systemctl status camera"
+2 -2
src/camera.service
··· 3 3 After=network.target 4 4 5 5 [Service] 6 - ExecStart=/usr/bin/python3 /home/inky/camera_server.py 7 - WorkingDirectory=/home/inky 6 + ExecStart=/usr/bin/python3 /home/ink/camera_server.py 7 + WorkingDirectory=/home/ink 8 8 StandardOutput=inherit 9 9 StandardError=inherit 10 10 Restart=always
+2 -2
src/camera_server.py
··· 15 15 logger = logging.getLogger('camera_server') 16 16 logger.setLevel(logging.INFO) 17 17 formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') 18 - file_handler = logging.FileHandler('/home/inky/camera_server.log') 18 + file_handler = logging.FileHandler('/home/ink/camera_server.log') 19 19 file_handler.setFormatter(formatter) 20 20 stream_handler = logging.StreamHandler() 21 21 stream_handler.setFormatter(formatter) ··· 24 24 25 25 class Config: 26 26 BUTTON_PIN = 17 27 - PHOTO_DIR = "/home/inky/photos" 27 + PHOTO_DIR = "/home/ink/photos" 28 28 WEB_PORT = 80 29 29 WS_PORT = 8765 30 30 PHOTO_RESOLUTION = (2592, 1944)