├── .github ├── ISSUE_TEMPLATE.md └── workflows │ └── build.yml ├── .gitignore ├── LICENSE ├── README.rst ├── media ├── OctoPi.png ├── OctoPi.svg └── rpi-imager-OctoPi.png └── src ├── build_dist ├── config ├── image-armbian └── README ├── image-raspios_lite_arm64 └── README ├── image-rpios_arm64 └── README ├── image └── README ├── modules └── octopi │ ├── config │ ├── filesystem │ ├── boot │ │ ├── octopi-network.txt │ │ └── octopi.txt │ ├── home │ │ ├── pi │ │ │ ├── .octoprint │ │ │ │ └── config.yaml │ │ │ └── OctoPrint │ │ │ │ └── README.txt │ │ └── root │ │ │ └── bin │ │ │ ├── gencert │ │ │ ├── git │ │ │ ├── streamer_select │ │ │ ├── user-fix │ │ │ └── webcamd │ └── root │ │ ├── etc │ │ ├── haproxy │ │ │ ├── errors │ │ │ │ ├── 503-no-octoprint.http │ │ │ │ ├── 503-no-webcam-hls.http │ │ │ │ └── 503-no-webcam.http │ │ │ ├── haproxy.1.x.cfg │ │ │ └── haproxy.2.x.cfg │ │ ├── init.d │ │ │ ├── change_hostname │ │ │ └── change_password │ │ ├── logrotate.d │ │ │ └── webcamd │ │ ├── nginx │ │ │ └── sites-available │ │ │ │ └── default │ │ ├── systemd │ │ │ └── system │ │ │ │ ├── ffmpeg_hls.service │ │ │ │ ├── gencert.service │ │ │ │ ├── octoprint.service │ │ │ │ ├── streamer_select.service │ │ │ │ ├── user-fix.service │ │ │ │ ├── webcamd.service │ │ │ │ └── wifi_powersave@.service │ │ └── udev │ │ │ └── rules.d │ │ │ └── 95-ads7846.rules │ │ ├── opt │ │ └── octopi │ │ │ └── scripts │ │ │ ├── add-octoprint-checkout │ │ │ ├── install-desktop │ │ │ ├── safemode │ │ │ └── welcome │ │ ├── usr │ │ └── lib │ │ │ └── systemd │ │ │ └── system │ │ │ └── nginx.service │ │ └── var │ │ └── lib │ │ └── ffmpeg_hls │ │ └── stream.m3u8 │ └── start_chroot_script ├── nightly_build_scripts ├── cleanup_storage.js ├── generate_nightly_page.js ├── template.html └── update_git_mirrors ├── vagrant ├── Vagrantfile ├── run_vagrant_build.sh └── setup.sh └── variants ├── rpios_arm64 ├── config ├── filesystem │ └── root │ │ └── etc │ │ ├── haproxy │ │ └── haproxy.cfg │ │ └── systemd │ │ └── system │ │ └── webcamd.service └── post_chroot_script └── ubuntu_arm64 ├── config ├── filesystem └── root │ └── etc │ ├── haproxy │ └── haproxy.cfg │ └── systemd │ └── system │ └── webcamd.service └── post_chroot_script /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 24 | 25 | #### What were you doing? 26 | 27 | 34 | 35 | 1. ... 36 | 2. ... 37 | 3. ... 38 | 39 | 43 | 44 | #### What did you expect to happen? 45 | 46 | #### What happened instead? 47 | 48 | #### Did the same happen when running OctoPrint in safe mode? 49 | 50 | 59 | 60 | #### Version of OctoPi 61 | 62 | 65 | 66 | 67 | #### Printer model & used firmware incl. version 68 | 69 | 72 | 73 | 74 | #### Screenshot(s)/video(s) showing the problem: 75 | 76 | 79 | 80 | I have read the FAQ. 81 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build Image 2 | 3 | on: 4 | repository_dispatch: 5 | push: 6 | schedule: 7 | - cron: '0 0 * * *' 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Install Dependencies 14 | run: | 15 | sudo apt update 16 | sudo apt install coreutils p7zip-full qemu-user-static python3-git 17 | 18 | - name: Checkout CustomPiOS 19 | uses: actions/checkout@v2 20 | with: 21 | repository: 'guysoft/CustomPiOS' 22 | path: CustomPiOS 23 | 24 | - name: Checkout Project Repository 25 | uses: actions/checkout@v2 26 | with: 27 | path: repository 28 | submodules: true 29 | 30 | - name: Download Raspbian Image 31 | run: | 32 | cd repository/src/image 33 | wget -c --trust-server-names 'https://downloads.raspberrypi.org/raspios_lite_armhf_latest' 34 | 35 | - name: Update CustomPiOS Paths 36 | run: | 37 | cd repository/src 38 | ../../CustomPiOS/src/update-custompios-paths 39 | 40 | # - name: Force apt mirror to work around intermittent mirror hiccups 41 | # run: | 42 | # echo "OCTOPI_APTMIRROR=http://mirror.us.leaseweb.net/raspbian/raspbian" > repository/src/config.local 43 | 44 | - name: Build Image 45 | run: | 46 | sudo modprobe loop 47 | cd repository/src 48 | sudo bash -x ./build_dist 49 | 50 | - name: Copy output 51 | id: copy 52 | run: | 53 | source repository/src/config 54 | NOW=$(date +"%Y-%m-%d-%H%M") 55 | IMAGE=$NOW-octopi-$DIST_VERSION 56 | 57 | cp repository/src/workspace/*.img $IMAGE.img 58 | 59 | echo "::set-output name=image::$IMAGE" 60 | 61 | # artifact upload will take care of zipping for us 62 | - uses: actions/upload-artifact@v4 63 | if: github.event_name == 'schedule' 64 | with: 65 | name: ${{ steps.copy.outputs.image }} 66 | path: ${{ steps.copy.outputs.image }}.img 67 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | src/config.local 2 | src/custompios_path 3 | src/image/*.zip 4 | src/image-raspios_lite_arm64/*.zip 5 | src/image-variants/*.zip 6 | **/key.json 7 | src/nightly_build_scripts/index.html 8 | src/nightly_build_scripts/node_modules 9 | src/workspace-* 10 | src/workspace 11 | src/build.log 12 | src/vagrant/*.log 13 | src/vagrant/.vagrant 14 | .vscode 15 | .idea 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | OctoPi 2 | ====== 3 | 4 | .. image:: https://raw.githubusercontent.com/guysoft/OctoPi/devel/media/OctoPi.png 5 | .. :scale: 50 % 6 | .. :alt: OctoPi logo 7 | 8 | A `Raspberry Pi `_ distribution for 3d printers. It includes the `OctoPrint `_ host software for 3d printers out of the box and `mjpg-streamer with RaspiCam support `_ for live viewing of prints and timelapse video creation. 9 | 10 | This repository contains the source script to generate the distribution out of an existing `Raspberry Pi OS `_ distro image or `Le Potato AML-S905X-CC `_ (currenly in beta). 11 | 12 | Where to get it? 13 | ---------------- 14 | 15 | Download the latest stable build via this button: 16 | 17 | .. image:: https://i.imgur.com/NvUOGfS.png 18 | :target: https://octopi.octoprint.org/latest 19 | 20 | Official mirror is `here `_ 21 | 22 | Second mirror is `here `_ 23 | 24 | Nightly builds are available `here `_ 25 | 26 | 64bit Nightly builds are available `here `_ 27 | 28 | You can also access the nightly builds raspberrypi imager channel by running:: 29 | 30 | rpi-imager --repo https://unofficialpi.org/rpi-imager/rpi-imager-octopi.json 31 | 32 | or for second mirror:: 33 | 34 | rpi-imager --repo https://octopi.gnethomelinux.com/rpi-imager/rpi-imager-octopi.json 35 | 36 | How to use it? 37 | -------------- 38 | 39 | #. Unzip the image and install it to an sd card `like any other Raspberry Pi image `_ 40 | #. Configure your WiFi by editing ``wifi.nmconnection`` on the root of the flashed card when using it like a thumb drive 41 | #. Boot the Pi from the card 42 | #. Log into your Pi via SSH (it is located at ``octopi.local`` `if your computer supports bonjour `_ or the IP address assigned by your router), default username is "pi", default password is "raspberry". Run ``sudo raspi-config``. Once that is open: 43 | 44 | a. Change the password via "Change User Password" 45 | b. Optionally: Change the configured timezone via "Localization Options" > "Timezone". 46 | c. Optionally: Change the hostname via "Network Options" > "Hostname". Your OctoPi instance will then no longer be reachable under ``octopi.local`` but rather the hostname you chose postfixed with ``.local``, so keep that in mind. 47 | 48 | You can navigate in the menus using the arrow keys and Enter. To switch to selecting the buttons at the bottom use Tab. 49 | 50 | You do not need to expand the filesystem, current versions of OctoPi do this automatically. 51 | 52 | OctoPrint is located at `http://octopi.local `_ and also at `https://octopi.local `_. Since the SSL certificate is self signed (and generated upon first boot), you will get a certificate warning at the latter location, please ignore it. 53 | 54 | To install plugins from the commandline instead of OctoPrint's built-in plugin manager, :code:`pip` may be found at :code:`/home/pi/oprint/bin/pip`. Thus, an example install cmd may be: :code:`/home/pi/oprint/bin/pip install ` 55 | 56 | If a USB webcam or the Raspberry Pi camera is detected, MJPG-streamer will be started automatically as webcam server. OctoPrint on OctoPi ships with correctly configured stream and snapshot URLs pointing at it. If necessary, you can reach it under `http://octopi.local/webcam/?action=stream `_ and SSL respectively, or directly on its configured port 8080: `http://octopi.local:8080/?action=stream `_. 57 | 58 | 59 | Features 60 | -------- 61 | 62 | * `OctoPrint `_ host software for 3d printers out of the box 63 | * `Raspberry Pi OS `_ tweaked for maximum performance for printing out of the box 64 | * `mjpg-streamer with RaspiCam support `_ for live viewing of prints and timelapse video creation. 65 | 66 | Developing 67 | ---------- 68 | 69 | Requirements 70 | ~~~~~~~~~~~~ 71 | 72 | #. `qemu-arm-static `_ 73 | #. `CustomPiOS `_ 74 | #. Downloaded `Raspberry Pi OS `_ image. 75 | #. root privileges for chroot 76 | #. Bash 77 | #. git 78 | #. sudo (the script itself calls it, running as root without sudo won't work) 79 | #. jq (part of CustomPiOS dependencies) 80 | 81 | Build OctoPi From within OctoPi / Raspberry Pi OS / Debian / Ubuntu 82 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 83 | 84 | OctoPi can be built from Debian, Ubuntu, Raspberry Pi OS, or even OctoPi. 85 | Build requires about 2.5 GB of free space available. 86 | You can build it by issuing the following commands:: 87 | 88 | sudo apt-get install gawk util-linux qemu-user-static git p7zip-full python3 jq 89 | 90 | git clone https://github.com/guysoft/CustomPiOS.git 91 | git clone https://github.com/guysoft/OctoPi.git 92 | cd OctoPi/src/image 93 | wget -c --trust-server-names 'https://downloads.raspberrypi.org/raspios_lite_armhf_latest' 94 | cd .. 95 | ../../CustomPiOS/src/update-custompios-paths 96 | sudo modprobe loop 97 | sudo bash -x ./build_dist 98 | 99 | Building OctoPi Variants 100 | ~~~~~~~~~~~~~~~~~~~~~~~~ 101 | 102 | OctoPi supports building variants, which are builds with changes from the main release build. An example and other variants are available in `CustomPiOS, folder src/variants/example `_. 103 | 104 | docker exec -it mydistro_builder:: 105 | 106 | sudo docker exec -it mydistro_builder build [Variant] 107 | 108 | Or to build a variant inside a container:: 109 | 110 | sudo bash -x ./build_dist [Variant] 111 | 112 | Building Using Docker 113 | ~~~~~~~~~~~~~~~~~~~~~~ 114 | `See Building with docker entry in wiki `_ 115 | 116 | Building Using Vagrant 117 | ~~~~~~~~~~~~~~~~~~~~~~ 118 | There is a vagrant machine configuration to let build OctoPi in case your build environment behaves differently. Unless you do extra configuration, vagrant must run as root to have nfs folder sync working. 119 | 120 | Make sure you have a version of vagrant later than 1.9! 121 | 122 | If you are using older versions of Ubuntu/Debian and not using apt-get `from the download page `_. 123 | 124 | To use it:: 125 | 126 | sudo apt-get install vagrant nfs-kernel-server virtualbox 127 | sudo vagrant plugin install vagrant-nfs_guest 128 | sudo modprobe nfs 129 | cd ../OctoPi 130 | git clone https://github.com/guysoft/CustomPiOS.git 131 | cd OctoPi/src 132 | ../../CustomPiOS/src/update-custompios-paths 133 | cd OctoPi/src/vagrant 134 | sudo vagrant up 135 | run_vagrant_build.sh 136 | 137 | After provisioning the machine, its also possible to run a nightly build which updates from devel using:: 138 | 139 | cd OctoPi/src/vagrant 140 | run_vagrant_build.sh 141 | 142 | To build a variant on the machine simply run:: 143 | 144 | cd src/vagrant 145 | run_vagrant_build.sh [Variant] 146 | 147 | 148 | Usage 149 | ~~~~~ 150 | 151 | #. If needed, override existing config settings by creating a new file ``src/config.local``. You can override all settings found in ``src/modules/octopi/config``. If you need to override the path to the Raspberry Pi OS image to use for building OctoPi, override the path to be used in ``ZIP_IMG``. By default the most recent file matching ``*-raspios*.xz`` found in ``src/image`` will be used. 152 | #. Run ``src/build_dist`` as root. 153 | #. The final image will be created at the ``src/workspace`` 154 | 155 | Code contribution would be appreciated! 156 | -------------------------------------------------------------------------------- /media/OctoPi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guysoft/OctoPi/62365d65444757575159071572c39b320b6dbfe1/media/OctoPi.png -------------------------------------------------------------------------------- /media/rpi-imager-OctoPi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guysoft/OctoPi/62365d65444757575159071572c39b320b6dbfe1/media/rpi-imager-OctoPi.png -------------------------------------------------------------------------------- /src/build_dist: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 | 5 | export DIST_PATH=${DIR} 6 | export CUSTOM_PI_OS_PATH=$(<${DIR}/custompios_path) 7 | export PATH=$PATH:$CUSTOM_PI_OS_PATH 8 | echo ${CUSTOM_PI_OS_PATH} 9 | 10 | ${CUSTOM_PI_OS_PATH}/build_custom_os $@ 11 | -------------------------------------------------------------------------------- /src/config: -------------------------------------------------------------------------------- 1 | export DIST_NAME=OctoPi 2 | export DIST_VERSION=1.2.0 3 | export MODULES="base(raspicam, network, disable-services(octopi), password-for-sudo)" 4 | 5 | export RPI_IMAGER_NAME="${DIST_NAME} version ${DIST_VERSION}" 6 | export RPI_IMAGER_DESCRIPTION="A Raspberry Pi distribution for 3D printers. Ships OctoPrint out-of-the-box." 7 | export RPI_IMAGER_ICON="https://raw.githubusercontent.com/guysoft/OctoPi/devel/media/rpi-imager-OctoPi.png" 8 | 9 | 10 | export BASE_IMAGE_ENLARGEROOT=2000 11 | export BASE_IMAGE_RESIZEROOT=200 12 | -------------------------------------------------------------------------------- /src/image-armbian/README: -------------------------------------------------------------------------------- 1 | Place zipped armbian images here. 2 | 3 | 4 | This folder is used in the armbian build variant. 5 | 6 | Not that if not otherwise specified in the variant, the build script will always use the most 7 | recent zip file matching the file name pattern "*-raspbian.zip" or "*-rpios.zip" or "*-rpios.xz" located 8 | here. 9 | -------------------------------------------------------------------------------- /src/image-raspios_lite_arm64/README: -------------------------------------------------------------------------------- 1 | Place zipped Raspberry Pi OS 64bit image here. 2 | 3 | If not otherwise specified, the build script will always use the most 4 | recent zip file matching the file name pattern "*-raspbian.zip" or "*-rpios.zip" located 5 | here. 6 | -------------------------------------------------------------------------------- /src/image-rpios_arm64/README: -------------------------------------------------------------------------------- 1 | Place zipped Raspberry Pi OS image here for the arm64 variant. Or any other variant you want to build/ 2 | 3 | If not otherwise specified, the build script will always use the most 4 | recent zip file matching the file name pattern "*-raspbian.zip" or "*-rpios.zip" or "*-rpios.xz" located 5 | here. 6 | -------------------------------------------------------------------------------- /src/image/README: -------------------------------------------------------------------------------- 1 | Place zipped Raspberry Pi OS image here. Or any other variant you want to build/ 2 | 3 | If not otherwise specified, the build script will always use the most 4 | recent zip file matching the file name pattern "*-raspbian.zip" or "*-rpios.zip" or "*-rpios.xz" located 5 | here. 6 | -------------------------------------------------------------------------------- /src/modules/octopi/config: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # All our config settings must start with OCTOPI_ 3 | 4 | # OctoPrint archive 5 | [ -n "$OCTOPI_OCTOPRINT_PACKAGE" ] || OCTOPI_OCTOPRINT_PACKAGE="OctoPrint" 6 | [ -n "$OCTOPI_INCLUDE_OCTOPRINT" ] || OCTOPI_INCLUDE_OCTOPRINT=yes 7 | 8 | # CuraEngine archive & version 9 | [ -n "$OCTOPI_CURAENGINE_VERSION" ] || OCTOPI_CURAENGINE_VERSION=15.04.6 10 | [ -n "$OCTOPI_CURAENGINE_ARCHIVE" ] || OCTOPI_CURAENGINE_ARCHIVE=https://github.com/Ultimaker/CuraEngine/archive/$OCTOPI_CURAENGINE_VERSION.zip 11 | [ -n "$OCTOPI_INCLUDE_CURAENGINE" ] || OCTOPI_INCLUDE_CURAENGINE=no 12 | 13 | # mjpg streamer 14 | [ -n "$OCTOPI_MJPGSTREAMER_ARCHIVE" ] || OCTOPI_MJPGSTREAMER_ARCHIVE=https://github.com/jacksonliam/mjpg-streamer/archive/master.zip 15 | [ -n "$OCTOPI_INCLUDE_MJPGSTREAMER" ] || OCTOPI_INCLUDE_MJPGSTREAMER=yes 16 | 17 | # FFMPEG HLS 18 | [ -n "$OCTOPI_INCLUDE_FFMPEG_HLS" ] || OCTOPI_INCLUDE_FFMPEG_HLS=yes 19 | 20 | # HAProxy 21 | [ -n "$OCTOPI_INCLUDE_HAPROXY" ] || OCTOPI_INCLUDE_HAPROXY=yes 22 | 23 | # yq 24 | [ -n "$OCTOPI_YQ_DOWNLOAD" ] || OCTOPI_YQ_DOWNLOAD=$(wget -q -O - https://api.github.com/repos/mikefarah/yq/releases/latest | grep "browser_download_url" | grep "yq_linux_arm" | cut -d : -f 2,3 | tr -d \" | tr -d ,) 25 | 26 | [ -n "$OCTOPI_COMMIT" ] || OCTOPI_COMMIT=`pushd "${DIST_PATH}" > /dev/null ; git rev-parse HEAD ; popd > /dev/null` 27 | 28 | # Fixed apt mirror 29 | [ -n "$OCTOPI_APTMIRROR" ] || OCTOPI_APTMIRROR= 30 | 31 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/boot/octopi-network.txt: -------------------------------------------------------------------------------- 1 | # Using this file to configure your network connection is no longer supported. 2 | # 3 | # Please use wifi.nmconnection instead. 4 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/boot/octopi.txt: -------------------------------------------------------------------------------- 1 | ### Windows users: To edit this file use Notepad++, VSCode, Atom or SublimeText. 2 | ### Do not use Notepad or WordPad. 3 | 4 | ### MacOSX users: If you use Textedit to edit this file make sure to use 5 | ### "plain text format" and "disable smart quotes" in "Textedit > Preferences" 6 | 7 | ### Heads-up: The "input_raspi" input module of mjpg-streamer is no longer supported. 8 | ### Raspicam support is now available on the "input_uvc" module. 9 | 10 | ### Additional options to supply to MJPG Streamer for the USB camera 11 | # 12 | # See https://faq.octoprint.org/mjpg-streamer-config for available options 13 | # 14 | # Defaults to a resolution of 640x480 px and a framerate of 10 fps 15 | # 16 | #camera_usb_options="-r 640x480 -f 10" 17 | 18 | ### Additional webcam devices known to cause problems with -f 19 | # 20 | # Apparently there a some devices out there that with the current 21 | # mjpg_streamer release do not support the -f parameter (for specifying 22 | # the capturing framerate) and will just refuse to output an image if it 23 | # is supplied. 24 | # 25 | # The webcam daemon will detect those devices by their USB Vendor and Product 26 | # ID and remove the -f parameter from the options provided to mjpg_streamer. 27 | # 28 | # By default, this is done for the following devices: 29 | # Logitech C170 (046d:082b) 30 | # GEMBIRD (1908:2310) 31 | # Genius F100 (0458:708c) 32 | # Cubeternet GL-UPC822 UVC WebCam (1e4e:0102) 33 | # 34 | # Using the following option it is possible to add additional devices. If 35 | # your webcam happens to show above symptoms, try determining your cam's 36 | # vendor and product id via lsusb, activating the line below by removing # and 37 | # adding it, e.g. for two broken cameras "aabb:ccdd" and "aabb:eeff" 38 | # 39 | # additional_brokenfps_usb_devices=("aabb:ccdd" "aabb:eeff") 40 | # 41 | # If this fixes your problem, please report it back so we can include the device 42 | # out of the box: https://github.com/guysoft/OctoPi/issues 43 | # 44 | #additional_brokenfps_usb_devices=() 45 | 46 | ### Configuration of camera HTTP output 47 | # 48 | # Usually you should NOT need to change this at all! Only touch if you 49 | # know what you are doing and what the parameters mean. 50 | # 51 | # Below settings are used in the mjpg-streamer call like this: 52 | # 53 | # -o "output_http.so -w $camera_http_webroot $camera_http_options" 54 | # 55 | # Current working directory is the mjpg-streamer base directory. 56 | # 57 | #camera_http_webroot="./www-octopi" 58 | #camera_http_options="-n" 59 | 60 | ### EXPERIMENTAL 61 | # Support for different streamer types. 62 | # 63 | # Available options: 64 | # mjpeg [default] - stable MJPG-streamer 65 | # hls - experimental FFMPEG HLS streamer 66 | #camera_streamer=mjpeg 67 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/home/pi/.octoprint/config.yaml: -------------------------------------------------------------------------------- 1 | webcam: 2 | stream: /webcam/?action=stream 3 | snapshot: http://127.0.0.1:8080/?action=snapshot 4 | ffmpeg: /usr/bin/ffmpeg 5 | plugins: 6 | cura: 7 | cura_engine: /usr/local/bin/cura_engine 8 | discovery: 9 | publicPort: 80 10 | server: 11 | commands: 12 | systemShutdownCommand: sudo shutdown -h now 13 | systemRestartCommand: sudo shutdown -r now 14 | serverRestartCommand: sudo service octoprint restart 15 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/home/pi/OctoPrint/README.txt: -------------------------------------------------------------------------------- 1 | OctoPrint 1.3.6 and newer no longer rely on a git checkout for updates, 2 | so OctoPi no longer goes that route either. 3 | 4 | Feel free to manually create a git clone though if you need it (e.g. for 5 | branch based updates or on board development): 6 | 7 | /opt/octopi/scripts/add-octoprint-checkout 8 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/home/root/bin/gencert: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | keyfile=/etc/ssl/private/ssl-cert-snakeoil.key 4 | pemfile=/etc/ssl/certs/ssl-cert-snakeoil.pem 5 | certfile=/etc/ssl/snakeoil.pem 6 | 7 | if [ ! -f $keyfile ] || [ ! -s $keyfile ] || [ ! -f $pemfile ] || [ ! -s $pemfile ] || [ ! -f $certfile ] || [ ! -s $certfile ]; then 8 | echo "Generating SSL certificate" 9 | sudo make-ssl-cert generate-default-snakeoil --force-overwrite 10 | sudo cat $keyfile $pemfile > $certfile 11 | fi -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/home/root/bin/git: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ "$(id -u)" == "0" ] 4 | then 5 | echo "Please do not run git as root, your regular user account is enough :)" 6 | echo "The rationale behind this restriction is to prevent cloning the OctoPrint" 7 | echo "repository as root, which will most likely break some functionality." 8 | echo 9 | echo "If you need to run git with root rights for some other application than" 10 | echo "what comes preinstalled on this image you can remove this sanity check:" 11 | echo 12 | echo " sudo rm /root/bin/git" 13 | echo 14 | echo "You might have to restart your login session after doing that." 15 | exit 1 16 | fi 17 | 18 | exec /usr/bin/git "$@" 19 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/home/root/bin/streamer_select: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Exit on any error. 4 | set -e 5 | 6 | CONFIG_FILE=/boot/firmware/octopi.txt 7 | # Fallback for older images 8 | if [ ! -f "${CONFIG_FILE}" ] && [ -f "/boot/octopi.txt" ]; then 9 | CONFIG_FILE=/boot/octopi.txt 10 | fi 11 | MJPEG_TYPE=mjpeg 12 | HLS_TYPE=hls 13 | MJPEG_SERVICE=webcamd.service 14 | HLS_SERVICE=ffmpeg_hls.service 15 | DEFAULT_TYPE=${MJPEG_TYPE} 16 | FLAG_DIRECTORY=/etc/octopi_streamer 17 | 18 | source ${CONFIG_FILE} 19 | 20 | if [ -z ${camera_streamer+x} ]; then 21 | echo "No streamer type is set. Defaulting to '${DEFAULT_TYPE}'." 22 | camera_streamer=${DEFAULT_TYPE} 23 | fi 24 | 25 | rm -rf ${FLAG_DIRECTORY} 26 | mkdir -p ${FLAG_DIRECTORY} 27 | 28 | echo "Setting streamer type '${camera_streamer}'." 29 | if [ "${camera_streamer}" = "${MJPEG_TYPE}" ]; then 30 | touch ${FLAG_DIRECTORY}/${MJPEG_TYPE} 31 | elif [ "${camera_streamer}" = "${HLS_TYPE}" ]; then 32 | touch ${FLAG_DIRECTORY}/${HLS_TYPE} 33 | else 34 | echo "Streamer type '${camera_streamer}' is not supported." 35 | exit 1 36 | fi 37 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/home/root/bin/user-fix: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Written by Gina Häußge originally at https://github.com/OctoPrint/OctoPi-UpToDate/blob/e70ccdaf0cd4ef4adfaa3f9b6b288fb6bfda116a/scripts/files/user-fix 3 | 4 | set -e 5 | 6 | USERID=1000 7 | FIRSTUSER=`getent passwd $USERID | cut -d: -f1` 8 | FIRSTUSERHOME=`getent passwd $USERID | cut -d: -f6` 9 | 10 | CURRENT=$(grep "ALL\=NOPASSWD" /etc/sudoers.d/octoprint-service | cut -d\ -f1) 11 | 12 | if [ "$CURRENT" = "pi" -a "$FIRSTUSER" != "pi" ]; then 13 | # if we get here it means that the first user was renamed but we haven't yet 14 | # updated all of OctoPi's files that depend on that name, so let's do that now 15 | 16 | # first we need to figure out if we can use the new user name in systemd files 17 | # directly or if we need to use the UID - we do that by checking if the 18 | # escaped name differes from the plain name, if so something is non ASCII 19 | # and the UID is the safer bet 20 | FIRSTUSERESC=`systemd-escape "$FIRSTUSER"` 21 | if [ "$FIRSTUSER" != "$FIRSTUSERESC" ]; then 22 | SERVICEUSER=$USERID 23 | else 24 | SERVICEUSER=$FIRSTUSER 25 | fi 26 | 27 | # fix sudoers files 28 | echo "Fixing sudoers" 29 | sed -i "s!^pi!$FIRSTUSER!g" /etc/sudoers.d/octoprint-service 30 | sed -i "s!^pi!$FIRSTUSER!g" /etc/sudoers.d/octoprint-shutdown 31 | 32 | # fix scripts 33 | echo "Fixing scripts" 34 | sed -i "s!/home/pi/!$FIRSTUSERHOME/!g" /opt/octopi/scripts/add-octoprint-checkout 35 | sed -i "s!/home/pi/!$FIRSTUSERHOME/!g" /root/bin/webcamd 36 | 37 | # finally, reboot for all of this to actually take affect 38 | echo "Adjusted scripts to new user, restarting services..." 39 | systemctl reboot 40 | fi 41 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/home/root/bin/webcamd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ############################################################################### 4 | ### DO NOT EDIT THIS FILE TO CHANGE THE CONFIG!!! ### 5 | ### ----------------------------------------------------------------------- ### 6 | ### There is no need to edit this file for changing resolution, ### 7 | ### frame rates or any other mjpg-streamer parameters. Please edit ### 8 | ### /boot/firmware/octopi.txt instead - that's what it's there for! You can ### 9 | ### even do this with your Pi powered down by directly accessing the ### 10 | ### file when using the SD card as thumb drive in your regular ### 11 | ### computer. ### 12 | ############################################################################### 13 | 14 | MJPGSTREAMER_HOME=/opt/mjpg-streamer 15 | MJPGSTREAMER_INPUT_USB="input_uvc.so" 16 | MJPGSTREAMER_INPUT_RASPICAM="input_raspicam.so" 17 | 18 | CONFIG_FILE=/boot/firmware/octopi.txt 19 | config_dir="/boot/firmware/octopi.conf.d" 20 | # Fallback for older images 21 | if [ ! -f "${CONFIG_FILE}" ] && [ -f "/boot/octopi.txt" ]; then 22 | CONFIG_FILE=/boot/octopi.txt 23 | config_dir="/boot/octopi.conf.d" 24 | fi 25 | 26 | brokenfps_usb_devices=("046d:082b" "1908:2310" "0458:708c" "0458:6006" "1e4e:0102" "0471:0311" "038f:6001" "046d:0804" "046d:0994" "0ac8:3450") 27 | 28 | echo "Starting up webcamDaemon..." 29 | echo "" 30 | 31 | cfg_files=() 32 | cfg_files+="${CONFIG_FILE}" 33 | if [[ -d ${config_dir} ]]; then 34 | cfg_files+=( `ls ${config_dir}/*.txt` ) 35 | fi 36 | 37 | array_camera_config=() 38 | array_camera=() 39 | array_camera_usb_options=() 40 | array_camera_usb_device=() 41 | array_camera_raspi_options=() 42 | array_camera_http_webroot=() 43 | array_camera_http_options=() 44 | array_additional_brokenfps_usb_devices=() 45 | array_camera_device=() 46 | array_assigned_device=() 47 | 48 | echo "--- Configuration: ----------------------------" 49 | for cfg_file in ${cfg_files[@]}; do 50 | # init configuration - DO NOT EDIT, USE /boot/firmware/octopi.conf.d/*.txt INSTEAD! 51 | camera="auto" 52 | camera_usb_options="-r 640x480 -f 10" 53 | camera_raspi_options="-fps 10" 54 | camera_http_webroot="./www-octopi" 55 | camera_http_options="-n --listen 127.0.0.1" 56 | additional_brokenfps_usb_devices=() 57 | 58 | if [[ -e ${cfg_file} ]]; then 59 | source "$cfg_file" 60 | fi 61 | usb_options="$camera_usb_options" 62 | 63 | # if webcam device is explicitly given in /boot/firmware/octopi.txt, save the path of the device 64 | # to a variable and remove its parameter from usb_options 65 | extracted_device=`echo $usb_options | sed 's@.*-d \(/dev/\(video[0-9]\+\|v4l/[^ ]*\)\).*@\1@'` 66 | if [ "$extracted_device" != "$usb_options" ] 67 | then 68 | # the camera options refer to a device, save it in a variable 69 | # replace video device parameter with empty string and strip extra whitespace 70 | usb_options=`echo $usb_options | sed 's/\-d \/dev\/\(video[0-9]\+\|v4l\/[^ ]*\)//g' | awk '$1=$1'` 71 | else 72 | extracted_device="" 73 | fi 74 | 75 | # echo configuration 76 | echo "cfg_file: $cfg_file" 77 | echo "camera: $camera" 78 | echo "usb options: $camera_usb_options" 79 | echo "raspi options: $camera_raspi_options" 80 | echo "http options: -w $camera_http_webroot $camera_http_options" 81 | echo "" 82 | echo "Explicitly set USB device: $extracted_device" 83 | echo "-----------------------------------------------" 84 | echo "" 85 | 86 | array_camera_config+=( $cfg_file ) 87 | array_camera+=( $camera ) 88 | array_camera_usb_options+=("$usb_options") 89 | array_camera_usb_device+=("$extracted_device") 90 | array_camera_raspi_options+=("$camera_raspi_options") 91 | array_camera_http_webroot+=("$camera_http_webroot") 92 | array_camera_http_options+=("$camera_http_options") 93 | array_camera_brokenfps_usb_devices+=("${brokenfps_usb_devices[*]} ${additional_brokenfps_usb_devices[*]}") 94 | array_camera_device+=("") 95 | done 96 | 97 | # check if array contains a string 98 | function containsString() { 99 | local e match="$1" 100 | shift 101 | for e; do [[ "$e" == "$match" ]] && return 0; done 102 | return 1 103 | } 104 | 105 | # cleans up when the script receives a SIGINT or SIGTERM 106 | function cleanup() { 107 | # make sure that all child processed die when we die 108 | local pids=$(jobs -pr) 109 | [ -n "$pids" ] && kill $pids 110 | exit 0 111 | } 112 | 113 | # waits for our child processes 114 | function awaitChildren() { 115 | local pids=$(jobs -pr) 116 | for pid in $pids; do 117 | wait $pid 118 | done 119 | } 120 | 121 | # says goodbye when the script shuts down 122 | function goodbye() { 123 | # say goodbye 124 | echo "" 125 | echo "Goodbye..." 126 | echo "" 127 | } 128 | 129 | # runs MJPG Streamer, using the provided input plugin + configuration 130 | function runMjpgStreamer { 131 | input=$1 132 | 133 | # There are problems with 0x000137ab firmware on VL805 (Raspberry Pi 4}). 134 | # Try to autodetect offending firmware and temporarily fix the issue 135 | # by changing power management mode 136 | echo "Checking for VL805 (Raspberry Pi 4)..." 137 | if [[ -f /usr/bin/vl805 ]]; then 138 | VL805_VERSION=$(/usr/bin/vl805) 139 | VL805_VERSION=${VL805_VERSION#*: } 140 | echo " - version 0x${VL805_VERSION} detected" 141 | case "$VL805_VERSION" in 142 | 00013701) 143 | echo " - nothing to be done. It shouldn't cause USB problems." 144 | ;; 145 | 000137ab) 146 | echo -e " - \e[31mThis version is known to cause problems with USB cameras.\e[39m" 147 | echo -e " You may want to downgrade to 0x0013701." 148 | echo -e " - [FIXING] Trying the setpci -s 01:00.0 0xD4.B=0x41 hack to mitigate the" 149 | echo -e " issue. It disables ASPM L1 on the VL805. Your board may (or may not) get" 150 | echo -e " slightly hotter. For details see:" 151 | echo -e " https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=244421" 152 | setpci -s 01:00.0 0xD4.B=0x41 153 | ;; 154 | *) 155 | echo " - unknown firmware version. Doing nothing." 156 | ;; 157 | esac 158 | else 159 | echo " - It seems that you don't have VL805 (Raspberry Pi 4)." 160 | echo " There should be no problems with USB (a.k.a. select() timeout)" 161 | fi 162 | 163 | pushd $MJPGSTREAMER_HOME > /dev/null 2>&1 164 | echo Running ./mjpg_streamer -o "output_http.so -w $camera_http_webroot $camera_http_options" -i "$input" 165 | LD_LIBRARY_PATH=. ./mjpg_streamer -o "output_http.so -w $camera_http_webroot $camera_http_options" -i "$input" & 166 | sleep 1 & 167 | sleep_pid=$! 168 | wait ${sleep_pid} 169 | popd > /dev/null 2>&1 170 | } 171 | 172 | # starts up the RasPiCam 173 | function startRaspi { 174 | logger -s "Starting Raspberry Pi camera" 175 | runMjpgStreamer "$MJPGSTREAMER_INPUT_RASPICAM $camera_raspi_options" 176 | } 177 | 178 | # starts up the USB webcam 179 | function startUsb { 180 | options="$usb_options" 181 | device="video0" 182 | 183 | # check for parameter and set the device if it is given as a parameter 184 | input=$1 185 | if [[ -n $input ]]; then 186 | device=`basename "$input"` 187 | fi 188 | 189 | # add video device into options 190 | options="$options -d /dev/$device" 191 | 192 | uevent_file="/sys/class/video4linux/$device/device/uevent" 193 | if [ -e $uevent_file ]; then 194 | # let's see what kind of webcam we have here, fetch vid and pid... 195 | product=`cat $uevent_file | grep PRODUCT | cut -d"=" -f2` 196 | vid=`echo $product | cut -d"/" -f1` 197 | pid=`echo $product | cut -d"/" -f2` 198 | 199 | if [[ -n "$vid" && -n "$pid" ]]; then 200 | vidpid=`printf "%04x:%04x" "0x$vid" "0x$pid"` 201 | 202 | # ... then look if it is in our list of known broken-fps-devices and if so remove 203 | # the -f parameter from the options (if it's in there, else that's just a no-op) 204 | for identifier in ${brokenfps_usb_devices[@]}; 205 | do 206 | if [ "$vidpid" = "$identifier" ]; then 207 | echo 208 | echo "Camera model $vidpid is known to not work with -f parameter, stripping it out" 209 | echo 210 | options=`echo $options | sed -e "s/\(\s\+\|^\)-f\s\+[0-9]\+//g"` 211 | fi 212 | done 213 | fi 214 | fi 215 | 216 | logger -s "Starting USB webcam" 217 | runMjpgStreamer "$MJPGSTREAMER_INPUT_USB $options" 218 | } 219 | 220 | # make sure our cleanup function gets called when we receive SIGINT, SIGTERM 221 | trap "cleanup" SIGINT SIGTERM 222 | # say goodbye when we EXIT 223 | trap "goodbye" EXIT 224 | 225 | # we need this to prevent the later calls to vcgencmd from blocking 226 | # I have no idea why, but that's how it is... 227 | vcgencmd version > /dev/null 2>&1 228 | 229 | # keep mjpg streamer running if some camera is attached 230 | while true; do 231 | 232 | # get list of usb video devices into an array 233 | video_devices=($(find /dev -regextype sed -regex '\/dev/video[0-9]\+' | sort 2> /dev/null)) 234 | 235 | # add list of raspi camera into an array 236 | vcgencmd_regex="supported=1 detected=1.*" 237 | # Example output matching: supported=1 detected=1, libcamera interfaces=0 238 | if [[ "`vcgencmd get_camera`" =~ $vcgencmd_regex ]]; then 239 | video_devices+=( "raspi" ) 240 | fi 241 | 242 | echo "Found video devices:" 243 | printf '%s\n' "${video_devices[@]}" 244 | 245 | for scan_mode in "usb" "usb-auto" "raspi" "auto"; do 246 | camera=$scan_mode 247 | if [[ "usb-auto" == "$scan_mode" ]]; then 248 | camera="usb" 249 | fi 250 | for ((i=0;i<${#array_camera[@]};i++)); do 251 | if [[ -z ${array_camera_device[${i}]} ]] && [[ $camera == ${array_camera[${i}]} ]]; then 252 | camera_config="${array_camera_config[${i}]}" 253 | usb_options="${array_camera_usb_options[${i}]}" 254 | camera_usb_device="${array_camera_usb_device[${i}]}" 255 | camera_raspi_options="${array_camera_raspi_options[${i}]}" 256 | camera_http_webroot="${array_camera_http_webroot[${i}]}" 257 | camera_http_options="${array_camera_http_options[${i}]}" 258 | brokenfps_usb_devices="${array_camera_brokenfps_usb_devices[${i}]}" 259 | 260 | if [[ ${camera_usb_device} ]] && { [[ "usb" == ${scan_mode} ]] || [[ "auto" == ${scan_mode} ]]; }; then 261 | # usb device is explicitly set in options 262 | usb_device_path=`readlink -f ${camera_usb_device}` 263 | if containsString "$usb_device_path" "${array_camera_device[@]}"; then 264 | if [[ "auto" != ${scan_mode} ]]; then 265 | array_camera_device[${i}]="already_in_use" 266 | echo "config file='$camera_config':Video device already in use." 267 | continue 268 | fi 269 | elif containsString "$usb_device_path" "${video_devices[@]}"; then 270 | array_camera_device[${i}]="$usb_device_path" 271 | # explicitly set usb device was found in video_devices array, start usb with the found device 272 | echo "config file='$camera_config':USB device was set in options and found in devices, starting MJPG-streamer with the configured USB video device: $usb_device_path" 273 | startUsb "$usb_device_path" 274 | continue 275 | fi 276 | 277 | elif [[ -z ${camera_usb_device} ]] && { [[ "usb-auto" == ${scan_mode} ]] || [[ "auto" == ${scan_mode} ]]; }; then 278 | for video_device in "${video_devices[@]}"; do 279 | if [[ "raspi" != "$video_device" ]]; then 280 | if containsString "$video_device" "${array_camera_device[@]}"; then 281 | : #already in use 282 | else 283 | array_camera_device[${i}]="$video_device" 284 | # device is not set explicitly in options, start usb with first found usb camera as the device 285 | echo "config file='$camera_config':USB device was not set in options, starting MJPG-streamer with the first found video device: ${video_device}" 286 | startUsb "${video_device}" 287 | break 288 | fi 289 | fi 290 | done 291 | if [[ -n ${array_camera_device[${i}]} ]]; then 292 | continue 293 | fi 294 | fi 295 | 296 | if [[ "raspi" == ${scan_mode} ]] || [[ "auto" == ${scan_mode} ]]; then 297 | video_device="raspi" 298 | if containsString "$video_device" "${array_camera_device[@]}"; then 299 | if [[ "auto" != ${scan_mode} ]]; then 300 | array_camera_device[${i}]="already_in_use" 301 | echo "config file='$camera_config':RasPiCam device already in use." 302 | fi 303 | elif containsString "$video_device" "${video_devices[@]}"; then 304 | array_camera_device[${i}]="$video_device" 305 | echo "config file='$camera_config':Starting MJPG-streamer with video device: ${video_device}" 306 | startRaspi 307 | sleep 30 & 308 | sleep_pid=$! 309 | wait ${sleep_pid} 310 | fi 311 | fi 312 | fi 313 | done 314 | done 315 | 316 | array_assigned_device=( ${array_camera_device[*]} ) 317 | if [[ ${#array_camera[@]} -eq ${#array_assigned_device[@]} ]]; then 318 | echo "Done bringing up all configured video devices" 319 | awaitChildren 320 | 321 | # reset array_camera_device to empty 322 | array_camera_device=() 323 | for cam in ${array_camera[@]}; do 324 | array_camera_device+=("") 325 | done 326 | fi 327 | 328 | echo "Scanning again in two minutes" 329 | sleep 120 330 | done 331 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/etc/haproxy/errors/503-no-octoprint.http: -------------------------------------------------------------------------------- 1 | HTTP/1.0 503 Service Unavailable 2 | Cache-Control: no-cache 3 | Connection: close 4 | Content-Type: text/html 5 | 6 | 7 | 8 | OctoPrint is currently not running 9 | 61 | 62 | 63 |
64 |

