├── .editorconfig ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── config.yml │ └── feature_request.yml ├── sdcard-logo.png └── workflows │ ├── BuildImages.yml │ ├── ReleaseRaspiOS.yml │ ├── ShellCheck.yml │ └── stale.yml ├── .gitignore ├── LICENSE ├── README.md ├── config ├── armbian │ └── default ├── default └── raspberry │ ├── default │ ├── rpi32 │ └── rpi64 └── src ├── build_dist ├── image └── README ├── modules ├── armbian │ ├── config │ ├── end_chroot_script │ ├── filesystem │ │ └── root │ │ │ └── etc │ │ │ └── update-motd.d │ │ │ └── 10-mainsailos │ └── start_chroot_script ├── crowsnest │ ├── config │ └── start_chroot_script ├── is_req_preinstall │ ├── config │ └── start_chroot_script ├── klipper │ ├── config │ ├── filesystem │ │ └── root │ │ │ └── etc │ │ │ └── systemd │ │ │ └── system │ │ │ └── klipper.service │ └── start_chroot_script ├── mainsail │ ├── config │ ├── filesystem │ │ ├── home │ │ │ └── pi │ │ │ │ └── klipper_config │ │ │ │ └── mainsail.cfg │ │ └── root │ │ │ └── etc │ │ │ ├── logrotate.d │ │ │ └── rsyslog │ │ │ └── nginx │ │ │ ├── conf.d │ │ │ ├── common_vars.conf │ │ │ └── upstreams.conf │ │ │ └── sites-available │ │ │ └── mainsail │ └── start_chroot_script ├── mainsailos │ ├── config │ └── start_chroot_script ├── moonraker │ ├── config │ ├── filesystem │ │ └── home │ │ │ └── pi │ │ │ └── klipper_config │ │ │ └── moonraker.conf │ └── start_chroot_script ├── net │ ├── config │ ├── filesystem │ │ ├── boot │ │ │ ├── WiFi-README.txt │ │ │ └── wpa_supplicant.conf.example │ │ ├── etc │ │ │ ├── systemd │ │ │ │ └── system │ │ │ │ │ └── disable-wifi-pwr-mgmt.service │ │ │ └── udev │ │ │ │ └── rules.d │ │ │ │ └── 070-wifi-powersave.rules │ │ └── usr │ │ │ └── local │ │ │ └── bin │ │ │ ├── pwrsave │ │ │ └── pwrsave-udev │ └── start_chroot_script ├── piconfig │ ├── config │ ├── filesystem │ │ └── root │ │ │ ├── boot │ │ │ └── config.txt │ │ │ └── etc │ │ │ └── dphys-swapfile │ └── start_chroot_script ├── postrename │ ├── config │ ├── filesystem │ │ └── root │ │ │ └── postrename │ └── start_chroot_script ├── sonar │ ├── config │ └── start_chroot_script └── timelapse │ ├── config │ ├── filesystem │ └── home │ │ └── pi │ │ └── klipper_config │ │ └── timelapse_template.txt │ └── start_chroot_script └── version /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | [*] 7 | indent_style = space 8 | indent_size = 4 9 | end_of_line = lf 10 | charset = utf-8 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | 14 | [Makefile] 15 | indent_style = tab 16 | 17 | [*.{yml, yaml}] 18 | indent_style = space 19 | indent_size = 2 20 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # Funding 2 | patreon: meteyou 3 | ko_fi: mainsail 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug report 2 | description: Create a report to help us improve 3 | labels: ["bug", "triage"] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | This issue form is for reporting bugs only! 9 | If you have a feature request, please use [feature_request](/new?template=feature_request.yml) 10 | - type: textarea 11 | id: what-happened 12 | attributes: 13 | label: What happened 14 | description: >- 15 | A clear and concise description of what the bug is. 16 | validations: 17 | required: true 18 | - type: textarea 19 | id: expected-behavior 20 | attributes: 21 | label: What did you expect to happen 22 | description: >- 23 | A clear and concise description of what you expected to happen. 24 | validations: 25 | required: true 26 | - type: textarea 27 | id: repro-steps 28 | attributes: 29 | label: How to reproduce 30 | description: >- 31 | Minimal and precise steps to reproduce this bug. 32 | validations: 33 | required: true 34 | - type: textarea 35 | id: additional-info 36 | attributes: 37 | label: Additional information 38 | description: | 39 | If you have any additional information for us, use the field below. 40 | 41 | Please note, you can attach logs, screenshots or screen recordings here, by 42 | dragging and dropping files in the field below. -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Mainsail Discord 4 | url: https://discord.gg/skWTwTD 5 | about: Quickest way to get in contact 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: Feature request 2 | description: Suggest an idea for this project 3 | labels: ["feature request"] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | This issue form is for feature requests only! 9 | If you've found a bug, please use [bug_report](/new?template=bug_report.yml) 10 | - type: textarea 11 | id: problem-description 12 | attributes: 13 | label: Is your feature request related to a problem? Please describe 14 | description: >- 15 | A clear and concise description of what the problem is. 16 | validations: 17 | required: true 18 | - type: textarea 19 | id: solution-description 20 | attributes: 21 | label: Describe the solution you'd like 22 | description: >- 23 | A clear and concise description of what you want to happen. 24 | validations: 25 | required: true 26 | - type: textarea 27 | id: possible-alternatives 28 | attributes: 29 | label: Describe alternatives you've considered 30 | description: >- 31 | A clear and concise description of any alternative solutions or features you've considered. 32 | - type: textarea 33 | id: additional-info 34 | attributes: 35 | label: Additional information 36 | description: | 37 | If you have any additional information for us, use the field below. 38 | 39 | Please note, you can attach logs, screenshots or screen recordings here, by 40 | dragging and dropping files in the field below. 41 | -------------------------------------------------------------------------------- /.github/sdcard-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigtreetech/MainsailOS/d24546513880743df766b1e1814a095b2760a281/.github/sdcard-logo.png -------------------------------------------------------------------------------- /.github/workflows/BuildImages.yml: -------------------------------------------------------------------------------- 1 | name: Build MainsailOS 2 | on: 3 | push: 4 | branches: 5 | - "master" 6 | - "develop" 7 | paths: 8 | - "src/**" 9 | - "config/**" 10 | - ".github/workflows/BuildImages.yml" 11 | tags-ignore: 12 | - "**" 13 | pull_request: 14 | types: [opened, edited, reopened, synchronize] 15 | paths: 16 | - "src/**" 17 | - "config/**" 18 | - ".github/workflows/BuildImages.yml" 19 | 20 | workflow_dispatch: 21 | 22 | # Allow to stop obsolete workflows 23 | concurrency: 24 | group: ci-buildtrain-${{ github.ref }}-1 25 | cancel-in-progress: true 26 | 27 | jobs: 28 | setup: 29 | runs-on: ubuntu-latest 30 | outputs: 31 | matrix: ${{ steps.set-matrix.outputs.matrix }} 32 | steps: 33 | - name: Checkout repository 34 | uses: actions/checkout@v3 35 | 36 | - name: Create Matrix 37 | id: set-matrix 38 | run: | 39 | ARRAY=$(find ${{ github.workspace }}/config -type f -printf '%P\n' | sed '/default/d' | sort | jq -R -s -c 'split("\n")[:-1]') 40 | echo "::set-output name=matrix::${ARRAY}" 41 | 42 | build: 43 | needs: setup 44 | runs-on: ubuntu-latest 45 | strategy: 46 | fail-fast: false 47 | matrix: 48 | config: ${{ fromJson(needs.setup.outputs.matrix) }} 49 | steps: 50 | - name: Build image 51 | id: build 52 | uses: mainsail-crew/MainsailOS-actions/build-image@master 53 | with: 54 | config: ${{ matrix.config }} 55 | github-token: ${{ secrets.GITHUB_TOKEN }} 56 | 57 | - name: Copy output 58 | id: copy-image 59 | if: always() 60 | shell: bash 61 | run: | 62 | source repository/src/config 63 | NOW="$(date +"%Y-%m-%d")" 64 | IMAGE="${NOW}-${DIST_NAME}-${DIST_VERSION}-${{ steps.build.outputs.type }}-${{ steps.build.outputs.sbc }}" 65 | 66 | cp repository/src/workspace/*.img $IMAGE.img 67 | 68 | echo "::set-output name=image::$IMAGE" 69 | 70 | - name: Upload failed Logfile 71 | if: failure() 72 | uses: actions/upload-artifact@v3 73 | with: 74 | name: failed-${{ steps.copy-image.outputs.image }}.log 75 | path: repository/src/build.log 76 | 77 | - name: Compressing Image 78 | shell: bash 79 | run: | 80 | CPU_COUNT="$(nproc)" 81 | echo -e "\e[32mUsing ${CPU_COUNT} Cores for compression...\e[0m" 82 | xz -efkvz9T"${CPU_COUNT}" ${{ steps.copy-image.outputs.image }}.img 83 | 84 | - name: Calculating checksums 85 | shell: bash 86 | run: | 87 | sha256sum ${{ steps.copy-image.outputs.image }}.img > ${{ steps.copy-image.outputs.image }}.img.sha256 88 | sha256sum ${{ steps.copy-image.outputs.image }}.img.xz > ${{ steps.copy-image.outputs.image }}.img.xz.sha256 89 | 90 | - name: Upload Compressed Image 91 | uses: actions/upload-artifact@v3 92 | with: 93 | name: ${{ steps.copy-image.outputs.image }}.img.xz 94 | path: ${{ steps.copy-image.outputs.image }}.img.xz 95 | 96 | - name: Upload Compressed Image Checksum 97 | uses: actions/upload-artifact@v3 98 | with: 99 | name: ${{ steps.copy-image.outputs.image }}.img.xz.sha256 100 | path: ${{ steps.copy-image.outputs.image }}.img.xz.sha256 101 | 102 | - name: Upload Image Checksum 103 | uses: actions/upload-artifact@v3 104 | with: 105 | name: ${{ steps.copy-image.outputs.image }}.img.sha256 106 | path: ${{ steps.copy-image.outputs.image }}.img.sha256 107 | -------------------------------------------------------------------------------- /.github/workflows/ReleaseRaspiOS.yml: -------------------------------------------------------------------------------- 1 | name: Build and Release MainsailOS - Raspberry Pi OS buster 2 | on: 3 | release: 4 | types: [ published ] 5 | 6 | env: 7 | DOWNLOAD_URL_CHECKSUM: "https://downloads.raspberrypi.org/raspios_lite_armhf_latest.sha256" 8 | DOWNLOAD_URL_IMAGE: "https://downloads.raspberrypi.org/raspios_lite_armhf_latest.torrent" 9 | FILENAME_CHECKSUM: "raspios_lite_armhf_latest.sha256" 10 | 11 | jobs: 12 | raspiosbuild: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: Install Dependencies 17 | run: sudo apt update; sudo apt install --yes coreutils p7zip-full qemu-user-static zip 18 | 19 | - name: Checkout CustomPiOS 20 | uses: actions/checkout@v2 21 | with: 22 | repository: "guysoft/CustomPiOS" 23 | path: CustomPiOS 24 | 25 | - name: Checkout MainsailOS Project 26 | uses: actions/checkout@v2 27 | with: 28 | repository: ${{ github.repository }} 29 | path: repository 30 | submodules: true 31 | 32 | - name: Raspberry Pi OS Checksum 33 | id: raspios-checksum 34 | run: | 35 | cd repository/src/image 36 | wget -O $FILENAME_CHECKSUM $DOWNLOAD_URL_CHECKSUM 37 | FILE_CONTENT=$(head -n 1 $FILENAME_CHECKSUM) 38 | CHECKSUM=$(echo $FILE_CONTENT | cut -d' ' -f1) 39 | echo "::set-output name=CHECKSUM::$CHECKSUM" 40 | 41 | - name: Cache Raspberry Pi OS Source Image 42 | id: cache-source-image 43 | uses: actions/cache@v3 44 | with: 45 | path: repository/src/image/*.img.xz 46 | key: ${{ runner.os }}-${{ steps.raspios-checksum.outputs.CHECKSUM }} 47 | 48 | - name: Download Raspberry Pi OS Source Image 49 | if: steps.cache-source-image.outputs.cache-hit != 'true' 50 | run: aria2c -d repository/src/image --seed-time=0 $DOWNLOAD_URL_IMAGE 51 | 52 | - name: Comparing Checksums 53 | run: | 54 | cd repository/src/image 55 | cat $FILENAME_CHECKSUM | awk '{print $1" "$2}' | sha256sum -c 56 | 57 | - name: Update CustomPiOS Paths 58 | run: cd repository/src && ../../CustomPiOS/src/update-custompios-paths 59 | 60 | - name: Build Image 61 | run: sudo modprobe loop && cd repository/src && sudo bash -x ./build_dist 62 | 63 | - name: Copy output image 64 | run: cp ${{ github.workspace }}/repository/src/workspace/*-raspios-*-lite.img MainsailOS-buster-lite-${{ github.event.release.tag_name }}.img 65 | 66 | - name: Compress the image 67 | run: zip MainsailOS-buster-lite-${{ github.event.release.tag_name }}.zip MainsailOS-buster-lite-${{ github.event.release.tag_name }}.img 68 | 69 | - name: Generate sha256 Checksum 70 | run: sha256sum MainsailOS-buster-lite-${{ github.event.release.tag_name }}.zip > MainsailOS-buster-lite-${{ github.event.release.tag_name }}.zip.sha256 71 | 72 | - uses: actions/upload-artifact@v2 73 | with: 74 | name: MainsailOS-buster-lite-${{ github.event.release.tag_name }}.zip 75 | path: MainsailOS-buster-lite-${{ github.event.release.tag_name }}.zip 76 | 77 | - name: Upload MainsailOS (Raspios buster based) Asset 78 | uses: actions/upload-release-asset@v1 79 | env: 80 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 81 | with: 82 | upload_url: ${{ github.event.release.upload_url }} 83 | asset_path: MainsailOS-buster-lite-${{ github.event.release.tag_name }}.zip 84 | asset_name: MainsailOS-buster-lite-${{ github.event.release.tag_name }}.zip 85 | asset_content_type: application/zip 86 | 87 | - name: Upload MainsailOS sha256 Checksum Asset 88 | uses: actions/upload-release-asset@v1 89 | env: 90 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 91 | with: 92 | upload_url: ${{ github.event.release.upload_url }} 93 | asset_path: MainsailOS-buster-lite-${{ github.event.release.tag_name }}.zip.sha256 94 | asset_name: MainsailOS-buster-lite-${{ github.event.release.tag_name }}.zip.sha256 95 | asset_content_type: text/plain 96 | -------------------------------------------------------------------------------- /.github/workflows/ShellCheck.yml: -------------------------------------------------------------------------------- 1 | name: "Linter: shellcheck" 2 | on: 3 | push: 4 | branches: 5 | - "**" 6 | paths: 7 | - "config/**" 8 | - "src/**" 9 | - "!src/version" 10 | 11 | pull_request: 12 | types: [opened, edited, reopened, synchronize] 13 | branches: 14 | - "**" 15 | paths: 16 | - "config/**" 17 | - "src/**" 18 | - "!src/version" 19 | 20 | jobs: 21 | shellcheck: 22 | name: Shellcheck 23 | runs-on: ubuntu-latest 24 | strategy: 25 | matrix: 26 | scripts: ["./config", "./src"] 27 | steps: 28 | - name: Fetch Repository 29 | uses: actions/checkout@v3 30 | 31 | - name: Run ShellCheck 32 | uses: ludeeus/action-shellcheck@master 33 | env: 34 | SHELLCHECK_OPTS: -ax -s bash 35 | with: 36 | scandir: ${{ matrix.scripts }} 37 | ignore_paths: ./version ./image/ 38 | format: gcc 39 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: 'Close stale issues or PRs' 2 | 3 | # Both `issue_comment` and `scheduled` event types are required for this Action 4 | # to work properly. 5 | on: 6 | issue_comment: 7 | types: [created] 8 | schedule: 9 | - cron: '30 1 * * *' 10 | 11 | permissions: 12 | issues: write 13 | pull-requests: write 14 | 15 | jobs: 16 | stale: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/stale@v5 20 | with: 21 | days-before-stale: 14 22 | days-before-close: 7 23 | exempt-all-milestones: true 24 | close-issue-reason: not_planned 25 | only-labels: '❔ User Input' 26 | labels-to-remove-when-unstale: '❔ User Input,💤 Stale' 27 | stale-issue-label: '💤 Stale' 28 | stale-pr-label: '💤 Stale' 29 | stale-issue-message: | 30 | Ahoi! 31 | It looks like there hasn't been any recent updates on 32 | this issue. If you created this issue and no longer 33 | consider it to get merged, then please login to github 34 | and close it. Otherwise, if there is no further activity 35 | on this issue, it will be automatically closedwithin the 36 | next 7 days. 37 | Fair wind and a following sea! 38 | ~ Your friendly MainsailGithubBot 39 | *PS: I'm just an automated script, not a real sailor.* 40 | stale-pr-message: | 41 | Ahoi! 42 | It looks like there hasn't been any recent updates on 43 | this pull request. If you created this pull request and 44 | no longer consider it to get merged, then please login 45 | to github and close it. Otherwise, if there is no further 46 | activity on this pull request, it will be automatically 47 | closed within the next 7 days. 48 | Fair wind and a following sea! 49 | ~ Your friendly MainsailGithubBot 50 | *PS: I'm just an automated script, not a real sailor.* 51 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore workspace 2 | src/workspace 3 | 4 | # Ignore src/image 5 | src/image/** 6 | 7 | # Ignore build.log 8 | src/build.log 9 | -------------------------------------------------------------------------------- /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.md: -------------------------------------------------------------------------------- 1 | ![downloads](https://img.shields.io/github/downloads/mainsail-crew/MainsailOS/total) 2 | [![discord](https://img.shields.io/discord/758059413700345988?color=%235865F2&label=discord&logo=discord&logoColor=white&style=flat)](https://discord.gg/mainsail) 3 | 4 |

