Skip to content

Commit

Permalink
[Automated] Merged develop into target master
Browse files Browse the repository at this point in the history
  • Loading branch information
meteyou authored May 23, 2023
2 parents 1957d67 + 991cfcd commit 6ba3d29
Show file tree
Hide file tree
Showing 17 changed files with 275 additions and 331 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ All notable changes to Mainsail will be documented in this file.
- Fix compress step (#205) | [fec2432](fec24320ea4bdcf51c9430e89443035b4ade70f1)
- Fix rpi-image.json workflow in Release.yml (#206) | [a03626a](a03626a54a21b1fa1175b458665ae14e9b755037)
- Remove enduser support msg from zero2 images (#209) | [4231216](42312164336966b8fabf72618f60216b6a797f04)
- Fix rpi-imager json value format for extract_size & image_download_size (#212) | [b82137c](b82137c14ea09f784478687d32a042c825af8262)
- Fix firstboot issue (#214) | [fae8b3f](fae8b3fd1f9f2b2cf2ca53e737f3862eddd62a36)

### Refactor

Expand All @@ -63,6 +65,7 @@ All notable changes to Mainsail will be documented in this file.
- Deactivate IPv6 in nginx per default (#157) | [40b3719](40b37192608e13b4f5e97b295840715a42974fb6)
- Change behavior of piconfig module (#180) | [825af74](825af74061c48043c1ae8390c0825d2220bd623f)
- Use mv to move the image from the workspace to the root (#203) | [b7acb1e](b7acb1e49c02d2d9f50dfdc3541c10f4f2b2becc)
- Drop armbian_pkgupgrade (#210) | [799a919](799a919c2c4f2f8bf46971de88a79ab7d0bea137)

### Documentation

Expand Down
2 changes: 1 addition & 1 deletion config/armbian/default
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ BASE_IMAGE_RESIZEROOT=600
# Compress not needed due compression done in workflow
BASE_RELEASE_COMPRESS=no
# Modules are valid for 32bit and 64bit images
MODULES="base,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)"
MODULES="base,udev_fix,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)"

# export Variables
export DOWNLOAD_BASE_URL
Expand Down
2 changes: 1 addition & 1 deletion config/orangepi/default
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ BASE_IMAGE_RESIZEROOT=600
# Compress not needed due compression done in workflow
BASE_RELEASE_COMPRESS=no
# Modules are valid for 32bit and 64bit images
MODULES="base,pkgupgrade,orangepi(orangepi_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)"
MODULES="base,pkgupgrade,udev_fix,orangepi(orangepi_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)"

# export Variables
export DOWNLOAD_BASE_URL
Expand Down
4 changes: 2 additions & 2 deletions config/raspberry/default
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
# Declare Variables before exporting.
# See https://www.shellcheck.net/wiki/SC2155

BASE_IMAGE_ENLARGEROOT=3000
BASE_IMAGE_ENLARGEROOT=4500
BASE_IMAGE_RESIZEROOT=600
# Compress not needed due compression done in workflow
BASE_RELEASE_COMPRESS=no
# Modules are valid for 32bit and 64bit images
MODULES="base,pkgupgrade,rpi_firstb_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename"
MODULES="base,pkgupgrade,udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename"

# export Variables
export BASE_IMAGE_ENLARGEROOT
Expand Down
42 changes: 40 additions & 2 deletions patches/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,48 @@

This Folder contains a script to patch MainsailOS to latest changes.

## Usage
## patch101.sh

`curl -sSL https://raw.githubusercontent.com/mainsail-crew/MainsailOS/develop/patches/patch.sh | bash`
This is intended to patch MainsailOS version 1.0.0 to 1.0.1
This fixes an error with WiFi powersave rules.
_**DO NOT RUN THIS ON LATER VERSIONS!!!**_

### Usage:

`curl -sSL https://raw.githubusercontent.com/mainsail-crew/MainsailOS/develop/patches/patch101.sh | bash`

This will ask you for sudo password!

In most cases a reboot is required!

## udev-fix.sh

This is intended to patch udev rules which has a Bug in udev package (version: 247.3-7+deb11u2 or 247.3-7+rpi1+deb11u2).
Which does not create `/dev/serial/by-id` symlinks for your MCU.\
For further details see:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1035094

This is fixed by:
https://github.com/systemd/systemd/pull/25246

What we do:

- Running `apt-get update`
- Running `apt-get upgrade --yes`
- `curl`ing the patched rule file from systemd repo
- Copying to desired location in `/etc/udev/rules.d/60-serial.rules`

This overwrites behaviour in the default configuration.
Since this is the version of the master branch of systemd/udev there is no further
need to intervention even on updates.

_**NOTE: DO NOT RUN THIS PATCH IF YOU ARE PRINTING!!!**_

### Usage:

`curl -sSL https://raw.githubusercontent.com/mainsail-crew/MainsailOS/develop/patches/udev-fix.sh | bash`

This will ask you for sudo password!

A reboot is essential!
2 changes: 1 addition & 1 deletion patches/patch.sh → patches/patch101.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
####
#### Written by Stephan Wendel aka KwadFan <[email protected]>
#### Copyright 2021
#### https://github.com/mainsail-crew/crowsnest
#### https://github.com/mainsail-crew/MainsailOS
####
#### This File is distributed under GPLv3
####
Expand Down
104 changes: 104 additions & 0 deletions patches/udev-fix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/usr/bin/env bash

#### Patch Script
#### This will patch MainsailOS udev rule
####
#### Written by Stephan Wendel aka KwadFan <[email protected]>
#### Copyright 2021
#### https://github.com/mainsail-crew/MainsailOS
####
#### This File is distributed under GPLv3
####

#### This should fix error in udev not creating symlinks fpr serial devices.
#### For details see: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1035094
#### This is fixed by: https://github.com/systemd/systemd/pull/25246
#### To fix this error in MainsailOS we implement that file as 'user rule'.

# shellcheck disable=SC2034

# Error Handling
set -eo pipefail

# Debug
# set -x

### Variables
DEBIAN_FRONTEND="noninteractive"
TITLE="\e[31mMainsailOS Patcher\e[0m - udev rule fix"
UDEV_PKG_VERSION="$(dpkg-query -s udev | grep "Version" | sed 's/Version\: //')"
UDEV_FIX_RAW_RULE_FILE="https://raw.githubusercontent.com/systemd/systemd/main/rules.d/60-serial.rules"
UDEV_FIX_TMP_FILE="/tmp/60-serial.rules"
UDEV_FIX_OUTPUT_FILE="/etc/udev/rules.d/60-serial.rules"

# Message Vars
MP_OK="\e[32mOK\e[0m"
MP_SK="\e[33mSKIPPED\e[0m"

## Helper funcs

## Message Funcs

echo_green(){
echo -e "\e[32m${1}\e[0m"
}

echo_red(){
echo -e "\e[31m${1}\e[0m"
}

echo_blue(){
echo -e "\e[34m${1}\e[0m"
}

echo_yellow(){
echo -e "\e[33m${1}\e[0m"
}

print_header(){
echo -e "${TITLE}\n"
echo_blue "Ahoi!"
echo -e "Please be patient, this might take a while ..."
echo_yellow "HINT: This should also work for any other Debian/Armbian based Distribution\n"
echo_red "\tYou'll be prompted for sudo password!\n"
# Dirty hack to grant root priviledges
sudo echo -e "\n"
echo -e "Trying to patch your system ..."
}

print_footer(){
echo -e "\nThank you for being patient ..."
echo_red "Reboot as soon as possible!\n"
}

# Patch Funcs

patch_udev(){
if [[ -n "${UDEV_PKG_VERSION}" ]] && [[ "${UDEV_PKG_VERSION}" =~ "deb11u2" ]]; then
echo_red "'udev' version: ${UDEV_PKG_VERSION}, is affected by bug ..."
echo_green "Install patched udev rule from systemd git repository ..."
curl -sSL "${UDEV_FIX_RAW_RULE_FILE}" > "${UDEV_FIX_TMP_FILE}"
sudo cp "${UDEV_FIX_TMP_FILE}" "${UDEV_FIX_OUTPUT_FILE}"
rm -f "${UDEV_FIX_TMP_FILE}"
else
echo_green "'udev' version: ${UDEV_PKG_VERSION}, is NOT affected by bug ... [SKIPPED]"
fi
}

### Main
# Step 1: Print Header
print_header

# Step 2: Run apt-get update
sudo apt-get update

# Step 3: Run apt-get upgrade
sudo apt-get upgrade --yes

# Step 4: Apply patches
patch_udev

# Step 5: Print footer
print_footer

exit 0
22 changes: 14 additions & 8 deletions src/modules/armbian/start_chroot_script
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ echo "${BASE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
apt update
# shellcheck disable=SC2086
check_install_pkgs ${ARMBIAN_DEPS}
## END Step 1



## Step 1: Manage groups
## Step 2: Manage groups
### Substep 1: Create group for gpio usage
sudo groupadd gpio
### END Substep 1
Expand All @@ -59,18 +59,19 @@ sudo groupadd gpio
if_group_exists_run i2c usermod -aG i2c "${BASE_USER}"
usermod -aG video,audio,plugdev,games,netdev,sudo,systemd-journal,gpio "${BASE_USER}"
### END Substep 2
## END Step 2

## Step 2: patch sshd_config
## Step 3: patch sshd_config
sed -i 's/PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config
sed -i 's/^X11Forwarding/#X11Forwarding/' /etc/ssh/sshd_config
sed -i 's/^#MaxAuthTries 6/MaxAuthTries 3/' /etc/ssh/sshd_config
## END
## END Step 3

## Step 4: Try patching first login in build stage
if [[ -f "/root/.not_logged_in_yet" ]]; then
rm -f /root/.not_logged_in_yet
fi
## END
## END Step 4

## Step 5: Move armbian-release to display mainsailos-release
### Substep 1: Move armbian-release
Expand All @@ -92,7 +93,7 @@ fi
sed -i "s|/etc/armbian-release|/etc/armbian-release-info.txt|g" "${f}"
done
popd &> /dev/null || exit 1
## END
## END Step 5

## Step 6: Patch dynamic motd
echo_green "Patch dynamic motd ..."
Expand All @@ -101,7 +102,7 @@ chmod +x /etc/update-motd.d/*
if [[ -f "/etc/default/armbian-motd" ]]; then
sed -i 's/MOTD_DISABLE=""/MOTD_DISABLE="header"/' /etc/default/armbian-motd
fi
## END
## END Step 6

## Step 7: Enable SPI interface by default
echo_green "Enable SPI interface on Orange Pi SBC's ..."
Expand All @@ -128,4 +129,9 @@ echo "spi-dev" >> "${ARMBIAN_MODULES_FILE}"
### END Substep 3

echo_green "Enable SPI interface on Orange Pi SBC's ... DONE!"
## END
## END Step 7

## Step 8: Remove unattended-upgrades
echo_green "Remove 'unattended-upgrades' service ..."
sudo apt-get remove --purge --yes unattended-upgrades
## END Step 8
7 changes: 5 additions & 2 deletions src/modules/crowsnest/config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#### crowsnest - A webcam Service for multiple Cams and Stream Services.
####
#### Written by Stephan Wendel aka KwadFan <[email protected]>
#### Copyright 2021 - 2022
#### Copyright 2021 - till today
#### https://github.com/mainsail-crew/crowsnest
####
#### This File is distributed under GPLv3
Expand All @@ -18,7 +18,6 @@
[[ -n "$CROWSNEST_CONFIG_PATH" ]] || CROWSNEST_CONFIG_PATH="/home/${BASE_USER}/printer_data/config"
[[ -n "$CROWSNEST_LOG_PATH" ]] || CROWSNEST_LOG_PATH="/home/${BASE_USER}/printer_data/logs"
[[ -n "$CROWSNEST_ENV_PATH" ]] || CROWSNEST_ENV_PATH="/home/${BASE_USER}/printer_data/systemd"
[[ -n "$CROWSNEST_RASPICAMFIX" ]] || CROWSNEST_RASPICAMFIX="1"
[[ -n "$CROWSNEST_ADD_CROWSNEST_MOONRAKER" ]] || CROWSNEST_ADD_CROWSNEST_MOONRAKER="1"
[[ -n "$CROWSNEST_MOONRAKER_CONF_PATH" ]] || CROWSNEST_MOONRAKER_CONF_PATH="/home/${BASE_USER}/printer_data/config/moonraker.conf"

Expand All @@ -27,6 +26,10 @@
[[ -n "$CROWSNEST_USTREAMER_REPO_SHIP" ]] || CROWSNEST_USTREAMER_REPO_SHIP="https://github.com/pikvm/ustreamer.git"
[[ -n "$CROWSNEST_USTREAMER_REPO_BRANCH" ]] || CROWSNEST_USTREAMER_REPO_BRANCH="master"

# camera-streamer
[[ -n "$CROWSNEST_CAMERA_STREAMER_REPO_SHIP" ]] || CROWSNEST_CAMERA_STREAMER_REPO_SHIP="https://github.com/ayufan/camera-streamer.git"
[[ -n "$CROWSNEST_CAMERA_STREAMER_REPO_BRANCH" ]] || CROWSNEST_CAMERA_STREAMER_REPO_BRANCH="master"

###########################################################################
### DO NOT EDIT BELOW THIS LINE, UNLESS YOU KNOW EXACTLY WHAT HAPPENDS! ###
###########################################################################
Expand Down
21 changes: 20 additions & 1 deletion src/modules/crowsnest/start_chroot_script
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,25 @@ install_cleanup_trap

# Module only Variables
CN_BUILD_PACKAGE_FILE="/tmp/cn_packages.lst"
CN_BUILD_INSTALL_SH="/home/${BASE_USER}/crowsnest/tools/install.sh"

# Helper Func
is_raspbian() {
if [[ -f /boot/config.txt ]] && [[ -f /etc/rpi-issue ]]; then
echo "1"
else
echo "0"
fi
}

get_pkglist() {
if [[ "$(is_raspbian)" = "1" ]]; then
CN_BUILD_INSTALL_SH="/home/${BASE_USER}/crowsnest/tools/libs/pkglist-rpi.sh"
fi
if [[ "$(is_raspbian)" = "0" ]]; then
CN_BUILD_INSTALL_SH="/home/${BASE_USER}/crowsnest/tools/libs/pkglist-generic.sh"
fi
}


echo_green "Installing crowsnest ..."

Expand All @@ -38,6 +56,7 @@ gitclone CROWSNEST_REPO crowsnest

## Step 3: grep PKGLIST from install.sh for dependencies
echo_green "Generating packages file ..."
get_pkglist
grep "PKGLIST=" "${CN_BUILD_INSTALL_SH}" >> "${CN_BUILD_PACKAGE_FILE}"

## Step 4: Rename PKGLIST to Module usable Var
Expand Down
19 changes: 16 additions & 3 deletions src/modules/piconfig/start_chroot_script
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ cp "${PICONFIG_CONFIG_TXT_FILE}" /tmp
mv "${PICONFIG_CONFIG_TXT_FILE}" "${PICONFIG_CONFIG_BAK_FILE}"

# Step 4: Concatenate files to config
cat /tmp/config.txt /tmp/msos_config.txt > /tmp/config.new
cat /tmp/config.txt /tmp/msos_config.txt >/tmp/config.new

# Step 5: Copy new config to "/boot/config.txt"
cp /tmp/config.new "${PICONFIG_CONFIG_TXT_FILE}"
Expand All @@ -47,13 +47,26 @@ cp "${PICONFIG_CMDLINE_TXT_FILE}" "${PICONFIG_CMDLINE_BAK_FILE}"
echo_green "Disable Serial Linux console ..."
sed -i 's/console=serial0,115200 //' "${PICONFIG_CMDLINE_TXT_FILE}"

# Step 9: Disable bluetooth and related services
# Step 9: Enable i2c modules
# Also needs corresponding bits in config.txt (see #196)
echo_green "Enabling i2c-dev"
# Enable i2c_bcm2708 is disabled
[[ -f /etc/modprobe.d/raspi-blacklist.conf ]] && sed /etc/modprobe.d/raspi-blacklist.conf -i -e "s/^\(blacklist[[:space:]]*i2c[-_]bcm2708\)/#\1/"
[[ -f /etc/modules ]] || touch /etc/modules
sed /etc/modules -i -e "s/^#[[:space:]]*\(i2c[-_]dev\)/\1/" # Uncomment i2c_dev
if ! grep -q "^i2c[-_]dev" /etc/modules; then # Add if doesn't exist
printf "i2c-dev\n" >>/etc/modules
fi
# install common i2c helpers
check_install_pkgs i2c-tools

# Step 10: Disable bluetooth and related services
echo_green "Disabling Bluetooth related services..."
systemctl_if_exists disable hciuart.service
systemctl_if_exists disable bluetooth.service
systemctl_if_exists disable bluealsa.service

# Step 10: Increase swapfile size
# Step 11: Increase swapfile size
if [[ -f "${PICONFIG_SWAP_CONF_FILE}" ]]; then
echo_green "Increasing swap file size to ${PICONFIG_SWAP_SIZE} Mb. Limit to ${PICONFIG_SWAP_MAX} Mb"
sed -i 's/^CONF_SWAPSIZE.*/'CONF_SWAPSIZE="${PICONFIG_SWAP_SIZE}"'/' "${PICONFIG_SWAP_CONF_FILE}"
Expand Down
13 changes: 0 additions & 13 deletions src/modules/rpi_firstb_fix/config

This file was deleted.

Loading

0 comments on commit 6ba3d29

Please sign in to comment.