The OctoPrint server is currently not running

65 | 66 |

67 | If you just started up your Raspberry Pi, please wait a couple of seconds, then 68 | try to refresh this page. 69 |

70 | 71 |

72 | If the issue persists, please log into your Raspberry Pi via SSH and check the following: 73 |

74 | 75 |
    76 |
  • 77 | Verify that the process is running: 78 | ps -ef | grep -i octoprint | grep -i python should show a 79 | python process: 80 |
    pi@octopi:~ $ ps -ef | grep -i octoprint | grep -i python
    81 | pi 1441 1 6 11:12 ? 00:00:15 /home/pi/oprint/bin/python
    82 | /home/pi/oprint/bin/octoprint --host=127.0.0.1 --port=5000
    83 |
  • 84 |
  • 85 | If it isn't, the question is why. Take a look into 86 | ~/.octoprint/logs/octoprint.log, there might 87 | be an error logged in there that helps to determine 88 | what's wrong. 89 |
  • 90 |
  • 91 | You might also want to try if you can restart the server 92 | (if no obvious error is visible): 93 | sudo service octoprint restart. 94 |
  • 95 |
96 | 97 |

98 | If all that doesn't help to trouble shoot the issue, you can seek 99 | support on the OctoPrint Community Forum. 100 | Please provide your OctoPi and OctoPrint versions as well as your octoprint.log 101 | and explain what you already tried and observed as detailed as possible. 102 |

