Full Code of cadriel/FluiddPI for AI

master 0d37b57a22d2 cached
41 files
77.2 KB
21.4k tokens
1 requests
Download .txt
Repository: cadriel/FluiddPI
Branch: master
Commit: 0d37b57a22d2
Files: 41
Total size: 77.2 KB

Directory structure:
gitextract_xzxxayr6/

├── .actrc
├── .github/
│   └── workflows/
│       ├── BuildRaspiOS.yml
│       └── ReleaseRaspiOS.yml
├── .gitignore
├── LICENSE
├── Makefile
├── README.md
├── docker-compose.yml
├── emulation/
│   ├── kernel-qemu-4.19.50-buster
│   └── versatile-pb.dtb
├── run.sh
└── src/
    ├── README.md
    ├── build_dist
    ├── config
    ├── image/
    │   └── README
    ├── modules/
    │   ├── fluidd/
    │   │   ├── config
    │   │   ├── filesystem/
    │   │   │   ├── home/
    │   │   │   │   └── pi/
    │   │   │   │       └── klipper_config/
    │   │   │   │           └── fluidd.cfg
    │   │   │   └── root/
    │   │   │       └── etc/
    │   │   │           ├── logrotate.d/
    │   │   │           │   └── rsyslog
    │   │   │           └── nginx/
    │   │   │               ├── conf.d/
    │   │   │               │   ├── common_vars.conf
    │   │   │               │   └── upstreams.conf
    │   │   │               └── sites-available/
    │   │   │                   └── fluidd
    │   │   └── start_chroot_script
    │   ├── klipper/
    │   │   ├── config
    │   │   ├── filesystem/
    │   │   │   └── root/
    │   │   │       └── etc/
    │   │   │           ├── logrotate.d/
    │   │   │           │   └── klipper
    │   │   │           └── systemd/
    │   │   │               └── system/
    │   │   │                   └── klipper.service
    │   │   └── start_chroot_script
    │   ├── mjpgstreamer/
    │   │   ├── config
    │   │   ├── filesystem/
    │   │   │   ├── home/
    │   │   │   │   └── pi/
    │   │   │   │       └── klipper_config/
    │   │   │   │           └── webcam.txt
    │   │   │   └── root/
    │   │   │       ├── etc/
    │   │   │       │   ├── logrotate.d/
    │   │   │       │   │   └── webcamd
    │   │   │       │   └── systemd/
    │   │   │       │       └── system/
    │   │   │       │           └── webcamd.service
    │   │   │       └── usr/
    │   │   │           └── local/
    │   │   │               └── bin/
    │   │   │                   └── webcamd
    │   │   └── start_chroot_script
    │   ├── moonraker/
    │   │   ├── config
    │   │   ├── filesystem/
    │   │   │   ├── home/
    │   │   │   │   └── pi/
    │   │   │   │       └── klipper_config/
    │   │   │   │           └── moonraker.conf
    │   │   │   └── root/
    │   │   │       └── etc/
    │   │   │           ├── logrotate.d/
    │   │   │           │   └── moonraker
    │   │   │           └── systemd/
    │   │   │               └── system/
    │   │   │                   └── moonraker.service
    │   │   └── start_chroot_script
    │   └── releaseinfochange/
    │       └── start_chroot_script
    └── vagrant/
        ├── Vagrantfile
        ├── run_vagrant_build.sh
        └── setup.sh

================================================
FILE CONTENTS
================================================

================================================
FILE: .actrc
================================================
-P ubuntu-latest=catthehacker/ubuntu:act-latest
-P ubuntu-20.04=catthehacker/ubuntu:act-20.04
-P ubuntu-18.04=catthehacker/ubuntu:act-18.04
ubuntu-16.04=catthehacker/ubuntu:act-16.04

================================================
FILE: .github/workflows/BuildRaspiOS.yml
================================================
name: Build FluiddPI - RapsiOS
on:
  push:
    branches:
      - '**'
    tags-ignore:
      - '**'
  pull_request:
    types: [ opened, edited ]
  workflow_dispatch:
  schedule:
    - cron: '0 0 * * *'