5 | 6 |

7 | 8 | # MainsailOS 9 | 10 | A [Raspberry Pi OS](https://www.raspberrypi.org/software/) based distribution for 3D Printers. \ 11 | It includes everything to get started with Klipper Firmware and Mainsail. 12 | 13 | Learn more about: 14 | 15 | - [Klipper Firmware](https://www.klipper3d.org/) 16 | - [Moonraker](https://moonraker.readthedocs.io/en/latest/) 17 | - [Mainsail](https://docs.mainsail.xyz/) 18 | 19 | ## How to install MainsailOS ? 20 | 21 | You can find detailed instructions in our [documentation](https://docs.mainsail.xyz/setup/mainsail-os). 22 | 23 | We recommend the installation via [Raspberry Pi Imager](https://docs.mainsail.xyz/setup/mainsailos/pi-imager). 24 | 25 | ## Community 26 | 27 | For additional help, join us on [Discord](https://discord.gg/mainsail). 28 | 29 | [![discord](https://img.shields.io/discord/758059413700345988?color=%235865F2&label=discord&logo=discord&logoColor=white&style=flat)](https://discord.gg/mainsail) 30 | 31 | ## What is included? 32 | 33 | Here a list of included and preinstalled Software: 34 | 35 | - [Klipper (3D Printer Firmware)](https://github.com/KevinOConnor/klipper) 36 | - [Moonraker (API Web Server for Klipper)](https://github.com/Arksine/moonraker) 37 | - [Mainsail (Web interface for Klipper/Moonraker)](https://github.com/meteyou/mainsail) 38 | - [Crowsnest (Webcam streaming)](https://github.com/mainsail-crew/crowsnest) 39 | - [Sonar (Keepalive daemon)](https://github.com/mainsail-crew/sonar) 40 | - [Nginx (Webserver & Proxy)](https://nginx.org/en/) 41 | 42 | ## also includes 43 | 44 | - Enabled Serial Connection by default. \ 45 | Using Hardware UART (PL011) for Boards like BTT SKR Mini E3 V3 46 | - Preinstalled Dependencies for Klipper's Input Shaper. \ 47 | You only need to build the [klipper_mcu](https://www.klipper3d.org/RPi_microcontroller.html) and installing the service. \ 48 | See [Klipper documentation](https://www.klipper3d.org/Measuring_Resonances.html) for more information. 49 | - Preinstalled python3-serial package, needed for [CanBoot](https://github.com/Arksine/CanBoot) 50 | 51 | ## Screenshots 52 | 53 | ![screenshot-dashboard](https://github.com/mainsail-crew/docs/raw/master/assets/img/screenshot.png) 54 | 55 | # Build your own / Developing 56 | 57 | To prevent you have to deal with an entire build chain setup, \ 58 | simply fork this repository. 59 | 60 | Enable the workflows in your fork and you are good to go. \ 61 | On each push you make, an image is build and uploaded as an artifact. 62 | 63 | If you want or need to build locally please visit [CustomPiOS](https://github.com/guysoft/CustomPiOS). \ 64 | Especially ["Build a Distro From within Raspbian / Debian / Ubuntu / CustomPiOS Distros"](https://github.com/guysoft/CustomPiOS#build-a-distro-from-within-raspbian--debian--ubuntu--custompios-distros) 65 | -------------------------------------------------------------------------------- /config/armbian/default: -------------------------------------------------------------------------------- 1 | export BASE_APT_CACHE=no 2 | export OCTOPI_INCLUDE_WIRINGPI=no 3 | export BASE_DISTRO=armbian 4 | export BASE_ROOT_PARTITION=2 5 | export BASE_IMAGE_RESIZEROOT=500 6 | export BASE_IMAGE_RASPBIAN=no 7 | export BASE_IMAGE_ENLARGEROOT=1000 8 | export BASE_ARCH=arm64 9 | 10 | export MODULES="base,pkgupgrade" 11 | -------------------------------------------------------------------------------- /config/default: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Shebang for better file detection 3 | # shellcheck enable=require-variable-braces 4 | 5 | get_version() { 6 | local ver 7 | ver="$(realpath "$( dirname -- "${BASH_SOURCE[0]}")"/version)" 8 | cat "${ver}" 9 | } 10 | 11 | get_img_name() { 12 | local -a types 13 | types=(zip 7z xz) 14 | if [ -n "${DIST_PATH}" ]; then 15 | for i in "${types[@]}"; do 16 | find "${DIST_PATH}/image/" -type f -name "*.${i}" -printf "%p\n" 17 | done 18 | fi 19 | 20 | if [ -z "${DIST_PATH}" ]; then 21 | echo "" 22 | fi 23 | } 24 | 25 | DIST_VERSION="$(get_version)" 26 | BASE_ZIP_IMG="$(get_img_name)" 27 | DIST_NAME="MainsailOS" 28 | 29 | # export Variables 30 | export DIST_NAME 31 | export DIST_VERSION 32 | export BASE_ZIP_IMG 33 | -------------------------------------------------------------------------------- /config/raspberry/default: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Shebang for better file detection 3 | 4 | # Declare Variables before exporting. 5 | # See https://www.shellcheck.net/wiki/SC2155 6 | 7 | BASE_IMAGE_ENLARGEROOT=2500 8 | BASE_IMAGE_RESIZEROOT=600 9 | # Compress not needed due compression done in workflow 10 | BASE_RELEASE_COMPRESS=no 11 | # Modules are valid for 32bit and 64bit images 12 | MODULES="base,pkgupgrade,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename" 13 | 14 | # export Variables 15 | export BASE_IMAGE_ENLARGEROOT 16 | export BASE_IMAGE_RESIZEROOT 17 | export BASE_RELEASE_COMPRESS 18 | export MODULES 19 | -------------------------------------------------------------------------------- /config/raspberry/rpi32: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Shebang for better file detection 3 | 4 | # Declare Variables before exporting. 5 | # See https://www.shellcheck.net/wiki/SC2155 6 | 7 | DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_armhf_latest.sha256" 8 | DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_armhf_latest.torrent" 9 | 10 | export DOWNLOAD_URL_CHECKSUM 11 | export DOWNLOAD_URL_IMAGE 12 | -------------------------------------------------------------------------------- /config/raspberry/rpi64: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Shebang for better file detection 3 | 4 | # Declare Variables before exporting. 5 | # See https://www.shellcheck.net/wiki/SC2155 6 | 7 | BASE_ARCH="arm64" 8 | 9 | DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.sha256" 10 | DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.torrent" 11 | 12 | 13 | 14 | # export variables 15 | export BASE_ARCH 16 | export DOWNLOAD_URL_CHECKSUM 17 | export DOWNLOAD_URL_IMAGE 18 | -------------------------------------------------------------------------------- /src/build_dist: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 3 | 4 | export DIST_PATH="${DIR}" 5 | CUSTOM_PI_OS_PATH=$(<"${DIR}"/custompios_path) 6 | export CUSTOM_PI_OS_PATH 7 | export PATH=$PATH:$CUSTOM_PI_OS_PATH 8 | 9 | "${CUSTOM_PI_OS_PATH}"/build_custom_os "$@" 10 | -------------------------------------------------------------------------------- /src/image/README: -------------------------------------------------------------------------------- 1 | Place zipped Rasbian 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" located 5 | here. 6 | -------------------------------------------------------------------------------- /src/modules/armbian/config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # shellcheck disable=all 3 | 4 | [ -n "$ARMBIAN_DEPS" ] || ARMBIAN_DEPS="armbian-config avahi-daemon iptables \ 5 | bash-completion" 6 | -------------------------------------------------------------------------------- /src/modules/armbian/end_chroot_script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # MainsailOS Specific Tweaks for armbian images 3 | # written by Stephan Wendel aka KwadFan 4 | # 5 | # GPL V3 6 | ######## 7 | 8 | ## functions 9 | gen_root_pw() { 10 | tr -dc "[:alnum:]" < /dev/urandom | head -c 50 11 | } 12 | 13 | # Clean up 14 | # Remove autologin and lock root account 15 | if [ -f "/etc/systemd/system/getty@.service.d/override.conf" ]; then 16 | rm -f /etc/systemd/system/getty@.service.d/override.conf 17 | fi 18 | 19 | # Disable autologin on serial console 20 | if [ -f "/etc/systemd/system/serial-getty@.service.d/override.conf" ]; then 21 | sed -i 's/--autologin root //' /etc/systemd/system/serial-getty@.service.d/override.conf 22 | fi 23 | 24 | # Generate random root passwd 25 | yes "$(gen_root_pw)" | passwd root 26 | 27 | # lock root account 28 | sudo -u "${BASE_USER}" passwd -l root 29 | 30 | # Remove passwdless sudo 31 | sed -i '/'"${BASE_USER}"' ALL=(ALL:ALL) NOPASSWD:ALL/d' /etc/sudoers 32 | -------------------------------------------------------------------------------- /src/modules/armbian/filesystem/root/etc/update-motd.d/10-mainsailos: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Based on: 4 | # https://github.com/armbian/build/blob/master/packages/bsp/common/etc/update-motd.d/10-armbian-header 5 | 6 | # Copyright (c) Authors: https://www.armbian.com/authors 7 | # 8 | # This file is licensed under the terms of the GNU General Public 9 | # License version 2. This program is licensed "as is" without any 10 | # warranty of any kind, whether express or implied. 11 | 12 | # Modified by Stephan Wendel aka KwadFan 13 | # All changes made are public at 14 | # https://github.com/mainsail-crew/MainsailOS 15 | 16 | # shellcheck enable=require-variable-braces 17 | 18 | # shellcheck disable=SC1091 19 | [[ -f /etc/armbian-release-info.txt ]] && . /etc/armbian-release-info.txt 20 | 21 | if [[ -f /etc/armbian-distribution-status ]]; then 22 | . /etc/armbian-distribution-status 23 | [[ -f /etc/lsb-release ]] && DISTRIBUTION_CODENAME=$(grep CODENAME /etc/lsb-release | cut -d"=" -f2) 24 | [[ -z "${DISTRIBUTION_CODENAME}" && -f /etc/os-release ]] && DISTRIBUTION_CODENAME=$(grep VERSION_CODENAME /etc/os-release | cut -d"=" -f2) 25 | [[ -z "${DISTRIBUTION_CODENAME}" && -x /usr/bin/lsb_release ]] && DISTRIBUTION_CODENAME=$(/usr/bin/lsb_release -c | cut -d":" -f2 | tr -d "\t") 26 | DISTRIBUTION_STATUS=$(grep "${DISTRIBUTION_CODENAME}" /etc/armbian-distribution-status | cut -d"=" -f2) 27 | fi 28 | [[ -f /etc/default/armbian-motd ]] && . /etc/default/armbian-motd 29 | 30 | for f in ${MOTD_DISABLE}; do 31 | [[ "${f}" == "${THIS_SCRIPT}" ]] && exit 0 32 | done 33 | 34 | 35 | KERNELID=$(uname -r) 36 | 37 | # Odroid N2 exception 38 | ODROID_EXCEPTION="$(tr -d '\000' < /proc/device-tree/model | grep ODROID | grep Plus)" 39 | [[ -f /proc/device-tree/model ]] && [[ -n "${ODROID_EXCEPTION}" ]] && BOARD_NAME+="+" 40 | 41 | 42 | echo -e "\e[31m$(toilet -f big MainsailOS)\e[0m" 43 | echo -e "Version $(cut -d ' ' -f3 /etc/mainsailos-release), based on \ 44 | \e[34mArmbian ${VERSION} ${DISTRIBUTION_CODENAME^}\e[0m $([[ ${BRANCH} == edge ]])" 45 | echo -e "Running on \e[34m$(echo ${BOARD_NAME} | sed 's/Orange Pi/OPi/' | \ 46 | sed 's/NanoPi/NPi/' | sed 's/Banana Pi/BPi/')\e[0m with \e[34mLinux ${KERNELID}\e[0m\n" 47 | 48 | # displaying status warnings 49 | 50 | if [[ "${IMAGE_TYPE}" != "stable" ]]; then 51 | [[ "${IMAGE_TYPE}" == "user-built" ]] && UNSUPPORTED_TEXT="built from trunk" 52 | [[ "${IMAGE_TYPE}" == "nightly" ]] && UNSUPPORTED_TEXT="untested automated build" 53 | else 54 | [[ "${BOARD_TYPE}" == "csc" || "${BOARD_TYPE}" == "tvb" ]] && UNSUPPORTED_TEXT="community creations" 55 | [[ "${BOARD_TYPE}" == "wip" ]] && UNSUPPORTED_TEXT="work in progress" 56 | [[ "${BOARD_TYPE}" == "eos" ]] && UNSUPPORTED_TEXT="end of life" 57 | fi 58 | 59 | if [[ -n ${DISTRIBUTION_STATUS} && ${DISTRIBUTION_STATUS} != supported ]]; then 60 | [[ -n ${UNSUPPORTED_TEXT} ]] && UNSUPPORTED_TEXT+=" & " 61 | UNSUPPORTED_TEXT+="unsupported (${DISTRIBUTION_CODENAME}) userspace!" 62 | fi 63 | 64 | if [[ -n ${UNSUPPORTED_TEXT} ]]; then 65 | echo -e "\e[0;91mNo end-user support: \x1B[0m${UNSUPPORTED_TEXT}\n" 66 | fi 67 | -------------------------------------------------------------------------------- /src/modules/armbian/start_chroot_script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # MainsailOS Specific Tweaks for armbian images 3 | # written by Stephan Wendel aka KwadFan 4 | # 5 | # GPL V3 6 | ######## 7 | 8 | # Source error handling, leave this in place 9 | set -xe 10 | 11 | # Source CustomPIOS common.sh 12 | # shellcheck disable=SC1091 13 | source /common.sh 14 | install_cleanup_trap 15 | 16 | # Install armbian specific packages 17 | apt update 18 | # shellcheck disable=SC2086 19 | check_install_pkgs ${ARMBIAN_DEPS} 20 | 21 | # passwordless sudo during install 22 | # Will be removed in cleanup 23 | echo "${BASE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers 24 | 25 | # Base User groups 26 | # Shameless "stolen" from 27 | # https://github.com/guysoft/CustomPiOS/blob/devel/src/variants/armbian/pre_chroot_script 28 | 29 | if_group_exists_run() { 30 | group=$1 31 | if grep -q $group /etc/group; then 32 | "${@:2}" 33 | fi 34 | } 35 | 36 | # set groups 37 | if_group_exists_run i2c usermod -aG i2c "${BASE_USER}" 38 | usermod -aG video,audio,plugdev,games,netdev,sudo "${BASE_USER}" 39 | 40 | # Patch sshd_config 41 | sed -i 's/PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config 42 | sed -i 's/^X11Forwarding/#X11Forwarding/' /etc/ssh/sshd_config 43 | sed -i 's/^#MaxAuthTries 6/MaxAuthTries 3/' /etc/ssh/sshd_config 44 | 45 | # Try patching first login in build stage 46 | if [ -f "/root/.not_logged_in_yet" ]; then 47 | rm -f /root/.not_logged_in_yet 48 | fi 49 | 50 | # Move armbian-release to display mainsailos-release 51 | mv /etc/armbian-release /etc/armbian-release-info.txt 52 | 53 | # update motd 54 | unpack /filesystem/root / 55 | chmod +x /etc/update-motd.d/* 56 | if [ -f "/etc/default/armbian-motd" ]; then 57 | sed -i 's/MOTD_DISABLE=""/MOTD_DISABLE="header"/' /etc/default/armbian-motd 58 | fi 59 | -------------------------------------------------------------------------------- /src/modules/crowsnest/config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #### crowsnest - A webcam Service for multiple Cams and Stream Services. 3 | #### 4 | #### Written by Stephan Wendel aka KwadFan 5 | #### Copyright 2021 6 | #### https://github.com/mainsail-crew/crowsnest 7 | #### 8 | #### This File is distributed under GPLv3 9 | #### 10 | # shellcheck disable=all 11 | 12 | # crowsnest 13 | [ -n "$CROWSNEST_CROWSNEST_REPO_SHIP" ] || CROWSNEST_CROWSNEST_REPO_SHIP=https://github.com/mainsail-crew/crowsnest.git 14 | [ -n "$CROWSNEST_CROWSNEST_REPO_BRANCH" ] || CROWSNEST_CROWSNEST_REPO_BRANCH=master 15 | [ -n "$CROWSNEST_CROWSNEST_DEPS" ] || CROWSNEST_CROWSNEST_DEPS="git crudini bsdutils findutils v4l-utils ffmpeg" 16 | [ -n "$CROWSNEST_DEFAULT_CONF" ] || CROWSNEST_DEFAULT_CONF="mainsail_default.conf" 17 | [ -n "$CROWSNEST_DEFAULT_CONF_DIR" ] || CROWSNEST_DEFAULT_CONF_DIR="/home/${BASE_USER}/klipper_config" 18 | # Force Raspicam fix bool (1:yes / 0:no) 19 | [ -n "$CROWSNEST_FORCE_RASPICAMFIX" ] || CROWSNEST_FORCE_RASPICAMFIX=1 20 | # Add Crowsnest to moonraker.conf (update manager) bool (1:yes / 0:no) 21 | [ -n "$CROWSNEST_ADD_CROWSNEST_MOONRAKER" ] || CROWSNEST_ADD_CROWSNEST_MOONRAKER=1 22 | 23 | 24 | # ustreamer 25 | [ -n "$CROWSNEST_USTREAMER_DEPS" ] || CROWSNEST_USTREAMER_DEPS="git build-essential libevent-dev libjpeg-dev \ 26 | libbsd-dev libraspberrypi-dev libgpiod-dev" 27 | [ -n "$CROWSNEST_USTREAMER_WITH_OMX" ] || CROWSNEST_USTREAMER_WITH_OMX="y" 28 | [ -n "$CROWSNEST_USTREAMER_WITH_GPIO" ] || CROWSNEST_USTREAMER_WITH_GPIO="n" 29 | -------------------------------------------------------------------------------- /src/modules/crowsnest/start_chroot_script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #### crowsnest - A webcam Service for multiple Cams and Stream Services. 4 | #### 5 | #### Written by Stephan Wendel aka KwadFan 6 | #### Copyright 2021 7 | #### https://github.com/mainsail-crew/crowsnest 8 | #### 9 | #### This File is distributed under GPLv3 10 | #### 11 | 12 | # shellcheck disable=all 13 | 14 | # Error handling 15 | set -Ee 16 | 17 | source /common.sh 18 | install_cleanup_trap 19 | 20 | echo_green "Installing crowsnest and enable webcam Service ..." 21 | # install dependencies 22 | # force apt update 23 | apt update 24 | # It could use inbuilt dependencie check, but should speed up if preinstalled. 25 | # shellcheck disable=SC2086 26 | check_install_pkgs ${CROWSNEST_CROWSNEST_DEPS} ${CROWSNEST_USTREAMER_DEPS} 27 | # Move to $HOME dir 28 | pushd "/home/${BASE_USER}" &> /dev/null || exit 1 29 | # make sure config folder exist 30 | if [ ! -d "${CROWSNEST_DEFAULT_CONF_DIR}" ]; then 31 | sudo -u "${BASE_USER}" mkdir -p "${CROWSNEST_DEFAULT_CONF_DIR}" 32 | fi 33 | # clone Repo 34 | echo_green "Clone crowsnest repository ..." 35 | gitclone CROWSNEST_CROWSNEST_REPO crowsnest 36 | # install crowsnest - use crowsnest's make unattended 37 | pushd "/home/${BASE_USER}/crowsnest" &> /dev/null || exit 1 38 | echo_green "Launch crowsnest install routine ..." 39 | pushd "/home/${BASE_USER}/crowsnest" &> /dev/null || exit 1 40 | sudo -u "${BASE_USER}" make unattended 41 | # Apply Raspicam fix if enabled. 42 | if [ "${CROWSNEST_FORCE_RASPICAMFIX}" == "1" ]; then 43 | echo -en "Applying Raspicam Fix ... \r" 44 | sudo sh -c 'echo "bcm2835-v4l2" >> /etc/modules' 45 | sudo cp file_templates/bcm2835-v4l2.conf /etc/modprobe.d/ 46 | echo -e "Applying Raspicam Fix ... [OK]" 47 | fi 48 | popd &> /dev/null || exit 1 49 | popd &> /dev/null || exit 1 50 | -------------------------------------------------------------------------------- /src/modules/is_req_preinstall/config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # shellcheck disable=all 3 | [ -n "$IS_REQ_PREINSTALL_VENV_DIR" ] || IS_REQ_PREINSTALL_VENV_DIR=/home/${BASE_USER}/klippy-env 4 | [ -n "$IS_REQ_PREINSTALL_DEPS" ] || IS_REQ_PREINSTALL_DEPS="python3-numpy python3-matplotlib \ 5 | libatlas3-base libatlas-base-dev" 6 | [ -n "$IS_REQ_PREINSTALL_PIP" ] || IS_REQ_PREINSTALL_PIP="numpy<=1.21.4" 7 | [ -n "$IS_REQ_PREINSTALL_CFG_FILE" ] || IS_REQ_PREINSTALL_CFG_FILE="/boot/config.txt" 8 | -------------------------------------------------------------------------------- /src/modules/is_req_preinstall/start_chroot_script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #### MainsailOS Build Chain 3 | #### 4 | #### Klipper Install Module 5 | #### 6 | #### Written by Stephan Wendel aka KwadFan 7 | #### Copyright 2021 - 2022 8 | #### https://github.com/mainsail-crew/MainsailOS 9 | #### 10 | #### This File is distributed under GPLv3 11 | #### 12 | 13 | # shellcheck enable=require-variable-braces 14 | 15 | ## Source error handling, leave this in place 16 | set -Eex 17 | 18 | # Set LC_ALL to prevent errors 19 | export LC_ALL=C 20 | 21 | # Set DEBIAN_FRONTEND to noninteractive 22 | if [ "${DEBIAN_FRONTEND}" != "noninteractive" ]; then 23 | export DEBIAN_FRONTEND=noninteractive 24 | fi 25 | 26 | # Source CustomPIOS common.sh 27 | # shellcheck disable=SC1091 28 | source /common.sh 29 | install_cleanup_trap 30 | 31 | echo_green "Install Input Shaper requirements ..." 32 | 33 | ### install all deps at once for time consumption reasons. 34 | ## APT: Update Repo Database and install Dependencies 35 | # Force apt update 36 | apt update 37 | echo_green "Installing Input Shaper Dependencies ..." 38 | # shellcheck disable=SC2086 39 | # Disabling shellcheck SC2086, because we want "wordsplitting" 40 | check_install_pkgs ${IS_REQ_PREINSTALL_DEPS} 41 | 42 | ### Check for Klipper Venv installed. 43 | pushd "/home/${BASE_USER}" &> /dev/null || exit 1 44 | if [ -d "${IS_REQ_PREINSTALL_VENV_DIR}" ] && [ -x "${IS_REQ_PREINSTALL_VENV_DIR}/bin/pip" ]; then 45 | echo_green "Installing numpy..." 46 | sudo -u "${BASE_USER}" "${IS_REQ_PREINSTALL_VENV_DIR}"/bin/pip install -v "${IS_REQ_PREINSTALL_PIP}" 47 | else 48 | echo_red "Klipper Venv not found!" 49 | return 1 50 | fi 51 | 52 | ## Cleanup 53 | echo_green "Cleanup ..." 54 | sudo -u "${BASE_USER}" rm -rf "/home/${BASE_USER}/.cache" 55 | popd &> /dev/null || exit 1 56 | 57 | ## Enable spi interface by default 58 | echo_green "Enabling SPI Interface..." 59 | sed -i 's/#dtparam=spi=on/dtparam=spi=on/' "${IS_REQ_PREINSTALL_CFG_FILE}" 60 | 61 | echo_green "Install Input Shaper requirements ... done!" 62 | -------------------------------------------------------------------------------- /src/modules/klipper/config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # shellcheck disable=all 3 | [ -n "$KLIPPER_SRC_DIR" ] || KLIPPER_SRC_DIR=/home/${BASE_USER}/klipper 4 | [ -n "$KLIPPER_PYTHON_DIR" ] || KLIPPER_PYTHON_DIR=/home/${BASE_USER}/klippy-env 5 | 6 | [ -n "$KLIPPER_REPO_SHIP" ] || KLIPPER_REPO_SHIP=https://github.com/Klipper3d/klipper.git 7 | [ -n "$KLIPPER_REPO_BRANCH" ] || KLIPPER_REPO_BRANCH=master 8 | [ -n "$KLIPPER_DEPS" ] || KLIPPER_DEPS="wget git gpiod \ 9 | virtualenv python3-dev python3-matplotlib \ 10 | libffi-dev build-essential \ 11 | libncurses-dev libusb-dev \ 12 | avrdude gcc-avr binutils-avr avr-libc \ 13 | stm32flash dfu-util libnewlib-arm-none-eabi \ 14 | gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0-0" 15 | [ -n "$KLIPPER_USER_GROUPS" ] || KLIPPER_USER_GROUPS=tty,dialout 16 | [ -n "$KLIPPER_USER_DIRS" ] || KLIPPER_USER_DIRS="klipper_config klipper_logs gcode_files" 17 | [ -n "$KLIPPER_PYENV_REQ" ] || KLIPPER_PYENV_REQ=scripts/klippy-requirements.txt 18 | -------------------------------------------------------------------------------- /src/modules/klipper/filesystem/root/etc/systemd/system/klipper.service: -------------------------------------------------------------------------------- 1 | #Systemd Klipper Service 2 | 3 | [Unit] 4 | Description=Starts Klipper and provides klippy Unix Domain Socket API 5 | Documentation=https://www.klipper3d.org/ 6 | After=network-online.target 7 | Before=moonraker.service 8 | Wants=udev.target 9 | 10 | [Install] 11 | Alias=klippy 12 | WantedBy=multi-user.target 13 | 14 | 15 | [Service] 16 | Environment=KLIPPER_CONFIG=/home/pi/klipper_config/printer.cfg 17 | Environment=KLIPPER_LOG=/home/pi/klipper_logs/klippy.log 18 | Environment=KLIPPER_SOCKET=/tmp/klippy_uds 19 | Type=simple 20 | User=pi 21 | RemainAfterExit=yes 22 | ExecStart= /home/pi/klippy-env/bin/python /home/pi/klipper/klippy/klippy.py ${KLIPPER_CONFIG} -l ${KLIPPER_LOG} -a ${KLIPPER_SOCKET} 23 | Restart=always 24 | RestartSec=10 25 | -------------------------------------------------------------------------------- /src/modules/klipper/start_chroot_script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #### MainsailOS Build Chain 3 | #### 4 | #### Klipper Install Module 5 | #### 6 | #### Based on work done by Raymond Himle and Stefan Dej 7 | #### 8 | #### Written by Stephan Wendel aka KwadFan 9 | #### Copyright 2022 10 | #### https://github.com/mainsail-crew/MainsailOS 11 | #### 12 | #### This File is distributed under GPLv3 13 | #### 14 | 15 | # shellcheck enable=require-variable-braces 16 | 17 | ### For easier maintainability look to klipper/config. 18 | 19 | ## Source error handling, leave this in place 20 | set -Eex 21 | 22 | ## Set LC_ALL to prevent errors 23 | export LC_ALL=C 24 | 25 | # Set DEBIAN_FRONTEND to noninteractive 26 | if [ "${DEBIAN_FRONTEND}" != "noninteractive" ]; then 27 | export DEBIAN_FRONTEND=noninteractive 28 | fi 29 | 30 | ## Source CustomPIOS common.sh 31 | # shellcheck disable=SC1091 32 | source /common.sh 33 | install_cleanup_trap 34 | 35 | unpack /filesystem/root / 36 | 37 | echo_green "Installing Klipper and enable klippy Service ..." 38 | 39 | ## Install all deps at once for time consumption reasons. 40 | ## APT: Update Repo Database and install Dependencies 41 | # Force apt update 42 | apt update 43 | echo_green "Installing Klipper Dependencies ..." 44 | ## Disabling shellcheck SC2086, because we want "wordsplitting" 45 | # shellcheck disable=SC2086 46 | check_install_pkgs ${KLIPPER_DEPS} 47 | 48 | ## Make sure user pi has access to serial ports 49 | ## NOTE: BASE_USER is defined by CustomPIOS Variable 50 | ## there for if you plan to set something else than "pi" 51 | ## Currently CustomPIOS uses "pi" 52 | 53 | usermod -a -G "${KLIPPER_USER_GROUPS}" "${BASE_USER}" 54 | 55 | ## Clone klipper repo 56 | pushd "/home/${BASE_USER}" &> /dev/null || exit 1 57 | gitclone KLIPPER_REPO klipper 58 | 59 | ## Create needed dirs 60 | for dir in ${KLIPPER_USER_DIRS}; do 61 | if [ -d "/home/${BASE_USER}/$dir" ]; then 62 | echo_green "${dir} already exists!" 63 | else 64 | echo_green "Creating ${dir}" 65 | sudo -u "${BASE_USER}" mkdir -p "${dir}" 66 | fi 67 | done 68 | popd &> /dev/null || exit 1 69 | 70 | ## create python virtualenv and install klipper requirements 71 | pushd "/home/${BASE_USER}" &> /dev/null || exit 1 72 | echo_green "Creating Virtualenv for Klipper (klippy-env) ..." 73 | sudo -u "${BASE_USER}" virtualenv -p python3 "${KLIPPER_PYTHON_DIR}" 74 | echo_green "Installing klippy Python Dependencies ..." 75 | sudo -u "${BASE_USER}" "${KLIPPER_PYTHON_DIR}"/bin/pip install -r "${KLIPPER_SRC_DIR}"/"${KLIPPER_PYENV_REQ}" 76 | popd &> /dev/null || exit 1 77 | 78 | 79 | ## Enable systemd service 80 | systemctl_if_exists enable klipper.service 81 | 82 | ## Done message 83 | echo_green "Installing Klipper and enable klippy Service ... done!" 84 | -------------------------------------------------------------------------------- /src/modules/mainsail/config: -------------------------------------------------------------------------------- 1 | [ -n "$MAINSAIL_DEPS" ] || MAINSAIL_DEPS="nginx" 2 | [ -n "$MAINSAIL_URL" ] || MAINSAIL_URL=https://github.com/mainsail-crew/mainsail/releases/latest/download/mainsail.zip 3 | -------------------------------------------------------------------------------- /src/modules/mainsail/filesystem/home/pi/klipper_config/mainsail.cfg: -------------------------------------------------------------------------------- 1 | # Mainsail klipper definitions 2 | # 3 | # Copyright (C) 2021 Alex Zellner 4 | # 5 | # This file may be distributed under the terms of the GNU GPLv3 license 6 | # 7 | # Version 1.11 8 | 9 | # add [include mainsail.cfg] to your printer.cfg to include it to your printer.cfg 10 | # modify x_park, y_park, z_park_delta and extrude value at the macro _TOOLHEAD_PARK_PAUSE_CANCEL if needed 11 | 12 | # use variable_park: False at CANCEL_PRINT to disallow the parking move 13 | 14 | [virtual_sdcard] 15 | path: ~/gcode_files 16 | on_error_gcode: 17 | CANCEL_PRINT 18 | 19 | [pause_resume] 20 | 21 | [display_status] 22 | 23 | [gcode_macro CANCEL_PRINT] 24 | description: Cancel the actual running print 25 | rename_existing: CANCEL_PRINT_BASE 26 | variable_park: True 27 | gcode: 28 | ## Move head and retract only if not already in the pause state and park set to true 29 | {% if printer.pause_resume.is_paused|lower == 'false' and park|lower == 'true'%} 30 | _TOOLHEAD_PARK_PAUSE_CANCEL 31 | {% endif %} 32 | TURN_OFF_HEATERS 33 | M106 S0 34 | CANCEL_PRINT_BASE 35 | 36 | [gcode_macro PAUSE] 37 | description: Pause the actual running print 38 | rename_existing: PAUSE_BASE 39 | gcode: 40 | PAUSE_BASE 41 | _TOOLHEAD_PARK_PAUSE_CANCEL 42 | 43 | [gcode_macro RESUME] 44 | description: Resume the actual running print 45 | rename_existing: RESUME_BASE 46 | gcode: 47 | ##### read extrude from _TOOLHEAD_PARK_PAUSE_CANCEL macro ##### 48 | {% set extrude = printer['gcode_macro _TOOLHEAD_PARK_PAUSE_CANCEL'].extrude %} 49 | #### get VELOCITY parameter if specified #### 50 | {% if 'VELOCITY' in params|upper %} 51 | {% set get_params = ('VELOCITY=' + params.VELOCITY) %} 52 | {%else %} 53 | {% set get_params = "" %} 54 | {% endif %} 55 | ##### end of definitions ##### 56 | {% if printer.extruder.can_extrude|lower == 'true' %} 57 | M83 58 | G1 E{extrude} F2100 59 | {% if printer.gcode_move.absolute_extrude |lower == 'true' %} M82 {% endif %} 60 | {% else %} 61 | {action_respond_info("Extruder not hot enough")} 62 | {% endif %} 63 | RESUME_BASE {get_params} 64 | 65 | [gcode_macro _TOOLHEAD_PARK_PAUSE_CANCEL] 66 | description: Helper: park toolhead used in PAUSE and CANCEL_PRINT 67 | variable_extrude: 1.0 68 | gcode: 69 | ##### set park positon for x and y ##### 70 | # default is your max posion from your printer.cfg 71 | {% set x_park = printer.toolhead.axis_maximum.x|float - 5.0 %} 72 | {% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %} 73 | {% set z_park_delta = 2.0 %} 74 | ##### calculate save lift position ##### 75 | {% set max_z = printer.toolhead.axis_maximum.z|float %} 76 | {% set act_z = printer.toolhead.position.z|float %} 77 | {% if act_z < (max_z - z_park_delta) %} 78 | {% set z_safe = z_park_delta %} 79 | {% else %} 80 | {% set z_safe = max_z - act_z %} 81 | {% endif %} 82 | ##### end of definitions ##### 83 | {% if printer.extruder.can_extrude|lower == 'true' %} 84 | M83 85 | G1 E-{extrude} F2100 86 | {% if printer.gcode_move.absolute_extrude |lower == 'true' %} M82 {% endif %} 87 | {% else %} 88 | {action_respond_info("Extruder not hot enough")} 89 | {% endif %} 90 | {% if "xyz" in printer.toolhead.homed_axes %} 91 | G91 92 | G1 Z{z_safe} F900 93 | G90 94 | G1 X{x_park} Y{y_park} F6000 95 | {% if printer.gcode_move.absolute_coordinates|lower == 'false' %} G91 {% endif %} 96 | {% else %} 97 | {action_respond_info("Printer not homed")} 98 | {% endif %} 99 | -------------------------------------------------------------------------------- /src/modules/mainsail/filesystem/root/etc/logrotate.d/rsyslog: -------------------------------------------------------------------------------- 1 | /var/log/syslog 2 | { 3 | rotate 2 4 | daily 5 | maxsize 128M 6 | missingok 7 | notifempty 8 | delaycompress 9 | compress 10 | postrotate 11 | /usr/lib/rsyslog/rsyslog-rotate 12 | endscript 13 | } 14 | 15 | /var/log/mail.info 16 | /var/log/mail.warn 17 | /var/log/mail.err 18 | /var/log/mail.log 19 | /var/log/daemon.log 20 | /var/log/kern.log 21 | /var/log/auth.log 22 | /var/log/user.log 23 | /var/log/lpr.log 24 | /var/log/cron.log 25 | /var/log/debug 26 | /var/log/messages 27 | { 28 | rotate 2 29 | daily 30 | maxsize 128M 31 | missingok 32 | notifempty 33 | compress 34 | delaycompress 35 | sharedscripts 36 | postrotate 37 | /usr/lib/rsyslog/rsyslog-rotate 38 | endscript 39 | } 40 | -------------------------------------------------------------------------------- /src/modules/mainsail/filesystem/root/etc/nginx/conf.d/common_vars.conf: -------------------------------------------------------------------------------- 1 | map $http_upgrade $connection_upgrade { 2 | default upgrade; 3 | '' close; 4 | } 5 | -------------------------------------------------------------------------------- /src/modules/mainsail/filesystem/root/etc/nginx/conf.d/upstreams.conf: -------------------------------------------------------------------------------- 1 | upstream apiserver { 2 | ip_hash; 3 | server 127.0.0.1:7125; 4 | } 5 | 6 | upstream mjpgstreamer1 { 7 | ip_hash; 8 | server 127.0.0.1:8080; 9 | } 10 | 11 | upstream mjpgstreamer2 { 12 | ip_hash; 13 | server 127.0.0.1:8081; 14 | } 15 | 16 | upstream mjpgstreamer3 { 17 | ip_hash; 18 | server 127.0.0.1:8082; 19 | } 20 | 21 | upstream mjpgstreamer4 { 22 | ip_hash; 23 | server 127.0.0.1:8083; 24 | } 25 | -------------------------------------------------------------------------------- /src/modules/mainsail/filesystem/root/etc/nginx/sites-available/mainsail: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default_server; 3 | # uncomment the next line to activate IPv6 4 | # listen [::]:80 default_server; 5 | 6 | access_log /var/log/nginx/mainsail-access.log; 7 | error_log /var/log/nginx/mainsail-error.log; 8 | 9 | # disable this section on smaller hardware like a pi zero 10 | gzip on; 11 | gzip_vary on; 12 | gzip_proxied any; 13 | gzip_proxied expired no-cache no-store private auth; 14 | gzip_comp_level 4; 15 | gzip_buffers 16 8k; 16 | gzip_http_version 1.1; 17 | gzip_types text/plain text/css text/xml text/javascript application/javascript application/x-javascript application/json application/xml; 18 | 19 | # web_path from mainsail static files 20 | root /home/pi/mainsail; 21 | 22 | index index.html; 23 | server_name _; 24 | 25 | # disable max upload size checks 26 | client_max_body_size 0; 27 | 28 | # disable proxy request buffering 29 | proxy_request_buffering off; 30 | 31 | location / { 32 | try_files $uri $uri/ /index.html; 33 | } 34 | 35 | location = /index.html { 36 | add_header Cache-Control "no-store, no-cache, must-revalidate"; 37 | } 38 | 39 | location /websocket { 40 | proxy_pass http://apiserver/websocket; 41 | proxy_http_version 1.1; 42 | proxy_set_header Upgrade $http_upgrade; 43 | proxy_set_header Connection $connection_upgrade; 44 | proxy_set_header Host $http_host; 45 | proxy_set_header X-Real-IP $remote_addr; 46 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 47 | proxy_read_timeout 86400; 48 | } 49 | 50 | location ~ ^/(printer|api|access|machine|server)/ { 51 | proxy_pass http://apiserver$request_uri; 52 | proxy_http_version 1.1; 53 | proxy_set_header Upgrade $http_upgrade; 54 | proxy_set_header Host $http_host; 55 | proxy_set_header X-Real-IP $remote_addr; 56 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 57 | proxy_set_header X-Scheme $scheme; 58 | } 59 | 60 | location /webcam/ { 61 | postpone_output 0; 62 | proxy_buffering off; 63 | proxy_ignore_headers X-Accel-Buffering; 64 | access_log off; 65 | error_log off; 66 | proxy_pass http://mjpgstreamer1/; 67 | } 68 | 69 | location /webcam2/ { 70 | postpone_output 0; 71 | proxy_buffering off; 72 | proxy_ignore_headers X-Accel-Buffering; 73 | access_log off; 74 | error_log off; 75 | proxy_pass http://mjpgstreamer2/; 76 | } 77 | 78 | location /webcam3/ { 79 | postpone_output 0; 80 | proxy_buffering off; 81 | proxy_ignore_headers X-Accel-Buffering; 82 | access_log off; 83 | error_log off; 84 | proxy_pass http://mjpgstreamer3/; 85 | } 86 | 87 | location /webcam4/ { 88 | postpone_output 0; 89 | proxy_buffering off; 90 | proxy_ignore_headers X-Accel-Buffering; 91 | access_log off; 92 | error_log off; 93 | proxy_pass http://mjpgstreamer4/; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/modules/mainsail/start_chroot_script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # MainSail installation script 3 | # Installs MainSail and nginx 4 | # Written by Raymond Himle 5 | # Thanks to meteyou 6 | # Revamped by KwadFan 7 | # GPL V3 8 | ######## 9 | 10 | 11 | # Source error handling, leave this in place 12 | set -xe 13 | 14 | # Source CustomPIOS common.sh 15 | source /common.sh 16 | install_cleanup_trap 17 | 18 | ### Install mainsail.cfg 19 | unpack /filesystem/home/${BASE_USER} /home/${BASE_USER} ${BASE_USER} 20 | 21 | echo_green "Installing Mainsail Webfrontend ..." 22 | 23 | ### install all deps at once for time consumption reasons. 24 | ## APT: Update Repo Database and install Dependencies 25 | 26 | apt update && apt install ${MAINSAIL_DEPS} -y 27 | 28 | ### Preparing nginx 29 | rm /etc/nginx/sites-enabled/default 30 | ln -s /etc/nginx/sites-available/mainsail /etc/nginx/sites-enabled/ 31 | 32 | # lower nginx rotate cycle to 2 instead 14 33 | sudo sed -i 's/rotate 14/rotate 2/' /etc/logrotate.d/nginx 34 | 35 | ### Download and Install Mainsail Web Frontend 36 | pushd /home/${BASE_USER} 37 | sudo -u ${BASE_USER} wget -q --show-progress -O mainsail.zip "${MAINSAIL_URL}" 38 | sudo -u ${BASE_USER} unzip mainsail.zip -d /home/${BASE_USER}/mainsail 39 | ## cleanup 40 | rm /home/${BASE_USER}/mainsail.zip 41 | popd 42 | 43 | ### Link logfiles to klipper_logs 44 | ln -s /var/log/nginx/mainsail-access.log /home/${BASE_USER}/klipper_logs/ 45 | ln -s /var/log/nginx/mainsail-error.log /home/${BASE_USER}/klipper_logs/ 46 | 47 | # Unpack root at the end, so files are modified before 48 | unpack /filesystem/root / -------------------------------------------------------------------------------- /src/modules/mainsailos/config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # shellcheck disable=all 3 | 4 | [ -n "$MAINSAILOS_DEPS" ] || MAINSAILOS_DEPS="python3-serial" 5 | -------------------------------------------------------------------------------- /src/modules/mainsailos/start_chroot_script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # MainsailOS Specific Tweaks 3 | # written by Stephan Wendel aka KwadFan 4 | # 5 | # GPL V3 6 | ######## 7 | 8 | 9 | # Source error handling, leave this in place 10 | set -xe 11 | 12 | # Source CustomPIOS common.sh 13 | source /common.sh 14 | install_cleanup_trap 15 | 16 | # Create mainsailos release file 17 | if [ -f "/etc/mainsailos_version" ]; then 18 | sudo rm -f /etc/mainsailos_version 19 | fi 20 | function get_parent { 21 | cat /etc/os-release | grep VERSION_CODENAME | cut -d '=' -f2 22 | } 23 | echo "${DIST_NAME} release ${DIST_VERSION} ($(get_parent))" > /etc/${DIST_NAME,,}-release 24 | 25 | ### Install CANBoot Dependency 26 | apt update 27 | # shellcheck disable=SC2086 28 | check_install_pkgs ${MAINSAILOS_DEPS} 29 | -------------------------------------------------------------------------------- /src/modules/moonraker/config: -------------------------------------------------------------------------------- 1 | [ -n "$MOONRAKER_REPO_SHIP" ] || MOONRAKER_REPO_SHIP=https://github.com/Arksine/moonraker.git 2 | [ -n "$MOONRAKER_REPO_BRANCH" ] || MOONRAKER_REPO_BRANCH=master 3 | -------------------------------------------------------------------------------- /src/modules/moonraker/filesystem/home/pi/klipper_config/moonraker.conf: -------------------------------------------------------------------------------- 1 | [server] 2 | host: 0.0.0.0 3 | port: 7125 4 | # Verbose logging used for debugging . Default False. 5 | enable_debug_logging: False 6 | # The maximum size allowed for a file upload (in MiB). Default 1024 MiB 7 | max_upload_size: 1024 8 | 9 | [file_manager] 10 | config_path: ~/klipper_config 11 | log_path: ~/klipper_logs 12 | # post processing for object cancel. Not recommended for low resource SBCs such as a Pi Zero. Default False 13 | enable_object_processing: False 14 | 15 | [authorization] 16 | cors_domains: 17 | https://my.mainsail.xyz 18 | http://my.mainsail.xyz 19 | http://*.local 20 | http://*.lan 21 | trusted_clients: 22 | 10.0.0.0/8 23 | 127.0.0.0/8 24 | 169.254.0.0/16 25 | 172.16.0.0/12 26 | 192.168.0.0/16 27 | FE80::/10 28 | ::1/128 29 | 30 | # enables partial support of Octoprint API 31 | [octoprint_compat] 32 | 33 | # enables moonraker to track and store print history. 34 | [history] 35 | 36 | # this enables moonraker announcements for mainsail 37 | [announcements] 38 | subscriptions: 39 | mainsail 40 | 41 | # this enables moonraker's update manager 42 | [update_manager] 43 | refresh_interval: 168 44 | enable_auto_refresh: True 45 | 46 | [update_manager mainsail] 47 | type: web 48 | channel: stable 49 | repo: mainsail-crew/mainsail 50 | path: ~/mainsail 51 | -------------------------------------------------------------------------------- /src/modules/moonraker/start_chroot_script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Moonraker install script 3 | # Script that installs Moonraker API service 4 | # Written by Raymond Himle and Stefan Dej 5 | # Refactored by Stephan Wendel aka KwadFan 6 | # Thanks to Arksine 7 | # GPL V3 8 | ######## 9 | 10 | # Source error handling, leave this in place 11 | set -xe 12 | 13 | # Source CustomPIOS common.sh 14 | source /common.sh 15 | install_cleanup_trap 16 | 17 | # make sure that this module can be used standalone 18 | apt_update_skip 19 | check_install_pkgs "git virtualenv wireless-tools" 20 | 21 | echo_green "Installing Moonraker and enable Moonraker Service" 22 | # install MainsailOS premade moonraker.conf 23 | echo_green "Copying MainsailOS premade moonraker.conf" 24 | unpack /filesystem/home/${BASE_USER} /home/${BASE_USER} ${BASE_USER} 25 | # clone klipper repo 26 | pushd /home/${BASE_USER} 27 | gitclone MOONRAKER_REPO moonraker 28 | # use moonrakers Install script 29 | echo_green "Launch moonraker Install script (scripts/install-moonraker.sh)" 30 | sudo -u ${BASE_USER} \ 31 | bash -c \ 32 | '${HOME}/moonraker/scripts/install-moonraker.sh \ 33 | -c ${HOME}/klipper_config/moonraker.conf \ 34 | -l ${HOME}/klipper_logs/moonraker.log' 35 | # install Polkit Rules 36 | echo_green "Install PolicyKit Rules" 37 | sudo -u ${BASE_USER} sh -c './moonraker/scripts/set-policykit-rules.sh --root' 38 | # finished 39 | popd 40 | -------------------------------------------------------------------------------- /src/modules/net/config: -------------------------------------------------------------------------------- 1 | # Network module setup 2 | # shellcheck disable=all 3 | 4 | # Use disable power save for wifi module 5 | [ -n "$NETWORK_DISABLE_PWRSAVE" ] || NETWORK_DISABLE_PWRSAVE=yes 6 | 7 | # Type of power save rclocal/service/udev 8 | # rclocal - backwards compatibility, runs via rc.local 9 | # service - will add an systemd.service to enable or disable behavior 10 | # on reboots 11 | # udev - creates a udev rules that should affect all wifi devices. 12 | 13 | [ -n "$NETWORK_PWRSAVE_TYPE" ] || NETWORK_PWRSAVE_TYPE=udev 14 | -------------------------------------------------------------------------------- /src/modules/net/filesystem/boot/WiFi-README.txt: -------------------------------------------------------------------------------- 1 | Wifi-README.txt 2 | ############### 3 | 4 | 5 | Due to changes in Raspberry Pi OS, which OS_NAME is based on, 6 | there is no longer a OS_NAME-wpa-supplicant.txt available. 7 | 8 | How do I setup a (new) network on my Pi ? 9 | ----------------------------------------- 10 | 11 | As described in the original Raspberry Pi OS documentation. 12 | See https://www.raspberrypi.com/documentation/computers/configuration.html#setting-up-a-headless-raspberry-pi. 13 | 14 | 15 | Quote: 16 | You will need to define a wpa_supplicant.conf file for your particular wireless network. 17 | Put this file onto the boot folder of the SD card. 18 | When the Raspberry Pi boots for the first time, 19 | it will copy that file into the correct location in the Linux root file system 20 | and use those settings to start up wireless networking. 21 | 22 | The Raspberry Pi’s IP address will not be visible immediately after power on, 23 | so this step is crucial to connect to it headlessly. 24 | Depending on the OS and editor you are creating this on, 25 | the file could have incorrect newlines or the wrong file extension, 26 | so make sure you use an editor that accounts for this. 27 | Linux expects the line feed (LF) newline character. 28 | 29 | What does that all mean? What do I have to do now? 30 | ---------------------------------------------- 31 | 32 | First, ensure you have a proper text editor of your choice. 33 | Recommendations are Notepad++, VSCode, Atom or SublimeText. 34 | 35 | ################################################################################ 36 | #### IMPORTANT! ATTENTION! #### 37 | ################################################################################ 38 | 39 | !!!!! HEADS-UP WINDOWS USERS !!!!! 40 | ---------------------------------- 41 | 42 | Do not use Wordpad for editing this file, it will mangle it and your 43 | configuration won't work. Use a proper text editor instead. 44 | 45 | !!!!! HEADS-UP MacOS X USERS !!!!! 46 | --------------------------------- 47 | 48 | If you use Textedit to edit this file make sure to use "plain text format" 49 | and "disable smart quotes" in "Textedit > Preferences", otherwise Textedit 50 | will use none-compatible characters and your network configuration won't work! 51 | 52 | 53 | 1.) Open your chosen text editor and create a new file called 54 | 55 | wpa_supplicant.conf 56 | 57 | 2.) Create a basic configuration. This has to be in place! 58 | 59 | ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev 60 | country= 61 | update_config=1 62 | 63 | Valid Country Codes are: 64 | 65 | GB (United Kingdom) 66 | FR (France) 67 | DE (Germany) 68 | US (United States) 69 | SE (Sweden) 70 | 71 | For a full list, please visit https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 72 | 73 | 2.1) If you plan to use multiple WiFi networks, also add 74 | 75 | ap_scan=1 76 | 77 | to the mentioned basic configuration. 78 | 79 | 80 | 3.) Setup your "network" block. 81 | 82 | For detailed information, please consult: 83 | https://linux.die.net/man/5/wpa_supplicant.conf 84 | or 85 | https://wiki.debian.org/WiFi/HowToUse#wpa_supplicant 86 | or 87 | https://man.archlinux.org/man/wpa_supplicant.conf.5 88 | 89 | Examples: 90 | 91 | Open or unsecured WiFi network: 92 | ------------------------------- 93 | 94 | # Open/unsecured 95 | network={ 96 | scan_ssid=1 # Used to find hidden SSID's 97 | ssid="put SSID here" 98 | key_mgmt=NONE 99 | } 100 | 101 | ------------------------------- 102 | 103 | 104 | WEP "secured" network: 105 | ------------------------------- 106 | 107 | NOTE: 108 | 109 | WEP can be cracked within minutes. If your network is still relying on this 110 | encryption scheme you should seriously consider to update your network ASAP. 111 | 112 | network={ 113 | ssid="put SSID here" 114 | key_mgmt=NONE 115 | wep_key0="put password here" 116 | wep_tx_keyidx=0 117 | } 118 | -------------------------------- 119 | 120 | 121 | WPA2 Personal secured network: 122 | (Please don't use WPA secured networks, WPA isn't secure anymore) 123 | -------------------------------- 124 | 125 | # WPA/WPA2 secured 126 | network={ 127 | scan_ssid=1 # Used to find hidden SSID's 128 | ssid="" 129 | psk="" 130 | proto=RSN 131 | key_mgmt=WPA-PSK 132 | pairwise=CCMP 133 | auth_alg=OPEN 134 | } 135 | -------------------------------- 136 | 137 | For the WPA2 Enterprise setup, please use your google-foo. 138 | This is an advanced topic! 139 | 140 | 4.) Put that file on to the "/boot" partition, 141 | this partition is FAT32 formatted and should be visible if you plug the SD Card into your computer. 142 | 143 | If you created a file while the Pi was running, copy that file to boot. 144 | Assuming you created the file in your users "home" directory use 145 | 146 | sudo cp -v wpa_supplicant.conf /boot/ 147 | 148 | 5.) Almost done... Please reboot the pi and wait for it to connect. 149 | 150 | NOTE: 151 | 152 | Attach a screen and watch the console output to get its IP address or 153 | consult your router setup page to grab that information. 154 | 155 | You could also try to reach it by its hostname. 156 | 157 | http://.local 158 | 159 | If you didnt change the hostname during initial flash, you could use 160 | 161 | http://OS_NAME.local 162 | 163 | 6.) Enjoy OS_NAME :) 164 | -------------------------------------------------------------------------------- /src/modules/net/filesystem/boot/wpa_supplicant.conf.example: -------------------------------------------------------------------------------- 1 | # Simple configuration for a typical WPA2 network 2 | 3 | ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev 4 | update_config=1 5 | country=US # US Country code 6 | 7 | network={ 8 | scan_ssid=1 9 | ssid="" 10 | psk="" 11 | proto=RSN 12 | key_mgmt=WPA-PSK 13 | pairwise=CCMP 14 | auth_alg=OPEN 15 | } 16 | -------------------------------------------------------------------------------- /src/modules/net/filesystem/etc/systemd/system/disable-wifi-pwr-mgmt.service: -------------------------------------------------------------------------------- 1 | #### Disable wifi power_save 2 | #### 3 | #### Written by Stephan Wendel aka KwadFan 4 | #### Copyright 2022 5 | #### https://github.com/mainsail-crew/MainsailOS 6 | #### 7 | #### This File is distributed under GPLv3 8 | #### 9 | #### Note: This is based on: 10 | #### https://www.intel.com/content/www/us/en/support/articles/000006168/boards-and-kits.html 11 | 12 | [Unit] 13 | Description=Disable power management for wlan0 14 | After=network.target 15 | 16 | [Service] 17 | Type=oneshot 18 | StandardOutput=tty 19 | ExecStart=/usr/local/bin/pwrsave off 20 | 21 | [Install] 22 | WantedBy=multi-user.target -------------------------------------------------------------------------------- /src/modules/net/filesystem/etc/udev/rules.d/070-wifi-powersave.rules: -------------------------------------------------------------------------------- 1 | ACTION=="add", \ 2 | SUBSYSTEM=="net", \ 3 | KERNEL=="wlan*" \ 4 | RUN+="/usr/sbin/iw %k set power_save off" -------------------------------------------------------------------------------- /src/modules/net/filesystem/usr/local/bin/pwrsave: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #### Disable wifi power_save 3 | #### 4 | #### Written by Stephan Wendel aka KwadFan 5 | #### Copyright 2022 6 | #### https://github.com/mainsail-crew/MainsailOS 7 | #### 8 | #### This File is distributed under GPLv3 9 | #### 10 | #### Note: This is based on: 11 | #### https://www.intel.com/content/www/us/en/support/articles/000006168/boards-and-kits.html 12 | 13 | 14 | ## Error handling 15 | set -eou pipefail 16 | 17 | ## Debug Mode 18 | #set -x 19 | 20 | ### Message func 21 | function help_msg { 22 | echo -e "Usage:\n" 23 | echo -e "\tpwrsave [ on | off ]" 24 | echo -e "\t\ton\tEnables Power Management of 'wlan0'" 25 | echo -e "\t\toff\tDisables Power Management of 'wlan0'\n" 26 | exit 1 27 | } 28 | 29 | function has_wifi { 30 | LC_ALL=C iwconfig wlan0 &> /dev/null && echo "0" || echo "1" 31 | } 32 | 33 | function check_wifi_present { 34 | # make sure to exit if command missing 35 | if [ -z "$(command -v iwconfig)" ]; then 36 | echo -e "Command 'iwconfig' not found ... [EXITING]" 37 | exit 1 38 | fi 39 | if [ "$(has_wifi)" != "0" ]; then 40 | echo -e "[ \e[33mWARN\e[0m ] No WiFi hardware present ... [SKIPPED]" 41 | exit 0 42 | fi 43 | } 44 | 45 | function disable_pwr_save { 46 | iwconfig wlan0 power off 47 | echo -e "[ \e[32mOK\e[0m ] Disabled Power Management for wlan0" 48 | } 49 | 50 | 51 | function enable_pwr_save { 52 | iwconfig wlan0 power on 53 | echo -e "[ \e[32mOK\e[0m ] Enabled Power Management for wlan0" 54 | } 55 | 56 | 57 | ### MAIN 58 | function main { 59 | local arg 60 | if [ "$(id -u)" != "0" ]; then 61 | echo -e "\n$(basename "${0}"): This script needs root priviledges!\n" 62 | exit 1 63 | fi 64 | if [ "${#}" == "0" ]; then 65 | echo -e "$(basename "${0}"): No argument set!" 66 | help_msg 67 | fi 68 | if [ "${#}" -gt 1 ]; then 69 | echo -e "$(basename "${0}"): Too many arguments set!" 70 | help_msg 71 | fi 72 | arg="${1}" 73 | case "${arg}" in 74 | "on") 75 | check_wifi_present 76 | enable_pwr_save 77 | ;; 78 | "off") 79 | check_wifi_present 80 | disable_pwr_save 81 | ;; 82 | ?|*) 83 | echo -e "$(basename "${0}"): Unknown argument '${arg}' !" 84 | help_msg 85 | ;; 86 | esac 87 | } 88 | 89 | main "${@}" 90 | exit 0 91 | -------------------------------------------------------------------------------- /src/modules/net/filesystem/usr/local/bin/pwrsave-udev: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #### Disable wifi power_save 3 | #### 4 | #### Written by Stephan Wendel aka KwadFan 5 | #### Copyright 2022 6 | #### https://github.com/mainsail-crew/MainsailOS 7 | #### 8 | #### This File is distributed under GPLv3 9 | #### 10 | #### Note: This is based on: 11 | #### https://www.intel.com/content/www/us/en/support/articles/000006168/boards-and-kits.html 12 | 13 | 14 | ## Error handling 15 | set -eou pipefail 16 | 17 | ## Debug Mode 18 | #set -x 19 | 20 | ### Message func 21 | function help_msg { 22 | echo -e "Usage:\n" 23 | echo -e "\tpwrsave-udev [ on | off | create ]" 24 | echo -e "\t\ton\tEnables Power Management via udev rule" 25 | echo -e "\t\toff\tDisables Power Management via udev rule" 26 | echo -e "\t\tcreate\tCreate Power Management udev rule\n" 27 | exit 1 28 | } 29 | 30 | 31 | ### Check rule exist 32 | function check_rule { 33 | if [ ! -f /etc/udev/rules.d/070-wifi-powersave.rules ]; then 34 | echo -e "[ \e[31mERROR\e[0m ] Udev Rule for WiFi Powermanagement not found!" 35 | help_msg 36 | exit 1 37 | fi 38 | } 39 | 40 | function disable_pwr_save { 41 | sed -i 's/on/off/' /etc/udev/rules.d/070-wifi-powersave.rules 42 | echo -e "[ \e[32mOK\e[0m ] Disabled Power Management" 43 | } 44 | 45 | 46 | function enable_pwr_save { 47 | sed -i 's/off/on/' /etc/udev/rules.d/070-wifi-powersave.rules 48 | echo -e "[ \e[32mOK\e[0m ] Enabled Power Management" 49 | } 50 | 51 | function create_rule { 52 | if [ -f /etc/udev/rules.d/070-wifi-powersave.rules ]; then 53 | echo -e "[ \e[33mSKIPPED\e[0m ] Udev rule already exists!" 54 | exit 0 55 | fi 56 | 57 | cat << EOF > /etc/udev/rules.d/070-wifi-powersave.rules 58 | ACTION=="add", \ 59 | SUBSYSTEM=="net", \ 60 | KERNEL=="wlan*" \ 61 | RUN+="/usr/sbin/iw %k set power_save off" 62 | EOF 63 | echo -e "[ \e[32mOK\e[0m ] Created Udev rule ... \n" 64 | echo -e "Please 'reboot' to take changes effect.\n" 65 | } 66 | 67 | 68 | 69 | ### MAIN 70 | function main { 71 | local arg 72 | if [ "$(id -u)" != "0" ]; then 73 | echo -e "\n$(basename "${0}"): This script needs root priviledges!\n" 74 | exit 1 75 | fi 76 | if [ "${#}" == "0" ]; then 77 | echo -e "$(basename "${0}"): No argument set!" 78 | help_msg 79 | fi 80 | if [ "${#}" -gt 1 ]; then 81 | echo -e "$(basename "${0}"): Too many arguments set!" 82 | help_msg 83 | fi 84 | arg="${1}" 85 | if [ "${arg}" == "create" ]; then 86 | create_rule 87 | exit 0 88 | fi 89 | check_rule 90 | case "${arg}" in 91 | "on") 92 | enable_pwr_save 93 | ;; 94 | "off") 95 | disable_pwr_save 96 | ;; 97 | ?|*) 98 | echo -e "$(basename "${0}"): Unknown argument '${arg}' !" 99 | help_msg 100 | ;; 101 | esac 102 | } 103 | 104 | main "${@}" 105 | exit 0 106 | -------------------------------------------------------------------------------- /src/modules/net/start_chroot_script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Network 3 | # Adds to /boot configuration files that let you set up wifi network before booting 4 | # Written by Guy Sheffer and Gina Häußge 5 | # GPL V3 6 | # 7 | # Modified by Stephan Wendel aka KwadFan 8 | # https://github.com/mainsail-crew/MainsailOS 9 | # Last modification: August/2022 10 | # 11 | ######## 12 | set -x 13 | set -e 14 | 15 | export LC_ALL=C 16 | 17 | # shellcheck disable=SC1091 18 | source /common.sh 19 | install_cleanup_trap 20 | 21 | unpack /filesystem/boot /"${BASE_BOOT_MOUNT_PATH}" 22 | 23 | if [ "${BASE_DISTRO}" == "ubuntu" ] || [ "${BASE_DISTRO}" == "armbian" ]; then 24 | { 25 | echo "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev"; 26 | echo "update_config=1"; 27 | echo "ap_scan=1"; 28 | echo "country=US"; 29 | } >> /etc/wpa_supplicant/wpa_supplicant.conf 30 | fi 31 | 32 | if [ "${BASE_DISTRO}" == "raspbian" ]; then 33 | # Workaround rfkill not unblocking on boot 34 | rm /var/lib/systemd/rfkill/* 35 | fi 36 | 37 | # set OS_NAME in Wifi-README.txt according to DIST_NAME 38 | if [ -f "/boot/WiFi-README.txt" ]; then 39 | sed -i 's|OS_NAME|'"${DIST_NAME}"'|g' /boot/WiFi-README.txt 40 | fi 41 | 42 | 43 | # copy /etc/wpa_supplicant/ifupdown.sh to /etc/ifplugd/action.d/ifupdown - for wlan auto reconnect 44 | [ -f /etc/ifplugd/action.d/ifupdown ] && mv /etc/ifplugd/action.d/ifupdown /etc/ifplugd/action.d/ifupdown.original 45 | [ -f /etc/wpa_supplicant/ifupdown.sh ] && ln -s /etc/wpa_supplicant/ifupdown.sh /etc/ifplugd/action.d/ifupdown 46 | 47 | if [ ! -f "/etc/rc.local" ];then 48 | echo 'exit 0' >> /etc/rc.local 49 | fi 50 | 51 | # prevent ntp updates from failing due to some Rpi3 weirdness, see also "Fix SSH" further below 52 | apt-get update --allow-releaseinfo-change 53 | apt-get install -y iptables 54 | sed -i 's@exit 0@@' /etc/rc.local 55 | echo '/sbin/iptables -t mangle -I POSTROUTING 1 -o wlan0 -p udp --dport 123 -j TOS --set-tos 0x00' >> /etc/rc.local 56 | echo 'exit 0' >> /etc/rc.local 57 | 58 | # Install powersave option 59 | if [ "$NETWORK_DISABLE_PWRSAVE" == "yes" ]; then 60 | 61 | # Copy pwrsave script 62 | unpack filesystem/usr/local/bin /usr/local/bin root 63 | 64 | # Use rc.local 65 | if [ "$NETWORK_PWRSAVE_TYPE" == "rclocal" ]; then 66 | echo_green "Modifying /etc/rc.local ..." 67 | sed -i 's@exit 0@@' /etc/rc.local 68 | (echo "# Disable WiFi Power Management"; \ 69 | echo 'echo "Disabling power management for wlan0 ..."' ; \ 70 | echo "/usr/local/bin/pwrsave off"; echo "exit 0") >> /etc/rc.local 71 | fi 72 | # Use service 73 | if [ "$NETWORK_PWRSAVE_TYPE" == "service" ]; then 74 | echo_green "Installing disable-wifi-pwr-mgmt service ..." 75 | unpack filesystem/etc/systemd/system /etc/systemd/system root 76 | systemctl_if_exists enable disable-wifi-pwr-mgmt.service 77 | fi 78 | # Use udev rule 79 | if [ "$NETWORK_PWRSAVE_TYPE" == "udev" ]; then 80 | echo_green "Installing WiFi Power Management udev rule ..." 81 | unpack filesystem/etc/udev/rules.d /etc/udev/rules.d root 82 | fi 83 | # strip out unneeded script, depending on choose 84 | if [ "$NETWORK_PWRSAVE_TYPE" != "udev" ]; then 85 | rm -f /usr/local/bin/pwrsave-udev 86 | else 87 | rm -f /usr/local/bin/pwrsave 88 | fi 89 | fi 90 | -------------------------------------------------------------------------------- /src/modules/piconfig/config: -------------------------------------------------------------------------------- 1 | [ -n "$PICONFIG_CONFIG_TXT_FILE" ] || PICONFIG_CONFIG_TXT_FILE="/boot/config.txt" 2 | [ -n "$PICONFIG_CMDLINE_TXT_FILE" ] || PICONFIG_CMDLINE_TXT_FILE="/boot/cmdline.txt" 3 | [ -n "$PICONFIG_CONFIG_BAK_FILE" ] || PICONFIG_CONFIG_BAK_FILE="/boot/orig-config.txt" 4 | [ -n "$PICONFIG_CMDLINE_BAK_FILE" ] || PICONFIG_CMDLINE_BAK_FILE="/boot/orig-cmdline.txt" 5 | -------------------------------------------------------------------------------- /src/modules/piconfig/filesystem/root/boot/config.txt: -------------------------------------------------------------------------------- 1 | # For more options and information see 2 | # http://rpf.io/configtxt 3 | # Some settings may impact device functionality. See link above for details 4 | 5 | # uncomment if you get no picture on HDMI for a default "safe" mode 6 | #hdmi_safe=1 7 | 8 | # uncomment this if your display has a black border of unused pixels visible 9 | # and your display can output without overscan 10 | #disable_overscan=1 11 | 12 | # uncomment the following to adjust overscan. Use positive numbers if console 13 | # goes off screen, and negative if there is too much border 14 | #overscan_left=16 15 | #overscan_right=16 16 | #overscan_top=16 17 | #overscan_bottom=16 18 | 19 | # uncomment to force a console size. By default it will be display's size minus 20 | # overscan. 21 | #framebuffer_width=1280 22 | #framebuffer_height=720 23 | 24 | # uncomment if hdmi display is not detected and composite is being output 25 | #hdmi_force_hotplug=1 26 | 27 | # uncomment to force a specific HDMI mode (this will force VGA) 28 | #hdmi_group=1 29 | #hdmi_mode=1 30 | 31 | # uncomment to force a HDMI mode rather than DVI. This can make audio work in 32 | # DMT (computer monitor) modes 33 | #hdmi_drive=2 34 | 35 | # uncomment to increase signal to HDMI, if you have interference, blanking, or 36 | # no display 37 | #config_hdmi_boost=4 38 | 39 | # uncomment for composite PAL 40 | #sdtv_mode=2 41 | 42 | #uncomment to overclock the arm. 700 MHz is the default. 43 | #arm_freq=800 44 | 45 | # Uncomment some or all of these to enable the optional hardware interfaces 46 | #dtparam=i2c_arm=on 47 | #dtparam=i2s=on 48 | dtparam=spi=on 49 | 50 | # Uncomment this to enable infrared communication. 51 | #dtoverlay=gpio-ir,gpio_pin=17 52 | #dtoverlay=gpio-ir-tx,gpio_pin=18 53 | 54 | # Additional overlays and parameters are documented /boot/overlays/README 55 | 56 | # Enable audio (loads snd_bcm2835) 57 | dtparam=audio=on 58 | 59 | 60 | #################################################### 61 | #### MainsailOS specific configurations #### 62 | #################################################### 63 | #### DO NOT CHANGE SECTION BELOW !!! #### 64 | #### UNLESS YOU KNOW WHAT YOU ARE DOING !!! #### 65 | #################################################### 66 | 67 | ## For more options and information see 68 | ## https://www.raspberrypi.com/documentation/computers/config_txt.html 69 | ## Some settings may impact device functionality. See link above for details 70 | 71 | ## For additional information about device filters see 72 | ## https://www.raspberrypi.com/documentation/computers/config_txt.html#model-filters 73 | 74 | 75 | [pi0] 76 | ## This affects Pi Zero(W) and Pi Zero2 77 | ## Due lag of RAM, limit GPU RAM 78 | gpu_mem=128 79 | 80 | [pi2] 81 | gpu_mem=256 82 | 83 | [pi3] 84 | ## Use 256 if 1Gb Ram Model! 85 | gpu_mem=128 86 | # gpu_mem=256 87 | 88 | [pi4] 89 | ## Enable DRM VC4 V3D driver on top of the dispmanx display stack 90 | dtoverlay=vc4-fkms-v3d 91 | max_framebuffers=2 92 | ## Do not use more than 256Mb on Pi Model 4, it uses its own Management. 93 | gpu_mem=256 94 | 95 | [all] 96 | 97 | ## SPI Interface is enabled by default for Input Shaper 98 | ## To revert that comment out line #48 99 | ## This colides with Hyperpixel Display! 100 | ## Hyperpixel Screen uses the same Pin for Backlight. 101 | 102 | ## Enable Hardware UART for Serial Communication 103 | enable_uart=1 104 | dtoverlay=disable-bt 105 | 106 | ## Enable VideoCore at boot, needed for Raspicams and DSI devices. 107 | start_x=1 108 | 109 | ### EXPERIMENTAL - Enable 64bit Kernel 110 | ### The 64-bit kernel will only work on: 111 | ### Raspberry Pi 3, 3+, 4, 400, Zero 2 W and 2B rev 1.2 112 | ### and Raspberry Pi Compute Modules 3, 3+ and 4. 113 | # arm_64bit=1 114 | 115 | #################################################### 116 | -------------------------------------------------------------------------------- /src/modules/piconfig/filesystem/root/etc/dphys-swapfile: -------------------------------------------------------------------------------- 1 | # /etc/dphys-swapfile - user settings for dphys-swapfile package 2 | # author Neil Franklin, last modification 2010.05.05 3 | # copyright ETH Zuerich Physics Departement 4 | # use under either modified/non-advertising BSD or GPL license 5 | 6 | # this file is sourced with . so full normal sh syntax applies 7 | 8 | # the default settings are added as commented out CONF_*=* lines 9 | 10 | 11 | # where we want the swapfile to be, this is the default 12 | #CONF_SWAPFILE=/var/swap 13 | 14 | # set size to absolute value, leaving empty (default) then uses computed value 15 | # you most likely don't want this, unless you have an special disk situation 16 | CONF_SWAPSIZE=256 17 | 18 | # set size to computed value, this times RAM size, dynamically adapts, 19 | # guarantees that there is enough swap without wasting disk space on excess 20 | #CONF_SWAPFACTOR=2 21 | 22 | # restrict size (computed and absolute!) to maximally this limit 23 | # can be set to empty for no limit, but beware of filled partitions! 24 | # this is/was a (outdated?) 32bit kernel limit (in MBytes), do not overrun it 25 | # but is also sensible on 64bit to prevent filling /var or even / partition 26 | CONF_MAXSWAP=1024 27 | -------------------------------------------------------------------------------- /src/modules/piconfig/start_chroot_script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Preinstall customized config.txt 3 | # Written by Stephan Wendel aka KwadFan 4 | # This file may distributed under GPLv3 5 | # Copyright 2021 6 | ######## 7 | 8 | # Source error handling, leave this in place 9 | set -e 10 | 11 | # Source CustomPIOS common.sh 12 | source /common.sh 13 | install_cleanup_trap 14 | 15 | echo_green "Backup original config.txt and cmdline.txt ..." 16 | mv "${PICONFIG_CONFIG_TXT_FILE}" "${PICONFIG_CONFIG_BAK_FILE}" 17 | cp "${PICONFIG_CMDLINE_TXT_FILE}" "${PICONFIG_CMDLINE_BAK_FILE}" 18 | 19 | echo_green "Copying files to root filesystem ..." 20 | unpack /filesystem/root / 21 | 22 | ### Disable Console and services to enable Hardware Serial. 23 | echo_green "Disable Serial Linux console ..." 24 | sed -i 's/console=serial0,115200 //' "${PICONFIG_CMDLINE_TXT_FILE}" 25 | 26 | ### disable bluetooth and related services 27 | echo_green "Disabling Bluetooth related services..." 28 | systemctl_if_exists disable hciuart.service 29 | systemctl_if_exists disable bluetooth.service 30 | systemctl_if_exists disable bluealsa.service 31 | -------------------------------------------------------------------------------- /src/modules/postrename/config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #### Post Rename 3 | #### 4 | #### Written by Stephan Wendel aka KwadFan 5 | #### Copyright 2021 6 | #### https://github.com/mainsail-crew/MainsailOS 7 | #### 8 | #### This File is distributed under GPLv3 9 | #### 10 | # shellcheck disable=all 11 | 12 | # Intentionally left blank 13 | -------------------------------------------------------------------------------- /src/modules/postrename/filesystem/root/postrename: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #### Post Rename 3 | #### 4 | #### Written by Stephan Wendel aka KwadFan 5 | #### Copyright 2021 6 | #### https://github.com/mainsail-crew/MainsailOS 7 | #### 8 | #### This File is distributed under GPLv3 9 | #### 10 | 11 | ## Error handling 12 | set -e 13 | 14 | # Colored Output 15 | RED="\e[31m" 16 | YEL="\e[33m" 17 | GRE="\e[32m" 18 | WHITE="\e[97m" 19 | NOC="\e[0m" 20 | 21 | ### Setup 22 | SERVICES=(moonraker klipper nginx sonar crowsnest) 23 | SYSTEMD_DIR="/etc/systemd/system" 24 | DEFAULT_USER="$(grep "1000" /etc/passwd | awk -F ':' '{print $1}')" 25 | 26 | 27 | ## Helper funcs 28 | ### Mangle services 29 | function stop_services { 30 | for srv in "${SERVICES[@]}"; do 31 | if [ "$(systemctl is-active "${srv}.service")" != "inactive" ]; then 32 | systemctl stop "${srv}.service" 33 | fi 34 | done 35 | } 36 | 37 | function start_services { 38 | for srv in "${SERVICES[@]}"; do 39 | systemctl start "${srv}.service" 40 | done 41 | } 42 | 43 | ### Clean up 44 | function cleanup { 45 | # Cleanup self 46 | rm -rf "${0}" 47 | # Cleanup rc.local 48 | sed -i '/\/postrename/d' /etc/rc.local 49 | } 50 | 51 | ### Change nginx root 52 | function change_www_root { 53 | bash -c " 54 | sed -i 's|/home/pi/mainsail|/home/${DEFAULT_USER}/mainsail|g' \ 55 | /etc/nginx/sites-available/mainsail 56 | " 57 | } 58 | 59 | 60 | ### change username in service files 61 | function change_service_user { 62 | ### Filter nginx service first! 63 | local -a servicefile 64 | servicefile=( "${SERVICES[@]/nginx}" ) 65 | 66 | for i in "${servicefile[@]}"; do 67 | if [ -n "${i}" ]; then 68 | sed -i 's/pi/'"${DEFAULT_USER}"'/g' "${SYSTEMD_DIR}/${i}.service" 69 | fi 70 | done 71 | } 72 | 73 | function relocate_venv { 74 | local -a venvs 75 | venvs=(klippy-env moonraker-env) 76 | 77 | for venv in "${venvs[@]}"; do 78 | # Move venv 79 | # delete pycache (*.pyc files) 80 | find "/home/${DEFAULT_USER}/${venv}" -name "__pycache__" -type d -exec rm -rf {} + 81 | 82 | # repair shebangs 83 | while IFS= read -r file ; do 84 | 85 | sed -i 's|pi/'"${venv}"'|'"${DEFAULT_USER}"'/'"${venv}"'|g' "${file}" 86 | 87 | done < <(grep -iR "pi/${venv}" "/home/${DEFAULT_USER}/${venv}"/* | cut -d":" -f1) 88 | 89 | done 90 | } 91 | 92 | function patch_polkit_rules { 93 | local polkit_dir polkit_legacy_dir polkit_usr_dir 94 | polkit_legacy_dir="/etc/polkit-1/localauthority/50-local.d" 95 | polkit_dir="/etc/polkit-1/rules.d" 96 | polkit_usr_dir="/usr/share/polkit-1/rules.d" 97 | if [ -f "${polkit_dir}/moonraker.rules" ]; then 98 | sed -i 's/pi/'"${DEFAULT_USER}"'/g' "${polkit_dir}/moonraker.rules" 99 | fi 100 | if [ -f "${polkit_usr_dir}/moonraker.rules" ]; then 101 | sed -i 's/pi/'"${DEFAULT_USER}"'/g' "${polkit_usr_dir}/moonraker.rules" 102 | fi 103 | if [ -f "${polkit_legacy_dir}/10-moonraker.pkla" ]; then 104 | sed -i 's/pi/'"${DEFAULT_USER}"'/g' "${polkit_legacy_dir}/10-moonraker.pkla" 105 | fi 106 | } 107 | 108 | function patch_cn_logrotate { 109 | if [ -f "/etc/logrotate.d/crowsnest" ]; then 110 | sed -i 's/pi/'"${DEFAULT_USER}"'/g' "/etc/logrotate.d/crowsnest" 111 | fi 112 | } 113 | 114 | ## Fix broken links 115 | function fix_broken_links { 116 | local -a brokenlinks 117 | local path 118 | brokenlinks=(crowsnest sonar) 119 | path="/usr/local/bin" 120 | 121 | for bl in "${brokenlinks[@]}"; do 122 | if [ -h "${path}/${bl}" ]; then 123 | rm -rf "${path:?}/${bl}" 124 | fi 125 | find "/home/${DEFAULT_USER}" -type f -iname "${bl}" -print0 | \ 126 | xargs -0 -I {} ln -s {} "${path}/${bl}" 127 | done 128 | } 129 | 130 | function fix_timelapse_links { 131 | local config_dir src_dir target_dir 132 | config_dir="/home/${DEFAULT_USER}/klipper_config" 133 | src_dir="/home/${DEFAULT_USER}/moonraker-timelapse" 134 | target_dir="/home/${DEFAULT_USER}/moonraker/moonraker/components" 135 | sudo -u "${DEFAULT_USER}" \ 136 | ln -sf "${src_dir}/component/timelapse.py" "${target_dir}/timelapse.py" 137 | sudo -u "${DEFAULT_USER}" \ 138 | ln -sf "${src_dir}/klipper_macro/timelapse.cfg" "${config_dir}/timelapse.cfg" 139 | } 140 | 141 | function main { 142 | local cmdltxt 143 | cmdltxt="/boot/cmdline.txt" 144 | 145 | ## Make sure init_resize.sh and firstrun.sh are finished 146 | if [ "$(grep -c "init" "${cmdltxt}")" != "0" ] && \ 147 | [ "$(grep -c "systemd.run.*" "${cmdltxt}")" != "0" ]; then 148 | echo -e "[${RED}ERROR${NOC}] \ 149 | ${WHITE}Sdcard resize and firtrun are not finished yet ... [ABORT]${NOC}" 150 | ## Make sure not failing rc.local 151 | return 0 152 | fi 153 | ## Abort if user = pi 154 | if [ "${DEFAULT_USER}" == "pi" ]; then 155 | echo -e "[${YEL}SKIPPED${NOC}] \ 156 | ${WHITE}User is ${DEFAULT_USER}! Nothing to do ...${NOC}" 157 | cleanup 158 | exit 0 159 | fi 160 | 161 | echo -e "\n\t${WHITE}Trying to fix user rename ...${NOC}" 162 | ## Stop services 163 | echo -en "${WHITE}Stopping all related services ...${NOC}\r" 164 | stop_services 165 | echo -e "${WHITE}Stopping all related services ...${NOC}[${GRE}OK${NOC}]" 166 | ## Change www root 167 | echo -en "${WHITE}Try changing path of nginx root ...${NOC}\r" 168 | change_www_root 169 | echo -e "${WHITE}Try changing path of nginx root ...${NOC}[${GRE}OK${NOC}]" 170 | ## patch service files 171 | echo -en "${WHITE}Patching service files ...${NOC}\r" 172 | change_service_user 173 | echo -e "${WHITE}Patching service files ...${NOC}[${GRE}OK${NOC}]" 174 | ## relocate venvs 175 | echo -e "${WHITE}Trying to relocate venv's ...${NOC}" 176 | relocate_venv 177 | echo -e "${WHITE}Trying to relocate venv's ...${NOC}[${GRE}OK${NOC}]" 178 | ## patch polkit rules 179 | echo -e "${WHITE}Patching moonraker's polkit rules ...${NOC}" 180 | patch_polkit_rules 181 | echo -e "${WHITE}Patching moonraker's polkit rules ...${NOC}[${GRE}OK${NOC}]" 182 | ## patch crowsnest logrotate 183 | echo -e "${WHITE}Patching crowsnest logrotate ...${NOC}" 184 | patch_cn_logrotate 185 | echo -e "${WHITE}Patching crowsnest logrotate ...${NOC}[${GRE}OK${NOC}]" 186 | ## fix broken links 187 | echo -en "${WHITE}Fix broken symlinks ...${NOC}\r" 188 | fix_broken_links 189 | fix_timelapse_links 190 | echo -e "${WHITE}Fix broken symlinks ...${NOC}[${GRE}OK${NOC}]" 191 | ## do a short break 192 | sleep 2 193 | ## reload daemons 194 | echo -en "${WHITE}Apply service file changes ...${NOC}\r" 195 | systemctl daemon-reload 196 | echo -e "${WHITE}Apply service file changes ...${NOC}[${GRE}OK${NOC}]" 197 | ## do a short break 198 | sleep 2 199 | ## restart services 200 | echo -e "${WHITE}Trying to restart services ...${NOC}" 201 | start_services 202 | ## wait 30sec to come up 203 | echo -e "${WHITE}Waiting for service restart completed ...${NOC}" 204 | sleep 30 205 | ## Cleanup 206 | echo -e "${WHITE}Cleanup files, remove postrename ...${NOC}" 207 | cleanup 208 | sleep 2 209 | ## reboot system 210 | echo -e "${WHITE}Reboot system ...${NOC}" 211 | reboot 212 | } 213 | 214 | ### MAIN 215 | main 216 | exit 0 217 | -------------------------------------------------------------------------------- /src/modules/postrename/start_chroot_script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #!/bin/bash 3 | #### Post Rename 4 | #### 5 | #### Written by Stephan Wendel aka KwadFan 6 | #### Copyright 2021 7 | #### https://github.com/mainsail-crew/MainsailOS 8 | #### 9 | #### This File is distributed under GPLv3 10 | #### 11 | # shellcheck disable=all 12 | 13 | # Source error handling, leave this in place 14 | set -xe 15 | 16 | # Source CustomPIOS common.sh 17 | source /common.sh 18 | install_cleanup_trap 19 | 20 | ## unpack postrename 21 | unpack filesystem/root / root 22 | ## set executable 23 | sudo chmod 0755 /postrename 24 | 25 | ## run postrename via rc.local 26 | sed -i 's@exit 0@@' /etc/rc.local 27 | echo -e "/postrename\nexit 0\n" | tee -a /etc/rc.local 28 | -------------------------------------------------------------------------------- /src/modules/sonar/config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #### Sonar - A WiFi Keepalive daemon 3 | #### 4 | #### Written by Stephan Wendel aka KwadFan 5 | #### Copyright 2022 6 | #### https://github.com/mainsail-crew/sonar 7 | #### 8 | #### This File is distributed under GPLv3 9 | #### 10 | # shellcheck disable=all 11 | 12 | # Sonar 13 | [ -n "$SONAR_REPO_SHIP" ] || SONAR_REPO_SHIP=https://github.com/mainsail-crew/sonar.git 14 | [ -n "$SONAR_REPO_BRANCH" ] || SONAR_REPO_BRANCH=main 15 | [ -n "$SONAR_DEPS" ] || SONAR_DEPS="git crudini iputils-ping" 16 | [ -n "$SONAR_DEFAULT_CONF_DIR" ] || SONAR_DEFAULT_CONF_DIR="/home/${BASE_USER}/klipper_config" 17 | [ -n "$SONAR_DEFAULT_CONF" ] || SONAR_DEFAULT_CONF="mainsail_default.conf" 18 | # Add Sonar to moonraker.conf (update_manager) bool (1:yes / 0:no) 19 | [ -n "$SONAR_ADD_SONAR_MOONRAKER" ] || SONAR_ADD_SONAR_MOONRAKER=1 20 | # Path to moonraker.conf (must be set if add to update_manager) 21 | [ -n "$SONAR_MOONRAKER_CONF" ] || SONAR_MOONRAKER_CONF="${SONAR_DEFAULT_CONF_DIR}/moonraker.conf" 22 | -------------------------------------------------------------------------------- /src/modules/sonar/start_chroot_script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #### Sonar - A WiFi Keepalive daemon 3 | #### 4 | #### Written by Stephan Wendel aka KwadFan 5 | #### Copyright 2022 6 | #### https://github.com/mainsail-crew/sonar 7 | #### 8 | #### This File is distributed under GPLv3 9 | #### 10 | 11 | # shellcheck enable=require-variable-braces 12 | 13 | ## Source error handling, leave this in place 14 | set -Eex 15 | 16 | ## Set LC_ALL to prevent errors 17 | export LC_ALL=C 18 | 19 | # Set DEBIAN_FRONTEND to noninteractive 20 | if [ "${DEBIAN_FRONTEND}" != "noninteractive" ]; then 21 | export DEBIAN_FRONTEND=noninteractive 22 | fi 23 | 24 | ## Source CustomPIOS common.sh 25 | # shellcheck disable=SC1091 26 | source /common.sh 27 | install_cleanup_trap 28 | 29 | # Setup template file 30 | MOONRAKER_TEMPLATE="/home/${BASE_USER}/sonar/file_templates/moonraker_update.txt" 31 | 32 | ## helper func moonraker update_manager 33 | function add_update_entry { 34 | if [ -f "${SONAR_MOONRAKER_CONF}" ]; then 35 | if [ -f "/tmp/moonraker.conf" ]; then 36 | rm -rf /tmp/moonraker.conf 37 | fi 38 | sudo -u "${BASE_USER}" \ 39 | cat "${SONAR_MOONRAKER_CONF}" "${MOONRAKER_TEMPLATE}" | \ 40 | tee /tmp/moonraker.conf > /dev/null && 41 | cp -rf /tmp/moonraker.conf "${SONAR_MOONRAKER_CONF}" 42 | fi 43 | } 44 | 45 | echo_green "Installing sonar and enable sonar Service ..." 46 | 47 | ## Install all deps at once for time consumption reasons. 48 | ## APT: Update Repo Database and install Dependencies 49 | # Force apt update 50 | apt update 51 | echo_green "Installing Sonar Dependencies ..." 52 | # shellcheck disable=SC2086 53 | ## Disabling shellcheck SC2086, because we want "wordsplitting" 54 | check_install_pkgs ${SONAR_DEPS} 55 | ## Move to $HOME dir 56 | pushd "/home/${BASE_USER}" &> /dev/null || exit 1 57 | ## clone Repo 58 | echo_green "Clone sonar repository ..." 59 | gitclone SONAR_REPO sonar 60 | ## Install sonar, using builtin installer 61 | pushd "/home/${BASE_USER}/sonar" &> /dev/null || exit 1 62 | echo_green "Running sonar installer ..." 63 | sudo -u "${BASE_USER}" make unattended 64 | ## Make sure config dir exits 65 | if [ ! -d "${SONAR_DEFAULT_CONF_DIR}" ]; then 66 | sudo -u "${BASE_USER}" mkdir -p "${SONAR_DEFAULT_CONF_DIR}" 67 | fi 68 | ## Copy default config 69 | echo_green "Copying default config file ..." 70 | sudo -u "${BASE_USER}" \ 71 | cp "${PWD}/sample_config/${SONAR_DEFAULT_CONF}" \ 72 | "${SONAR_DEFAULT_CONF_DIR}/sonar.conf" 73 | 74 | ## Add moonraker update_manager 75 | if [ "${SONAR_ADD_SONAR_MOONRAKER}" == "1" ]; then 76 | echo -en "Adding Sonar Update Manager entry to moonraker.conf ...\r" 77 | add_update_entry 78 | echo -e "Adding Sonar Update Manager entry to moonraker.conf ... [OK]" 79 | fi 80 | popd &> /dev/null || exit 1 81 | popd &> /dev/null || exit 1 82 | 83 | ## Done message 84 | echo_green "Installing sonar and enable sonar Service ... done!" 85 | -------------------------------------------------------------------------------- /src/modules/timelapse/config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # moonraker-timelapse custompios module 3 | # https://github.com/mainsail-crew/moonraker-timelapse 4 | # written by Stephan Wendel aka KwadFan 5 | # 6 | # GPL V3 7 | ######## 8 | # shellcheck disable=all 9 | [ -n "$TIMELAPSE_SRC_DIR" ] || TIMELAPSE_SRC_DIR="/home/${BASE_USER}/moonraker-timelapse" 10 | [ -n "$TIMELAPSE_PYTHON_DIR" ] || TIMELAPSE_TARGET_DIR="/home/${BASE_USER}/moonraker/moonraker/components" 11 | [ -n "$TIMELAPSE_CONFIG_DIR" ] || TIMELAPSE_CONFIG_DIR="/home/${BASE_USER}/klipper_config" 12 | [ -n "$TIMELAPSE_TEMPLATE" ] || TIMELAPSE_TEMPLATE="/home/${BASE_USER}/klipper_config/timelapse_template.txt" 13 | 14 | [ -n "$TIMELAPSE_REPO_SHIP" ] || TIMELAPSE_REPO_SHIP=https://github.com/mainsail-crew/moonraker-timelapse.git 15 | [ -n "$TIMELAPSE_REPO_BRANCH" ] || TIMELAPSE_REPO_BRANCH=main 16 | [ -n "$TIMELAPSE_DEPS" ] || TIMELAPSE_DEPS="ffmpeg" 17 | -------------------------------------------------------------------------------- /src/modules/timelapse/filesystem/home/pi/klipper_config/timelapse_template.txt: -------------------------------------------------------------------------------- 1 | 2 | ### moonraker-timelapse 3 | ### Don't forget to include timelapse.cfg to your printer.cfg 4 | ### Uncomment to enable moonraker-timelapse 5 | 6 | #[timelapse] 7 | 8 | #[update_manager timelapse] 9 | #type: git_repo 10 | #primary_branch: main 11 | #path: ~/moonraker-timelapse 12 | #origin: https://github.com/mainsail-crew/moonraker-timelapse.git 13 | #managed_services: klipper moonraker 14 | -------------------------------------------------------------------------------- /src/modules/timelapse/start_chroot_script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #### MainsailOS Build Chain 3 | #### 4 | #### moonraker-timelapse install module 5 | #### #!/bin/bash 6 | #### https://github.com/mainsail-crew/moonraker-timelapse 7 | #### 8 | #### Written by Stephan Wendel aka KwadFan 9 | #### Copyright 2022 10 | #### https://github.com/mainsail-crew/MainsailOS 11 | #### 12 | #### This File is distributed under GPLv3 13 | #### 14 | 15 | ###### THIS MODULE HAS TO BE PLACED RIGHT AFTER "moonraker" MODULE!!! 16 | 17 | # shellcheck enable=require-variable-braces 18 | 19 | ## Source error handling, leave this in place 20 | set -Eex 21 | 22 | ## Set LC_ALL to prevent errors 23 | export LC_ALL=C 24 | 25 | # Set DEBIAN_FRONTEND to noninteractive 26 | if [ "${DEBIAN_FRONTEND}" != "noninteractive" ]; then 27 | export DEBIAN_FRONTEND=noninteractive 28 | fi 29 | 30 | ## Source CustomPIOS common.sh 31 | # shellcheck disable=SC1091 32 | source /common.sh 33 | install_cleanup_trap 34 | 35 | ## helper func moonraker update_manager 36 | function add_timelapse_entry { 37 | if [ -f "${TIMELAPSE_CONFIG_DIR}/moonraker.conf" ]; then 38 | if [ -f "/tmp/moonraker.conf" ]; then 39 | rm -rf /tmp/moonraker.conf 40 | fi 41 | sudo -u "${BASE_USER}" \ 42 | cat "${TIMELAPSE_CONFIG_DIR}/moonraker.conf" "${TIMELAPSE_TEMPLATE}" | \ 43 | tee /tmp/moonraker.conf > /dev/null && 44 | cp -rf /tmp/moonraker.conf "${TIMELAPSE_CONFIG_DIR}/moonraker.conf" 45 | fi 46 | ## Cleanup template 47 | if [ -f "${TIMELAPSE_TEMPLATE}" ]; then 48 | rm -f "${TIMELAPSE_TEMPLATE}" 49 | fi 50 | } 51 | 52 | echo_green "Installing moonraker-timelapse plugin ..." 53 | 54 | ### Install template file 55 | unpack /filesystem/home/${BASE_USER} /home/${BASE_USER} ${BASE_USER} 56 | 57 | ## Install all deps at once for time consumption reasons. 58 | ## APT: Update Repo Database and install Dependencies 59 | # Force apt update 60 | apt update 61 | echo_green "Installing moonraker-timelapse Dependencies ..." 62 | ## Disabling shellcheck SC2086, because we want "wordsplitting" 63 | # shellcheck disable=SC2086 64 | check_install_pkgs ${TIMELAPSE_DEPS} 65 | 66 | 67 | ## Clone klipper repo 68 | pushd "/home/${BASE_USER}" &> /dev/null || exit 1 69 | gitclone TIMELAPSE_REPO moonraker-timelapse 70 | 71 | ## Link component 72 | if [ -d "${TIMELAPSE_TARGET_DIR}" ]; then 73 | echo "Linking extension to moonraker ..." 74 | sudo -u "${BASE_USER}" \ 75 | ln -sf "${TIMELAPSE_SRC_DIR}/component/timelapse.py" "${TIMELAPSE_TARGET_DIR}/timelapse.py" 76 | fi 77 | 78 | ## Link timelapse.cfg 79 | if [ -d "/home/${BASE_USER}/klipper_config" ]; then 80 | echo "Linking macro file ..." 81 | sudo -u "${BASE_USER}" \ 82 | ln -sf "${TIMELAPSE_SRC_DIR}/klipper_macro/timelapse.cfg" "${TIMELAPSE_CONFIG_DIR}/timelapse.cfg" 83 | fi 84 | 85 | ## Extend moonraker.conf 86 | echo "Modifying moonraker.conf ..." 87 | add_timelapse_entry 88 | 89 | 90 | popd || exit 1 91 | 92 | 93 | ## Done message 94 | echo_green "Installing moonraker-timelapse plugin ... done!" 95 | -------------------------------------------------------------------------------- /src/version: -------------------------------------------------------------------------------- 1 | 0.7.1 2 | --------------------------------------------------------------------------------