103 |
104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/etc/haproxy/errors/503-no-webcam-hls.http: -------------------------------------------------------------------------------- 1 | HTTP/1.0 503 Service Unavailable 2 | Cache-Control: no-cache 3 | Connection: close 4 | Content-Type: text/html 5 | 6 | 7 | 8 | HLS Webcam server is currently not running 9 | 61 | 62 | 63 |
64 |

The HLS webcam server is currently not running

65 |
66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/etc/haproxy/errors/503-no-webcam.http: -------------------------------------------------------------------------------- 1 | HTTP/1.0 503 Service Unavailable 2 | Cache-Control: no-cache 3 | Connection: close 4 | Content-Type: text/html 5 | 6 | 7 | 8 | Webcam server is currently not running 9 | 61 | 62 | 63 |
64 |

The webcam server is currently not running

65 | 66 |

67 | If you do not have a camera attached, this is normal and can be safely ignored. 68 |

69 | 70 |

71 | Otherwise, if you just started up your Raspberry Pi or just plugged in your camera, 72 | please wait a couple of seconds. 73 |

74 | 75 |

76 | If the issue persists, please check the following: 77 |

78 | 79 |
    80 |
  • 81 | If you have a Raspberry Pi camera, verify that it is properly attached. The ribbon 82 | cable can be plugged in the wrong way. Power off your Pi first, do not attempt 83 | to attach or detach the Raspberry Pi camera while the Pi is powered! 84 |
  • 85 |
  • 86 | If you have a USB camera, it might be that it does not support MJPG (Motion JPEG) natively and needs the 87 | -y parameter to work. Try editing octopi.txt, 88 | add -y to camera_usb_options and make sure to remove the leading #, e.g.: 89 |
    camera_usb_options="-r 640x480 -f 10 -y"
    90 | Reboot your Raspberry Pi with the camera attached and see if that makes it work.
    91 | Note: If your camera doesn't support MJPG natively, the webcam server will have to use valuable 92 | system resources to transcode the camera stream which could be better used for printing. Consider 93 | getting a camera that does support MJPG natively. 94 |
  • 95 |
  • 96 | Log into your Raspberry Pi via SSH. Check if your camera is detected by the system via lsusb. 97 | If it is check what the webcam server is reporting in /var/log/webcamd.log, there might be an 98 | error logged in there that helps to determine what's wrong. 99 |
  • 100 |
101 | 102 |

103 | If all that doesn't help to trouble shoot the issue, you can seek 104 | support on the OctoPrint Community Forum. 105 | Please provide your camera model, lsusb output and /var/log/webcamd.log and explain what you 106 | already tried and observed as detailed as possible. 107 |

108 |
109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/etc/haproxy/haproxy.1.x.cfg: -------------------------------------------------------------------------------- 1 | global 2 | maxconn 4096 3 | user haproxy 4 | group haproxy 5 | log /dev/log local1 debug 6 | tune.ssl.default-dh-param 2048 7 | 8 | defaults 9 | log global 10 | mode http 11 | compression algo gzip 12 | option httplog 13 | option dontlognull 14 | retries 3 15 | option redispatch 16 | option http-server-close 17 | option forwardfor 18 | maxconn 2000 19 | timeout connect 5s 20 | timeout client 15min 21 | timeout server 15min 22 | 23 | frontend public 24 | bind :::80 v4v6 25 | bind :::443 v4v6 ssl crt /etc/ssl/snakeoil.pem 26 | option forwardfor except 127.0.0.1 27 | use_backend webcam if { path_beg /webcam/ } 28 | use_backend webcam_hls if { path_beg /hls/ } 29 | use_backend webcam_hls if { path_beg /jpeg/ } 30 | default_backend octoprint 31 | 32 | backend octoprint 33 | acl needs_scheme req.hdr_cnt(X-Scheme) eq 0 34 | 35 | reqrep ^([^\ :]*)\ /(.*) \1\ /\2 36 | reqadd X-Scheme:\ https if needs_scheme { ssl_fc } 37 | reqadd X-Scheme:\ http if needs_scheme !{ ssl_fc } 38 | option forwardfor 39 | server octoprint1 127.0.0.1:5000 40 | errorfile 503 /etc/haproxy/errors/503-no-octoprint.http 41 | 42 | backend webcam 43 | reqrep ^([^\ :]*)\ /webcam/(.*) \1\ /\2 44 | server webcam1 127.0.0.1:8080 45 | errorfile 503 /etc/haproxy/errors/503-no-webcam.http 46 | 47 | backend webcam_hls 48 | server webcam_hls_1 127.0.0.1:28126 49 | errorfile 503 /etc/haproxy/errors/503-no-webcam-hls.http 50 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/etc/haproxy/haproxy.2.x.cfg: -------------------------------------------------------------------------------- 1 | global 2 | maxconn 4096 3 | user haproxy 4 | group haproxy 5 | log /dev/log local1 debug 6 | tune.ssl.default-dh-param 2048 7 | 8 | defaults 9 | log global 10 | mode http 11 | compression algo gzip 12 | option httplog 13 | option dontlognull 14 | retries 3 15 | option redispatch 16 | option http-server-close 17 | option forwardfor 18 | maxconn 2000 19 | timeout connect 5s 20 | timeout client 15m 21 | timeout server 15m 22 | 23 | frontend public 24 | bind :::80 v4v6 25 | bind :::443 v4v6 ssl crt /etc/ssl/snakeoil.pem 26 | option forwardfor except 127.0.0.1 27 | use_backend webcam if { path_beg /webcam/ } 28 | use_backend webcam_hls if { path_beg /hls/ } 29 | use_backend webcam_hls if { path_beg /jpeg/ } 30 | default_backend octoprint 31 | 32 | backend octoprint 33 | acl needs_scheme req.hdr_cnt(X-Scheme) eq 0 34 | 35 | http-request replace-path ^([^\ :]*)\ /(.*) \1\ /\2 36 | http-request add-header X-Scheme https if needs_scheme { ssl_fc } 37 | http-request add-header X-Scheme http if needs_scheme !{ ssl_fc } 38 | option forwardfor 39 | server octoprint1 127.0.0.1:5000 40 | errorfile 503 /etc/haproxy/errors/503-no-octoprint.http 41 | 42 | backend webcam 43 | http-request replace-path /webcam/(.*) /\1 44 | server webcam1 127.0.0.1:8080 45 | errorfile 503 /etc/haproxy/errors/503-no-webcam.http 46 | 47 | backend webcam_hls 48 | server webcam_hls_1 127.0.0.1:28126 49 | errorfile 503 /etc/haproxy/errors/503-no-webcam-hls.http 50 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/etc/init.d/change_hostname: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ### BEGIN INIT INFO 3 | # Provides: change_hostname 4 | # Required-Start: $local_fs 5 | # Required-Stop: 6 | # Default-Start: 3 7 | # Default-Stop: 8 | # Short-Description: Change pi's hostname via /boot/octopi-hostname.txt 9 | # Description: 10 | ### END INIT INFO 11 | 12 | . /lib/lsb/init-functions 13 | 14 | BOOT_FOLDER=/boot/firmware 15 | # Fallback for older images 16 | if [ ! -f "${CONFIG_FILE}" ] && [ -f "/boot/octopi.txt" ]; then 17 | BOOT_FOLDER=/boot 18 | fi 19 | 20 | do_start () { 21 | text_file="${BOOT_FOLDER}/octopi-hostname.txt" 22 | if [ ! -f "$text_file" ] 23 | then 24 | exit 0 25 | fi 26 | 27 | old_hostname=`hostname` 28 | new_hostname=`head -n1 "$text_file" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr -d '\n'` 29 | 30 | if [ ! -n "$new_hostname" ] 31 | then 32 | log_failure_msg "No new host name provided, refusing to change to empty host name" 33 | exit 1 34 | fi 35 | 36 | # make sure we do have a valid hostname here (see RFC 952 and 1123, a-zA-Z0-9 only) 37 | sanitized_hostname=`echo "$new_hostname" | tr -cd '[[:alnum:]]-'` 38 | if [ "$new_hostname" = "$sanitized_hostname" ] 39 | then 40 | rm "$text_file" 41 | echo "$new_hostname" > /etc/hostname 42 | sed -i -e "s@$old_hostname@$new_hostname@g" /etc/hosts 43 | 44 | log_success_msg "Change of host name prepared, rebooting to apply..." 45 | /sbin/reboot 46 | else 47 | log_failure_msg "Hostname $new_hostname contains invalid characters (only a-zA-Z0-9 are allowed), refusing to change" 48 | fi 49 | } 50 | 51 | case "$1" in 52 | start|"") 53 | do_start 54 | ;; 55 | restart|reload|force-reload) 56 | echo "Error: argument '$1' not supported" >&2 57 | exit 3 58 | ;; 59 | stop) 60 | # No-op 61 | ;; 62 | *) 63 | echo "Usage: change_hostname [start|stop]" >&2 64 | exit 3 65 | ;; 66 | esac 67 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/etc/init.d/change_password: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ### BEGIN INIT INFO 3 | # Provides: change_password 4 | # Required-Start: $local_fs 5 | # Required-Stop: 6 | # Default-Start: 3 7 | # Default-Stop: 8 | # Short-Description: Change pi's password via /boot/octopi-password.txt 9 | # Description: 10 | ### END INIT INFO 11 | 12 | . /lib/lsb/init-functions 13 | 14 | BOOT_FOLDER=/boot/firmware 15 | # Fallback for older images 16 | if [ ! -f "${CONFIG_FILE}" ] && [ -f "/boot/octopi.txt" ]; then 17 | BOOT_FOLDER=/boot 18 | fi 19 | 20 | do_start () { 21 | text_file="${BOOT_FOLDER}/octopi-password.txt" 22 | if [ ! -f "$text_file" ] 23 | then 24 | exit 0 25 | fi 26 | 27 | new_password=`head -n1 "$text_file" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr -d '\n'` 28 | if [ ! -n "$new_password" ] 29 | then 30 | log_failure_msg "No new password provided, refusing to change to empty password" 31 | exit 1 32 | fi 33 | 34 | (echo "pi:$new_password" | chpasswd && rm "$text_file" && log_success_msg "Password for user pi changed and change file deleted") || log_failure_msg "Could not change password" 35 | } 36 | 37 | case "$1" in 38 | start|"") 39 | do_start 40 | ;; 41 | restart|reload|force-reload) 42 | echo "Error: argument '$1' not supported" >&2 43 | exit 3 44 | ;; 45 | stop) 46 | # No-op 47 | ;; 48 | *) 49 | echo "Usage: change_password [start|stop]" >&2 50 | exit 3 51 | ;; 52 | esac 53 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/etc/logrotate.d/webcamd: -------------------------------------------------------------------------------- 1 | /var/log/webcamd.log 2 | { 3 | rotate 4 4 | weekly 5 | missingok 6 | notifempty 7 | compress 8 | delaycompress 9 | sharedscripts 10 | } 11 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/etc/nginx/sites-available/default: -------------------------------------------------------------------------------- 1 | server { 2 | listen 127.0.0.1:28126; 3 | 4 | root /run/webcam; 5 | 6 | location / { 7 | # First attempt to serve request as file, then 8 | # as directory, then fall back to displaying a 404. 9 | try_files $uri $uri/ =404; 10 | } 11 | } -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=FFMPEG HLS webcam streaming service 3 | ConditionPathExists=/etc/octopi_streamer/hls 4 | 5 | [Service] 6 | User=root 7 | Restart=always 8 | RestartSec=5 9 | WatchdogSec=21600 10 | Nice=10 11 | ExecStartPre=/bin/rm -rf /run/webcam 12 | ExecStartPre=/bin/mkdir -p /run/webcam/hls 13 | ExecStartPre=/bin/mkdir -p /run/webcam/hls/240p 14 | ExecStartPre=/bin/mkdir -p /run/webcam/hls/480p 15 | ExecStartPre=/bin/mkdir -p /run/webcam/jpeg 16 | ExecStartPre=/bin/cp /var/lib/ffmpeg_hls/stream.m3u8 /run/webcam/hls/stream.m3u8 17 | ExecStartPre=/bin/chown -R webcam:webcam /run/webcam 18 | ExecStartPre=/bin/chmod -R 0755 /run/webcam 19 | 20 | ExecStart=/usr/bin/sudo -u webcam \ 21 | /opt/ffmpeg-hls/ffmpeg \ 22 | \ 23 | -framerate 30 -video_size 640x480 \ 24 | -i /dev/video0 \ 25 | -pix_fmt yuv420p \ 26 | \ 27 | -c:v mjpeg -q:v 0 \ 28 | -f image2 -r 1 -update 1 -atomic_writing 1 \ 29 | /run/webcam/jpeg/frame.jpg \ 30 | \ 31 | -c:v h264_v4l2m2m -level:v 4.0 \ 32 | -b:v 1264k -flags +cgop \ 33 | -g 30 -keyint_min 30 \ 34 | \ 35 | -f hls -hls_time 1 \ 36 | -hls_flags delete_segments+program_date_time+temp_file+independent_segments \ 37 | -hls_allow_cache 0 -hls_segment_type fmp4 \ 38 | -hls_list_size 32 -hls_delete_threshold 64 \ 39 | /run/webcam/hls/480p/stream.m3u8 \ 40 | \ 41 | -vf scale=-1:240 \ 42 | \ 43 | -c:v h264_v4l2m2m -level:v 4.0 \ 44 | -b:v 240k -flags +cgop \ 45 | -g 30 -keyint_min 30 \ 46 | \ 47 | -f hls -hls_time 1 \ 48 | -hls_flags delete_segments+program_date_time+temp_file+independent_segments \ 49 | -hls_allow_cache 0 -hls_segment_type fmp4 \ 50 | -hls_list_size 32 -hls_delete_threshold 64 \ 51 | /run/webcam/hls/240p/stream.m3u8 52 | 53 | [Install] 54 | WantedBy=multi-user.target -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/etc/systemd/system/gencert.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Ensure that haproxy certs are generated 3 | 4 | DefaultDependencies=no 5 | 6 | Before=network-pre.target 7 | Wants=network-pre.target 8 | 9 | After=local-fs.target 10 | Wants=local-fs.target 11 | 12 | [Service] 13 | Type=oneshot 14 | ExecStart=/root/bin/gencert 15 | 16 | [Install] 17 | WantedBy=multi-user.target 18 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/etc/systemd/system/octoprint.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=The snappy web interface for your 3D printer 3 | After=network.online.target 4 | Wants=network.online.target 5 | 6 | [Service] 7 | Environment="HOST=127.0.0.1" 8 | Environment="PORT=5000" 9 | Environment="REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt" 10 | Type=simple 11 | User=1000 12 | ExecStart=/opt/octopi/oprint/bin/octoprint serve --host=${HOST} --port=${PORT} 13 | 14 | [Install] 15 | WantedBy=multi-user.target 16 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/etc/systemd/system/streamer_select.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=OctoPi streamer selector 3 | Before=webcamd.service ffmpeg_hls.service nginx.service 4 | 5 | [Service] 6 | Type=oneshot 7 | ExecStart=/root/bin/streamer_select 8 | 9 | [Install] 10 | WantedBy=multi-user.target 11 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/etc/systemd/system/user-fix.service: -------------------------------------------------------------------------------- 1 | # Written by Gina Häußge originally at https://github.com/OctoPrint/OctoPi-UpToDate/blob/e70ccdaf0cd4ef4adfaa3f9b6b288fb6bfda116a/scripts/files/user-fix.service 2 | [Unit] 3 | Description=Ensure that user name changes are applied as needed 4 | 5 | DefaultDependencies=no 6 | 7 | Before=network-pre.target 8 | Wants=network-pre.target 9 | 10 | After=local-fs.target 11 | Wants=local-fs.target 12 | 13 | [Service] 14 | Type=oneshot 15 | ExecStart=/root/bin/user-fix 16 | 17 | [Install] 18 | WantedBy=multi-user.target 19 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/etc/systemd/system/webcamd.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=the OctoPi webcam daemon with the user specified config 3 | ConditionPathExists=/etc/octopi_streamer/mjpeg 4 | 5 | [Service] 6 | WorkingDirectory=/root/bin 7 | StandardOutput=append:/var/log/webcamd.log 8 | StandardError=append:/var/log/webcamd.log 9 | ExecStart=/root/bin/webcamd 10 | Restart=always 11 | Type=simple 12 | RestartSec=1 13 | 14 | [Install] 15 | WantedBy=multi-user.target 16 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/etc/systemd/system/wifi_powersave@.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Set WiFi power save %i 3 | After=sys-subsystem-net-devices-wlan0.device 4 | 5 | [Service] 6 | Type=oneshot 7 | RemainAfterExit=yes 8 | ExecStart=/sbin/iw dev wlan0 set power_save %i 9 | 10 | [Install] 11 | WantedBy=sys-subsystem-net-devices-wlan0.device 12 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/etc/udev/rules.d/95-ads7846.rules: -------------------------------------------------------------------------------- 1 | SUBSYSTEM=="input", KERNEL=="event[0-9]*", ATTRS{name}=="ADS7846*", SYMLINK+="input/touchscreen" 2 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/opt/octopi/scripts/add-octoprint-checkout: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | USER_NAME=$(id -nu 1000)' 3 | OCTOPRINT_FOLDER=/home/"${USER_NAME}"/OctoPrint 4 | OCTOPRINT_CONFIG=/home/"${USER_NAME}"/.octoprint/config.yaml 5 | 6 | if [ "${PWD}" == "${OCTOPRINT_FOLDER}" ]; then 7 | echo "Error: you are in the folder: "${OCTOPRINT_FOLDER} 8 | echo "This is where OctoPrint is going to be checked out, please change to a different folder before running this script" 9 | exit 1 10 | fi 11 | 12 | pause() { 13 | read -n1 -r -p $'Press any key to continue or Ctrl+C to exit...\n' key 14 | } 15 | 16 | echo 17 | echo "This will add a git checkout of OctoPrint to ~/OctoPrint." 18 | echo 19 | echo "This can be helpful if you want to run development branches" 20 | echo "of OctoPrint or do local development yourself." 21 | echo 22 | echo "It is however not needed for OctoPrint's normal operation." 23 | echo 24 | echo "If you do not want to add the git checkout after all, please" 25 | echo "hit Ctrl+C now." 26 | echo 27 | 28 | pause 29 | 30 | echo "--- Adding git checkout" 31 | 32 | rm -r $OCTOPRINT_FOLDER || true 33 | git clone https://github.com/foosel/OctoPrint.git $OCTOPRINT_FOLDER 34 | 35 | echo "--- Configuring checkout folder in OctoPrint's config.yaml" 36 | 37 | echo "plugins: {softwareupdate: {checks: {octoprint: {update_folder: $OCTOPRINT_FOLDER}}}}" | yq m -i $OCTOPRINT_CONFIG - 38 | 39 | echo 40 | echo "--- Done!" 41 | echo 42 | 43 | echo "Your git checkout is now available at ~/OctoPrint. Please note that it" 44 | echo "is currently not installed. If you want to replace the default installation" 45 | echo "of OctoPrint with whatever is currently checked out in your git checkout" 46 | echo "you'll need to do this manually. You'll also need to keep your checkout" 47 | echo "up to date manually if you still have OctoPrint's update mode set to release" 48 | echo "tracking." 49 | echo 50 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/opt/octopi/scripts/install-desktop: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ "$(id -u)" != "0" ] 4 | then 5 | echo "Please run this with sudo or as user root" 2>&1 6 | echo "Since we need to install a couple of packages, sudo" 2>&1 7 | echo "actually IS needed here. Thanks :)" 2>&1 8 | exit 1 9 | fi 10 | 11 | pause() { 12 | read -n1 -r -p $'Press any key to continue or Ctrl+C to exit...\n' key 13 | } 14 | 15 | echo 16 | echo "This will install the desktop environment on your Pi" 17 | echo "Please keep in mind that the desktop environment needs" 18 | echo "system resources that then might not be available for" 19 | echo "printing, possible leading to print artifacts." 20 | echo "It is not recommended to run the desktop environment" 21 | echo "alongside OctoPrint if you do not have a Pi with" 22 | echo "multiple cores (e.g. Pi1 or PiZero). Even then, use" 23 | echo "at your own risk." 24 | echo 25 | echo "If you do not want to install the desktop environment" 26 | echo "after all, please hit Ctrl+C now." 27 | echo 28 | 29 | pause 30 | 31 | echo 32 | echo "The desktop environment can be set up to start" 33 | echo "automatically when the Pi boots." 34 | echo "If you want to have it set up this way, please" 35 | echo "type 'yes' now. Type 'no' if not." 36 | echo -n "Finish with ENTER: " 37 | 38 | read x_on_boot 39 | [ "$x_on_boot" == "yes" ] || x_on_boot="no" 40 | 41 | echo 42 | echo "Going to install the desktop environment (automatic start on boot: $x_on_boot)" 43 | echo 44 | echo "This will take a while, do NOT switch off the Pi or close this console until done!" 45 | echo 46 | 47 | echo 48 | echo "--- Updating our package list" 49 | echo 50 | 51 | apt-get update 52 | 53 | echo 54 | echo "--- Installing desktop packages" 55 | echo 56 | 57 | apt-get install --yes raspberrypi-ui-mods 58 | 59 | if [ "$x_on_boot" == "yes" ] 60 | then 61 | echo 62 | echo "--- Setting up Pi to boot to desktop" 63 | echo 64 | systemctl set-default graphical.target 65 | else 66 | echo 67 | echo "--- Setting up Pi to not boot to desktop" 68 | echo 69 | systemctl set-default multi-user.target 70 | fi 71 | 72 | echo 73 | echo "--- Done!" 74 | echo 75 | 76 | echo "You might want to reboot now: sudo reboot" 77 | echo 78 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/opt/octopi/scripts/safemode: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if grep -q "startOnceInSafeMode" ~/.octoprint/config.yaml; 4 | then 5 | # If found,replace the existing line 6 | sed -i 's/.*startOnceInSafeMode: false.*/\ \ startOnceInSafeMode: true/' ~/.octoprint/config.yaml 7 | else 8 | # Append otherwise 9 | sed -i '/server:/a \ \ startOnceInSafeMode: true' ~/.octoprint/config.yaml 10 | fi 11 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/opt/octopi/scripts/welcome: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | _NAME=$(hostname) 4 | _IP=$(hostname -I) 5 | _OCTOPRINT_VERSION=$(/opt/octopi/oprint/bin/python -c "from octoprint._version import get_versions; print(get_versions()['version'])" || echo "unknown") 6 | _OCTOPI_VERSION=$(cat /etc/octopi_version || echo "unknown") 7 | 8 | echo 9 | echo "------------------------------------------------------------------------------" 10 | echo "Access OctoPrint from a web browser on your network by navigating to any of:" 11 | echo 12 | 13 | for name in $_NAME; 14 | do 15 | echo " http://$name.local" 16 | done 17 | for ip in $_IP; 18 | do 19 | if [[ $ip =~ .*:.* ]] 20 | then 21 | echo " http://[$ip]" 22 | else 23 | echo " http://$ip" 24 | fi 25 | done 26 | 27 | echo 28 | echo "https is also available, with a self-signed certificate." 29 | 30 | if ! which lightdm 2>&1 >/dev/null; 31 | then 32 | echo "------------------------------------------------------------------------------" 33 | echo "This image comes without a desktop environment installed because it's not " 34 | echo "required for running OctoPrint. If you want a desktop environment you can " 35 | echo "install it via" 36 | echo 37 | echo " sudo /opt/octopi/scripts/install-desktop" 38 | fi 39 | 40 | echo "------------------------------------------------------------------------------" 41 | echo "OctoPrint version : $_OCTOPRINT_VERSION" 42 | echo "OctoPi version : $_OCTOPI_VERSION" 43 | echo "------------------------------------------------------------------------------" 44 | echo 45 | -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/usr/lib/systemd/system/nginx.service: -------------------------------------------------------------------------------- 1 | # NGINX service definition based on Debian buster version. 2 | [Unit] 3 | Description=NGINX server for serving HLS and JPEG frames 4 | Documentation=man:nginx(8) 5 | After=network.target nss-lookup.target 6 | ConditionPathExists=/etc/octopi_streamer/hls 7 | 8 | [Service] 9 | Type=forking 10 | PIDFile=/run/nginx.pid 11 | ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;' 12 | ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;' 13 | ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload 14 | ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid 15 | TimeoutStopSec=5 16 | KillMode=mixed 17 | Nice=10 18 | 19 | [Install] 20 | WantedBy=multi-user.target -------------------------------------------------------------------------------- /src/modules/octopi/filesystem/root/var/lib/ffmpeg_hls/stream.m3u8: -------------------------------------------------------------------------------- 1 | #EXTM3U 2 | #EXT-X-VERSION:3 3 | #EXT-X-STREAM-INF:BANDWIDTH=245760,RESOLUTION=320x240 4 | 240p/stream.m3u8 5 | #EXT-X-STREAM-INF:BANDWIDTH=1294336,RESOLUTION=640x480 6 | 480p/stream.m3u8 -------------------------------------------------------------------------------- /src/modules/octopi/start_chroot_script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # OctoPI generation script 3 | # Helper script that runs in a Raspbian chroot to create the OctoPI distro 4 | # Written by Guy Sheffer and Gina Häußge 5 | # GPL V3 6 | ######## 7 | set -x 8 | set -e 9 | 10 | export LC_ALL=C 11 | 12 | source /common.sh 13 | 14 | if [ -n "$OCTOPI_APTMIRROR" ]; 15 | then 16 | echo "Switching apt mirror in /etc/apt/sources.list to $OCTOPI_APTMIRROR" 17 | cp /etc/apt/sources.list /etc/apt/sources.list.backup 18 | sed -i "s@http://raspbian.raspberrypi.org/raspbian/@$OCTOPI_APTMIRROR@g" /etc/apt/sources.list 19 | fi 20 | 21 | WEBCAM_USER=webcam 22 | FFMPEG_HLS_COMMIT=c6fdbe26ef30fff817581e5ed6e078d96111248a 23 | FFMPEG_HLS_DIR=/opt/ffmpeg-hls 24 | 25 | ### Script #### 26 | 27 | unpack /filesystem/home/pi /home/"${BASE_USER}" "${BASE_USER}" 28 | unpack /filesystem/home/root /root root 29 | unpack /filesystem/boot /boot/firmware 30 | 31 | # Not using apt_update_skip, forcing an update here because it does not calculate correctly 32 | apt-get update 33 | # in case we are building from a regular raspbian image instead of the lite one... 34 | remove_extra=$(remove_if_installed scratch squeak-plugins-scratch squeak-vm wolfram-engine python-minecraftpi minecraft-pi sonic-pi oracle-java8-jdk bluej libreoffice-common libreoffice-core freepats greenfoot nodered) 35 | echo "removing:" $remove_extra 36 | apt-get remove -y --purge $remove_extra 37 | apt-get autoremove -y 38 | 39 | apt-get -y --allow-change-held-packages install python3 python3-virtualenv python3-dev git screen subversion cmake cmake-data avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev unzip libopenblas0-pthread libgfortran5 40 | 41 | echo " - Reinstall iputils-ping" 42 | apt-get -y --force-yes install --reinstall iputils-ping 43 | 44 | # Path is hardcoded systemd service, this is not configurable 45 | OCTOPI_OPT_FOLDER=/opt/octopi 46 | mkdir -p "${OCTOPI_OPT_FOLDER}" 47 | chown "${BASE_USER}":"${BASE_USER}" "${OCTOPI_OPT_FOLDER}" 48 | OCTOPI_OCTOPRINT_FOLDER="${OCTOPI_OPT_FOLDER}"/oprint 49 | ln -s "${OCTOPI_OCTOPRINT_FOLDER}" /home/"${BASE_USER}"/oprint 50 | PIP="${OCTOPI_OCTOPRINT_FOLDER}"/bin/pip 51 | pushd "${OCTOPI_OPT_FOLDER}" 52 | 53 | # build virtualenv 54 | sudo -u "${BASE_USER}" python3 -m virtualenv --python=python3 oprint 55 | sudo -u "${BASE_USER}" "${PIP}" install --upgrade pip 56 | 57 | # OctoPrint 58 | if [ "$OCTOPI_INCLUDE_OCTOPRINT" == "yes" ] 59 | then 60 | echo "--- Installing OctoPrint" 61 | PIP_DEFAULT_TIMEOUT=60 sudo -u "${BASE_USER}" "${PIP}" install $OCTOPI_OCTOPRINT_PACKAGE 62 | fi 63 | 64 | #mjpg-streamer 65 | if [ "$OCTOPI_INCLUDE_MJPGSTREAMER" == "yes" ] 66 | then 67 | install_dir=/opt/mjpg-streamer 68 | echo "--- Installing mjpg-streamer to $install_dir" 69 | if [ "${BASE_DISTRO}" == "ubuntu" ]; then 70 | apt-get -y --allow-downgrades --allow-remove-essential --allow-change-held-packages install libjpeg8-dev 71 | else 72 | if [ $( is_in_apt libjpeg62-turbo-dev ) -eq 1 ]; then 73 | apt-get -y --allow-change-held-packages install libjpeg62-turbo-dev 74 | elif [ $( is_in_apt libjpeg8-dev ) -eq 1 ]; then 75 | apt-get -y --allow-change-held-packages install libjpeg8-dev 76 | fi 77 | fi 78 | 79 | apt-get -y --allow-change-held-packages --no-install-recommends install imagemagick ffmpeg libv4l-dev 80 | 81 | wget $OCTOPI_MJPGSTREAMER_ARCHIVE -O mjpg-streamer.zip 82 | unzip mjpg-streamer.zip 83 | rm mjpg-streamer.zip 84 | 85 | pushd mjpg-streamer-master/mjpg-streamer-experimental 86 | # As said in Makefile, it is just a wrapper around CMake. 87 | # To apply -j option, we have to unwrap it. 88 | build_dir=_build 89 | mkdir -p $build_dir 90 | pushd $build_dir 91 | cmake -DCMAKE_BUILD_TYPE=Release .. 92 | popd 93 | 94 | make -j $(nproc) -C $build_dir 95 | 96 | mkdir -p $install_dir 97 | 98 | install -m 755 $build_dir/mjpg_streamer $install_dir 99 | find $build_dir -name "*.so" -type f -exec install -m 644 {} $install_dir \; 100 | 101 | # copy bundled web folder 102 | cp -a -r ./www $install_dir 103 | chmod 755 $install_dir/www 104 | chmod -R 644 $install_dir/www 105 | 106 | # create our custom web folder and add a minimal index.html to it 107 | mkdir $install_dir/www-octopi 108 | pushd $install_dir/www-octopi 109 | cat <> index.html 110 | 111 | mjpg_streamer test page 112 | 113 |

Snapshot

114 |

Refresh the page to refresh the snapshot

115 | Snapshot 116 |

Stream

117 | Stream 118 | 119 | 120 | EOT 121 | popd 122 | popd 123 | rm -rf mjpg-streamer-master 124 | 125 | # symlink for backwards compatibility 126 | sudo -u "${BASE_USER}" ln -s $install_dir /home/"${BASE_USER}"/mjpg-streamer 127 | fi 128 | 129 | # FFMPEG HLS 130 | if [ "$OCTOPI_INCLUDE_FFMPEG_HLS" == "yes" ] 131 | then 132 | apt-get install -y --allow-change-held-packages --no-install-recommends nginx 133 | 134 | ARCH=arm 135 | if [ "${BASE_ARCH}" == "aarch64" ] || [ "${BASE_ARCH}" == "arm64" ]; then 136 | ARCH=aarch64 137 | fi 138 | 139 | FFMPEG_BUILD_DIR=$(mktemp -d) 140 | pushd ${FFMPEG_BUILD_DIR} 141 | FFMPEG_ARCHIVE=ffmpeg.tar.gz 142 | wget https://api.github.com/repos/FFmpeg/FFmpeg/tarball/${FFMPEG_COMMIT} -O ${FFMPEG_ARCHIVE} 143 | tar xvzf ${FFMPEG_ARCHIVE} 144 | cd FFmpeg* 145 | ./configure \ 146 | --arch="${ARCH}" \ 147 | --disable-doc \ 148 | --disable-htmlpages \ 149 | --disable-manpages \ 150 | --disable-podpages \ 151 | --disable-txtpages \ 152 | --disable-ffplay \ 153 | --disable-ffprobe 154 | make -j$(nproc) 155 | mkdir -p ${FFMPEG_HLS_DIR} 156 | copy_and_export ffmpeg-hls-"${ARCH}" ffmpeg "${FFMPEG_HLS_DIR}" 157 | popd 158 | rm -r ${FFMPEG_BUILD_DIR} 159 | 160 | useradd ${WEBCAM_USER} 161 | usermod -aG video ${WEBCAM_USER} 162 | fi 163 | 164 | #CuraEngine 165 | if [ "$OCTOPI_INCLUDE_CURAENGINE" == "yes" ] 166 | then 167 | echo "--- Installing CuraEngine" 168 | folder=CuraEngine-$OCTOPI_CURAENGINE_VERSION 169 | zipfile=$folder.zip 170 | apt-get -y install gcc-4.9 g++-4.9 171 | sudo -u "${BASE_USER}" wget -O$zipfile $OCTOPI_CURAENGINE_ARCHIVE 172 | sudo -u "${BASE_USER}" unzip $zipfile 173 | pushd $folder 174 | sudo -u "${BASE_USER}" make -j$(nproc) CXX=g++-4.9 VERSION=$OCTOPI_CURAENGINE_VERSION 175 | cp build/CuraEngine /usr/local/bin/cura_engine 176 | popd 177 | sudo -u "${BASE_USER}" rm -r $folder $zipfile 178 | fi 179 | 180 | #setup haproxy for http and https, and webcam 181 | if [ "$OCTOPI_INCLUDE_HAPROXY" == "yes" ] 182 | then 183 | echo "--- Installing haproxy" 184 | DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" -y --allow-change-held-packages install ssl-cert haproxy 185 | rm /etc/ssl/private/ssl-cert-snakeoil.key /etc/ssl/certs/ssl-cert-snakeoil.pem 186 | fi 187 | 188 | # fetch current yq build and install to /usr/local/bin 189 | wget -O yq $OCTOPI_YQ_DOWNLOAD && chmod +x yq && mv yq /usr/local/bin 190 | 191 | popd 192 | 193 | #Make sure user pi / ${BASE_USER} has access to serial ports 194 | usermod -a -G tty "${BASE_USER}" 195 | usermod -a -G dialout "${BASE_USER}" 196 | 197 | # If building against Ubuntu, make sure vcgencmd is available and pi has the rights to use it 198 | if [ "${BASE_DISTRO}" == "ubuntu" ]; then 199 | apt-get -y --allow-change-held-packages install libraspberrypi-bin 200 | usermod -a -G video "${BASE_USER}" 201 | fi 202 | 203 | # store octopi commit used to build this image 204 | echo "$OCTOPI_COMMIT" > /etc/octopi_commit 205 | 206 | # Keep legacy compatibility 207 | ln -s /etc/custompios_buildbase /etc/octopi_buildbase 208 | 209 | # allow pi / ${BASE_USER} user to run shutdown and service commands 210 | echo "${BASE_USER} ALL=NOPASSWD: /sbin/shutdown" > /etc/sudoers.d/octoprint-shutdown 211 | echo "${BASE_USER} ALL=NOPASSWD: /usr/sbin/service" > /etc/sudoers.d/octoprint-service 212 | 213 | #make sure users don't run git with sudo, thus breaking permissions, by adding /root/bin to the 214 | #default sudo path and placing a git wrapper script there that checks if it's run as root 215 | sed -i "s@secure_path=\"@secure_path=\"/root/bin:@g" /etc/sudoers 216 | chmod +x /root/bin/git 217 | 218 | # add some "How To" info to boot output 219 | # Note, this code is also in /filesystem/root/opt/octopi/scripts 220 | sed -i 's@exit 0@@' /etc/rc.local 221 | cat <<'EOT' >> /etc/rc.local 222 | 223 | echo 224 | echo "------------------------------------------------------------" 225 | echo 226 | echo "You may now open a web browser on your local network and " 227 | echo "navigate to any of the following addresses to access " 228 | echo "OctoPrint:" 229 | echo 230 | for name in $_NAME; 231 | do 232 | echo " http://$name.local" 233 | done 234 | 235 | for ip in $(hostname -I); 236 | do 237 | echo " http://$ip" 238 | done 239 | 240 | echo 241 | echo "https is also available, with a self-signed certificate." 242 | echo 243 | echo "------------------------------------------------------------" 244 | echo 245 | EOT 246 | 247 | echo 'exit 0' >> /etc/rc.local 248 | 249 | # add a longer welcome text to ~pi/.bashrc / ~${BASE_USER}/.bashrc 250 | echo "source /opt/octopi/scripts/welcome" >> /home/${BASE_USER}/.bashrc 251 | 252 | #unpack root in the end, so etc file are not overwritten, might need to add two roots int he future 253 | unpack /filesystem/root / 254 | 255 | ##################################################################### 256 | ### setup services 257 | 258 | ### Disable GUI at start 259 | systemctl_if_exists disable lightdm.service || true 260 | 261 | update-rc.d change_password defaults 262 | update-rc.d change_hostname defaults 263 | 264 | 265 | ### OctoPrint 266 | 267 | if [ "$OCTOPI_INCLUDE_OCTOPRINT" == "yes" ] 268 | then 269 | systemctl_if_exists enable octoprint.service 270 | else 271 | # let's remove the configs for system services we don't need 272 | rm /etc/systemd/system/octoprint.service 273 | fi 274 | 275 | ### haproxy 276 | 277 | if [ "$OCTOPI_INCLUDE_HAPROXY" == "yes" ] 278 | then 279 | systemctl_if_exists enable gencert.service 280 | 281 | haproxy_version=$(dpkg -s haproxy | grep '^Version:' | awk '{print $2}') 282 | if [[ $haproxy_version = 2.* ]]; then 283 | mv /etc/haproxy/haproxy.2.x.cfg /etc/haproxy/haproxy.cfg 284 | rm /etc/haproxy/haproxy.1.x.cfg 285 | else 286 | mv /etc/haproxy/haproxy.1.x.cfg /etc/haproxy/haproxy.cfg 287 | rm /etc/haproxy/haproxy.2.x.cfg 288 | fi 289 | else 290 | # let's remove the configs for system services we don't need 291 | rm /etc/systemd/system/gencert.service 292 | 293 | # also we need to make OctoPrint bind to all interfaces because otherwise 294 | # it will be unaccessible... 295 | [ -f /etc/systemd/system/octoprint.service ] && sed -i "s@HOST=127.0.0.1@HOST=0.0.0.0@" /etc/systemd/system/octoprint.service 296 | fi 297 | 298 | ### CuraEngine 299 | 300 | if [ ! "$OCTOPI_INCLUDE_CURAENGINE" == "yes" ] 301 | then 302 | # unconfigure the cura engine path in octoprint's config.yaml 303 | sudo -u "${BASE_USER}" sed -i -e "s@cura_engine: /usr/local/bin/cura_engine@cura_engine:@g" /home/"${BASE_USER}"/.octoprint/config.yaml 304 | fi 305 | 306 | ### Streamer select service. 307 | 308 | systemctl_if_exists enable streamer_select.service 309 | 310 | ### mjpg_streamer 311 | 312 | if [ "$OCTOPI_INCLUDE_MJPGSTREAMER" == "yes" ] 313 | then 314 | systemctl_if_exists enable webcamd.service 315 | ### use legacy camera stack on bullseye for now 316 | if grep "camera_auto_detect=1" /boot/config.txt 317 | then 318 | sed -i "s/camera_auto_detect=1/camera_auto_detect=0/g" /boot/config.txt 319 | fi 320 | else 321 | rm /etc/logrotate.d/webcamd 322 | rm /etc/systemd/system/webcamd.service 323 | rm /root/bin/webcamd 324 | fi 325 | 326 | ### HLS streamer 327 | 328 | systemctl_if_exists enable ffmpeg_hls.service 329 | 330 | ### Disable Wifi Power management 331 | 332 | systemctl_if_exists enable wifi_powersave@off.service 333 | 334 | ### Firmare flashing 335 | 336 | echo "--- Installing avrdude" 337 | apt-get -y install avrdude 338 | 339 | ### User-fixing 340 | # Users can change their username easily via the Raspberry Pi imager, which breaks some of OctoPi's scripts 341 | # we need to install virtualenv-tools3, so let's get pip and that 342 | if [ "${BASE_DISTRO}" == "raspbian" ] || [ "${BASE_DISTRO}" == "raspios64" ] || [ "${BASE_DISTRO}" == "raspios" ]; then 343 | apt install -y python3-pip python3-virtualenv 344 | # sudo -u pi pip3 install --user virtualenv-tools3 345 | systemctl_if_exists enable user-fix.service 346 | fi 347 | 348 | 349 | #cleanup 350 | apt-get clean 351 | apt-get autoremove -y 352 | 353 | if [ -n "$OCTOPI_APTMIRROR" ]; 354 | then 355 | echo "Reverting /etc/apt/sources.list" 356 | mv /etc/apt/sources.list.backup /etc/apt/sources.list 357 | fi 358 | -------------------------------------------------------------------------------- /src/nightly_build_scripts/cleanup_storage.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Usage: node cleanup_storage.js [] 3 | * 4 | * action: 5 | * "print" or "delete" 6 | * keyfile: 7 | * The key.json file to use for authentication 8 | * 9 | * Setup: 10 | * npm install pkgcloud 11 | */ 12 | 13 | //~~ setup 14 | 15 | // imports 16 | 17 | var pkgcloud = require('pkgcloud'), 18 | fs = require('fs'), 19 | path = require('path'); 20 | 21 | // polyfills 22 | 23 | if (!String.prototype.startsWith) { 24 | String.prototype.startsWith = function (str) { 25 | return !this.indexOf(str); 26 | } 27 | } 28 | 29 | if (!String.prototype.endsWith) { 30 | String.prototype.endsWith = function(searchString, position) { 31 | var subjectString = this.toString(); 32 | if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) { 33 | position = subjectString.length; 34 | } 35 | position -= searchString.length; 36 | var lastIndex = subjectString.indexOf(searchString, position); 37 | return lastIndex !== -1 && lastIndex === position; 38 | }; 39 | } 40 | 41 | //~~ argument parsing 42 | 43 | // "delete" -> delete, "print" -> only print 44 | if (process.argv.length < 3) { 45 | console.log("Missing mandatory action parameter"); 46 | process.exit(); 47 | } 48 | var action = process.argv[2]; 49 | 50 | // key file to use => ./key.json or second command line argument 51 | var keyfile = path.join(__dirname, 'key.json'); 52 | if (process.argv.length >= 4) { 53 | keyfile = process.argv[3]; 54 | } 55 | 56 | //~~ helpers 57 | 58 | var sortByDate = function(a, b) { 59 | if (a.timeCreated < b.timeCreated) return 1; 60 | if (a.timeCreated > b.timeCreated) return -1; 61 | return 0; 62 | } 63 | 64 | //~~ action and go 65 | 66 | // construct client 67 | var client = require('pkgcloud').storage.createClient({ 68 | provider: 'google', 69 | keyFilename: keyfile, // path to a JSON key file 70 | }); 71 | var container = "octoprint"; 72 | 73 | // fetch our files and render our page 74 | var matchers = [ 75 | { 76 | matcher: function(obj) { return !obj.name.startsWith("stable/") && !obj.name.startsWith("bananapi-m1/") && /octopi-(wheezy|jessie)-/.test(obj.name); }, 77 | limit: 14 78 | }, 79 | { 80 | matcher: function(obj) { return /^bananapi-m1\//.test(obj.name); }, 81 | limit: 14 82 | } 83 | ] 84 | 85 | var now = new Date(); 86 | client.getFiles(container, function (err, files) { 87 | matchers.forEach(function(m) { 88 | var cutoff = new Date(); 89 | cutoff.setDate(now.getDate() - m.limit); 90 | 91 | var filesToDelete = files.filter(m.matcher) 92 | .filter(function(obj) { return new Date(Date.parse(obj.timeCreated)) < cutoff }); 93 | 94 | filesToDelete.forEach(function (file) { 95 | if (action == "delete") { 96 | client.removeFile(container, encodeURIComponent(file.name), function(err) { 97 | if (err) { 98 | console.log("Error deleting " + file.name + ": " + err); 99 | } else { 100 | console.log("Deleted " + file.name + " on " + container); 101 | } 102 | }); 103 | } else { 104 | console.log("Would now delete " + file.name + " on " + container); 105 | } 106 | }); 107 | }); 108 | }); 109 | -------------------------------------------------------------------------------- /src/nightly_build_scripts/generate_nightly_page.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Usage: node generate_nightly_page.js [ [ []]] 3 | * 4 | * keyfile: 5 | * The key.json file to use for authentication 6 | * outputfile: 7 | * The file where to write the output to 8 | * templatefile: 9 | * The HTML template to use, supports the following placeholders: 10 | * - "{{ title }}" - will be replaced with page title 11 | * - "{{ description }}" - will be replaced with page description 12 | * - "{{ content }}" - will be replaced with page content 13 | * 14 | * Setup: 15 | * npm install pkgcloud 16 | * For NodeJS < 0.10 also 17 | * npm install readable-stream 18 | */ 19 | 20 | //~~ setup 21 | 22 | // imports 23 | 24 | var pkgcloud = require('pkgcloud'), 25 | fs = require('fs'), 26 | path = require('path'), 27 | stream = require('stream'), 28 | util = require('util'); 29 | 30 | // polyfills 31 | 32 | if (!String.prototype.startsWith) { 33 | String.prototype.startsWith = function (str) { 34 | return !this.indexOf(str); 35 | } 36 | } 37 | 38 | if (!String.prototype.endsWith) { 39 | String.prototype.endsWith = function(searchString, position) { 40 | var subjectString = this.toString(); 41 | if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) { 42 | position = subjectString.length; 43 | } 44 | position -= searchString.length; 45 | var lastIndex = subjectString.indexOf(searchString, position); 46 | return lastIndex !== -1 && lastIndex === position; 47 | }; 48 | } 49 | 50 | //~~ argument parsing 51 | 52 | // key file to use => ./key.json or first command line argument 53 | var keyfile = path.join(__dirname, 'key.json'); 54 | if (process.argv.length >= 3) { 55 | keyfile = process.argv[2]; 56 | } 57 | 58 | // output file => ./index.html or second command line argument 59 | var outputfile = path.join(__dirname, 'index.html'); 60 | if (process.argv.length >= 4) { 61 | outputfile = process.argv[3]; 62 | } 63 | 64 | // template file ==> ./template.html or third command line argument 65 | var templatefile = path.join(__dirname, 'template.html'); 66 | if (process.argv.length >= 5) { 67 | templatefile = process.argv[4]; 68 | } 69 | 70 | //~~ helpers 71 | 72 | var filterByExtension = function(fileObjs, extensions) { 73 | return fileObjs.filter(function (obj) { 74 | var name = obj.name; 75 | return extensions.some(function (extension) { return name.endsWith(extension); }) 76 | }); 77 | } 78 | 79 | var filterByName = function(fileObjs, name) { 80 | return fileObjs.filter(function (obj) { return obj.name.startsWith(name) }); 81 | } 82 | 83 | var filterNameByRegex = function(fileObjs, regex) { 84 | return fileObjs.filter(function (obj) { return regex.test(obj.name) }); 85 | } 86 | 87 | var stripLeading = function(name, toStrip) { 88 | return name.substring(toStrip.length); 89 | } 90 | 91 | var sortByDate = function(a, b) { 92 | if (a.timeCreated < b.timeCreated) return 1; 93 | if (a.timeCreated > b.timeCreated) return -1; 94 | return 0; 95 | } 96 | 97 | var formatDate = function(date) { 98 | return date.replace(/T/, ' ').replace(/\..+/, '') + " UTC"; 99 | } 100 | 101 | var formatSize = function(bytes) { 102 | // Formats the given file size in bytes 103 | if (!bytes) return "-"; 104 | 105 | var units = ["bytes", "KB", "MB"]; 106 | for (var i = 0; i < units.length; i++) { 107 | if (bytes < 1024) { 108 | return bytes.toFixed(1) + units[i]; 109 | } 110 | bytes /= 1024; 111 | } 112 | return bytes.toFixed(1) + "GB"; 113 | } 114 | 115 | var convertHash = function(hash) { 116 | // Converts a hash from base64 to hex 117 | return new Buffer(hash, 'base64').toString('hex'); 118 | } 119 | 120 | var outputTable = function(fileObjs, s, nameProcessor, limit) { 121 | // Outputs an HTML table to for the provided , limiting them to 122 | // and preprocessing the filename with 123 | 124 | limit = limit || 20; 125 | 126 | s.write('\n'); 127 | s.write('\n'); 128 | 129 | // sort by date and limit 130 | fileObjs.sort(sortByDate).slice(0, limit).forEach(function(fileObj) { 131 | console.log("Processing file object: %j", fileObj); 132 | 133 | var url = "https://storage.googleapis.com/octoprint/" + fileObj.name; 134 | var name = nameProcessor(fileObj.name); 135 | 136 | s.write(''); 137 | s.write('"); 138 | s.write('"); 139 | s.write(""); 140 | s.write(""); 141 | s.write("\n"); 142 | }); 143 | 144 | s.write('
NameCreation DateSizeMD5 Hash
' + name + "' + formatDate(fileObj.timeCreated) + "" + formatSize(fileObj.size) + "" + convertHash(fileObj.md5Hash) + "
\n'); 145 | } 146 | 147 | var outputPage = function(files, s) { 148 | // Outputs the page for to stream , using the template. 149 | var title = "OctoPi Downloads"; 150 | var description = "OctoPi Downloads"; 151 | 152 | var Writable = stream.Writable || require('readable-stream').Writable; 153 | function StringStream(options) { 154 | Writable.call(this, options); 155 | this.buffer = ""; 156 | } 157 | util.inherits(StringStream, Writable); 158 | StringStream.prototype._write = function (chunk, enc, cb) { 159 | this.buffer += chunk; 160 | cb(); 161 | }; 162 | 163 | var output = new StringStream(); 164 | 165 | output.write(""); 166 | 167 | output.write("

Raspberry Pi

\n"); 168 | 169 | output.write("

Stable Builds

\n") 170 | outputTable(filterNameByRegex(files, /^stable\/.*octopi-(wheezy|jessie|stretch|buster)-.*/), 171 | output, 172 | function(name) { return stripLeading(name, "stable/") }, 173 | 3); 174 | 175 | output.write("

Nightly Builds

\n"); 176 | output.write("Warning: These builds are untested and can be unstable and/or broken. If in doubt use a stable build."); 177 | outputTable(filterNameByRegex(files.filter(function (obj) { return !obj.name.startsWith("stable/") && !obj.name.startsWith("bananapi-m1/") }), /octopi-(wheezy|jessie|stretch|buster)-armhf/), 178 | output, 179 | function(name) { return name }, 180 | 14); 181 | 182 | output.write("

64Bit Nightly Builds

\n") 183 | 184 | output.write("

Nightly Builds arm64

\n"); 185 | output.write("Warning: These builds are untested and can be unstable and/or broken."); 186 | outputTable(filterNameByRegex(files.filter(function (obj) { return !obj.name.startsWith("stable/") && !obj.name.startsWith("bananapi-m1/") }), /octopi-(wheezy|jessie|stretch|buster)-arm64/), 187 | output, 188 | function(name) { return name }, 189 | 14); 190 | 191 | var content = output.buffer; 192 | fs.readFile(templatefile, "utf8", function (err, template) { 193 | var result = template.replace(/{{ content }}/g, content) 194 | .replace(/{{ title }}/g, title) 195 | .replace(/{{ description }}/g, description); 196 | s.write(result); 197 | }) 198 | 199 | } 200 | 201 | //~~ action and go 202 | 203 | // construct client 204 | var client = require('pkgcloud').storage.createClient({ 205 | provider: 'google', 206 | keyFilename: keyfile, // path to a JSON key file 207 | }); 208 | var container = "octoprint"; 209 | 210 | // fetch our files and render our page 211 | client.getFiles(container, function (err, files) { 212 | var stream = fs.createWriteStream(outputfile); 213 | outputPage(filterByExtension(files, [".zip"]), stream); 214 | }); 215 | 216 | -------------------------------------------------------------------------------- /src/nightly_build_scripts/template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | {{ title }} 10 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 46 | 47 | 48 | 49 | 50 | 51 | 52 |
53 |
54 | 63 |
64 |
65 |
66 | {{ content }} 67 |
68 |
69 |
70 |
71 |
72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/nightly_build_scripts/update_git_mirrors: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | MIRROR_LOCATION=/var/www/git 3 | mkdir $MIRROR_LOCATION 4 | pushd MIRROR_LOCATION 5 | for repo in `ls` 6 | do 7 | pushd $repo 8 | git fetch --prune 9 | git update-server-info 10 | popd 11 | done 12 | popd 13 | -------------------------------------------------------------------------------- /src/vagrant/Vagrantfile: -------------------------------------------------------------------------------- 1 | vagrant_root = File.dirname(__FILE__) 2 | Vagrant.configure("2") do |o| 3 | # o.vm.box = "octopi-build" 4 | o.vm.box= "debian/buster64" 5 | o.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" 6 | o.vm.synced_folder File.read("../custompios_path").gsub("\n",""), "/CustomPiOS", create:true, type: "nfs" 7 | o.vm.synced_folder "../", "/distro", create:true, type: "nfs" 8 | o.vm.network :private_network, ip: "192.168.55.55" 9 | o.vm.provision :shell, :path => "setup.sh", args: ENV['SHELL_ARGS'] 10 | 11 | #o.vbguest.auto_update = false 12 | 13 | o.vm.provider "virtualbox" do |v| 14 | v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] 15 | v.customize ["modifyvm", :id, "--natdnsproxy1", "on"] 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /src/vagrant/run_vagrant_build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | sudo vagrant ssh -- -t "sudo /CustomPiOS/nightly_build_scripts/custompios_nightly_build $@" 3 | 4 | -------------------------------------------------------------------------------- /src/vagrant/setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | sudo apt-get update 3 | sudo apt-get install -y gawk util-linux realpath git qemu-user-static p7zip-full unzip zip 4 | 5 | -------------------------------------------------------------------------------- /src/variants/rpios_arm64/config: -------------------------------------------------------------------------------- 1 | export BASE_ARCH=aarch64 2 | export BASE_DISTRO=raspios64 3 | export BASE_IMAGE_PATH=${DIST_PATH}/image-rpios_arm64 4 | # export BASE_ZIP_IMG=`ls -t $BASE_IMAGE_PATH/*-{ubuntu}-*-arm64-*.xz | head -n 1` 5 | export BASE_IGNORE_VARIANT_NAME=yes 6 | export BASE_USER=pi 7 | export BASE_USER_PASSWORD=raspberry 8 | export RPI_IMAGER_NAME="${DIST_NAME} version ${DIST_VERSION} 64-bit" 9 | -------------------------------------------------------------------------------- /src/variants/rpios_arm64/filesystem/root/etc/haproxy/haproxy.cfg: -------------------------------------------------------------------------------- 1 | global 2 | maxconn 4096 3 | user haproxy 4 | group haproxy 5 | log /dev/log local1 debug 6 | tune.ssl.default-dh-param 2048 7 | 8 | defaults 9 | log global 10 | mode http 11 | compression algo gzip 12 | option httplog 13 | option dontlognull 14 | retries 3 15 | option redispatch 16 | option http-server-close 17 | option forwardfor 18 | maxconn 2000 19 | timeout connect 5s 20 | timeout client 15min 21 | timeout server 15min 22 | 23 | frontend public 24 | bind :::80 v4v6 25 | bind :::443 v4v6 ssl crt /etc/ssl/snakeoil.pem 26 | option forwardfor except 127.0.0.1 27 | use_backend webcam if { path_beg /webcam/ } 28 | use_backend webcam_hls if { path_beg /hls/ } 29 | use_backend webcam_hls if { path_beg /jpeg/ } 30 | default_backend octoprint 31 | 32 | backend octoprint 33 | acl needs_scheme req.hdr_cnt(X-Scheme) eq 0 34 | 35 | http-request replace-path ^([^\ :]*)\ /(.*) \1\ /\2 36 | http-request add-header X-Scheme https if needs_scheme { ssl_fc } 37 | http-request add-header X-Scheme http if needs_scheme !{ ssl_fc } 38 | option forwardfor 39 | server octoprint1 127.0.0.1:5000 40 | errorfile 503 /etc/haproxy/errors/503-no-octoprint.http 41 | 42 | backend webcam 43 | http-request replace-path /webcam/(.*) /\1 44 | server webcam1 127.0.0.1:8080 45 | errorfile 503 /etc/haproxy/errors/503-no-webcam.http 46 | 47 | backend webcam_hls 48 | server webcam_hls_1 127.0.0.1:28126 49 | errorfile 503 /etc/haproxy/errors/503-no-webcam-hls.http 50 | -------------------------------------------------------------------------------- /src/variants/rpios_arm64/filesystem/root/etc/systemd/system/webcamd.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=the OctoPi webcam daemon with the user specified config 3 | # ConditionPathExists=/etc/octopi_streamer/mjpeg 4 | 5 | [Service] 6 | WorkingDirectory=/root/bin 7 | StandardOutput=append:/var/log/webcamd.log 8 | StandardError=append:/var/log/webcamd.log 9 | ExecStart=/root/bin/webcamd 10 | Restart=always 11 | Type=simple 12 | RestartSec=1 13 | 14 | [Install] 15 | WantedBy=multi-user.target 16 | -------------------------------------------------------------------------------- /src/variants/rpios_arm64/post_chroot_script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -x 3 | set -e 4 | 5 | export LC_ALL=C 6 | 7 | source /common.sh 8 | install_cleanup_trap 9 | 10 | # Unpack the filesystem changes for the variant 11 | unpack /filesystem/root / 12 | 13 | # add-apt-repository ppa:ubuntu-raspi2/ppa -y 14 | apt-get update 15 | apt-get -y --force-yes install libraspberrypi-bin rpi.gpio-common 16 | apt-get clean 17 | apt-get autoremove -y 18 | -------------------------------------------------------------------------------- /src/variants/ubuntu_arm64/config: -------------------------------------------------------------------------------- 1 | export BASE_ARCH=aarch64 2 | export BASE_DISTRO=ubuntu 3 | 4 | export BASE_IMAGE_PATH=${DIST_PATH}/image-ubuntu_arm64 5 | export BASE_ZIP_IMG=`ls -t $BASE_IMAGE_PATH/*-{ubuntu}-*-arm64-*.xz | head -n 1` 6 | export BASE_IGNORE_VARIANT_NAME=yes 7 | export BASE_USER=pi 8 | export BASE_USER_PASSWORD=raspberry 9 | export RPI_IMAGER_NAME="${DIST_NAME} version ${DIST_VERSION} 64bit" 10 | 11 | -------------------------------------------------------------------------------- /src/variants/ubuntu_arm64/filesystem/root/etc/haproxy/haproxy.cfg: -------------------------------------------------------------------------------- 1 | global 2 | maxconn 4096 3 | user haproxy 4 | group haproxy 5 | log /dev/log local1 debug 6 | tune.ssl.default-dh-param 2048 7 | 8 | defaults 9 | log global 10 | mode http 11 | compression algo gzip 12 | option httplog 13 | option dontlognull 14 | retries 3 15 | option redispatch 16 | option http-server-close 17 | option forwardfor 18 | maxconn 2000 19 | timeout connect 5s 20 | timeout client 15min 21 | timeout server 15min 22 | 23 | frontend public 24 | bind :::80 v4v6 25 | bind :::443 v4v6 ssl crt /etc/ssl/snakeoil.pem 26 | option forwardfor except 127.0.0.1 27 | use_backend webcam if { path_beg /webcam/ } 28 | use_backend webcam_hls if { path_beg /hls/ } 29 | use_backend webcam_hls if { path_beg /jpeg/ } 30 | default_backend octoprint 31 | 32 | backend octoprint 33 | acl needs_scheme req.hdr_cnt(X-Scheme) eq 0 34 | 35 | http-request replace-path ^([^\ :]*)\ /(.*) \1\ /\2 36 | http-request add-header X-Scheme https if needs_scheme { ssl_fc } 37 | http-request add-header X-Scheme http if needs_scheme !{ ssl_fc } 38 | option forwardfor 39 | server octoprint1 127.0.0.1:5000 40 | errorfile 503 /etc/haproxy/errors/503-no-octoprint.http 41 | 42 | backend webcam 43 | http-request replace-path /webcam/(.*) /\1 44 | server webcam1 127.0.0.1:8080 45 | errorfile 503 /etc/haproxy/errors/503-no-webcam.http 46 | 47 | backend webcam_hls 48 | server webcam_hls_1 127.0.0.1:28126 49 | errorfile 503 /etc/haproxy/errors/503-no-webcam-hls.http 50 | -------------------------------------------------------------------------------- /src/variants/ubuntu_arm64/filesystem/root/etc/systemd/system/webcamd.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=the OctoPi webcam daemon with the user specified config 3 | # ConditionPathExists=/etc/octopi_streamer/mjpeg 4 | 5 | [Service] 6 | WorkingDirectory=/root/bin 7 | StandardOutput=append:/var/log/webcamd.log 8 | StandardError=append:/var/log/webcamd.log 9 | ExecStart=/root/bin/webcamd 10 | Restart=always 11 | Type=simple 12 | RestartSec=1 13 | 14 | [Install] 15 | WantedBy=multi-user.target 16 | -------------------------------------------------------------------------------- /src/variants/ubuntu_arm64/post_chroot_script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -x 3 | set -e 4 | 5 | export LC_ALL=C 6 | 7 | source /common.sh 8 | install_cleanup_trap 9 | 10 | # Unpack the filesystem changes for the variant 11 | unpack /filesystem/root / 12 | 13 | # add-apt-repository ppa:ubuntu-raspi2/ppa -y 14 | apt-get update 15 | apt-get -y --force-yes install libraspberrypi-bin rpi.gpio-common 16 | apt-get clean 17 | apt-get autoremove -y 18 | --------------------------------------------------------------------------------