jobs:
  raspiosbuild:
    runs-on: ubuntu-latest

    steps:
      - name: Install Dependencies
        run: sudo apt update; sudo apt install coreutils p7zip-full qemu-user-static zip

      - name: Checkout CustomPiOS
        uses: actions/checkout@v2
        with:
          repository: 'guysoft/CustomPiOS'
          path: CustomPiOS

      - name: Checkout FluiddPI Project
        uses: actions/checkout@v2
        with:
          repository: ${{ github.repository }}
          path: repository
          submodules: true

      - name: Download Raspberry Pi OS Source Image
        run: aria2c -d repository/src/image/ --seed-time=0 https://downloads.raspberrypi.org/raspios_lite_armhf_latest.torrent

      - name: Update CustomPiOS Paths
        run: cd repository/src && ../../CustomPiOS/src/update-custompios-paths

      - name: Build Image
        run: sudo modprobe loop && cd repository/src && sudo bash -x ./build_dist

      - name: Copy output image
        run: cp ${{ github.workspace }}/repository/src/workspace/*-raspios-*-lite.img fluiddpi-raspios-lite-latest.img

      - name: Compress the image
        run: zip fluiddpi-raspios-lite-latest.zip fluiddpi-raspios-lite-latest.img

      - uses: actions/upload-artifact@v1
        with:
          name: fluiddpi-raspios-lite-latest.zip
          path: fluiddpi-raspios-lite-latest.zip


================================================
FILE: .github/workflows/ReleaseRaspiOS.yml
================================================
name: Build and Release FluiddPI - RapsiOS
on:
  release:
    types: [ published ]

jobs:
  raspiosbuild:
    runs-on: ubuntu-latest

    steps:
      - name: Install Dependencies
        run: sudo apt install coreutils p7zip-full qemu-user-static zip

      - name: Checkout CustomPiOS
        uses: actions/checkout@v2
        with:
          repository: 'guysoft/CustomPiOS'
          path: CustomPiOS

      - name: Checkout FluiddPI Project
        uses: actions/checkout@v2
        with:
          repository: ${{ github.repository }}
          path: repository
          submodules: true

      - name: Download Raspberry Pi OS Source Image
        run: aria2c -d repository/src/image/ --seed-time=0 https://downloads.raspberrypi.org/raspios_lite_armhf_latest.torrent

      - name: Update CustomPiOS Paths
        run: cd repository/src && ../../CustomPiOS/src/update-custompios-paths

      - name: Build Image
        run: sudo modprobe loop && cd repository/src && sudo bash -x ./build_dist

      - name: Copy output image
        run: cp ${{ github.workspace }}/repository/src/workspace/*-raspios-*-lite.img fluiddpi-raspios-lite-latest.img

      - name: Compress the image
        run: zip fluiddpi-raspios-lite-latest.zip fluiddpi-raspios-lite-latest.img

      - uses: actions/upload-artifact@v1
        with:
          name: fluiddpi-raspios-lite-latest.zip
          path: fluiddpi-raspios-lite-latest.zip

      - name: Upload RaspiOS Asset
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ github.event.release.upload_url }}
          asset_path: fluiddpi-raspios-lite-latest.zip
          asset_name: fluiddpi-rpi-lite-${{ github.event.release.tag_name }}.zip
          asset_content_type: application/zip


================================================
FILE: .gitignore
================================================
src/config.local
src/custompios_path
src/image/*.zip
src/image-variants/*.zip
**/key.json
src/nightly_build_scripts/index.html
src/nightly_build_scripts/node_modules
src/workspace-*
src/workspace
src/build.log
src/vagrant/*.log
src/vagrant/.vagrant
.vscode
.idea
build.log
.DS_Store


================================================
FILE: LICENSE
================================================
                    GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The GNU General Public License is a free, copyleft license for
software and other kinds of works.

  The licenses for most software and other practical works are designed
to take away your freedom to share and change the works.  By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.  We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors.  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

  To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights.  Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received.  You must make sure that they, too, receive
or can get the source code.  And you must show them these terms so they
know their rights.

  Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.

  For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software.  For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.

  Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so.  This is fundamentally incompatible with the aim of
protecting users' freedom to change the software.  The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable.  Therefore, we
have designed this version of the GPL to prohibit the practice for those
products.  If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.

  Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary.  To prevent this, the GPL assures that
patents cannot be used to render the program non-free.

  The precise terms and conditions for copying, distribution and
modification follow.

                       TERMS AND CONDITIONS

  0. Definitions.

  "This License" refers to version 3 of the GNU General Public License.

  "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

  "The Program" refers to any copyrightable work licensed under this
License.  Each licensee is addressed as "you".  "Licensees" and
"recipients" may be individuals or organizations.

  To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy.  The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

  A "covered work" means either the unmodified Program or a work based
on the Program.

  To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy.  Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

  To "convey" a work means any kind of propagation that enables other
parties to make or receive copies.  Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

  An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License.  If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

  1. Source Code.

  The "source code" for a work means the preferred form of the work
for making modifications to it.  "Object code" means any non-source
form of a work.

  A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

  The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form.  A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

  The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities.  However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work.  For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

  The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

  The Corresponding Source for a work in source code form is that
same work.

  2. Basic Permissions.

  All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met.  This License explicitly affirms your unlimited
permission to run the unmodified Program.  The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work.  This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

  You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force.  You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright.  Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

  Conveying under any other circumstances is permitted solely under
the conditions stated below.  Sublicensing is not allowed; section 10
makes it unnecessary.

  3. Protecting Users' Legal Rights From Anti-Circumvention Law.

  No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

  When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

  4. Conveying Verbatim Copies.

  You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

  You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

  5. Conveying Modified Source Versions.

  You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

    a) The work must carry prominent notices stating that you modified
    it, and giving a relevant date.

    b) The work must carry prominent notices stating that it is
    released under this License and any conditions added under section
    7.  This requirement modifies the requirement in section 4 to
    "keep intact all notices".

    c) You must license the entire work, as a whole, under this
    License to anyone who comes into possession of a copy.  This
    License will therefore apply, along with any applicable section 7
    additional terms, to the whole of the work, and all its parts,
    regardless of how they are packaged.  This License gives no
    permission to license the work in any other way, but it does not
    invalidate such permission if you have separately received it.

    d) If the work has interactive user interfaces, each must display
    Appropriate Legal Notices; however, if the Program has interactive
    interfaces that do not display Appropriate Legal Notices, your
    work need not make them do so.

  A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit.  Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

  6. Conveying Non-Source Forms.

  You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

    a) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by the
    Corresponding Source fixed on a durable physical medium
    customarily used for software interchange.

    b) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by a
    written offer, valid for at least three years and valid for as
    long as you offer spare parts or customer support for that product
    model, to give anyone who possesses the object code either (1) a
    copy of the Corresponding Source for all the software in the
    product that is covered by this License, on a durable physical
    medium customarily used for software interchange, for a price no
    more than your reasonable cost of physically performing this
    conveying of source, or (2) access to copy the
    Corresponding Source from a network server at no charge.

    c) Convey individual copies of the object code with a copy of the
    written offer to provide the Corresponding Source.  This
    alternative is allowed only occasionally and noncommercially, and
    only if you received the object code with such an offer, in accord
    with subsection 6b.

    d) Convey the object code by offering access from a designated
    place (gratis or for a charge), and offer equivalent access to the
    Corresponding Source in the same way through the same place at no
    further charge.  You need not require recipients to copy the
    Corresponding Source along with the object code.  If the place to
    copy the object code is a network server, the Corresponding Source
    may be on a different server (operated by you or a third party)
    that supports equivalent copying facilities, provided you maintain
    clear directions next to the object code saying where to find the
    Corresponding Source.  Regardless of what server hosts the
    Corresponding Source, you remain obligated to ensure that it is
    available for as long as needed to satisfy these requirements.

    e) Convey the object code using peer-to-peer transmission, provided
    you inform other peers where the object code and Corresponding
    Source of the work are being offered to the general public at no
    charge under subsection 6d.

  A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

  A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling.  In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage.  For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product.  A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

  "Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source.  The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

  If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information.  But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

  The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed.  Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

  Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

  7. Additional Terms.

  "Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law.  If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

  When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it.  (Additional permissions may be written to require their own
removal in certain cases when you modify the work.)  You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

  Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

    a) Disclaiming warranty or limiting liability differently from the
    terms of sections 15 and 16 of this License; or

    b) Requiring preservation of specified reasonable legal notices or
    author attributions in that material or in the Appropriate Legal
    Notices displayed by works containing it; or

    c) Prohibiting misrepresentation of the origin of that material, or
    requiring that modified versions of such material be marked in
    reasonable ways as different from the original version; or

    d) Limiting the use for publicity purposes of names of licensors or
    authors of the material; or

    e) Declining to grant rights under trademark law for use of some
    trade names, trademarks, or service marks; or

    f) Requiring indemnification of licensors and authors of that
    material by anyone who conveys the material (or modified versions of
    it) with contractual assumptions of liability to the recipient, for
    any liability that these contractual assumptions directly impose on
    those licensors and authors.

  All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10.  If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term.  If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

  If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

  Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

  8. Termination.

  You may not propagate or modify a covered work except as expressly
provided under this License.  Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

  However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

  Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

  Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License.  If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

  9. Acceptance Not Required for Having Copies.

  You are not required to accept this License in order to receive or
run a copy of the Program.  Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance.  However,
nothing other than this License grants you permission to propagate or
modify any covered work.  These actions infringe copyright if you do
not accept this License.  Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

  10. Automatic Licensing of Downstream Recipients.

  Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License.  You are not responsible
for enforcing compliance by third parties with this License.

  An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations.  If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

  You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License.  For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

  11. Patents.

  A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based.  The
work thus licensed is called the contributor's "contributor version".

  A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version.  For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

  Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

  In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement).  To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

  If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients.  "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

  If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

  A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License.  You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

  Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

  12. No Surrender of Others' Freedom.

  If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all.  For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

  13. Use with the GNU Affero General Public License.

  Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work.  The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.

  14. Revised Versions of this License.

  The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

  Each version is given a distinguishing version number.  If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation.  If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.

  If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

  Later license versions may give you additional or different
permissions.  However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

  15. Disclaimer of Warranty.

  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  16. Limitation of Liability.

  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

  17. Interpretation of Sections 15 and 16.

  If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

  If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

    <program>  Copyright (C) <year>  <name of author>
    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

  You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.

  The GNU General Public License does not permit incorporating your program
into proprietary programs.  If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.  But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.


================================================
FILE: Makefile
================================================
all: build

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

verifyimage:
	@if [ ! -f "src/image/raspberry_pi_os-latest.zip" ]; then echo "Raspbian image does not exist. Starting Download..."; curl -J -L  https://downloads.raspberrypi.org/raspios_lite_armhf_latest > src/image/raspberry_pi_os.zip; else \
	echo "Raspberry Pi OS image found. Starting checksum verification"; curl -J -L https://downloads.raspberrypi.org/raspios_lite_armhf_latest.sha1 > src/image/raspberry_pi_os-latest.zip.sha1; \
	IMAGE_SHA1=`sha1sum src/image/raspberry_pi_os-latest.zip | awk '{print $$1}'`; \
	DL_SHA1=`awk '{print $$1}' src/image/raspberry_pi_os-latest.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  https://downloads.raspberrypi.org/raspios_lite_armhf_latest > src/image/raspberry_pi_os-latest.zip; else echo "SHAs Matched"; fi; fi

clean:
	rm -rf src/workspace
	rm -f src/build.log
	rm -f src/image/raspberry_pi_os-latest.zip.sha1

distclean:
	rm -rf src/image/*.zip

test:
	./run.sh


================================================
FILE: README.md
================================================
# fluiddpi

A pi image with Klipper, Moonraker and Fluidd pre-installed.

This repository contains the necessary code to generate the distribution from an existing Raspberry Pi OS lite distro image.

## Deprecated

⚠️ WARNING ⚠️

FluiddPI is not under active maintenance and we’ve had reports from users finding issues while using it.

As such, our recommendation is that you **do not use FluiddPI**, and instead use [KIAUH](https://github.com/th33xitus/kiauh) to install Fluidd.

## Where to download?

You can download the latest release [here](https://github.com/fluidd-core/FluiddPI/releases/latest).

Older releases can be found [here](https://github.com/fluidd-core/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 `fluiddpi.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://fluiddpi.local` - and will present an error about a missing `printer.cfg` file.

Please ensure your `printer.cfg` is configured correctly for Fluidd, see the fluidd docs [here](https://docs.fluidd.xyz). Once this is complete, you can now progress with your standard printer setup.

## 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)
- QEMU for emulation
- around ~5gb free space

```bash
# Packages for Ubuntu 18.04/20.04
# Dekstop variants are known to cause issues during build due to snaps takeing up loop mounts **

sudo apt-get install gawk make build-essential util-linux \
qemu-user-static qemu-system-arm \
git p7zip-full python3 curl
```

```bash
# To build;
git clone https://github.com/fluidd-core/FluiddPI.git
cd FluiddPI/
make build
```

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

```bash
# Other make options

# 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

```bash
fluiddpi/
  /emulation - Contains dependencies for emulation testing
  /src/image - Contains our base Raspberry Pi OS image
  /src/workspace - Created during build, and output for compiled images
```

### With Thanks

FluiddPI wouldn't be possible without the hard work of Raymond Himle, Stefan Dej
and the team behind CustomPiOS. Thank you!


================================================
FILE: docker-compose.yml
================================================
version: '3.6'

services:
  custompios:
    image: guysoft/custompios:devel
    container_name: fluiddpi-build
    tty: true
    restart: always
    privileged: true
    volumes:
      - ./src:/distro
    devices:
      - /dev/loop-control
    labels:
      - com.centurylinklabs.watchtower.enable=true

================================================
FILE: run.sh
================================================
#!/bin/bash

#####  run.sh - test new image
<<COMMENT
    Original by "prg3" ( https://github.com/prg3 ) and "Noms" ( https://github.com/Nomsplease )

    Modified by "KwadFan" ( https://github.com/KwadFan )

COMMENT

### Configuration
WORKSPACE=src/workspace
IMG_FILE=               #if blank, will be detected


## QEMU Parameters
QEMU_BIN='qemu-system-arm'
QEMU_CPU='arm1176' #CPU Type
QEMU_RAM='256' # in Megabyte
QEMU_KERNEL='emulation/kernel-qemu-4.19.50-buster' #kernel image, do not modify except you what you doing.
QEMU_MACHINE='versatilepb'
QEMU_DTB='emulation/versatile-pb.dtb'
QEMU_OPTIONS='-no-reboot -nographic'
QEMU_NET='-net user,ipv4=on,ipv6=on,hostfwd=tcp::22222-:22,hostfwd=tcp::8888-:80 -net nic'


### Functions

## Hint
start_hint() {
    echo -e "\e[1;30m\n------------------------------------\e[0m"
    echo -e "\e[1;31m Hit Control-a x to exit Emulation!\e[0m "
    echo -e "\e[1;30m------------------------------------\e[0m\n"
}

## looking for qemu-system-arm , package manager independent
search_for_qemu() {
    for BIN_PATH in $(awk -F':' '{ for(i=1;i<=NF;i++) print $i}' <<< ${PATH})
        do
            [[ -x $BIN_PATH/$QEMU_BIN ]] && { QEMU_CMD=$BIN_PATH/$QEMU_BIN ; break; } 
        done
}

## check if needed files missing.
check_env() {
    echo -e "\e[0;37mChecking Environment...\e[0m"
    if [ ! -z $QEMU_CMD ];
        then
            echo -e "\n\e[1;32mqemu-system-arm\e[0m installed..."
        else
            echo -e '\n\e[1;31mCommand qemu-system-arm not found:\n\e[0m
            \e[1;33mPlease install qemu-user-static and qemu-system-arm first!\e[0m'
            exit 2;
    fi
    if [ ! -e $QEMU_KERNEL ];
        then
            echo -e "\n\e[1;32m${QEMU_KERNEL}\e[0m missing, exiting..."
            exit 2
        else 
            echo -e "\n\e[1;32m${QEMU_KERNEL}\e[0m found..."
    fi
    if [ ! -e $QEMU_DTB ];
        then
            echo -e "\n\e[1;32m${QEMU_DTB}\e[0m missing, exiting..."
            exit 2
        else                         
            echo -e "\n\e[1;32m${QEMU_DTB}\e[0m found..."
    fi
}

img_file_handling() {
    if [ $(ls $WORKSPACE/*.img | wc -l) -gt 1 ];
        then
            echo -e "\n\e[1;33mOoops\e[0m, more than \e[1;32m1\e[0m Image found...\n"

            PS3='Choose Image File: '
            select IMAGE in $(cd $WORKSPACE && ls *.img)
                do
                    echo -e "\nUsing \e[1;32m$IMAGE\e[0m\n"
                    IMG_FILE=$IMAGE
                    break
                done

        elif [ $(ls $WORKSPACE/*.img | wc -l) = 1 ];
            then
                IMG_FILE=$(cd $WORKSPACE && ls *.img)
                echo -e "\nFound \e[1;32m${IMG_FILE}\e[0m in \e[1;34m${WORKSPACE}\e[0m\n"
            else
                echo -e "\n 'Image File' not specified or found, exiting script."
                exit 2
    fi
}

## run image 
run_img() {
  qemu-system-arm -cpu $QEMU_CPU -m $QEMU_RAM \
  -kernel $QEMU_KERNEL -M $QEMU_MACHINE -dtb \
  $QEMU_DTB $QEMU_OPTIONS \
  -append 'dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait' \
  -drive file=$WORKSPACE/$IMG_FILE,index=0,media=disk,format=raw $QEMU_NET
}

### Main
start_hint
search_for_qemu
check_env
img_file_handling
run_img


================================================
FILE: src/README.md
================================================
# FluiddPI source

Build FluiddPI from within FluiddPI / OctoPi / Raspberry Pi OS / Debian / Ubuntu.

## Build
FluiddPI can be built from Debian, Ubuntu, Raspberry Pi OS, OctoPi, or even FluiddPI. Build requires about 5 GB of free space available. You can build it by issuing the following commands:

```bash
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/fluidd-core/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
sudo modprobe loop
sudo bash -x ./build_dist
```


================================================
FILE: src/build_dist
================================================
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

export DIST_PATH=${DIR}
export CUSTOM_PI_OS_PATH=$(<${DIR}/custompios_path)
export PATH=$PATH:$CUSTOM_PI_OS_PATH

${CUSTOM_PI_OS_PATH}/build_custom_os $@


================================================
FILE: src/config
================================================
export DIST_NAME=FluiddPI
export DIST_VERSION=0.4.0
export BASE_IMAGE_ENLARGEROOT=2500
export BASE_IMAGE_RESIZEROOT=500
export MODULES="base,releaseinfochange(network,raspicam,klipper,moonraker,fluidd,mjpgstreamer,password-for-sudo)"


================================================
FILE: src/image/README
================================================
Place zipped Rasbian image here.

If not otherwise specified, the build script will always use the most
recent zip file matching the file name pattern "*.zip" located
here.


================================================
FILE: src/modules/fluidd/config
================================================
FLUIDD_VAR="This is a module variable"


================================================
FILE: src/modules/fluidd/filesystem/home/pi/klipper_config/fluidd.cfg
================================================
[virtual_sdcard]
path: /home/pi/gcode_files

[pause_resume]

[display_status]

[gcode_macro CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
gcode:
    TURN_OFF_HEATERS
    CANCEL_PRINT_BASE

[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
# change this if you need more or less extrusion
variable_extrude: 1.0
gcode:
    ##### read E from pause macro #####
    {% set E = printer["gcode_macro PAUSE"].extrude|float %}
    ##### set park positon for x and y #####
    # default is your max posion from your printer.cfg
    {% set x_park = printer.toolhead.axis_maximum.x|float - 5.0 %}
    {% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %}
    ##### calculate save lift position #####
    {% set max_z = printer.toolhead.axis_maximum.z|float %}
    {% set act_z = printer.toolhead.position.z|float %}
    {% if act_z < (max_z - 2.0) %}
        {% set z_safe = 2.0 %}
    {% else %}
        {% set z_safe = max_z - act_z %}
    {% endif %}
    ##### end of definitions #####
    PAUSE_BASE
    G91
    {% if printer.extruder.can_extrude|lower == 'true' %}
      G1 E-{E} F2100
    {% else %}
      {action_respond_info("Extruder not hot enough")}
    {% endif %}
    {% if "xyz" in printer.toolhead.homed_axes %}
      G1 Z{z_safe} F900
      G90
      G1 X{x_park} Y{y_park} F6000
    {% else %}
      {action_respond_info("Printer not homed")}
    {% endif %} 
    
[gcode_macro RESUME]
description: Resume the actual running print
rename_existing: RESUME_BASE
gcode:
    ##### read E from pause macro #####
    {% set E = printer["gcode_macro PAUSE"].extrude|float %}
    #### get VELOCITY parameter if specified ####
    {% if 'VELOCITY' in params|upper %}
      {% set get_params = ('VELOCITY=' + params.VELOCITY)  %}
    {%else %}
      {% set get_params = "" %}
    {% endif %}
    ##### end of definitions #####
    {% if printer.extruder.can_extrude|lower == 'true' %}
      G91
      G1 E{E} F2100
    {% else %}
      {action_respond_info("Extruder not hot enough")}
    {% endif %}  
    RESUME_BASE {get_params}

================================================
FILE: src/modules/fluidd/filesystem/root/etc/logrotate.d/rsyslog
================================================
/var/log/syslog
{
        rotate 4
        daily
        maxsize 256M
        missingok
        notifempty
        delaycompress
        compress
        postrotate
                /usr/lib/rsyslog/rsyslog-rotate
        endscript
}

/var/log/mail.info
/var/log/mail.warn
/var/log/mail.err
/var/log/mail.log
/var/log/daemon.log
/var/log/kern.log
/var/log/auth.log
/var/log/user.log
/var/log/lpr.log
/var/log/cron.log
/var/log/debug
/var/log/messages
{
        rotate 4
        weekly
        maxsize 256M
        missingok
        notifempty
        compress
        delaycompress
        sharedscripts
        postrotate
                /usr/lib/rsyslog/rsyslog-rotate
        endscript
}


================================================
FILE: src/modules/fluidd/filesystem/root/etc/nginx/conf.d/common_vars.conf
================================================
map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}


================================================
FILE: src/modules/fluidd/filesystem/root/etc/nginx/conf.d/upstreams.conf
================================================
upstream apiserver {
    ip_hash;
    server 127.0.0.1:7125;
}

upstream mjpgstreamer1 {
    ip_hash;
    server 127.0.0.1:8080;
}

upstream mjpgstreamer2 {
    ip_hash;
    server 127.0.0.1:8081;
}

upstream mjpgstreamer3 {
    ip_hash;
    server 127.0.0.1:8082;
}

upstream mjpgstreamer4 {
    ip_hash;
    server 127.0.0.1:8083;
}


================================================
FILE: src/modules/fluidd/filesystem/root/etc/nginx/sites-available/fluidd
================================================
server {
    listen 80 default_server;

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

    # 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 _;

    # disable max upload size checks
    client_max_body_size 0;

    # disable proxy request buffering
    proxy_request_buffering off;

    location / {
        try_files $uri $uri/ /index.html;
    }

    location = /index.html {
        add_header Cache-Control "no-store, no-cache, must-revalidate";
    }

    location /websocket {
        proxy_pass http://apiserver/websocket;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_read_timeout 86400;
    }

    location ~ ^/(printer|api|access|machine|server)/ {
        proxy_pass http://apiserver$request_uri;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Scheme $scheme;
    }
	
    location /webcam/ {
        proxy_pass http://mjpgstreamer1/;
    }

    location /webcam2/ {
        proxy_pass http://mjpgstreamer2/;
    }

    location /webcam3/ {
        proxy_pass http://mjpgstreamer3/;
    }

    location /webcam4/ {
        proxy_pass http://mjpgstreamer4/;
    }
}


================================================
FILE: src/modules/fluidd/start_chroot_script
================================================
#!/usr/bin/env bash
# Fluidd installation script
# Installs Fluidd and nginx
# Originally Written by Raymond Himle
# With contributions from Meteyou and Cadriel
# With thanks to KevinOConnor & Arksine
# 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 Fluidd"

apt update
apt install nginx -y
rm /etc/nginx/sites-enabled/default
ln -s /etc/nginx/sites-available/fluidd /etc/nginx/sites-enabled/
cd /home/pi/
[ ! -d /home/pi/gcode_files ] && su -c "mkdir /home/pi/gcode_files" - pi
su -c "mkdir /home/pi/fluidd" - pi
su -c "wget -q -O fluidd.zip https://github.com/fluidd-core/fluidd/releases/latest/download/fluidd.zip" - pi
su -c "unzip fluidd.zip -d /home/pi/fluidd" - pi
rm /home/pi/fluidd.zip

# link logfiles to klipper_logs
ln -s /var/log/nginx/fluidd-access.log /home/pi/klipper_logs/
ln -s /var/log/nginx/fluidd-error.log /home/pi/klipper_logs/

# Run installation steps defined above

# Unpack root at the end, so files are modified before
unpack /filesystem/root /

================================================
FILE: src/modules/klipper/config
================================================
[ -n "$KLIPPER_SRC_DIR" ] || KLIPPER_SRC_DIR=/home/pi/klipper
[ -n "$KLIPPER_PYTHON_DIR" ] || KLIPPER_PYTHON_DIR=/home/pi/klippy-env

[ -n "$KLIPPER_REPO_SHIP" ] || KLIPPER_REPO_SHIP=https://github.com/Klipper3d/klipper.git
[ -n "$KLIPPER_REPO_BRANCH" ] || KLIPPER_REPO_BRANCH=master


================================================
FILE: src/modules/klipper/filesystem/root/etc/logrotate.d/klipper
================================================
  
/home/pi/klipper_logs/klippy.log
{
    rotate 7
    daily
    maxsize 64M
    missingok
    notifempty
    compress
    delaycompress
    sharedscripts
}


================================================
FILE: src/modules/klipper/filesystem/root/etc/systemd/system/klipper.service
================================================
#Systemd service file for klipper

[Unit]
Description=Starts klipper on startup
After=network.target

[Install]
WantedBy=multi-user.target

[Service]
Type=simple
User=pi
RemainAfterExit=yes
ExecStart=/home/pi/klippy-env/bin/python /home/pi/klipper/klippy/klippy.py /home/pi/klipper_config/printer.cfg -l /home/pi/klipper_logs/klippy.log -a /tmp/klippy_uds
Restart=always
RestartSec=10

================================================
FILE: src/modules/klipper/start_chroot_script
================================================
#!/usr/bin/env bash
# Klipper install script
# Script that installs Klipper
# Written by Raymond Himle and Stefan Dej
# Thanks to KevinOConnor
# GPL V3
########


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

source /common.sh
install_cleanup_trap

unpack /filesystem/root /

echo "Installing Klipper"

apt update
apt install wget git gpiod -y

# Packages for python cffi
apt install virtualenv python-dev libffi-dev build-essential -y

# kconfig requirements
apt install libncurses-dev -y

# hub-ctrl
apt install libusb-dev -y

# AVR chip installation and building
apt install avrdude gcc-avr binutils-avr avr-libc -y
apt install stm32flash dfu-util libnewlib-arm-none-eabi -y
apt install gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0-0 -y

#Make sure user pi has access to serial ports
usermod -a -G tty pi
usermod -a -G dialout pi

# clone klipper repo
cd /home/pi
gitclone KLIPPER_REPO klipper

[ ! -d /home/pi/klipper_config ] && su -c "mkdir /home/pi/klipper_config" - pi
[ ! -d /home/pi/klipper_logs ] && su -c "mkdir /home/pi/klipper_logs" - pi

# create python virtualenv and install klipper requirements
su -c "virtualenv -p python2 ${KLIPPER_PYTHON_DIR}" - pi
su -c "${KLIPPER_PYTHON_DIR}/bin/pip install -r ${KLIPPER_SRC_DIR}/scripts/klippy-requirements.txt" - pi

# enable systemd service
systemctl_if_exists enable klipper.service

# Run installation steps defined above


================================================
FILE: src/modules/mjpgstreamer/config
================================================
[ -n "$MJPGSTREAMER_MJPGSTREAMER_REPO_SHIP" ] || MJPGSTREAMER_MJPGSTREAMER_REPO_SHIP=https://github.com/jacksonliam/mjpg-streamer.git
[ -n "$MJPGSTREAMER_MJPGSTREAMER_REPO_BUILD" ] || MJPGSTREAMER_MJPGSTREAMER_REPO_BUILD=
[ -n "$MJPGSTREAMER_MJPGSTREAMER_REPO_BRANCH" ] || MJPGSTREAMER_MJPGSTREAMER_REPO_BRANCH=master
[ -n "$MJPGSTREAMER_MJPGSTREAMER_REPO_DEPTH" ] || MJPGSTREAMER_MJPGSTREAMER_REPO_DEPTH=1
[ -n "$MJPGSTREAMER_INCLUDE_MJPGSTREAMER" ] || MJPGSTREAMER_INCLUDE_MJPGSTREAMER=yes


================================================
FILE: src/modules/mjpgstreamer/filesystem/home/pi/klipper_config/webcam.txt
================================================
### Windows users: To edit this file use Notepad++, VSCode, Atom or SublimeText.
### Do not use Notepad or WordPad.

### MacOSX users: If you use Textedit to edit this file make sure to use 
### "plain text format" and "disable smart quotes" in "Textedit > Preferences"

### Configure which camera to use
#
# Available options are:
# - auto: tries first usb webcam, if that's not available tries raspi cam
# - usb: only tries usb webcam
# - raspi: only tries raspi cam
#
# Defaults to auto
#
#camera="auto"

### Additional options to supply to MJPG Streamer for the USB camera
#
# See https://faq.octoprint.org/mjpg-streamer-config for available options
#
# Defaults to a resolution of 640x480 px and a framerate of 10 fps
#
#camera_usb_options="-r 640x480 -f 10"

### Additional webcam devices known to cause problems with -f
#
# Apparently there a some devices out there that with the current 
# mjpg_streamer release do not support the -f parameter (for specifying 
# the capturing framerate) and will just refuse to output an image if it 
# is supplied.
#
# The webcam daemon will detect those devices by their USB Vendor and Product
# ID and remove the -f parameter from the options provided to mjpg_streamer.
#
# By default, this is done for the following devices:
#   Logitech C170 (046d:082b)
#   GEMBIRD (1908:2310)
#   Genius F100 (0458:708c)
#   Cubeternet GL-UPC822 UVC WebCam (1e4e:0102)
#
# Using the following option it is possible to add additional devices. If
# your webcam happens to show above symptoms, try determining your cam's
# vendor and product id via lsusb, activating the line below by removing # and 
# adding it, e.g. for two broken cameras "aabb:ccdd" and "aabb:eeff"
#
#   additional_brokenfps_usb_devices=("aabb:ccdd" "aabb:eeff")
#
#
#additional_brokenfps_usb_devices=()

### Additional options to supply to MJPG Streamer for the RasPi Cam
#
# See https://faq.octoprint.org/mjpg-streamer-config for available options
#
# Defaults to 10fps
#
#camera_raspi_options="-fps 10"

### Configuration of camera HTTP output
#
# Usually you should NOT need to change this at all! Only touch if you
# know what you are doing and what the parameters mean.
#
# Below settings are used in the mjpg-streamer call like this:
#
#   -o "output_http.so -w $camera_http_webroot $camera_http_options"
#
# Current working directory is the mjpg-streamer base directory.
#
#camera_http_webroot="./www-fluidd"
#camera_http_options="-n"

### EXPERIMENTAL
# Support for different streamer types.
#
# Available options:
#   mjpeg [default] - stable MJPG-streamer
#camera_streamer=mjpeg


================================================
FILE: src/modules/mjpgstreamer/filesystem/root/etc/logrotate.d/webcamd
================================================
  
/var/log/webcamd.log
{
    rotate 4
    weekly
    maxsize 64M
    missingok
    notifempty
    compress
    delaycompress
    sharedscripts
}


================================================
FILE: src/modules/mjpgstreamer/filesystem/root/etc/systemd/system/webcamd.service
================================================

[Unit]
Description=the FluiddPI webcam daemon (based on OctoPi) with the user specified config

[Service]
WorkingDirectory=/usr/local/bin
StandardOutput=append:/var/log/webcamd.log
StandardError=append:/var/log/webcamd.log
ExecStart=/usr/local/bin/webcamd
Restart=always
Type=forking
User=pi

[Install]
WantedBy=multi-user.target


================================================
FILE: src/modules/mjpgstreamer/filesystem/root/usr/local/bin/webcamd
================================================
#!/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   ###
### /home/pi/klipper_config/webcam.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="/home/pi/klipper_config"

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

cfg_files=()
#cfg_files+=/boot/fluidd.txt
if [[ -d ${config_dir} ]]; then
  cfg_files+=( `ls ${config_dir}/webcam*.txt` )
fi

array_camera_config=()
array_camera=()
array_camera_usb_options=()
array_camera_usb_device=()
array_camera_raspi_options=()
array_camera_http_webroot=()
array_camera_http_options=()
array_additional_brokenfps_usb_devices=()
array_camera_device=()
array_assigned_device=()

echo "--- Configuration: ----------------------------"
for cfg_file in ${cfg_files[@]}; do
  # init configuration - DO NOT EDIT, USE /home/pi/klipper_config/webcam*.txt INSTEAD!
  camera="auto"
  camera_usb_options="-r 640x480 -f 10"
  camera_raspi_options="-fps 10"
  camera_http_webroot="./www-mjpgstreamer"
  camera_http_options="-n"
  additional_brokenfps_usb_devices=()

  if [[ -e ${cfg_file} ]]; then
      source "$cfg_file"
  fi
  usb_options="$camera_usb_options"

  # if webcam device is explicitly given in /home/pi/klipper_config/webcam*.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" ]
  then
    # the camera options refer to a device, save it in a variable
    # replace video device parameter with empty string and strip extra whitespace
    usb_options=`echo $usb_options | sed 's/\-d \/dev\/\(video[0-9]\+\|v4l\/[^ ]*\)//g' | awk '$1=$1'`
  else
    extracted_device=""
  fi

  # echo configuration
  echo "cfg_file:      $cfg_file"
  echo "camera:        $camera"
  echo "usb options:   $camera_usb_options"
  echo "raspi options: $camera_raspi_options"
  echo "http options:  -w $camera_http_webroot $camera_http_options"
  echo ""
  echo "Explicitly USB device: $extracted_device"
  echo "-----------------------------------------------"
  echo ""

  array_camera_config+=( $cfg_file )
  array_camera+=( $camera )
  array_camera_usb_options+=("$usb_options")
  array_camera_usb_device+=("$extracted_device")
  array_camera_raspi_options+=("$camera_raspi_options")
  array_camera_http_webroot+=("$camera_http_webroot")
  array_camera_http_options+=("$camera_http_options")
  array_camera_brokenfps_usb_devices+=("${brokenfps_usb_devices[*]} ${additional_brokenfps_usb_devices[*]}")
  array_camera_device+=("")
done

# check if array contains a string
function containsString() {
  local e match="$1"
  shift
  for e; do [[ "$e" == "$match" ]] && return 0; done
  return 1
}

# cleans up when the script receives a SIGINT or SIGTERM
function cleanup() {
    # make sure that all child processed die when we die
    local pids=$(jobs -pr)
    [ -n "$pids" ] && kill $pids
    exit 0
}

# says goodbye when the script shuts down
function goodbye() {
    # say goodbye
    echo ""
    echo "Goodbye..."
    echo ""
}

# runs MJPG Streamer, using the provided input plugin + configuration
function runMjpgStreamer {
    input=$1

    # There are problems with 0x000137ab firmware on VL805 (Raspberry Pi 4}).
    # Try to autodetect offending firmware and temporarily fix the issue
    # by changing power management mode
    echo "Checking for VL805 (Raspberry Pi 4)..."
    if [[ -f /usr/bin/vl805 ]]; then
        VL805_VERSION=$(/usr/bin/vl805)
        VL805_VERSION=${VL805_VERSION#*: }
        echo " - version 0x${VL805_VERSION} detected"
        case "$VL805_VERSION" in
            00013701)
                echo "    - nothing to be done. It shouldn't cause USB problems."
                ;;
            000137ab)
                echo -e "    - \e[31mThis version is known to cause problems with USB cameras.\e[39m"
                echo -e "      You may want to downgrade to 0x0013701."
                echo -e "    - [FIXING] Trying the setpci -s 01:00.0 0xD4.B=0x41 hack to mitigate the"
                echo -e "      issue. It disables ASPM L1 on the VL805. Your board may (or may not) get"
                echo -e "      slightly hotter. For details see:"
                echo -e "      https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=244421"
                setpci -s 01:00.0 0xD4.B=0x41
                ;;
            *)
                echo "   - unknown firmware version. Doing nothing."
                ;;
        esac
    else
        echo "  - It seems that you don't have VL805 (Raspberry Pi 4)."
        echo "    There should be no problems with USB (a.k.a. select() timeout)"
    fi

    pushd $MJPGSTREAMER_HOME > /dev/null 2>&1
        echo Running ./mjpg_streamer -o \"output_http.so -w $camera_http_webroot $camera_http_options\" -i \"$input\"
        LD_LIBRARY_PATH=. ./mjpg_streamer -o "output_http.so -w $camera_http_webroot $camera_http_options" -i "$input" &
        sleep 1 &
        sleep_pid=$!
        wait ${sleep_pid}
    popd > /dev/null 2>&1
}

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

# starts up the USB webcam
function startUsb {
    options="$usb_options"
    device="video0"

    # check for parameter and set the device if it is given as a parameter
    input=$1
    if [[ -n $input ]]; then
        device=`basename "$input"`
    fi

    # add video device into options
    options="$options -d /dev/$device"

    uevent_file="/sys/class/video4linux/$device/device/uevent"
    if [ -e $uevent_file ]; then
        # let's see what kind of webcam we have here, fetch vid and pid...
        product=`cat $uevent_file | grep PRODUCT | cut -d"=" -f2`
        vid=`echo $product | cut -d"/" -f1`
        pid=`echo $product | cut -d"/" -f2`
        vidpid=`printf "%04x:%04x" "0x$vid" "0x$pid"`

        # ... then look if it is in our list of known broken-fps-devices and if so remove
        # the -f parameter from the options (if it's in there, else that's just a no-op)
        for identifier in ${brokenfps_usb_devices[@]};
        do
            if [ "$vidpid" = "$identifier" ]; then
                echo
                echo "Camera model $vidpid is known to not work with -f parameter, stripping it out"
                echo
                options=`echo $options | sed -e "s/\(\s\+\|^\)-f\s\+[0-9]\+//g"`
            fi
        done
    fi

    logger -s "Starting USB webcam"
    runMjpgStreamer "$MJPGSTREAMER_INPUT_USB $options"
}

# make sure our cleanup function gets called when we receive SIGINT, SIGTERM
trap "cleanup" SIGINT SIGTERM
# say goodbye when we EXIT
trap "goodbye" EXIT

# 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 > /dev/null 2>&1

# keep mjpg streamer running if some camera is attached
while true; do

  # get list of usb video devices into an array
  video_devices=($(find /dev -regextype sed -regex '\/dev/video[0-9]\+' | sort -nk1.11 2> /dev/null))

  # add list of raspi camera into an array
  if [ "`vcgencmd get_camera`" = "supported=1 detected=1" ]; then
    video_devices+=( "raspi" )
  fi

  echo "Found video devices:"
  printf '%s\n' "${video_devices[@]}"

  for scan_mode in "usb" "usb-auto" "raspi" "auto"; do
    camera=$scan_mode
    if [[ "usb-auto" == "$scan_mode" ]]; then
      camera="usb"
    fi
    for ((i=0;i<${#array_camera[@]};i++));  do
      if [[ -z ${array_camera_device[${i}]} ]] && [[ $camera == ${array_camera[${i}]} ]]; then
        camera_config="${array_camera_config[${i}]}"
        usb_options="${array_camera_usb_options[${i}]}"
        camera_usb_device="${array_camera_usb_device[${i}]}"
        camera_raspi_options="${array_camera_raspi_options[${i}]}"
        camera_http_webroot="${array_camera_http_webroot[${i}]}"
        camera_http_options="${array_camera_http_options[${i}]}"
        brokenfps_usb_devices="${array_camera_brokenfps_usb_devices[${i}]}"
        if [[ ${camera_usb_device} ]] && { [[ "usb" == ${scan_mode} ]] || [[ "auto" == ${scan_mode} ]]; }; then
           # usb device is explicitly set in options
          usb_device_path=`readlink -f ${camera_usb_device}`
          if containsString "$usb_device_path" "${array_camera_device[@]}"; then
            if [[ "auto" != ${scan_mode} ]]; then
              array_camera_device[${i}]="alredy_in_use"
              echo "config file='$camera_config':Video device already in use."
              continue
            fi
          elif containsString "$usb_device_path" "${video_devices[@]}"; then
            array_camera_device[${i}]="$usb_device_path"
            # explicitly set usb device was found in video_devices array, start usb with the found device
            echo "config file='$camera_config':USB device was set in options and found in devices, start MJPG-streamer with the configured USB video device: $usb_device_path"
            startUsb "$usb_device_path"
            continue
          fi
        elif [[ -z ${camera_usb_device} ]] && { [[ "usb-auto" == ${scan_mode} ]] || [[ "auto" == ${scan_mode} ]]; }; then
          for video_device in "${video_devices[@]}"; do
            if [[ "raspi" != "$video_device" ]]; then
              if containsString "$video_device" "${array_camera_device[@]}"; then
                : #already in use
              else
                array_camera_device[${i}]="$video_device"
                # device is not set explicitly in options, start usb with first found usb camera as the device
                echo "config file='$camera_config':USB device was not set in options, start MJPG-streamer with the first found video device: ${video_device}"
                startUsb "${video_device}"
                break
              fi
            fi
          done
          if [[ -n ${array_camera_device[${i}]} ]]; then
            continue
          fi
        fi
        if [[ "raspi" == ${scan_mode} ]] || [[ "auto" == ${scan_mode} ]]; then
          video_device="raspi"
          if containsString "$video_device" "${array_camera_device[@]}"; then
            if [[ "auto" != ${scan_mode} ]]; then
              array_camera_device[${i}]="alredy_in_use"
              echo "config file='$camera_config':RasPiCam device already in use."
            fi
          elif containsString "$video_device" "${video_devices[@]}"; then
            array_camera_device[${i}]="$video_device"
            echo "config file='$camera_config':Start MJPG-streamer with video device: ${video_device}"
            startRaspi
            sleep 30 &
            sleep_pid=$!
            wait ${sleep_pid}
          fi
        fi
      fi
    done
  done
  array_assigned_device=( ${array_camera_device[*]} )
  if [[ ${#array_camera[@]} -eq ${#array_assigned_device[@]} ]]; then
    echo "Done bring up all configured video device"
    exit 0
  else
    echo "Scan again in two minutes"
    sleep 120 &
    sleep_pid=$!
    wait ${sleep_pid}
  fi
done


================================================
FILE: src/modules/mjpgstreamer/start_chroot_script
================================================
#!/usr/bin/env bash
# MJPGstreamer installer
# Builds MJPGstreamer for rPi devices
# Written by Raymond Himle (Adapted from the OctoPi image creation scripts. Thanks Gina and Guysoft!)
# 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

apt update
apt install -y --allow-downgrades git cmake cmake-data
cd /home/pi
  #mjpg-streamer
  if [ "$MJPGSTREAMER_INCLUDE_MJPGSTREAMER" == "yes" ]
  then
    echo "--- Installing mjpg-streamer"
    if [ $( is_in_apt libjpeg62-turbo-dev ) -eq 1 ]; then
      apt-get -y --force-yes install libjpeg62-turbo-dev
    elif [ $( is_in_apt libjpeg8-dev ) -eq 1 ]; then
      apt-get -y --force-yes install libjpeg8-dev
    fi

    apt-get -y --allow-downgrades --allow-remove-essential --allow-change-held-packages --no-install-recommends install imagemagick ffmpeg libv4l-dev
    gitclone MJPGSTREAMER_MJPGSTREAMER_REPO mjpg-streamer
    pushd mjpg-streamer
      mv mjpg-streamer-experimental/* .

      # As said in Makefile, it is just a wrapper around CMake.
      # To apply -j option, we have to unwrap it.
      MJPG_STREAMER_BUILD_DIR=_build
      [ -d ${MJPG_STREAMER_BUILD_DIR} ] || (mkdir ${MJPG_STREAMER_BUILD_DIR} && \
        chown pi:pi ${MJPG_STREAMER_BUILD_DIR})
      [ -f ${MJPG_STREAMER_BUILD_DIR}/Makefile ] || (cd ${MJPG_STREAMER_BUILD_DIR} && \
        sudo -u pi cmake -DCMAKE${MJPG_STREAMER_BUILD_DIR}_TYPE=Release ..)

      sudo -u pi make -j $(nproc) -C ${MJPG_STREAMER_BUILD_DIR}

      sudo -u pi cp ${MJPG_STREAMER_BUILD_DIR}/mjpg_streamer .
      sudo -u pi find ${MJPG_STREAMER_BUILD_DIR} -name "*.so" -type f -exec cp {} . \;

      # create our custom web folder and add a minimal index.html to it
      sudo -u pi mkdir www-mjpgstreamer
      pushd www-mjpgstreamer
        cat <<EOT >> index.html
<html>
<head><title>mjpg_streamer test page</title></head>
<body>
<h1>Snapshot</h1>
<p>Refresh the page to refresh the snapshot</p>
<img src="./?action=snapshot" alt="Snapshot">
<h1>Stream</h1>
<img src="./?action=stream" alt="Stream">
</body>
</html>
EOT
      popd
    popd
  fi

### mjpg_streamer

unpack /filesystem/root /

if [ "$MJPGSTREAMER_INCLUDE_MJPGSTREAMER" == "yes" ]
then
 systemctl_if_exists enable webcamd.service
else
  rm /etc/logrotate.d/webcamd
  rm /etc/systemd/system/webcamd.service
  rm /root/bin/webcamd
fi

#cleanup
apt-get clean
apt-get autoremove -y

# link logfiles to klipper_logs
ln -s /var/log/webcamd.log /home/pi/klipper_logs/

# Run installation steps defined above

# Unpack root at the end, so files are modified before
unpack /filesystem/root /


================================================
FILE: src/modules/moonraker/config
================================================
[ -n "$MOONRAKER_SRC_DIR" ] || MOONRAKER_SRC_DIR=/home/pi/moonraker
[ -n "$MOONRAKER_PYTHON_DIR" ] || MOONRAKER_PYTHON_DIR=/home/pi/moonraker-env

[ -n "$MOONRAKER_REPO_SHIP" ] || MOONRAKER_REPO_SHIP=https://github.com/Arksine/moonraker.git
[ -n "$MOONRAKER_REPO_BRANCH" ] || MOONRAKER_REPO_BRANCH=master


================================================
FILE: src/modules/moonraker/filesystem/home/pi/klipper_config/moonraker.conf
================================================
[server]
host: 0.0.0.0
port: 7125

[file_manager]
# cancel object preprocessing - set to True to enable; leave disabled when running on a low-powered device (e.g. Pi Zero)
enable_object_processing: False

[data_store]
temperature_store_size: 600
gcode_store_size: 1000

[authorization]
force_logins: True

cors_domains:
  *.local
  *.lan
  *://app.fluidd.xyz

trusted_clients:
  10.0.0.0/8
  127.0.0.0/8
  169.254.0.0/16
  172.16.0.0/12
  192.168.0.0/16
  FE80::/10
  ::1/128

# enables partial support of Octoprint API
[octoprint_compat]

# enables moonraker to track and store print history.
[history]

# this enables moonraker announcements for fluidd
[announcements]
subscriptions:
  fluidd

# this enables moonraker's update manager
[update_manager]
enable_auto_refresh: True

# this enabled fluidd updates
[update_manager fluidd]
type: web
repo: fluidd-core/fluidd
path: ~/fluidd

================================================
FILE: src/modules/moonraker/filesystem/root/etc/logrotate.d/moonraker
================================================
  
/home/pi/klipper_logs/moonraker.log
{
    rotate 7
    daily
    maxsize 64M
    missingok
    notifempty
    compress
    delaycompress
    sharedscripts
}


================================================
FILE: src/modules/moonraker/filesystem/root/etc/systemd/system/moonraker.service
================================================
#Systemd service file for moonraker

[Unit]
Description=Starts Moonraker on startup
After=network.target

[Install]
WantedBy=multi-user.target

[Service]
Type=simple
User=pi
RemainAfterExit=yes
ExecStart=/home/pi/moonraker-env/bin/python /home/pi/moonraker/moonraker/moonraker.py -c /home/pi/klipper_config/moonraker.conf -l /home/pi/klipper_logs/moonraker.log
Restart=always
RestartSec=10

================================================
FILE: src/modules/moonraker/start_chroot_script
================================================
#!/usr/bin/env bash
# Moonraker install script
# Script that installs Moonraker API service
# Written by Raymond Himle and Stefan Dej
# Thanks to Arksine
# 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
unpack /filesystem/root /

echo "Installing Moonraker"

apt update
apt install wget git gpiod -y

# Packages for python and moonraker requirements
apt install python3-virtualenv python3-dev libopenjp2-7 python3-libgpiod curl libcurl4-openssl-dev libssl-dev liblmdb-dev libsodium-dev zlib1g-dev libjpeg-dev packagekit -y

# clone moonraker repo
cd /home/pi
gitclone MOONRAKER_REPO moonraker

# create python virtualenv and install moonraker python requirements
su -c "virtualenv -p /usr/bin/python3 ${MOONRAKER_PYTHON_DIR}" - pi
su -c "ln -s /usr/lib/python3/dist-packages/gpiod* ${MOONRAKER_PYTHON_DIR}/lib/python*/site-packages" - pi
su -c "${MOONRAKER_PYTHON_DIR}/bin/pip install -r ${MOONRAKER_SRC_DIR}/scripts/moonraker-requirements.txt" - pi
su -c "${MOONRAKER_SRC_DIR}/scripts/sudo_fix.sh" - pi

