From f4bd84db1c8708df825afb1b45893f39a5a25ef2 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Tue, 16 Aug 2022 21:09:42 +0200 Subject: [PATCH 1/7] chore: add wireless-tools as moonraker dependency (#137) --- src/modules/moonraker/start_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/moonraker/start_chroot_script b/src/modules/moonraker/start_chroot_script index ed8f3b364..f191bf8ed 100644 --- a/src/modules/moonraker/start_chroot_script +++ b/src/modules/moonraker/start_chroot_script @@ -16,7 +16,7 @@ install_cleanup_trap # make sure that this module can be used standalone apt_update_skip -check_install_pkgs "git virtualenv" +check_install_pkgs "git virtualenv wireless-tools" echo_green "Installing Moonraker and enable Moonraker Service" # install MainsailOS premade moonraker.conf From 75109963b7bc0cc5ba4c6330b58656a7fd175600 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 20 Aug 2022 21:39:04 +0200 Subject: [PATCH 2/7] chore: add workflow to close stale issues / pull requests (#139) Signed-off-by: Stefan Dej --- .github/workflows/stale.yml | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/stale.yml diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 000000000..6390f631e --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,50 @@ +name: 'Close stale issues or PRs' + +# Both `issue_comment` and `scheduled` event types are required for this Action +# to work properly. +on: + issue_comment: + types: [created] + schedule: + - cron: '*/5 * * * *' + +permissions: + issues: write + pull-requests: write + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v5 + with: + days-before-stale: 14 + days-before-close: 7 + exempt-all-milestones: true + close-issue-reason: not_planned + only-labels: '❔ User Input' + labels-to-remove-when-unstale: '❔ User Input,💤 Stale' + stale-issue-label: '💤 Stale' + stale-pr-label: '💤 Stale' + stale-issue-message: | + Ahoi! + It looks like there hasn't been any recent updates on + this issue. If you created this issue and no longer + consider it to get merged, then please login to github + and close it. Otherwise, if there is no further activity + on this issue, it will be automatically closedwithin the + next 7 days. + Fair wind and a following sea! + ~ Your friendly MainsailGithubBot + *PS: I'm just an automated script, not a real sailor.* + stale-pr-message: | + Ahoi! + It looks like there hasn't been any recent updates on + this pull request. If you created this pull request and + no longer consider it to get merged, then please login + to github and close it. Otherwise, if there is no further + activity on this pull request, it will be automatically + closed within the next 7 days. + Fair wind and a following sea! + ~ Your friendly MainsailGithubBot + *PS: I'm just an automated script, not a real sailor.* From 3f63e658019016a3b2605a128b53e3fd35344700 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Sun, 21 Aug 2022 11:08:25 +0200 Subject: [PATCH 3/7] chore: add additional Input shaper dependencies (#140) Input Shaper now needs libatlas3-base and libatlas-base-dev as additional dependencies Signed-off-by: Stephan Wendel --- src/modules/is_req_preinstall/config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/is_req_preinstall/config b/src/modules/is_req_preinstall/config index ab8e7aa6e..7e7333603 100644 --- a/src/modules/is_req_preinstall/config +++ b/src/modules/is_req_preinstall/config @@ -1,6 +1,7 @@ #!/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_DEPS" ] || IS_REQ_PREINSTALL_DEPS="python3-numpy python3-matplotlib \ +libatlas3-base libatlas-base-dev" [ -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" From cb8a82201bf92fd0cb2bc21e8134a76e6f42b89f Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Tue, 23 Aug 2022 18:14:42 +0200 Subject: [PATCH 4/7] fix: fix errors in moved venvs (#138) This should fix #136 Due moving venv's with virtualenv, some path aren't get changed. Now pycache will be deleted and shebang lines manipulated to match paths Signed-off-by: Stephan Wendel --- src/modules/postrename/config | 2 +- src/modules/postrename/filesystem/root/postrename | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/modules/postrename/config b/src/modules/postrename/config index 64222e8b6..c61ed45c6 100644 --- a/src/modules/postrename/config +++ b/src/modules/postrename/config @@ -9,4 +9,4 @@ #### # shellcheck disable=all -# Intentionaly left blank +# Intentionally left blank diff --git a/src/modules/postrename/filesystem/root/postrename b/src/modules/postrename/filesystem/root/postrename index dab0f55dc..8e8833ce5 100644 --- a/src/modules/postrename/filesystem/root/postrename +++ b/src/modules/postrename/filesystem/root/postrename @@ -75,8 +75,20 @@ function relocate_venv { venvs=(klippy-env moonraker-env) for venv in "${venvs[@]}"; do + # Move venv sudo -u "${DEFAULT_USER}" \ virtualenv --relocatable -p /usr/bin/python3 "/home/${DEFAULT_USER}/${venv}" + + # delete pycache (*.pyc files) + find "/home/${DEFAULT_USER}/${venv}" -name "__pycache__" -type d -exec rm -rf {} + + + # repair shebangs + while IFS= read -r file ; do + + sed -i 's|pi/'"${venv}"'|'"${DEFAULT_USER}"'/'"${venv}"'|g' "${file}" + + done < <(grep -iR "pi/${venv}" "/home/${DEFAULT_USER}/${venv}"/* | cut -d":" -f1) + done } From 53cb81958474766c3dfdcfcd2ea2e8fe708e0bd8 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Thu, 1 Sep 2022 20:19:55 +0200 Subject: [PATCH 5/7] fix: fixes error unusable wpa_supplicant.txt (#142) This is more a workaround as a fix. Raspberry Foundation changed handling of wpa_supplicant.conf. Also KlipperScreen uses wpa_cli which overrides softlink to txt. fixes #134 Signed-off-by: Stephan Wendel Signed-off-by: Stephan Wendel --- src/config | 2 +- src/modules/net/config | 13 ++ .../net/filesystem/boot/WiFi-README.txt | 163 ++++++++++++++++++ .../boot/wpa_supplicant.conf.example | 15 ++ .../system/disable-wifi-pwr-mgmt.service | 22 +++ .../etc/udev/rules.d/070-wifi-powersave.rules | 4 + .../net/filesystem/usr/local/bin/pwrsave | 90 ++++++++++ .../net/filesystem/usr/local/bin/pwrsave-udev | 105 +++++++++++ src/modules/net/start_chroot_script | 86 +++++++++ 9 files changed, 499 insertions(+), 1 deletion(-) create mode 100755 src/modules/net/config create mode 100644 src/modules/net/filesystem/boot/WiFi-README.txt create mode 100644 src/modules/net/filesystem/boot/wpa_supplicant.conf.example create mode 100644 src/modules/net/filesystem/etc/systemd/system/disable-wifi-pwr-mgmt.service create mode 100644 src/modules/net/filesystem/etc/udev/rules.d/070-wifi-powersave.rules create mode 100755 src/modules/net/filesystem/usr/local/bin/pwrsave create mode 100755 src/modules/net/filesystem/usr/local/bin/pwrsave-udev create mode 100755 src/modules/net/start_chroot_script diff --git a/src/config b/src/config index ea9e7bc4b..24f00c720 100644 --- a/src/config +++ b/src/config @@ -4,6 +4,6 @@ export DIST_NAME=MainsailOS export DIST_VERSION=0.7.0 export BASE_IMAGE_ENLARGEROOT=2500 -export MODULES="base,pkgupgrade,mainsailos(network,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename" +export MODULES="base,pkgupgrade,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename" export BASE_RELEASE_COMPRESS=yes export BASE_IMAGE_RESIZEROOT=600 diff --git a/src/modules/net/config b/src/modules/net/config new file mode 100755 index 000000000..3b5df77d8 --- /dev/null +++ b/src/modules/net/config @@ -0,0 +1,13 @@ +# Network module setup +# shellcheck disable=all + +# Use disable power save for wifi module +[ -n "$NETWORK_DISABLE_PWRSAVE" ] || NETWORK_DISABLE_PWRSAVE=yes + +# Type of power save rclocal/service/udev +# rclocal - backwards compatibility, runs via rc.local +# service - will add an systemd.service to enable or disable behavior +# on reboots +# udev - creates a udev rules that should affect all wifi devices. + +[ -n "$NETWORK_PWRSAVE_TYPE" ] || NETWORK_PWRSAVE_TYPE=udev diff --git a/src/modules/net/filesystem/boot/WiFi-README.txt b/src/modules/net/filesystem/boot/WiFi-README.txt new file mode 100644 index 000000000..ad6c6bdea --- /dev/null +++ b/src/modules/net/filesystem/boot/WiFi-README.txt @@ -0,0 +1,163 @@ +Wifi-README.txt +############### + + +Due to changes in Raspberry Pi OS, which is OS_NAME is based on, +there is no longer a OS_NAME-wpa-supplicant.txt available. + +How do I setup a (new) network on my Pi ? +----------------------------------------- + +As described in the original Raspberry Pi OS documentation. +See https://www.raspberrypi.com/documentation/computers/configuration.html#setting-up-a-headless-raspberry-pi. + + +Quote: + You will need to define a wpa_supplicant.conf file for your particular wireless network. + Put this file onto the boot folder of the SD card. + When the Raspberry Pi boots for the first time, + it will copy that file into the correct location in the Linux root file system + and use those settings to start up wireless networking. + + The Raspberry Pi’s IP address will not be visible immediately after power on, + so this step is crucial to connect to it headlessly. + Depending on the OS and editor you are creating this on, + the file could have incorrect newlines or the wrong file extension, + so make sure you use an editor that accounts for this. + Linux expects the line feed (LF) newline character. + +What does that all mean? What have I todo now? +---------------------------------------------- + +For short, get a proper text editor of your choice. +Recommendations are Notepad++, VSCode, Atom or SublimeText. + +################################################################################ +#### IMPORTANT! ATTENTION! #### +################################################################################ + +!!!!! HEADS-UP WINDOWS USERS !!!!! +---------------------------------- + +Do not use Wordpad for editing this file, it will mangle it and your +configuration won't work. Use a proper text editor instead. + +!!!!! HEADS-UP MACOSX USERS !!!!! +--------------------------------- + +If you use Textedit to edit this file make sure to use "plain text format" +and "disable smart quotes" in "Textedit > Preferences", otherwise Textedit +will use none-compatible characters and your network configuration won't work! + + +1.) Open your choosen Texteditor and create a new file called + + wpa_supplicant.conf + +2.) Create a some basic configuration. This has to be in place! + + ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev + country= + update_config=1 + +Valid Country Codes are: + + GB (United Kingdom) + FR (France) + DE (Germany) + US (United States) + SE (Sweden) + +For a full list, please visit https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 + +2.1) If you plan to use multiple WiFi networks, also add + + ap_scan=1 + +to the mentioned basic configuration. + + +3.) Setup your "network" block. + +For detailed information, please consult: +https://linux.die.net/man/5/wpa_supplicant.conf +or +https://wiki.debian.org/WiFi/HowToUse#wpa_supplicant +or +https://man.archlinux.org/man/wpa_supplicant.conf.5 + +Examples: + +Open or unsecured WiFi network: +------------------------------- + +# Open/unsecured +network={ + scan_ssid=1 # Used to find hidden SSID's + ssid="put SSID here" + key_mgmt=NONE +} + +------------------------------- + + +WEP "secured" network: +------------------------------- + +NOTE: + + WEP can be cracked within minutes. If your network is still relying on this + encryption scheme you should seriously consider to update your network ASAP. + +network={ + ssid="put SSID here" + key_mgmt=NONE + wep_key0="put password here" + wep_tx_keyidx=0 +} +-------------------------------- + + +WPA2 Personal secured network: +(Please don't use WPA secured networks, WPA isn't secure anymore) +-------------------------------- + +# WPA/WPA2 secured +network={ + scan_ssid=1 # Used to find hidden SSID's + ssid="" + psk="" + proto=RSN + key_mgmt=WPA-PSK + pairwise=CCMP + auth_alg=OPEN +} +-------------------------------- + +For the WPA2 Enterprise setup, please use your google-foo. +This is an advanced topic! + +4.) Put that file on to the "/boot" partition, +this partition is FAT32 formatted and should be visible if you plug the SD Card into your computer. + +If you created a file while the Pi was running, copy that file to boot. +Assuming you created the file in your users "home" directory use + + sudo cp -v wpa_supplicant.conf /boot/ + +5.) Almost done... Please reboot the pi and wait for it to connect. + +NOTE: + +Attach a screen and watch the console output to get its IP or +consult your Router setup page to grab that information. + +You could also try to reach it by its hostname. + + http://.local + +If you didnt change the hostname during initial flash, you could use + + http://OS_NAME.local + +6.) Enjoy OS_NAME :) diff --git a/src/modules/net/filesystem/boot/wpa_supplicant.conf.example b/src/modules/net/filesystem/boot/wpa_supplicant.conf.example new file mode 100644 index 000000000..8c928cdd9 --- /dev/null +++ b/src/modules/net/filesystem/boot/wpa_supplicant.conf.example @@ -0,0 +1,15 @@ +# Simple configuration for a typical WPA2 network + +ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev +update_config=1 +country=US # US Country code + +network={ + scan_ssid=1 + ssid="" + psk="" + proto=RSN + key_mgmt=WPA-PSK + pairwise=CCMP + auth_alg=OPEN +} diff --git a/src/modules/net/filesystem/etc/systemd/system/disable-wifi-pwr-mgmt.service b/src/modules/net/filesystem/etc/systemd/system/disable-wifi-pwr-mgmt.service new file mode 100644 index 000000000..ab9f2805d --- /dev/null +++ b/src/modules/net/filesystem/etc/systemd/system/disable-wifi-pwr-mgmt.service @@ -0,0 +1,22 @@ +#### Disable wifi power_save +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2022 +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### +#### Note: This is based on: +#### https://www.intel.com/content/www/us/en/support/articles/000006168/boards-and-kits.html + +[Unit] +Description=Disable power management for wlan0 +After=network.target + +[Service] +Type=oneshot +StandardOutput=tty +ExecStart=/usr/local/bin/pwrsave off + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/src/modules/net/filesystem/etc/udev/rules.d/070-wifi-powersave.rules b/src/modules/net/filesystem/etc/udev/rules.d/070-wifi-powersave.rules new file mode 100644 index 000000000..6ff2774c4 --- /dev/null +++ b/src/modules/net/filesystem/etc/udev/rules.d/070-wifi-powersave.rules @@ -0,0 +1,4 @@ +ACTION=="add", \ +SUBSYSTEM=="net", \ +KERNEL=="wlan*" \ +RUN+="/usr/sbin/iw %k set power_save off" \ No newline at end of file diff --git a/src/modules/net/filesystem/usr/local/bin/pwrsave b/src/modules/net/filesystem/usr/local/bin/pwrsave new file mode 100755 index 000000000..c9d9417c8 --- /dev/null +++ b/src/modules/net/filesystem/usr/local/bin/pwrsave @@ -0,0 +1,90 @@ +#!/bin/bash +#### Disable wifi power_save +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2022 +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### +#### Note: This is based on: +#### https://www.intel.com/content/www/us/en/support/articles/000006168/boards-and-kits.html + + +## Error handling +set -eou pipefail + +## Debug Mode +#set -x + +### Message func +function help_msg { + echo -e "Usage:\n" + echo -e "\tpwrsave [ on | off ]" + echo -e "\t\ton\tEnables Power Management of 'wlan0'" + echo -e "\t\toff\tDisables Power Management of 'wlan0'\n" + exit 1 +} + +function has_wifi { + LC_ALL=C iwconfig wlan0 &> /dev/null && echo "0" || echo "1" +} + +function check_wifi_present { + # make sure to exit if command missing + if [ -z "$(command -v iwconfig)" ]; then + echo -e "Command 'iwconfig' not found ... [EXITING]" + exit 1 + fi + if [ "$(has_wifi)" != "0" ]; then + echo -e "[ \e[33mWARN\e[0m ] No WiFi hardware present ... [SKIPPED]" + exit 0 + fi +} + +function disable_pwr_save { + iwconfig wlan0 power off + echo -e "[ \e[32mOK\e[0m ] Disabled Power Management for wlan0" +} + + +function enable_pwr_save { + iwconfig wlan0 power on + echo -e "[ \e[32mOK\e[0m ] Enabled Power Management for wlan0" +} + + +### MAIN +function main { + local arg + if [ "$(id -u)" != "0" ]; then + echo -e "\n$(basename "${0}"): This script needs root priviledges!\n" + exit 1 + fi + if [ "${#}" == "0" ]; then + echo -e "$(basename "${0}"): No argument set!" + help_msg + fi + if [ "${#}" -gt 1 ]; then + echo -e "$(basename "${0}"): Too many arguments set!" + help_msg + fi + arg="${1}" + case "${arg}" in + "on") + check_wifi_present + enable_pwr_save + ;; + "off") + check_wifi_present + disable_pwr_save + ;; + ?|*) + echo -e "$(basename "${0}"): Unknown argument '${arg}' !" + help_msg + ;; + esac +} + +main "${@}" +exit 0 diff --git a/src/modules/net/filesystem/usr/local/bin/pwrsave-udev b/src/modules/net/filesystem/usr/local/bin/pwrsave-udev new file mode 100755 index 000000000..3afc9149c --- /dev/null +++ b/src/modules/net/filesystem/usr/local/bin/pwrsave-udev @@ -0,0 +1,105 @@ +#!/bin/bash +#### Disable wifi power_save +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2022 +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### +#### Note: This is based on: +#### https://www.intel.com/content/www/us/en/support/articles/000006168/boards-and-kits.html + + +## Error handling +set -eou pipefail + +## Debug Mode +#set -x + +### Message func +function help_msg { + echo -e "Usage:\n" + echo -e "\tpwrsave-udev [ on | off | create ]" + echo -e "\t\ton\tEnables Power Management via udev rule" + echo -e "\t\toff\tDisables Power Management via udev rule" + echo -e "\t\tcreate\tCreate Power Management udev rule\n" + exit 1 +} + + +### Check rule exist +function check_rule { + if [ ! -f /etc/udev/rules.d/070-wifi-powersave.rules ]; then + echo -e "[ \e[31mERROR\e[0m ] Udev Rule for WiFi Powermanagement not found!" + help_msg + exit 1 + fi +} + +function disable_pwr_save { + sed -i 's/on/off/' /etc/udev/rules.d/070-wifi-powersave.rules + echo -e "[ \e[32mOK\e[0m ] Disabled Power Management" +} + + +function enable_pwr_save { + sed -i 's/off/on/' /etc/udev/rules.d/070-wifi-powersave.rules + echo -e "[ \e[32mOK\e[0m ] Enabled Power Management" +} + +function create_rule { +if [ -f /etc/udev/rules.d/070-wifi-powersave.rules ]; then + echo -e "[ \e[33mSKIPPED\e[0m ] Udev rule already exists!" + exit 0 +fi + +cat << EOF > /etc/udev/rules.d/070-wifi-powersave.rules +ACTION=="add", \ +SUBSYSTEM=="net", \ +KERNEL=="wlan*" \ +RUN+="/usr/sbin/iw %k set power_save off" +EOF +echo -e "[ \e[32mOK\e[0m ] Created Udev rule ... \n" +echo -e "Please 'reboot' to take changes effect.\n" +} + + + +### MAIN +function main { + local arg + if [ "$(id -u)" != "0" ]; then + echo -e "\n$(basename "${0}"): This script needs root priviledges!\n" + exit 1 + fi + if [ "${#}" == "0" ]; then + echo -e "$(basename "${0}"): No argument set!" + help_msg + fi + if [ "${#}" -gt 1 ]; then + echo -e "$(basename "${0}"): Too many arguments set!" + help_msg + fi + arg="${1}" + if [ "${arg}" == "create" ]; then + create_rule + exit 0 + fi + check_rule + case "${arg}" in + "on") + enable_pwr_save + ;; + "off") + disable_pwr_save + ;; + ?|*) + echo -e "$(basename "${0}"): Unknown argument '${arg}' !" + help_msg + ;; + esac +} + +main "${@}" +exit 0 diff --git a/src/modules/net/start_chroot_script b/src/modules/net/start_chroot_script new file mode 100755 index 000000000..ad189e124 --- /dev/null +++ b/src/modules/net/start_chroot_script @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +# Network +# Adds to /boot configuration files that let you set up wifi network before booting +# Written by Guy Sheffer and Gina Häußge +# GPL V3 +# +# Modified by Stephan Wendel aka KwadFan +# https://github.com/mainsail-crew/MainsailOS +# Last modification: August/2022 +# +######## +set -x +set -e + +export LC_ALL=C + +source /common.sh +install_cleanup_trap + +unpack /filesystem/boot /"${BASE_BOOT_MOUNT_PATH}" + +if [ "${BASE_DISTRO}" == "ubuntu" ] || [ "${BASE_DISTRO}" == "armbian" ]; then + echo "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev" > /etc/wpa_supplicant/wpa_supplicant.conf + echo "update_config=1" >> /etc/wpa_supplicant/wpa_supplicant.conf + echo "ap_scan=1" >> /etc/wpa_supplicant/wpa_supplicant.conf + echo "country=US" >> /etc/wpa_supplicant/wpa_supplicant.conf +fi + +if [ "${BASE_DISTRO}" == "raspbian" ]; then + # Workaround rfkill not unblocking on boot + rm /var/lib/systemd/rfkill/* +fi + +# set OS_NAME in Wifi-README.txt according to DIST_NAME +if [ -f "/boot/WiFi-README.txt" ]; then + sed -i 's|OS_NAME|'"${DIST_NAME}"'|g' /boot/WiFi-README.txt +fi + + +# copy /etc/wpa_supplicant/ifupdown.sh to /etc/ifplugd/action.d/ifupdown - for wlan auto reconnect +[ -f /etc/ifplugd/action.d/ifupdown ] && mv /etc/ifplugd/action.d/ifupdown /etc/ifplugd/action.d/ifupdown.original +[ -f /etc/wpa_supplicant/ifupdown.sh ] && ln -s /etc/wpa_supplicant/ifupdown.sh /etc/ifplugd/action.d/ifupdown + +if [ ! -f "/etc/rc.local" ];then + echo 'exit 0' >> /etc/rc.local +fi + +# prevent ntp updates from failing due to some Rpi3 weirdness, see also "Fix SSH" further below +apt-get update --allow-releaseinfo-change +apt-get install -y iptables +sed -i 's@exit 0@@' /etc/rc.local +echo '/sbin/iptables -t mangle -I POSTROUTING 1 -o wlan0 -p udp --dport 123 -j TOS --set-tos 0x00' >> /etc/rc.local +echo 'exit 0' >> /etc/rc.local + +# Install powersave option +if [ "$NETWORK_DISABLE_PWRSAVE" == "yes" ]; then + + # Copy pwrsave script + unpack filesystem/usr/local/bin /usr/local/bin root + + # Use rc.local + if [ "$NETWORK_PWRSAVE_TYPE" == "rclocal" ]; then + echo_green "Modifying /etc/rc.local ..." + sed -i 's@exit 0@@' /etc/rc.local + (echo "# Disable WiFi Power Management"; \ + echo 'echo "Disabling power management for wlan0 ..."' ; \ + echo "/usr/local/bin/pwrsave off"; echo "exit 0") >> /etc/rc.local + fi + # Use service + if [ "$NETWORK_PWRSAVE_TYPE" == "service" ]; then + echo_green "Installing disable-wifi-pwr-mgmt service ..." + unpack filesystem/etc/systemd/system /etc/systemd/system root + systemctl_if_exists enable disable-wifi-pwr-mgmt.service + fi + # Use udev rule + if [ "$NETWORK_PWRSAVE_TYPE" == "udev" ]; then + echo_green "Installing WiFi Power Management udev rule ..." + unpack filesystem/etc/udev/rules.d /etc/udev/rules.d root + fi + # strip out unneeded script, depending on choose + if [ "$NETWORK_PWRSAVE_TYPE" != "udev" ]; then + rm -f /usr/local/bin/pwrsave-udev + else + rm -f /usr/local/bin/pwrsave + fi +fi From af3d78bdb9eb5090f3b3a092d98c28b0ac25d147 Mon Sep 17 00:00:00 2001 From: John O'Shaughnessy Date: Sun, 4 Sep 2022 10:57:52 -0700 Subject: [PATCH 6/7] docs: Update README for improved readability (#144) --- src/modules/net/filesystem/boot/WiFi-README.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/modules/net/filesystem/boot/WiFi-README.txt b/src/modules/net/filesystem/boot/WiFi-README.txt index ad6c6bdea..5c36ef371 100644 --- a/src/modules/net/filesystem/boot/WiFi-README.txt +++ b/src/modules/net/filesystem/boot/WiFi-README.txt @@ -2,7 +2,7 @@ Wifi-README.txt ############### -Due to changes in Raspberry Pi OS, which is OS_NAME is based on, +Due to changes in Raspberry Pi OS, which OS_NAME is based on, there is no longer a OS_NAME-wpa-supplicant.txt available. How do I setup a (new) network on my Pi ? @@ -26,10 +26,10 @@ Quote: so make sure you use an editor that accounts for this. Linux expects the line feed (LF) newline character. -What does that all mean? What have I todo now? +What does that all mean? What do I have to do now? ---------------------------------------------- -For short, get a proper text editor of your choice. +First, ensure you have a proper text editor of your choice. Recommendations are Notepad++, VSCode, Atom or SublimeText. ################################################################################ @@ -42,7 +42,7 @@ Recommendations are Notepad++, VSCode, Atom or SublimeText. Do not use Wordpad for editing this file, it will mangle it and your configuration won't work. Use a proper text editor instead. -!!!!! HEADS-UP MACOSX USERS !!!!! +!!!!! HEADS-UP MacOS X USERS !!!!! --------------------------------- If you use Textedit to edit this file make sure to use "plain text format" @@ -50,11 +50,11 @@ and "disable smart quotes" in "Textedit > Preferences", otherwise Textedit will use none-compatible characters and your network configuration won't work! -1.) Open your choosen Texteditor and create a new file called +1.) Open your chosen text editor and create a new file called wpa_supplicant.conf -2.) Create a some basic configuration. This has to be in place! +2.) Create a basic configuration. This has to be in place! ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev country= @@ -149,8 +149,8 @@ Assuming you created the file in your users "home" directory use NOTE: -Attach a screen and watch the console output to get its IP or -consult your Router setup page to grab that information. +Attach a screen and watch the console output to get its IP address or +consult your router setup page to grab that information. You could also try to reach it by its hostname. From 8863d0050f239c78894bb977490c7e94c0d5bea7 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Tue, 6 Sep 2022 19:26:15 +0200 Subject: [PATCH 7/7] chore: bump version to v0.7.1 (#145) --- src/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config b/src/config index 24f00c720..649cb5dbf 100644 --- a/src/config +++ b/src/config @@ -2,7 +2,7 @@ # Shebang for better detection of file type export DIST_NAME=MainsailOS -export DIST_VERSION=0.7.0 +export DIST_VERSION=0.7.1 export BASE_IMAGE_ENLARGEROOT=2500 export MODULES="base,pkgupgrade,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,crowsnest,sonar,password-for-sudo),postrename" export BASE_RELEASE_COMPRESS=yes