İçeriğe geç

Install Octoprint on Linux

Base Install

Run Updates

sudo apt update
sudo apt upgrade

Install Packages

sudo apt install python3-pip python3-dev python3-setuptools python3-venv git libyaml-dev build-essential

Setup Octoprint Folder

cd ~
mkdir OctoPrint && cd OctoPrint

Setup Virtual Environment

python3 -m venv venv
source venv/bin/activate

Install Octoprint

pip install pip --upgrade
pip install octoprint

Add pi User to Serial Ports

sudo usermod -a -G tty pi
sudo usermod -a -G dialout pi

Note: You can test the Octproint install now by starting the service “~/OctoPrint/venv/bin/octoprint serve” and connecting to HTTP://<Your IP>:5000. You should get a setup page.

Set Octoprint to Automatically Start

wget https://github.com/OctoPrint/OctoPrint/raw/master/scripts/octoprint.service && sudo mv octoprint.service /etc/systemd/system/octoprint.service
ExecStart=/home/pi/OctoPrint/venv/bin/octoprint
sudo systemctl enable octoprint.service

You can get the status with

sudo service octoprint {start|stop|restart }

HAProxy Install/Setup

HAProxy is used to serve the front end of the site on port 80 and direct the traffic to the backend ports as needed.

Install HAProxy

sudo apt install haproxy

Update HAProxy Config

sudo nano /etc/haproxy/haproxy.cfg

Add this to the bottom of the config

frontend public
        bind *:80
        use_backend webcam if { path_beg /webcam/ }
        default_backend octoprint

backend octoprint
        option forwardfor
        server octoprint1 127.0.0.1:5000

backend webcam
        http-request replace-path /webcam/(.*)   /
        server webcam1  127.0.0.1:8080

Install/Setup Webcam Support

Build mjpg-streamer

cd ~
sudo apt install subversion libjpeg62-turbo-dev imagemagick ffmpeg libv4l-dev cmake
git clone https://github.com/jacksonliam/mjpg-streamer.git
cd mjpg-streamer/mjpg-streamer-experimental
export LD_LIBRARY_PATH=.
make

You can find package here: http://ftp.br.debian.org/debian/pool/main/libj/libjpeg-turbo

Run:

wget http://ftp.br.debian.org/debian/pool/main/libj/libjpeg-turbo/libjpeg62-turbo_1.5.1-2_amd64.deb
sudo dpkg -i libjpeg62-turbo_1.5.1-2_amd64.deb

Set mjpg-streamer to Autostart

mkdir /home/pi/scripts
nano /home/pi/scripts/webcamDaemon

Copy code below into webcamDaemon file just created

#!/bin/bash

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

# init configuration
camera="auto"
camera_usb_options="-r 640x480 -f 10"
camera_raspi_options="-fps 10"

if [ -e "/boot/octopi.txt" ]; then
    source "/boot/octopi.txt"
fi

# runs MJPG Streamer, using the provided input plugin + configuration
function runMjpgStreamer {
    input=$1
    pushd $MJPGSTREAMER_HOME
    echo Running ./mjpg_streamer -o "output_http.so -w ./www" -i "$input"
    LD_LIBRARY_PATH=. ./mjpg_streamer -o "output_http.so -w ./www" -i "$input"
    popd
}

# starts up the RasPiCam
function startRaspi {
    logger "Starting Raspberry Pi camera"
    runMjpgStreamer "$MJPGSTREAMER_INPUT_RASPICAM $camera_raspi_options"
}

# starts up the USB webcam
function startUsb {
    logger "Starting USB webcam"
    runMjpgStreamer "$MJPGSTREAMER_INPUT_USB $camera_usb_options"
}

# we need this to prevent the later calls to vcgencmd from blocking
# I have no idea why, but that's how it is...
vcgencmd version

# echo configuration
echo camera: $camera
echo usb options: $camera_usb_options
echo raspi options: $camera_raspi_options

# keep mjpg streamer running if some camera is attached
while true; do
    if [ -e "/dev/video0" ] && { [ "$camera" = "auto" ] || [ "$camera" = "usb" ] ; }; then
        startUsb
    elif [ "`vcgencmd get_camera`" = "supported=1 detected=1" ] && { [ "$camera" = "auto" ] || [ "$camera" = "raspi" ] ; }; then
        startRaspi
    fi

    sleep 120
done

Setup Permissions on webcam File

chmod +x /home/pi/scripts/webcamDaemon

Create webcamd Service

sudo nano /etc/systemd/system/webcamd.service

Copy code below into webcamd service file just created

[Unit]
Description=Camera streamer for OctoPrint
After=network-online.target OctoPrint.service
Wants=network-online.target

[Service]
Type=simple
User=pi
ExecStart=/home/pi/scripts/webcamDaemon

[Install]
WantedBy=multi-user.target

Enable the webcamd Service

sudo systemctl daemon-reload
sudo systemctl enable webcamd

Reboot

sudo reboot

Webcam URLs

Stream URL: /webcam/?action=stream
Snapshot URL: http://127.0.0.1:8080/?action=snapshot
Path to FFMPEG: /usr/bin/ffmpeg

Alıntı : Install Octoprint on Linux – Complete Guide! – 3dprintscape.com

Kategori:3D PrinterLinuxOctoprint

İlk Yorumu Siz Yapın

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir