Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
  • Loading branch information
meteyou committed Jul 29, 2022
2 parents e20f357 + 1b78efb commit 7cddfdf
Show file tree
Hide file tree
Showing 32 changed files with 834 additions and 620 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Funding
patreon: meteyou
ko_fi: mainsail
42 changes: 42 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Bug report
description: Create a report to help us improve
labels: ["bug", "triage"]
body:
- type: markdown
attributes:
value: |
This issue form is for reporting bugs only!
If you have a feature request, please use [feature_request](/new?template=feature_request.yml)
- type: textarea
id: what-happened
attributes:
label: What happened
description: >-
A clear and concise description of what the bug is.
validations:
required: true
- type: textarea
id: expected-behavior
attributes:
label: What did you expect to happen
description: >-
A clear and concise description of what you expected to happen.
validations:
required: true
- type: textarea
id: repro-steps
attributes:
label: How to reproduce
description: >-
Minimal and precise steps to reproduce this bug.
validations:
required: true
- type: textarea
id: additional-info
attributes:
label: Additional information
description: |
If you have any additional information for us, use the field below.
Please note, you can attach logs, screenshots or screen recordings here, by
dragging and dropping files in the field below.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Mainsail Discord
url: https://discord.gg/skWTwTD
about: Quickest way to get in contact
40 changes: 40 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Feature request
description: Suggest an idea for this project
labels: ["feature request"]
body:
- type: markdown
attributes:
value: |
This issue form is for feature requests only!
If you've found a bug, please use [bug_report](/new?template=bug_report.yml)
- type: textarea
id: problem-description
attributes:
label: Is your feature request related to a problem? Please describe
description: >-
A clear and concise description of what the problem is.
validations:
required: true
- type: textarea
id: solution-description
attributes:
label: Describe the solution you'd like
description: >-
A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
id: possible-alternatives
attributes:
label: Describe alternatives you've considered
description: >-
A clear and concise description of any alternative solutions or features you've considered.
- type: textarea
id: additional-info
attributes:
label: Additional information
description: |
If you have any additional information for us, use the field below.
Please note, you can attach logs, screenshots or screen recordings here, by
dragging and dropping files in the field below.
Binary file added .github/sdcard-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 33 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
![downloads](https://img.shields.io/github/downloads/mainsail-crew/MainsailOS/total)
[![discord](https://img.shields.io/discord/758059413700345988?color=%235865F2&label=discord&logo=discord&logoColor=white&style=flat)](https://discord.gg/skWTwTD)
[![discord](https://img.shields.io/discord/758059413700345988?color=%235865F2&label=discord&logo=discord&logoColor=white&style=flat)](https://discord.gg/mainsail)

<p align="center">
<img src=".github/sdcard-logo.png" style="width:40%" >
</p>

# MainsailOS

![Mainsail Logo](https://github.com/meteyou/mainsail/raw/master/docs/assets/img/logo.png?raw=true)
A [Raspberry Pi OS](https://www.raspberrypi.org/software/) based distribution for 3D Printers. \
It includes everything to get started with Klipper Firmware and Mainsail.

Learn more about:

A [Raspberry Pi OS](https://www.raspberrypi.org/software/) based distribution for 3d Printers. It includes everything to get started with Klipper Firmware and Mainsail.
- [Klipper Firmware](https://www.klipper3d.org/)
- [Moonraker](https://moonraker.readthedocs.io/en/latest/)
- [Mainsail](https://docs.mainsail.xyz/)

Learn More about...
Klipper Firmware: https://www.klipper3d.org/
Moonraker: https://moonraker.readthedocs.io/en/latest/
Mainsail: https://docs.mainsail.xyz/
## How to install MainsailOS ?

## Installing
You can find detailed instructions in our [documentation](https://docs.mainsail.xyz/setup/mainsail-os).

See the installation instructions on the Mainsail documentation page:
https://docs.mainsail.xyz/setup/mainsail-os
We recommend the installation via [Raspberry Pi Imager](https://docs.mainsail.xyz/setup/mainsailos/pi-imager).

## Community

For additional help, join us in the [Mainsail Discord](https://discord.gg/skWTwTD).
For additional help, join us on [Discord](https://discord.gg/mainsail).

[![discord](https://img.shields.io/discord/758059413700345988?color=%235865F2&label=discord&logo=discord&logoColor=white&style=flat)](https://discord.gg/skWTwTD)
[![discord](https://img.shields.io/discord/758059413700345988?color=%235865F2&label=discord&logo=discord&logoColor=white&style=flat)](https://discord.gg/mainsail)

## What is included?

Expand All @@ -30,30 +35,30 @@ Here a list of included and preinstalled Software:
- [Klipper (3D Printer Firmware)](https://github.com/KevinOConnor/klipper)
- [Moonraker (API Web Server for Klipper)](https://github.com/Arksine/moonraker)
- [Mainsail (Web interface for Klipper/Moonraker)](https://github.com/meteyou/mainsail)
- [Mjpeg-streamer (Webcam streaming)](https://github.com/jacksonliam/mjpg-streamer)
- [Crowsnest (Webcam streaming)](https://github.com/mainsail-crew/crowsnest)
- [Sonar (Keepalive daemon)](https://github.com/mainsail-crew/sonar)
- [Nginx (Webserver & Proxy)](https://nginx.org/en/)
- [FFMPEG (upcoming features)](https://www.ffmpeg.org/)

## also includes

- Enabled Serial Connection by default. \
Using Hardware UART (PL011) for Boards like BTT SKR Mini E3 V3
- Preinstalled Dependencies for Klipper's Input Shaper. \
You only need to build the [klipper_mcu](https://www.klipper3d.org/RPi_microcontroller.html) and installing the service. \
See [Klipper documentation](https://www.klipper3d.org/Measuring_Resonances.html) for more information.
- Preinstalled python3-serial package, needed for [CanBoot](https://github.com/Arksine/CanBoot)

## Screenshots

![screenshot-dashboard](https://raw.githubusercontent.com/mainsail-crew/docs/master/assets/img/screenshot.png)
![screenshot-dashboard](https://github.com/mainsail-crew/docs/raw/master/assets/img/screenshot.png)

# Build your own / Developing

To prevent you have to deal with an entire build chain setup, \
simply fork this repository.

Enable the workflows in your fork and you are good to go.
On every push you make, it will build an Image and upload it as artifact.

If you want or need to build locally please visit [CustomPiOS](https://github.com/guysoft/CustomPiOS)
Especcially ["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)

---

## Credits
Enable the workflows in your fork and you are good to go. \
On each push you make, an image is build and uploaded as an artifact.

We want to give a shoutout to [jottr](https://github.com/jottr) for mentioning a naming convention problem.\
In the past we used 'raspbian' at some points for names.\
But this isn't technicaly true.\
MainsailOS is based of Raspberry Pi OS, not raspbian.
If you want or need to build locally please visit [CustomPiOS](https://github.com/guysoft/CustomPiOS). \
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)
4 changes: 2 additions & 2 deletions src/config
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Shebang for better detection of file type

export DIST_NAME=MainsailOS
export DIST_VERSION=0.6.1
export DIST_VERSION=0.7.0
export BASE_IMAGE_ENLARGEROOT=2500
export MODULES="base,pkgupgrade,mainsailos(network,piconfig,klipper,is_req_preinstall,moonraker,mainsail,mjpgstreamer,serialcomm,password-for-sudo)"
export MODULES="base,pkgupgrade,mainsailos(network,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename"
export BASE_RELEASE_COMPRESS=yes
export BASE_IMAGE_RESIZEROOT=600
28 changes: 28 additions & 0 deletions src/modules/crowsnest/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
#### crowsnest - A webcam Service for multiple Cams and Stream Services.
####
#### Written by Stephan Wendel aka KwadFan <[email protected]>
#### Copyright 2021
#### https://github.com/mainsail-crew/crowsnest
####
#### This File is distributed under GPLv3
####
# shellcheck disable=all

# crowsnest
[ -n "$CROWSNEST_CROWSNEST_REPO_SHIP" ] || CROWSNEST_CROWSNEST_REPO_SHIP=https://github.com/mainsail-crew/crowsnest.git
[ -n "$CROWSNEST_CROWSNEST_REPO_BRANCH" ] || CROWSNEST_CROWSNEST_REPO_BRANCH=master
[ -n "$CROWSNEST_CROWSNEST_DEPS" ] || CROWSNEST_CROWSNEST_DEPS="git crudini bsdutils findutils v4l-utils ffmpeg"
[ -n "$CROWSNEST_DEFAULT_CONF" ] || CROWSNEST_DEFAULT_CONF="mainsail_default.conf"
[ -n "$CROWSNEST_DEFAULT_CONF_DIR" ] || CROWSNEST_DEFAULT_CONF_DIR="/home/${BASE_USER}/klipper_config"
# Force Raspicam fix bool (1:yes / 0:no)
[ -n "$CROWSNEST_FORCE_RASPICAMFIX" ] || CROWSNEST_FORCE_RASPICAMFIX=1
# Add Crowsnest to moonraker.conf (update manager) bool (1:yes / 0:no)
[ -n "$CROWSNEST_ADD_CROWSNEST_MOONRAKER" ] || CROWSNEST_ADD_CROWSNEST_MOONRAKER=1


# ustreamer
[ -n "$CROWSNEST_USTREAMER_DEPS" ] || CROWSNEST_USTREAMER_DEPS="git build-essential libevent-dev libjpeg-dev \
libbsd-dev libraspberrypi-dev libgpiod-dev"
[ -n "$CROWSNEST_USTREAMER_WITH_OMX" ] || CROWSNEST_USTREAMER_WITH_OMX="y"
[ -n "$CROWSNEST_USTREAMER_WITH_GPIO" ] || CROWSNEST_USTREAMER_WITH_GPIO="n"
49 changes: 49 additions & 0 deletions src/modules/crowsnest/start_chroot_script
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash

#### crowsnest - A webcam Service for multiple Cams and Stream Services.
####
#### Written by Stephan Wendel aka KwadFan <[email protected]>
#### Copyright 2021
#### https://github.com/mainsail-crew/crowsnest
####
#### This File is distributed under GPLv3
####

# shellcheck disable=all

# Error handling
set -Ee

source /common.sh
install_cleanup_trap

echo_green "Installing crowsnest and enable webcam Service ..."
# install dependencies
# force apt update
apt update
# It could use inbuilt dependencie check, but should speed up if preinstalled.
# shellcheck disable=SC2086
check_install_pkgs ${CROWSNEST_CROWSNEST_DEPS} ${CROWSNEST_USTREAMER_DEPS}
# Move to $HOME dir
pushd "/home/${BASE_USER}" &> /dev/null || exit 1
# make sure config folder exist
if [ ! -d "${CROWSNEST_DEFAULT_CONF_DIR}" ]; then
sudo -u "${BASE_USER}" mkdir -p "${CROWSNEST_DEFAULT_CONF_DIR}"
fi
# clone Repo
echo_green "Clone crowsnest repository ..."
gitclone CROWSNEST_CROWSNEST_REPO crowsnest
# install crowsnest - use crowsnest's make unattended
pushd "/home/${BASE_USER}/crowsnest" &> /dev/null || exit 1
echo_green "Launch crowsnest install routine ..."
pushd "/home/${BASE_USER}/crowsnest" &> /dev/null || exit 1
sudo -u "${BASE_USER}" make unattended
# Apply Raspicam fix if enabled.
if [ "${CROWSNEST_FORCE_RASPICAMFIX}" == "1" ]; then
echo -en "Applying Raspicam Fix ... \r"
sudo sh -c 'echo "bcm2835-v4l2" >> /etc/modules'
sudo cp file_templates/bcm2835-v4l2.conf /etc/modprobe.d/
echo -e "Applying Raspicam Fix ... [OK]"
fi
popd &> /dev/null || exit 1
popd &> /dev/null || exit 1
6 changes: 4 additions & 2 deletions src/modules/is_req_preinstall/config
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
# shellcheck disable=all
[ -n "$IS_REQ_PREINSTALL_VENV_DIR" ] || IS_REQ_PREINSTALL_VENV_DIR=/home/${BASE_USER}/klippy-env
[ -n "$IS_REQ_PREINSTALL_DEPS" ] || IS_REQ_PREINSTALL_DEPS="python3-numpy python3-matplotlib"
[ -n "$IS_REQ_PREINSTALL_PIP" ] || IS_REQ_PREINSTALL_PIP="numpy"
[ -n "$IS_REQ_PREINSTALL_CFG_FILE" ] || IS_REQ_PREINSTALL_CFG_FILE="/boot/config.txt"
[ -n "$IS_REQ_PREINSTALL_PIP" ] || IS_REQ_PREINSTALL_PIP="numpy<=1.21.4"
[ -n "$IS_REQ_PREINSTALL_CFG_FILE" ] || IS_REQ_PREINSTALL_CFG_FILE="/boot/config.txt"
68 changes: 35 additions & 33 deletions src/modules/is_req_preinstall/start_chroot_script
Original file line number Diff line number Diff line change
@@ -1,59 +1,61 @@
#!/usr/bin/env bash
#
# Copyright 2021 by Stephan Wendel aka KwadFan
# <[email protected]>
# This file may distributed under GPLv3
########

### For easier maintainability look to klipper/config.
#### MainsailOS Build Chain
####
#### Klipper Install Module
####
#### Written by Stephan Wendel aka KwadFan <[email protected]>
#### Copyright 2021 - 2022
#### https://github.com/mainsail-crew/MainsailOS
####
#### This File is distributed under GPLv3
####

# shellcheck enable=require-variable-braces

## Source error handling, leave this in place
set -xe
set -Eex

# Set LC_ALL to prevent errors
export LC_ALL=C

# Set DEBIAN_FRONTEND to noninteractive
if [ "${DEBIAN_FRONTEND}" != "noninteractive" ]; then
export DEBIAN_FRONTEND=noninteractive
fi

# Source CustomPIOS common.sh
# shellcheck disable=SC1091
source /common.sh
install_cleanup_trap

echo_green "Input Shaper Requirements preinstall"
echo_green "Install Input Shaper requirements ..."

### install all deps at once for time consumption reasons.
## APT: Update Repo Database and install Dependencies

# Force apt update
apt update
echo_green "Installing Input Shaper Dependencies ..."
apt update && apt install ${IS_REQ_PREINSTALL_DEPS} -y

### numpy Parallelizing
function max_cores() {
local core_count
core_count="$(nproc)"
if [ "${core_count}" -lt 3 ]; then
echo "$core_count"
else
echo "$(("${core_count}" -1))"
fi
}

echo_green "System has $(nproc) Cores available."
echo_green "Using $(max_cores)..."
export NPY_NUM_BUILD_JOBS="$(max_cores)"

# shellcheck disable=SC2086
# Disabling shellcheck SC2086, because we want "wordsplitting"
check_install_pkgs ${IS_REQ_PREINSTALL_DEPS}

### Check for Klipper Venv installed.
pushd /home/${BASE_USER}
pushd "/home/${BASE_USER}" &> /dev/null || exit 1
if [ -d "${IS_REQ_PREINSTALL_VENV_DIR}" ] && [ -x "${IS_REQ_PREINSTALL_VENV_DIR}/bin/pip" ]; then
echo_green "Installing numpy..."
sudo -u ${BASE_USER} ${IS_REQ_PREINSTALL_VENV_DIR}/bin/pip install -v "${IS_REQ_PREINSTALL_PIP}"
sudo -u "${BASE_USER}" "${IS_REQ_PREINSTALL_VENV_DIR}"/bin/pip install -v "${IS_REQ_PREINSTALL_PIP}"
else
echo_red "Klipper Venv not found!"
return 1
fi

## Cleanup
sudo -u ${BASE_USER} rm -rf /home/${BASE_USER}/.cache
popd
echo_green "Cleanup ..."
sudo -u "${BASE_USER}" rm -rf "/home/${BASE_USER}/.cache"
popd &> /dev/null || exit 1

## Enable spi interface by default
echo_green "Enabling SPI Interface..."
sed -i 's/#dtparam=spi=on/dtparam=spi=on/' ${IS_REQ_PREINSTALL_CFG_FILE}
sed -i 's/#dtparam=spi=on/dtparam=spi=on/' "${IS_REQ_PREINSTALL_CFG_FILE}"

### EOF
echo_green "Install Input Shaper requirements ... done!"
Loading

0 comments on commit 7cddfdf

Please sign in to comment.