# enable systemd service
systemctl_if_exists enable moonraker.service
# Run installation steps defined above


================================================
FILE: src/modules/releaseinfochange/start_chroot_script
================================================
#!/usr/bin/env bash

set -xe

source /common.sh
install_cleanup_trap

apt update --allow-releaseinfo-change
apt full-upgrade --yes

================================================
FILE: src/vagrant/Vagrantfile
================================================
vagrant_root = File.dirname(__FILE__)
Vagrant.configure("2") do |o|
    o.vm.box = "debian/buster64"
    o.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
    o.vm.synced_folder File.read("../custompios_path").gsub("\n",""), "/CustomPiOS", create:true, type: "nfs"
    o.vm.synced_folder "../", "/distro", create:true, type: "nfs"
    o.vm.network :private_network, ip: "192.168.55.55"
    o.vm.provision :shell, :path => "setup.sh", args: ENV['SHELL_ARGS']

    #o.vbguest.auto_update = false

    o.vm.provider "virtualbox" do |v|
        v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
        v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
    end
end


================================================
FILE: src/vagrant/run_vagrant_build.sh
================================================
#!/usr/bin/env bash
sudo vagrant ssh -- -t "sudo /CustomPiOS/nightly_build_scripts/custompios_nightly_build $@"



================================================
FILE: src/vagrant/setup.sh
================================================
#!/usr/bin/env bash
sudo apt-get update
sudo apt-get install -y gawk util-linux git qemu-user-static p7zip-full unzip zip

