Skip to content
This repository has been archived by the owner on Jul 7, 2021. It is now read-only.

Commit

Permalink
Initial changes for Fluidd.
Browse files Browse the repository at this point in the history
  • Loading branch information
cadriel committed Oct 5, 2020
1 parent a2911c3 commit 21a1b96
Show file tree
Hide file tree
Showing 22 changed files with 153 additions and 101 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ all: build

build: verifyimage
docker-compose up -d
docker exec -it mainsailos-build build
docker exec -it fluiddpi-build build
docker-compose down

verifyimage:
@if [ ! -f "src/image/raspbian_latest-raspbian.zip" ]; then echo "Raspbian image does not exist. Starting Download..."; curl -J -L http://downloads.raspberrypi.org/raspbian_latest > src/image/raspbian_latest-raspbian.zip; else \
echo "Raspbian image found. Starting checksum verification"; curl -J -L http://downloads.raspberrypi.org/raspbian_latest.sha1 > src/image/raspbian_latest-raspbian.zip.sha1; \
IMAGE_SHA1=`sha1sum src/image/raspbian_latest-raspbian.zip | awk '{print $$1}'`; \
DL_SHA1=`awk '{print $$1}' src/image/raspbian_latest-raspbian.zip.sha1`; \
if [ "$$IMAGE_SHA1" != "$$DL_SHA1" ]; then echo "SHAs do not match."; echo "Got $$IMAGE_SHA1"; echo "Expected $$DL_SHA1"; echo "Starting image download"; curl -J -L http://downloads.raspberrypi.org/raspbian_latest > src/image/raspbian_latest-raspbian.zip; else echo "SHAs Matched"; fi; fi
@if [ ! -f "src/image/raspios_latest-raspbian.zip" ]; then echo "Raspios image does not exist. Starting Download..."; curl -J -L http://downloads.raspberrypi.org/raspios_lite_armhf_latest > src/image/raspios_latest-raspbian.zip; else \
echo "Raspios image found. Starting checksum verification"; curl -J -L http://downloads.raspberrypi.org/raspios_lite_armhf_latest.sha1 > src/image/raspios_latest-raspbian.zip.sha1; \
IMAGE_SHA1=`sha1sum src/image/raspios_latest-raspbian.zip | awk '{print $$1}'`; \
DL_SHA1=`awk '{print $$1}' src/image/raspios_latest-raspbian.zip.sha1`; \
if [ "$$IMAGE_SHA1" != "$$DL_SHA1" ]; then echo "SHAs do not match."; echo "Got $$IMAGE_SHA1"; echo "Expected $$DL_SHA1"; echo "Starting image download"; curl -J -L http://downloads.raspberrypi.org/raspios_lite_armhf_latest > src/image/raspios_latest-raspbian.zip; else echo "SHAs Matched"; fi; fi

clean:
rm -rf src/workspace
rm -f src/build.log
rm -f src/image/raspbian_latest-raspbian.zip.sha1
rm -f src/image/raspios_latest-raspbian.zip.sha1

