How to: Create Printer Cluster Image: Difference between revisions

From Open Source Ecology
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(31 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''Warning: This instructionals may be functional, but the provided files are not! The scanner is completely untested and the webserver is in a stage of heavy testing!!'''
This Page has a full documentation on how the Printer Cluster Image is created, so it can be reproduced or modified.
 
This Page will have a full documentation on how the Printer Cluster Image is created, so it can be reproduced or modified.
This will of course be an advanced process, so the reader should have a basic understanding about linux in general and [https://wiki.ubuntuusers.de/SSH/ SSH] in specific.
This will of course be an advanced process, so the reader should have a basic understanding about linux in general and [https://wiki.ubuntuusers.de/SSH/ SSH] in specific.


Line 8: Line 6:
As a basic, we use Octopi, therefore our basic assumption is the use of the octopi image found here: [https://octopi.octoprint.org/ Link]
As a basic, we use Octopi, therefore our basic assumption is the use of the octopi image found here: [https://octopi.octoprint.org/ Link]


However, this set of rules should work basically on every Debian based system (like Ubuntu), some commands may need adjustment and of course there should be about the same folder structure regarding the location of octoprint and it's configuration folders. There is however nothing [[https://de.wikipedia.org/wiki/ARM-Architektur ARM]] specific involved so there is nothing strictly speaking against porting the system to a desktop or laptop.  
However, this set of rules should work basically on every Debian based system (like Ubuntu), some commands may need adjustment and of course there should be about the same folder structure regarding the location of octoprint and it's configuration folders. There is however nothing [https://de.wikipedia.org/wiki/ARM-Architektur ARM] specific involved so there is nothing strictly speaking against porting the system to a desktop or laptop.  


For a manual on how to write the octopi to an SD card and connect it to the network look [How_to:Write_Image_to_SD_Card here]
For a manual on how to write the octopi to an SD card and connect it to the network look here [[How_to:Write_Image_to_SD_Card]]


=The custom setup=
=The custom setup=


After logging into the pi with SSH (basic credentials: pi, raspberry) we can start customizing the image to fit our needs. The credentials and data for setting up the Printer Cluster System are collected together in a zip found [File:PrinterClusterData.zip here].
After logging into the pi with SSH (basic credentials: pi, raspberry) we can start customizing the image to fit our needs. The credentials and data for setting up the Printer Cluster System are collected together in a zip found here [[File:PrinterClusterData.zip]].


This File contains a Readme with a full step by step manual on how the image Printer Cluster image was created additionaly to all files that are needed for the setup (the instructions are also listed below). For getting the files and readme onto the pi we may use [https://wiki.ubuntuusers.de/wget/ wget], taking the file directly from the wiki. The command unzip (Name of the File) will then expand the content.
This File contains a Readme with a full step by step manual on how the image Printer Cluster image was created additionaly to all files that are needed for the setup (the instructions are also listed below). For getting the files and readme onto the pi we may use [https://wiki.ubuntuusers.de/wget/ wget], taking the file directly from the wiki.  


When the (command line) instructions of the readme or below are followed, we should have the system ready, after reboot it should recognize all attached 3d Printer.
When the (command line) instructions of the readme or below are followed, we should have the system ready, after reboot it should recognize all attached 3d Printer.


=Instructions=
=Instructions=
<pre>
sudo raspi-config
    <-- Expand File System, Change User Password, change hostname to 'replab'


sudo raspi-config
sudo -i


    <-- Expand File System, Change User Password
apt-get purge haproxy -y


sudo apt-get purge haproxy
service octoprint stop


sudo service octoprint stop
apt-get update


sudo apt-get update
apt-get upgrade -y


sudo apt-get upgrade
apt-get install htop apache2 libapache2-mod-wsgi python-flask python-serial freecad -y


sudo apt-get install screen htop apache2 (maybe as 2 commandspart) libapache2-mod-wsgi python-flask
a2enmod wsgi


sudo a2enmod wsgi
rm /etc/apache2/sites-enabled/000-default.conf


sudo rm /etc/apache2/sites-available/000-default.conf
     Place Files, the folder RepLabHUB gets placed in /var/www  
     Place Files, the folder RepLabHUB gets placed in /var/www  
     The .conf file to /etc/apache2/sites-available/
     The .conf file to /etc/apache2/sites-available/
     Lastly, the scripts folder in /home/pi/scripts
     Lastly, the scripts folder in /home/pi/scripts
sudo a2ensite RepLabHUB
    The .local file into /etc/ (yes, override)
   
    Moving a folder means NOT moving the folder contents there, but the folder itself
 
a2ensite RepLabHUB
 
echo "www-data ALL=(ALL) NOPASSWD: /sbin/reboot" >> /etc/sudoers
 
chown -R www-data:www-data /var/www/RepLabHUB
 
chown root:root /etc/rc.local
 
chmod +x /etc/rc.local
 
chmod +x /home/pi/scripts/scripts/Scanner.py
 
reboot
</pre>
 
Little addendum: The reboot will result in the start of the completed Server, this means for perfect efficiency, plug in your Printers BEFORE doing the last step, they will be recognized and available on restart. Otherwise, you have to start a scan manually after plugging in the printers
 
=What the parts do=
 
This shall be a very brief explanation on what the components provided by OSE (so excluding octopi, freecad, apache, python) do.
 
==The scripts Folder==
 
In this Folder we have the heart of the recognition software for the 3d printers, namely the Scanner.py .
 
These around 200 Codelines have two main purposes:
 
Checking the device folder for any kind of Serial connection, then sending a basic GCode to get information and verify that it is indeed a printer
 
Writing all the devices down and adjust several files on the system according to it
 
This scripts also removes files it has produced when it is started so it can start from the basics. The data this script collects is also saved here so it can be accessed from the other programs. Everything else stored here are basic blueprints of the files this script creates.
 
This however does not mean this script alone can do the job, this Script has to be run as root and after its running there are several ownership shifts to be done for the new setup to function. These commands are located in the rc.local.
 
==rc.local==
 
This script will be run on linux startup and trigger, if the Scanactive.txt is set, the Scanner and after it the modifications necessary to make the new files function. After all that, a reboot is necessary, so the file does that as well.
 
==RebLabHUB==
 
This is basically the Webserver, so it contains the HTML, css, js and as a core the __init__.py, which sets all the parts together with pythons flask. The Script reads the data provided by the Scanner and adjusts itself accordingly within the html code. This file will actually be rewritten every time the scanner is run, there will be a few lines added at the end of the file. This may seem a strange approach, but it seems to be impossible to name a recursive amount of pages with flask, so it seemed the best workaround and lastly, it works flawless.
 
The Scanactive.txt is within this folder, so the webserver can trigger this rather complex event of the scan with root rights without further access violation.
 
The conf file named the same way is of course the apache conf file, and it's most minimalistic with it's setup of flask


sudo service apache2 reload


sudo service octoprint start
= Related Wiki Pages =
* [[Print Cluster Specification]]
* [[3d Printer Cluster]]


sudo nano /etc/hosts
[[Category:Missing]]
    --> change the line Octopi to RepLab

Latest revision as of 20:00, 27 July 2017

This Page has a full documentation on how the Printer Cluster Image is created, so it can be reproduced or modified. This will of course be an advanced process, so the reader should have a basic understanding about linux in general and SSH in specific.

Creating the Image

As a basic, we use Octopi, therefore our basic assumption is the use of the octopi image found here: Link

However, this set of rules should work basically on every Debian based system (like Ubuntu), some commands may need adjustment and of course there should be about the same folder structure regarding the location of octoprint and it's configuration folders. There is however nothing ARM specific involved so there is nothing strictly speaking against porting the system to a desktop or laptop.

For a manual on how to write the octopi to an SD card and connect it to the network look here How_to:Write_Image_to_SD_Card

The custom setup

After logging into the pi with SSH (basic credentials: pi, raspberry) we can start customizing the image to fit our needs. The credentials and data for setting up the Printer Cluster System are collected together in a zip found here File:PrinterClusterData.zip.

This File contains a Readme with a full step by step manual on how the image Printer Cluster image was created additionaly to all files that are needed for the setup (the instructions are also listed below). For getting the files and readme onto the pi we may use wget, taking the file directly from the wiki.

When the (command line) instructions of the readme or below are followed, we should have the system ready, after reboot it should recognize all attached 3d Printer.

Instructions

sudo raspi-config

    <-- Expand File System, Change User Password, change hostname to 'replab'

sudo -i

apt-get purge haproxy -y

service octoprint stop

apt-get update

apt-get upgrade -y

apt-get install htop apache2 libapache2-mod-wsgi python-flask python-serial freecad -y

a2enmod wsgi

rm /etc/apache2/sites-enabled/000-default.conf

    Place Files, the folder RepLabHUB gets placed in /var/www 
    The .conf file to /etc/apache2/sites-available/
    Lastly, the scripts folder in /home/pi/scripts
    The .local file into /etc/ (yes, override)
    
    Moving a folder means NOT moving the folder contents there, but the folder itself

a2ensite RepLabHUB

echo "www-data ALL=(ALL) NOPASSWD: /sbin/reboot" >> /etc/sudoers

chown -R www-data:www-data /var/www/RepLabHUB

chown root:root /etc/rc.local

chmod +x /etc/rc.local

chmod +x /home/pi/scripts/scripts/Scanner.py 

reboot

Little addendum: The reboot will result in the start of the completed Server, this means for perfect efficiency, plug in your Printers BEFORE doing the last step, they will be recognized and available on restart. Otherwise, you have to start a scan manually after plugging in the printers

What the parts do

This shall be a very brief explanation on what the components provided by OSE (so excluding octopi, freecad, apache, python) do.

The scripts Folder

In this Folder we have the heart of the recognition software for the 3d printers, namely the Scanner.py .

These around 200 Codelines have two main purposes:

Checking the device folder for any kind of Serial connection, then sending a basic GCode to get information and verify that it is indeed a printer

Writing all the devices down and adjust several files on the system according to it

This scripts also removes files it has produced when it is started so it can start from the basics. The data this script collects is also saved here so it can be accessed from the other programs. Everything else stored here are basic blueprints of the files this script creates.

This however does not mean this script alone can do the job, this Script has to be run as root and after its running there are several ownership shifts to be done for the new setup to function. These commands are located in the rc.local.

rc.local

This script will be run on linux startup and trigger, if the Scanactive.txt is set, the Scanner and after it the modifications necessary to make the new files function. After all that, a reboot is necessary, so the file does that as well.

RebLabHUB

This is basically the Webserver, so it contains the HTML, css, js and as a core the __init__.py, which sets all the parts together with pythons flask. The Script reads the data provided by the Scanner and adjusts itself accordingly within the html code. This file will actually be rewritten every time the scanner is run, there will be a few lines added at the end of the file. This may seem a strange approach, but it seems to be impossible to name a recursive amount of pages with flask, so it seemed the best workaround and lastly, it works flawless.

The Scanactive.txt is within this folder, so the webserver can trigger this rather complex event of the scan with root rights without further access violation.

The conf file named the same way is of course the apache conf file, and it's most minimalistic with it's setup of flask


Related Wiki Pages