Download .txt
gitextract_xzxxayr6/

├── .actrc
├── .github/
│   └── workflows/
│       ├── BuildRaspiOS.yml
│       └── ReleaseRaspiOS.yml
├── .gitignore
├── LICENSE
├── Makefile
├── README.md
├── docker-compose.yml
├── emulation/
│   ├── kernel-qemu-4.19.50-buster
│   └── versatile-pb.dtb
├── run.sh
└── src/
    ├── README.md
    ├── build_dist
    ├── config
    ├── image/
    │   └── README
    ├── modules/
    │   ├── fluidd/
    │   │   ├── config
    │   │   ├── filesystem/
    │   │   │   ├── home/
    │   │   │   │   └── pi/
    │   │   │   │       └── klipper_config/
    │   │   │   │           └── fluidd.cfg
    │   │   │   └── root/
    │   │   │       └── etc/
    │   │   │           ├── logrotate.d/
    │   │   │           │   └── rsyslog
    │   │   │           └── nginx/
    │   │   │               ├── conf.d/
    │   │   │               │   ├── common_vars.conf
    │   │   │               │   └── upstreams.conf
    │   │   │               └── sites-available/
    │   │   │                   └── fluidd
    │   │   └── start_chroot_script
    │   ├── klipper/
    │   │   ├── config
    │   │   ├── filesystem/
    │   │   │   └── root/
    │   │   │       └── etc/
    │   │   │           ├── logrotate.d/
    │   │   │           │   └── klipper
    │   │   │           └── systemd/
    │   │   │               └── system/
    │   │   │                   └── klipper.service
    │   │   └── start_chroot_script
    │   ├── mjpgstreamer/
    │   │   ├── config
    │   │   ├── filesystem/
    │   │   │   ├── home/
    │   │   │   │   └── pi/
    │   │   │   │       └── klipper_config/
    │   │   │   │           └── webcam.txt
    │   │   │   └── root/
    │   │   │       ├── etc/
    │   │   │       │   ├── logrotate.d/
    │   │   │       │   │   └── webcamd
    │   │   │       │   └── systemd/
    │   │   │       │       └── system/
    │   │   │       │           └── webcamd.service
    │   │   │       └── usr/
    │   │   │           └── local/
    │   │   │               └── bin/
    │   │   │                   └── webcamd
    │   │   └── start_chroot_script
    │   ├── moonraker/
    │   │   ├── config
    │   │   ├── filesystem/
    │   │   │   ├── home/
    │   │   │   │   └── pi/
    │   │   │   │       └── klipper_config/
    │   │   │   │           └── moonraker.conf
    │   │   │   └── root/
    │   │   │       └── etc/
    │   │   │           ├── logrotate.d/
    │   │   │           │   └── moonraker
    │   │   │           └── systemd/
    │   │   │               └── system/
    │   │   │                   └── moonraker.service
    │   │   └── start_chroot_script
    │   └── releaseinfochange/
    │       └── start_chroot_script
    └── vagrant/
        ├── Vagrantfile
        ├── run_vagrant_build.sh
        └── setup.sh
Condensed preview — 41 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (84K chars).
[
  {
    "path": ".actrc",
    "chars": 182,
    "preview": "-P ubuntu-latest=catthehacker/ubuntu:act-latest\n-P ubuntu-20.04=catthehacker/ubuntu:act-20.04\n-P ubuntu-18.04=catthehack"
  },
  {
    "path": ".github/workflows/BuildRaspiOS.yml",
    "chars": 1562,
    "preview": "name: Build FluiddPI - RapsiOS\non:\n  push:\n    branches:\n      - '**'\n    tags-ignore:\n      - '**'\n  pull_request:\n    "
  },
  {
    "path": ".github/workflows/ReleaseRaspiOS.yml",
    "chars": 1829,
    "preview": "name: Build and Release FluiddPI - RapsiOS\non:\n  release:\n    types: [ published ]\n\njobs:\n  raspiosbuild:\n    runs-on: u"
  },
  {
    "path": ".gitignore",
    "chars": 283,
    "preview": "src/config.local\nsrc/custompios_path\nsrc/image/*.zip\nsrc/image-variants/*.zip\n**/key.json\nsrc/nightly_build_scripts/inde"
  },
  {
    "path": "LICENSE",
    "chars": 35149,
    "preview": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
  },
  {
    "path": "Makefile",
    "chars": 1158,
    "preview": "all: build\n\nbuild: verifyimage\n\tdocker-compose up -d\n\tdocker exec -it fluiddpi-build build\n\tdocker-compose down\n\nverifyi"
  },
  {
    "path": "README.md",
    "chars": 3271,
    "preview": "# fluiddpi\n\nA pi image with Klipper, Moonraker and Fluidd pre-installed.\n\nThis repository contains the necessary code to"
  },
  {
    "path": "docker-compose.yml",
    "chars": 302,
    "preview": "version: '3.6'\n\nservices:\n  custompios:\n    image: guysoft/custompios:devel\n    container_name: fluiddpi-build\n    tty: "
  },
  {
    "path": "run.sh",
    "chars": 3266,
    "preview": "#!/bin/bash\n\n#####  run.sh - test new image\n<<COMMENT\n    Original by \"prg3\" ( https://github.com/prg3 ) and \"Noms\" ( ht"
  },
  {
    "path": "src/README.md",
    "chars": 706,
    "preview": "# FluiddPI source\n\nBuild FluiddPI from within FluiddPI / OctoPi / Raspberry Pi OS / Debian / Ubuntu.\n\n## Build\nFluiddPI "
  },
  {
    "path": "src/build_dist",
    "chars": 231,
    "preview": "#!/usr/bin/env bash\nDIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\n\nexport DIST_PATH=${DIR}\nexport CUSTOM_PI_OS"
  },
  {
    "path": "src/config",
    "chars": 234,
    "preview": "export DIST_NAME=FluiddPI\nexport DIST_VERSION=0.4.0\nexport BASE_IMAGE_ENLARGEROOT=2500\nexport BASE_IMAGE_RESIZEROOT=500\n"
  },
  {
    "path": "src/image/README",
    "chars": 173,
    "preview": "Place zipped Rasbian image here.\n\nIf not otherwise specified, the build script will always use the most\nrecent zip file "
  },
  {
    "path": "src/modules/fluidd/config",
    "chars": 39,
    "preview": "FLUIDD_VAR=\"This is a module variable\"\n"
  },
  {
    "path": "src/modules/fluidd/filesystem/home/pi/klipper_config/fluidd.cfg",
    "chars": 2125,
    "preview": "[virtual_sdcard]\npath: /home/pi/gcode_files\n\n[pause_resume]\n\n[display_status]\n\n[gcode_macro CANCEL_PRINT]\ndescription: C"
  },
  {
    "path": "src/modules/fluidd/filesystem/root/etc/logrotate.d/rsyslog",
    "chars": 690,
    "preview": "/var/log/syslog\n{\n        rotate 4\n        daily\n        maxsize 256M\n        missingok\n        notifempty\n        delay"
  },
  {
    "path": "src/modules/fluidd/filesystem/root/etc/nginx/conf.d/common_vars.conf",
    "chars": 77,
    "preview": "map $http_upgrade $connection_upgrade {\n    default upgrade;\n    '' close;\n}\n"
  },
  {
    "path": "src/modules/fluidd/filesystem/root/etc/nginx/conf.d/upstreams.conf",
    "chars": 335,
    "preview": "upstream apiserver {\n    ip_hash;\n    server 127.0.0.1:7125;\n}\n\nupstream mjpgstreamer1 {\n    ip_hash;\n    server 127.0.0"
  },
  {
    "path": "src/modules/fluidd/filesystem/root/etc/nginx/sites-available/fluidd",
    "chars": 1947,
    "preview": "server {\n    listen 80 default_server;\n\n    access_log /var/log/nginx/fluidd-access.log;\n    error_log /var/log/nginx/fl"
  },
  {
    "path": "src/modules/fluidd/start_chroot_script",
    "chars": 1100,
    "preview": "#!/usr/bin/env bash\n# Fluidd installation script\n# Installs Fluidd and nginx\n# Originally Written by Raymond Himle\n# Wit"
  },
  {
    "path": "src/modules/klipper/config",
    "chars": 284,
    "preview": "[ -n \"$KLIPPER_SRC_DIR\" ] || KLIPPER_SRC_DIR=/home/pi/klipper\n[ -n \"$KLIPPER_PYTHON_DIR\" ] || KLIPPER_PYTHON_DIR=/home/p"
  },
  {
    "path": "src/modules/klipper/filesystem/root/etc/logrotate.d/klipper",
    "chars": 157,
    "preview": "  \n/home/pi/klipper_logs/klippy.log\n{\n    rotate 7\n    daily\n    maxsize 64M\n    missingok\n    notifempty\n    compress\n "
  },
  {
    "path": "src/modules/klipper/filesystem/root/etc/systemd/system/klipper.service",
    "chars": 384,
    "preview": "#Systemd service file for klipper\n\n[Unit]\nDescription=Starts klipper on startup\nAfter=network.target\n\n[Install]\nWantedBy"
  },
  {
    "path": "src/modules/klipper/start_chroot_script",
    "chars": 1405,
    "preview": "#!/usr/bin/env bash\n# Klipper install script\n# Script that installs Klipper\n# Written by Raymond Himle and Stefan Dej\n# "
  },
  {
    "path": "src/modules/mjpgstreamer/config",
    "chars": 492,
    "preview": "[ -n \"$MJPGSTREAMER_MJPGSTREAMER_REPO_SHIP\" ] || MJPGSTREAMER_MJPGSTREAMER_REPO_SHIP=https://github.com/jacksonliam/mjpg"
  },
  {
    "path": "src/modules/mjpgstreamer/filesystem/home/pi/klipper_config/webcam.txt",
    "chars": 2591,
    "preview": "### Windows users: To edit this file use Notepad++, VSCode, Atom or SublimeText.\n### Do not use Notepad or WordPad.\n\n###"
  },
  {
    "path": "src/modules/mjpgstreamer/filesystem/root/etc/logrotate.d/webcamd",
    "chars": 146,
    "preview": "  \n/var/log/webcamd.log\n{\n    rotate 4\n    weekly\n    maxsize 64M\n    missingok\n    notifempty\n    compress\n    delaycom"
  },
  {
    "path": "src/modules/mjpgstreamer/filesystem/root/etc/systemd/system/webcamd.service",
    "chars": 331,
    "preview": "\n[Unit]\nDescription=the FluiddPI webcam daemon (based on OctoPi) with the user specified config\n\n[Service]\nWorkingDirect"
  },
  {
    "path": "src/modules/mjpgstreamer/filesystem/root/usr/local/bin/webcamd",
    "chars": 11900,
    "preview": "#!/bin/bash\n\n########################################################################\n### DO NOT EDIT THIS FILE TO CHANG"
  },
  {
    "path": "src/modules/mjpgstreamer/start_chroot_script",
    "chars": 2659,
    "preview": "#!/usr/bin/env bash\n# MJPGstreamer installer\n# Builds MJPGstreamer for rPi devices\n# Written by Raymond Himle (Adapted f"
  },
  {
    "path": "src/modules/moonraker/config",
    "chars": 305,
    "preview": "[ -n \"$MOONRAKER_SRC_DIR\" ] || MOONRAKER_SRC_DIR=/home/pi/moonraker\n[ -n \"$MOONRAKER_PYTHON_DIR\" ] || MOONRAKER_PYTHON_D"
  },
  {
    "path": "src/modules/moonraker/filesystem/home/pi/klipper_config/moonraker.conf",
    "chars": 885,
    "preview": "[server]\nhost: 0.0.0.0\nport: 7125\n\n[file_manager]\n# cancel object preprocessing - set to True to enable; leave disabled "
  },
  {
    "path": "src/modules/moonraker/filesystem/root/etc/logrotate.d/moonraker",
    "chars": 160,
    "preview": "  \n/home/pi/klipper_logs/moonraker.log\n{\n    rotate 7\n    daily\n    maxsize 64M\n    missingok\n    notifempty\n    compres"
  },
  {
    "path": "src/modules/moonraker/filesystem/root/etc/systemd/system/moonraker.service",
    "chars": 389,
    "preview": "#Systemd service file for moonraker\n\n[Unit]\nDescription=Starts Moonraker on startup\nAfter=network.target\n\n[Install]\nWant"
  },
  {
    "path": "src/modules/moonraker/start_chroot_script",
    "chars": 1224,
    "preview": "#!/usr/bin/env bash\n# Moonraker install script\n# Script that installs Moonraker API service\n# Written by Raymond Himle a"
  },
  {
    "path": "src/modules/releaseinfochange/start_chroot_script",
    "chars": 130,
    "preview": "#!/usr/bin/env bash\n\nset -xe\n\nsource /common.sh\ninstall_cleanup_trap\n\napt update --allow-releaseinfo-change\napt full-upg"
  },
  {
    "path": "src/vagrant/Vagrantfile",
    "chars": 684,
    "preview": "vagrant_root = File.dirname(__FILE__)\nVagrant.configure(\"2\") do |o|\n    o.vm.box = \"debian/buster64\"\n    o.ssh.shell = \""
  },
  {
    "path": "src/vagrant/run_vagrant_build.sh",
    "chars": 113,
    "preview": "#!/usr/bin/env bash\nsudo vagrant ssh -- -t \"sudo /CustomPiOS/nightly_build_scripts/custompios_nightly_build $@\"\n\n"
  },
  {
    "path": "src/vagrant/setup.sh",
    "chars": 123,
    "preview": "#!/usr/bin/env bash\nsudo apt-get update\nsudo apt-get install -y gawk util-linux git qemu-user-static p7zip-full unzip zi"
  }
]

// ... and 2 more files (download for full content)

About this extraction

This page contains the full source code of the cadriel/FluiddPI GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 41 files (77.2 KB), approximately 21.4k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!