distclean:
rm -rf src/image/*.zip
Expand Down
81 changes: 61 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,79 @@
# Developing
# fluiddpi
A pi image with Klipper, Moonraker and Fluidd pre-installed.

## Requirements
This repository contains the necessary code to generate the distribution from an existing Raspbian lite distro image.

## Where to download?
You can download the latest release [here](/cadriel/fluiddpi/releases/latest/download/fluiddpi.zip).

Older releases can be found [here](/cadriel/fluiddpi/releases).

## How to use?
1. Download the image as per above and install on an sdcard like you would any other Raspberry pi image.
2. Optionally, if you require WiFi, configure by editing the `fluiddpi-wpa-supplicant.txt` on the root of the sd card - whilst it is still connected to your computer.
3. Boot your Pi from the new sd card.
4. Log into your Pi via SSH (located at fluidd.local). Default username is `pi` and password is `raspberry`.
5. Best practice would have you;
- `sudo apt-get update`
- `sudo apt-get upgrade`
- `sudo raspi-config`
- Change your password
- Define your timezone via 'Localization Options'
- Optionally Change your hostname
6. Reboot.

Fluidd will be available at `http://fluidd.local` - and will present an error about a missing `printer.cfg` file.
You should now progress with standard klipper setup, upon which time Fluidd will begin working correctly.

## Compiling / Developing Quick Start
Regular users of FluiddPI should **not** need to follow any of these steps. This is
for those that wish to compile their own image and / or help in the development
of this project.

### Requirements
Recommended environment is Ubuntu or similar, with docker and docker-compose installed.

- bash
- git
- [docker](https://docs.docker.com/engine/install/ubuntu/)
- [docker-compose](https://docs.docker.com/compose/install/)
- [qemu-arm-static](http://packages.debian.org/sid/qemu-user-static)
- [CustomPiOS](https://github.com/guysoft/CustomPiOS)
- [Downloaded Raspbian Image](http://www.raspbian.org/)
- Bash
- Git
- [Docker](https://docs.docker.com/engine/install/ubuntu/)
- [Docker-Compose](https://docs.docker.com/compose/install/)
- QEMU for emulation
- About 5GB of free diskspace for the build
- around ~5gb free space

### Packages for Ubuntu 18.04/20.04
** Dekstop variants are known to cause issues during build due to snaps takeing up loop mounts **
```bash
# Packages for Ubuntu 18.04/20.04
sudo apt-get install gawk make build-essential util-linux \
qemu-user-static qemu-system-arm \
git p7zip-full python3 curl
```

## Compiling source
To build;
```bash
git clone https://github.com/raymondh2/MainsailOS.git
cd MainsailOS/
git clone https://github.com/cadriel/FluiddPI.git
cd fluiddpi
make build
```

### Other make options
To test;
```bash
# To exit emulation - Ctrl-a x
./run.sh
```

Other make options
```bash
make clean - Clean all previous build items except the source raspian image
make distclean - Clean up the source image and trigger a new download
# Clean all previous build items except the source raspian image
make clean

# Clean up the source image and trigger a new download
make distclean
```

### Build layout
MainsailOS/emulation - Contains dependencies for emulation testing
MainsailOS/src/image - Contains our base raspbian image
MainsailOS/src/workspace - Created during build, and output for compiled images
```
fluiddpi/
/emulation - Dependencies for emulation testing
/src/image - Base raspbian image
/src/workspace - Created during build
```
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3.6'
services:
custompios:
image: guysoft/custompios:devel
container_name: mainsailos-build
container_name: fluiddpi-build
tty: true
restart: always
privileged: true
Expand All @@ -12,4 +12,4 @@ services:
devices:
- /dev/loop-control
labels:
- com.centurylinklabs.watchtower.enable=true
- com.centurylinklabs.watchtower.enable=true
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ qemu-system-arm -cpu arm1176 -m 256 \
-no-reboot \
-nographic \
-append "dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait" \
-drive "file=src/workspace/2020-02-13-raspbian-buster-0.0.5.img,index=0,media=disk,format=raw" \
-drive "file=src/workspace/FluiddPI.img,index=0,media=disk,format=raw" \
-net user,ipv4=on,ipv6=on,hostfwd=tcp::22222-:22,hostfwd=tcp::8888-:80 -net nic
8 changes: 4 additions & 4 deletions src/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Build OctoPi From within OctoPi / Raspbian / Debian / Ubuntu
OctoPi can be built from Debian, Ubuntu, Raspbian, or even OctoPi. Build requires about 2.5 GB of free space available. You can build it by issuing the following commands:
Build FluiddPI From within FluiddPI / Raspbian / Debian / Ubuntu
FluiddPI can be built from Debian, Ubuntu, Raspbian, or even FluiddPI. Build requires about 2.5 GB of free space available. You can build it by issuing the following commands:

sudo apt-get install gawk util-linux qemu-user-static git p7zip-full python3

git clone https://github.com/guysoft/CustomPiOS.git
git clone https://github.com/guysoft/OctoPi.git
cd OctoPi/src/image
git clone https://github.com/cadriel/FluiddPI.git
cd FluiddPI/src/image
wget -c --trust-server-names 'https://downloads.raspberrypi.org/raspios_lite_armhf_latest'
cd ..
../../CustomPiOS/src/update-custompios-paths
Expand Down
9 changes: 6 additions & 3 deletions src/config
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export DIST_NAME=MainSailOS
export DIST_VERSION=0.0.8
export DIST_NAME=FluiddPI
export DIST_VERSION=0.0.1
export BASE_IMAGE_ENLARGEROOT=2000
export BASE_IMAGE_RESIZEROOT=500
export MODULES="base(network,raspicam,klipper_moonraker,mainsail,mjpgstreamer)"
export BASE_RELEASE_IMG_NAME=fluiddpi-buster-lite-v0.0.1.img
export BASE_IMG_NAME=fluiddpi-buster-lite-v0.0.1.img
export BASE_RELEASE_ZIP_NAME=fluiddpi-buster-lite-v0.0.1
export MODULES="base(network, raspicam, klipper_moonraker, fluidd, mjpgstreamer, password-for-sudo)"
1 change: 1 addition & 0 deletions src/image/raspios_latest-raspbian.zip.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7a364204e920931701c9859f74a0cf5067ccbbe0 2020-08-20-raspios-buster-armhf-lite.zip
1 change: 1 addition & 0 deletions src/modules/fluidd/config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FLUIDD_VAR="This is a module variable"
Empty file.
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
server {
listen 80 default_server;

access_log /var/log/nginx/mainsail-access.log;
error_log /var/log/nginx/mainsail-error.log;
access_log /var/log/nginx/fluidd-access.log;
error_log /var/log/nginx/fluidd-error.log;

#web_path from mainsail static files
root /home/pi/mainsail;
# disable this section on smaller hardware like a pi zero
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_proxied expired no-cache no-store private auth;
gzip_comp_level 4;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/json application/xml;

# web_path from fluidd static files
root /home/pi/fluidd;

index index.html;
server_name _;

#max upload size for gcodes
# max upload size for gcode files
client_max_body_size 200M;

location / {
Expand Down
31 changes: 31 additions & 0 deletions src/modules/fluidd/start_chroot_script
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# Fluidd installation script
# Installs Fluidd and nginx
# Written by Craig Bassett
# Thanks to Raymond Himle
# GPL V3
########


# Source error handling, leave this in place
set -x
set -e

source /common.sh
install_cleanup_trap

unpack /filesystem/home/pi /home/pi pi

echo "Installing nginx and Fluidd"

apt-get update
apt-get install nginx -y
rm /etc/nginx/sites-enabled/default
ln -s /etc/nginx/sites-available/fluidd /etc/nginx/sites-enabled/
cd /home/pi/
sudo -u pi mkdir /home/pi/fluidd
sudo -u pi wget -q -O fluidd.zip https://github.com/cadriel/fluidd/releases/latest/download/fluidd_v0.0.3.zip && sudo -u pi unzip fluidd.zip -d /home/pi/fluidd && rm fluidd.zip
# Run installation steps defined above

# Unpack root at the end, so files are modified before
unpack /filesystem/root /
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ config_path: ~/klipper_config
[authorization]
enabled: True
trusted_clients:
10.0.0.0/8
127.0.0.1
169.254.0.0/16
172.16.0.0/12
192.168.0.0/16
192.168.0.0/24
10.0.0.0/24
192.168.1.0/24
FE80::/10
::1/128

6 changes: 3 additions & 3 deletions src/modules/klipper_moonraker/start_chroot_script
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ unpack /filesystem/home/pi /home/pi pi
echo "Installing Klipper and Moonraker"
echo "$KLIPPER_MOONRAKER_VAR"

apt update
apt install wget git gpiod -y
apt-get update
apt-get install wget git gpiod -y
cd /home/pi
gitclone KLIPPER_MOONRAKER_KLIPPER_REPO klipper
gitclone KLIPPER_MOONRAKER_MOONRAKER_REPO_SHIP moonraker
gitclone KLIPPER_MOONRAKER_MOONRAKER_REPO moonraker
sudo -u pi bash /home/pi/./install-custompios.sh
rm /home/pi/install-custompios.sh
# Run installation steps defined above
1 change: 0 additions & 1 deletion src/modules/mainsail/config

This file was deleted.

This file was deleted.

31 changes: 0 additions & 31 deletions src/modules/mainsail/start_chroot_script

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
#
# Current working directory is the mjpg-streamer base directory.
#
#camera_http_webroot="./www-mainsail"
#camera_http_webroot="./www-fluiddpi"
#camera_http_options="-n"

### EXPERIMENTAL
Expand Down
28 changes: 14 additions & 14 deletions src/modules/mjpgstreamer/filesystem/home/root/bin/webcamd
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
#!/bin/bash

########################################################################
### DO NOT EDIT THIS FILE TO CHANGE THE CONFIG!!! ###
### ---------------------------------------------------------------- ###
### There is no need to edit this file for changing resolution, ###
### frame rates or any other mjpg-streamer parameters. Please edit ###
### /boot/mainsail.txt instead - that's what it's there for! You can ###
### even do this with your Pi powered down by directly accessing the ###
### file when using the SD card as thumb drive in your regular ###
### computer. ###
########################################################################
##########################################################################
### DO NOT EDIT THIS FILE TO CHANGE THE CONFIG!!! ###
### ------------------------------------------------------------------ ###
### There is no need to edit this file for changing resolution, ###
### frame rates or any other mjpg-streamer parameters. Please edit ###
### /boot/fluiddpi.txt instead - that's what it's there for! You can ###
### even do this with your Pi powered down by directly accessing the ###
### file when using the SD card as thumb drive in your regular ###
### computer. ###
##########################################################################

MJPGSTREAMER_HOME=/home/pi/mjpg-streamer
MJPGSTREAMER_INPUT_USB="input_uvc.so"
MJPGSTREAMER_INPUT_RASPICAM="input_raspicam.so"

brokenfps_usb_devices=("046d:082b" "1908:2310" "0458:708c" "1e4e:0102" "0471:0311" "038f:6001" "046d:0804" "046d:0825" "046d:0994" "0ac8:3450")

config_dir="/boot/mainsail.conf.d"
config_dir="/boot/fluiddpi.conf.d"

echo "Starting up webcamDaemon..."
echo ""

cfg_files=()
cfg_files+=/boot/mainsail.txt
cfg_files+=/boot/fluiddpi.txt
if [[ -d ${config_dir} ]]; then
cfg_files+=( `ls ${config_dir}/*.txt` )
fi
Expand All @@ -41,7 +41,7 @@ array_assigned_device=()

echo "--- Configuration: ----------------------------"
for cfg_file in ${cfg_files[@]}; do
# init configuration - DO NOT EDIT, USE /boot/mainsail.conf.d/*.txt INSTEAD!
# init configuration - DO NOT EDIT, USE /boot/fluiddpi.conf.d/*.txt INSTEAD!
camera="auto"
camera_usb_options="-r 640x480 -f 10"
camera_raspi_options="-fps 10"
Expand All @@ -54,7 +54,7 @@ for cfg_file in ${cfg_files[@]}; do
fi
usb_options="$camera_usb_options"

# if webcam device is explicitly given in /boot/mainsail.txt, save the path of the device
# if webcam device is explicitly given in /boot/fluiddpi.txt, save the path of the device
# to a variable and remove its parameter from usb_options
extracted_device=`echo $usb_options | sed 's@.*-d \(/dev/\(video[0-9]\+\|v4l/[^ ]*\)\).*@\1@'`
if [ "$extracted_device" != "$usb_options" ]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

[Unit]
Description=the OctoPi webcam daemon with the user specified config
Description=the FluiddPI webcam daemon with the user specified config

[Service]
WorkingDirectory=/root/bin
Expand Down
Loading

0 comments on commit 21a1b96

Please sign in to comment.