# Technical Documentation: dw-0/kiauh

> ℹ️ **Provenance:** Multi-Tier Ingestion · [CodeWiki Reference](https://codewiki.google/github.com/dw-0/kiauh)

### Overview (`README.md`)

<p align="center">
    <img src="docs/assets/logo-large.png" alt="KIAUH Logo" height="181">
    <h1 align="center">Klipper Installation And Update Helper</h1>
</p>

<p align="center">
  A handy installation script that makes installing Klipper (and more) a breeze!
</p>

<p align="center">
  <a><img src="https://img.shields.io/github/license/dw-0/kiauh"></a>
  <a><img src="https://img.shields.io/github/stars/dw-0/kiauh"></a>
  <a><img src="https://img.shields.io/github/forks/dw-0/kiauh"></a>
  <a><img src="https://img.shields.io/github/languages/top/dw-0/kiauh?logo=gnubash&logoColor=white"></a>
  <a><img src="https://img.shields.io/github/v/tag/dw-0/kiauh"></a>
  <br />
  <a><img src="https://img.shields.io/github/last-commit/dw-0/kiauh"></a>
  <a><img src="https://img.shields.io/github/contributors/dw-0/kiauh"></a>
</p>

<hr>

<h2 align="center">
  📄️ Instructions 📄
</h2>

### 📋 Prerequisites

KIAUH is a script that assists you in installing Klipper on a Linux operating
system that has
already been flashed to your Raspberry Pi's (or other SBC's) SD card. As a
result, you must ensure
that you have a functional Linux system on hand.
`Raspberry Pi OS Lite (either 32bit or 64bit)` is a recommended Linux image
if you are using a Raspberry Pi.
The [official Raspberry Pi Imager](https://www.raspberrypi.com/software/)
is the simplest way to flash an image like this to an SD card.

* Once you have downloaded, installed and launched the Raspberry Pi Imager,
  select `Choose OS -> Raspberry Pi OS (other)`: \

<p align="center">
  <img src="docs/assets/rpi_imager1.png" alt="KIAUH logo" height="350">
</p>

* Then select `Raspberry Pi OS Lite (32bit)` (or 64bit if you want to use that
  instead):

<p align="center">
  <img src="docs/assets/rpi_imager2.png" alt="KIAUH logo" height="350">
</p>

* Back in the Raspberry Pi Imager's main menu, select the corresponding SD card
  to which
  you want to flash the image.

* Make sure to go into the Advanced Option (the cog icon in the lower left
  corner of the main menu)
  and enable SSH and configure Wi-Fi.

* If you need more help for using the Raspberry Pi Imager, please visit
  the [official documentation](https://www.raspberrypi.com/documentation/computers/getting-started.html).

These steps **only** apply if you are actually using a Raspberry Pi. In case you
want
to use a different SBC (like an Orange Pi or any other Pi derivates), please
look up on how to get an appropriate Linux image flashed
to the SD card before proceeding further (usually done with Balena Etcher in
those cases). Also make sure that KIAUH will be able to run
and operate on the Linux Distribution you are going to flash. You likely will
have the most success with
distributions based on Debian 11 Bullseye. Read the notes further down below in
this document.

### 💾 Download and use KIAUH

**📢 Disclaimer: Usage of this script happens at your own risk!**

* **Step 1:** \
  To download this script, it is necessary to have git installed. If you don't
  have git already installed, or if you are unsure, run the following command:

```shell
sudo apt-get update && sudo apt-get install git -y
```

* **Step 2:** \
  Once git is installed, use the following command to download KIAUH into your
  home-directory:

```shell
cd ~ && git clone https://github.com/dw-0/kiauh.git
```

* **Step 3:** \
  Finally, start KIAUH by running the next command:

```shell
./kiauh/kiauh.sh
```

* **Step 4:** \
  You should now find yourself in the main menu of KIAUH. You will see several
  actions to choose from depending
  on what you want to do. To choose an action, simply type the corresponding
  number into the "Perform action"
  prompt and confirm by hitting ENTER.

<hr>

<h2 align="center">❗ Notes ❗</h2>

### **📋 Please see the [Changelog](docs/changelog.md) for possible important

changes!**

- Mainly tested on Raspberry Pi OS Lite (Debian 10 Buster / Debian 11 Bullseye)
    - Other Debian based distributions (like Ubuntu 20 to 22) likely work too
    - Reported to work on Armbian as well but not tested in detail
- During the use of this script you will be asked for your sudo password. There
  are several functions involved which need sudo privileges.

<hr>

<h2 align="center">⚙️ Core Components ⚙️</h2>

<table align="center" style="text-align: center;">
<tr>
    <th><h3><a href="https://github.com/Klipper3d/klipper">Klipper</a></h3></th>
    <th><h3><a href="https://github.com/Arksine/moonraker">Moonraker</a></h3></th>
    <th><h3><a href="https://github.com/mainsail-crew/mainsail">Mainsail</a></h3></th>
</tr>
<tr>
    <th><img src="https://raw.githubusercontent.com/Klipper3d/klipper/master/docs/img/klipper-logo.png" alt="Klipper Logo" height="64"></th>
    <th><img src="https://avatars.githubusercontent.com/u/9563098?v=4" alt="Arksine avatar" height="64"></th>
    <th><img src="https://raw.githubusercontent.com/mainsail-crew/docs/master/assets/img/logo.png" alt="Mainsail Logo" height="64"></th>
</tr>
<tr>
    <th>by <a href="https://github.com/KevinOConnor">KevinOConnor</a></th>
    <th>by <a href="https://github.com/Arksine">Arksine</a></th>
    <th>by <a href="https://github.com/mainsail-crew">mainsail-crew</a></th>
</tr>
<tr>
    <th><h3><a href="https://github.com/fluidd-core/fluidd">Fluidd</a></h3></th>
    <th><h3><a href="https://github.com/KlipperScreen/KlipperScreen">KlipperScreen</a></h3></th>
    <th></th>
</tr>
<tr>
    <th><img src="https://raw.githubusercontent.com/fluidd-core/fluidd/master/docs/docs/assets/images/logo.svg" alt="Fluidd Logo" height="64"></th>
    <th><img src="https://avatars.githubusercontent.com/KlipperScreen?v=4" alt="KlipperScreen Logo" height="64"></th>
    <th></th>
</tr>
<tr>
    <th>by <a href="https://github.com/fluidd-core">fluidd-core</a></th>
    <th>by <a href="https://github.com/alfrix">alfrix</a></th>
    <th></th>
</tr>
</table>

<hr>

<h2 align="center">🧩 Community Extensions 🧩</h2>

<table align="center" style="text-align: center;">
<tr>
    <th><h3><a href="https://github.com/OctoPrint/OctoPrint">OctoPrint</a></h3></th>
    <th><h3><a href="https://github.com/nlef/moonraker-telegram-bot">Moonraker-Telegram-Bot</a></h3></th>
    <th><h3><a href="https://github.com/Kragrathea/pgcode">PrettyGCode for Klipper</a></h3></th>
</tr>
<tr>
    <th><a href="https://github.com/OctoPrint/OctoPrint"><img src="https://raw.githubusercontent.com/OctoPrint/OctoPrint/master/docs/images/octoprint-logo.png" alt="OctoPrint Logo" height="64"></a></th>
    <th><a href="https://github.com/nlef/moonraker-telegram-bot"><img src="https://avatars.githubusercontent.com/u/52351624?v=4" alt="nlef avatar" height="64"></a></th>
    <th><a href="https://github.com/Kragrathea/pgcode"><img src="https://avatars.githubusercontent.com/u/5917231?v=4" alt="Kragrathea avatar" height="64"></a></th>
</tr>
<tr>
    <th>by <a href="https://github.com/OctoPrint">OctoPrint</a></th>
    <th>by <a href="https://github.com/nlef">nlef</a></th>
    <th>by <a href="https://github.com/Kragrathea">Kragrathea</a></th>
</tr>
<tr>
    <th><h3><a href="https://github.com/TheSpaghettiDetective/moonraker-obico">Obico for Klipper</a></h3></th>
    <th><h3><a href="https://github.com/Clon1998/mobileraker_companion">Mobileraker's Companion</a></h3></th>
    <th><h3><a href="https://octoeverywhere.com/?source=kiauh_readme">OctoEverywhere For Klipper</a></h3></th>
</tr>
<tr>
    <th><a href="https://github.com/TheSpaghettiDetective/moonraker-obico"><img src="https://avatars.githubusercontent.com/u/46323662?s=200&v=4" alt="Obico logo" height="64"></a></th>
    <th><a href="https://github.com/Clon1998/mobileraker_companion"><img src="https://raw.githubusercontent.com/Clon1998/mobileraker/master/assets/icon/mr_appicon.png" alt="Mobileraker Logo" height="64"></a></th>
    <th><a href="https://octoeverywhere.com/?source=kiauh_readme"><img src="https://octoeverywhere.com/img/logo.svg" alt="OctoEverywhere Logo" height="64"></a></th>
</tr>
<tr>
    <th>by <a href="https://github.com/TheSpaghettiDetective">Obico</a></th>
    <th>by <a href="https://github.com/Clon1998">Patrick Schmidt</a></th>
    <th>by <a href="https://github.com/QuinnDamerell">Quinn Damerell</a></th>
</tr>
<tr>
    <th><h3><a href="https://github.com/crysxd/OctoApp-Plugin">OctoApp For Klipper</a></h3></th>
    <th><h3><a href="https://github.com/staubgeborener/klipper-backup">Klipper-Backup</a></h3></th>
    <th><h3><a href="https://simplyprint.io/">SimplyPrint for Klipper</a></h3></th>
</tr>
<tr>
    <th><a href="https://octoapp.eu/?source=kiauh_readme"><img src="https://octoapp.eu/octoapp.webp" alt="OctoApp Logo" height="64"></a></th>
    <th><a href="https://github.com/staubgeborener/klipper-backup"><img src="https://avatars.githubusercontent.com/u/28908603?v=4" alt="Staubgeroner Avatar" height="64"></a></th>
    <th><a href="https://github.com/SimplyPrint"><img src="https://avatars.githubusercontent.com/u/64896552?s=200&v=4" alt="SimplyPrint Logo" height="64"></a></th>
</tr>
<tr>
    <th>by <a href="https://github.com/crysxd">Christian Würthner</a></th>
    <th>by <a href="https://github.com/Staubgeborener">Staubgeborener</a></th>
    <th>by <a href="https://github.com/SimplyPrint">SimplyPrint</a></th>
</tr>
<tr>
    <th><h3><a href="https://github.com/CodeMasterCody3D/DroidKlipp">DroidKlipp</a></h3></th>
    <th><h3><a href="https://github.com/PEEKYPAUL/Moongate">Moongate</a></h3></th>
    <th></th>
</tr>
<tr>
    <th><a href="https://github.com/CodeMasterCody3D/DroidKlipp"><img src="https://raw.githubusercontent.com/CodeMasterCody3D/DroidKlipp/main/logo.png" alt="DroidKlipp Logo" height="64"></a></th>
    <th><a href="https://github.com/PEEKYPAUL/Moongate"><img src="https://raw.githubusercontent.com/PEEKYPAUL/Moongate/master/docs/moongate-icon.png" alt="Moongate Logo" height="64"></a></th>
    <th></th>
</tr>
<tr>
    <th>by <a href="https://github.com/CodeMasterCody3D">CodeMasterCody3D</a></th>
    <th>by <a href="https://github.com/PEEKYPAUL">PEEKYPAUL</a></th>
    <th></th>
</tr>
</table>

<hr>

<h2 align="center">🎖️ Contributors 🎖️</h2>

<div align="center">
  <a href="https://github.com/dw-0/kiauh/graphs/contributors">
    <img src="https://contrib.rocks/image?repo=dw-0/kiauh" alt=""/>
  </a>
</div>

<hr>

<div align="center">
    <img src="https://repobeats.axiom.co/api/embed/a1afbda9190c04a90cf4bd3061e5573bc836cb05.svg" alt="Repobeats analytics image"/>
</div>

<hr>

<h2 align="center">✨ Credits ✨</h2>

* A big thank you to [lixxbox](https://github.com/lixxbox) for that awesome
  KIAUH-Logo!
* Also, a big thank you to everyone who supported my work with
  a [Ko-fi](https://ko-fi.com/dw__0) !
* Last but not least: Thank you to all contributors and members of the Klipper
  Community who like and share this project!

---

### Overview (`kiauh/core/simple_config_parser/README.md`)

# Simple Config Parser

A custom config parser inspired by Python's configparser module.
Specialized for handling Klipper style config files.

---

### When parsing a config file, it will be split into the following elements:
- Header: All lines before the first section
- Section: A section is defined by a line starting with a `[` and ending with a `]`
- Option: A line starting with a word, followed by a `:` or `=` and a value
- Option Block: A line starting with a word, followed by a `:` or `=` and a newline
  - The word `gcode` is excluded from being treated as an option block
- Gcode Block: A line starting with the word `gcode`, followed by a `:` or `=` and a newline
  - All indented lines following the gcode line are considered part of the gcode block
- Comment: A line starting with a `#` or `;`
- Blank: A line containing only whitespace characters
- SaveConfig Block: Klippers auto-generated SAVE_CONFIG section that can be found at the very end of the config file

---

### Changelog (`docs/changelog.md`)

## Changelog

This document covers possible important changes to KIAUH.

### 2025-10-10 (v6.0.0)

KIAUH has now reached version 6! The majority of the changes mentioned in the
previous changelog are now available in the final version.
Most notible are the following changes:

- The dialog for selecting between v5 and v6 is gone and all v5 code was
  removed. V6 is the new default
- You can add/remove alternative repositories for Klipper and Moonraker from
  within KIAUH, no need to manually edit any file
- You can store and load firmware configurations for Klipper during the firmware
  compilation process
- Spoolman is available as an extension, it does not use the bare-metal
  installation anymore, instead it uses the Docker Container approach
- OctoApp is available as an extension
- OctoPrint support was NOT killed. OctoPrint is available as an extension
- I probably forgot to mention some other changes, but the idea is to create
  official docs for KIAUH where the new changelog will live in the future and
  available features and mechanics are explained in detail

If you really want to use v5, there is a v5 branch available in the repository.
Keep in mind that v5 will not be updated anymore.

### 2024-08-31 (v6.0.0-alpha.1)

Long time no see, but here we are again!
A lot has happened in the background, but now it is time to take it out into the
wild.

#### KIAUH has now reached version 6! Well, at least in an alpha state...

The project has seen a complete rewrite of the script from scratch in Python.
It requires Python 3.8 or newer to run. Because this update is still in an alpha
state, bugs may or will occur.
During startup, you will be asked if you want to start the new version 6 or the
old version 5.
As long as version 6 is in a pre-release state, version 5 will still be
available. If there are any critical issues
with the new version that were overlooked, you can always switch back to the old
version.

In case you selected not to get asked about which version to start (option 3 or
4 in the startup dialog) and you want to
revert that decision, you will find a line called `version_to_launch=` within
the `.kiauh.ini` file in your home directory.
Just delete that line, save the file and restart KIAUH. KIAUH will then ask you
again which version you want to start.

Here is a list of the most important changes to KIAUH in regard to version 6:

- The majority of features available in KIAUH v5 are still available; they just
  got migrated from Bash to Python.
- It is now possible to add new/remove instances to/from existing multi-instance
  installations of Klipper and Moonraker
- KIAUH now has an Extension-System. This allows contributors to add new
  installers to KIAUH without having to modify the main script.
    - You will now find some of the features that were previously available in
      the Installer-Menu in the Extensions-Menu.
    - The current extensions are:
        - G-Code Shell Command (previously found in the Advanced-Menu)
        - Mainsail Theme Installer (previously found in the Advanced-Menu)
        - Klipper-Backup (new in v6!)
        - Moonraker Telegram Bot (previously found in the Installer-Menu)
        - PrettyGCode for Klipper (previously found in the Installer-Menu)
        - Obico for Klipper (previously found in the Installer-Menu)
    - The following additional extensions are planned, but not yet available:
        - Spoolman (available in v5 in the Installer-Menu)
        - OctoApp (available in v5 in the Installer-Menu)
- KIAUH has its own config file now
    - The file has some default values for the currently supported options
    - There might be more options in the future
    - It is located in KIAUH's root directory and is called `default.kiauh.cfg`
        - DO NOT EDIT the default file directly, instead make a copy of it and
          call it `kiauh.cfg`
        - Settings changed via the Advanced-Menu will be written to the
          `kiauh.cfg`
- Support for OctoPrint was removed

Feel free to give version 6 a try and report any bugs or issues you encounter!
Every feedback is appreciated.

### 2023-06-17

KIAUH has now added support for installing Mobileraker's companion!
Mobileraker is a free and Open Source Android and iOS App for Klipper, utilizing
the Moonraker API, allowing you
to control your printer. Thank you to [Clon1998](https://github.com/Clon1998)
for adding this feature!

### 2023-02-03

The installer for MJPG-Streamer got replaced by crowsnest. It is an improved
webcam service, utilizing ustreamer.
Please have a look here for additional info about crowsnest and how to configure
it: https://github.com/mainsail-crew/crowsnest \
It's unsure if the previous MJPG-Streamer installer will be updated and make its
way back into KIAUH.
A big thanks to [KwadFan](https://github.com/KwadFan) for writing the crowsnest
implementation.

### 2022-10-31

Some functions got updated, though not all of them.

The following functions are still currently unavailable:

- Installation of: MJPG-Streamer
- All backup functions and the Log-Upload

### 2022-10-20

KIAUH has now reached major version 5 !

Recently Moonraker introduced some changes which makes it necessary to change
the folder structure of printer setups.
If you are interested in the details, check out this
PR: https://github.com/Arksine/moonraker/pull/491 \
Although Moonraker has some mechanics available to migrate existing setups to
the new file structure with the use of symlinks, fresh and clean installs
should be considered.

The version jump of KIAUH to v5 is a breaking change due to those major changes!
That means v4 and v5 are not compatible with each other!
This is also the reason why you will currently be greeted by a yellow
notification in the main menu of KIAUH leading to this changelog.
I decided to disable a few functions of the script and focus on releasing the
required changes to the core components of this script.
I will work on updating the other parts of the script piece by piece during the
next days/weeks.
So I am already sorry in advance if one of your desired components you wanted to
install or use temporarily cannot be installed or used right now.

The following functions are currently unavailable:

- Installation of: KlipperScreen, Obico, Octoprint, MJPG-Streamer, Telegram Bot
  and PrettyGCode
- All backup functions and the Log-Upload

**So what is working?**\
Installation of Klipper, Moonraker, Mainsail and Fluidd. Both, single and
multi-instance setups work!\
As already said, the rest will follow in the near future. Updating and removal
of already installed components should continue to work.

**What was removed?**\
The option to change Klippers configuration directory got removed. From now on
it will not be possible anymore to change
the configuration directory from within KIAUH and the new filestructure is
enforced.

**What if I don't have an existing Klipper/Moonraker install right now?**\
Nothing important to think about, install Klipper and Moonraker. KIAUH will
install both of them with the new filestructure.

**What if I have an existing Klipper/Moonraker install?**\
First of all: Backups! Please copy all of your config files and the Moonraker
database (it is a hidden folder, usually `~/.moonraker_database`) to a safe
location.
After that, uninstall Klipper and Moonraker with KIAUH. You can then proceed and
re-install both of them with KIAUH again. It is important that you are on KIAUH
v5 for that!
Once everything is installed again, you need to manually copy your configuration
files from the old `~/klipper_config` folder to the new `~/printer_data/config`
folder.
Previous, by Moonraker created symlinks to folder of the old filestructure will
not work anymore, you need to move the files to their new location now!
Do the same with the two files inside of `~/.moonraker_database`. Move/copy them
into `~/printer_data/database`. If `~/printer_data/database` is already
populated with a `data.mdb` and `lock.mdb`
delete them or simply overwrite them. Nothing should be lost as those should be
empty database files. Anyway, you made backups, right?
You can now proceed and restart Moonraker. Either from within Mainsail or
Fluidd, or use SSH and execute `sudo systemctl restart moonraker`.
If everything went smooth, you should be good to go again. If you see some
Moonraker warnings about deprecated options in the `moonraker.conf`, go ahead
and resolve them.
I will not cover them in detail here. A good source is the Moonraker
documentation: https://moonraker.readthedocs.io/en/latest/configuration/

**What if I have an existing Klipper/Moonraker multi-instance install?**\
Pretty much the same steps that are required for single instance installs apply
to multi-instance setups. So please go ahead and read the previous paragraph if
you didn't already.
Make backups of everything first. Then remove and install the desired amount of
Klipper and Moonraker instances again.
Now you need to move all config and database files to their new locations.\
Example with an instance called `printer_1`:\
The config files go from `~/klipper_config/printer_1` to
`~/printer_1_data/config`.
The database files go from `~/.moonraker_database_1` to
`~/printer_1_data/database`.
Now restart all Moonraker services. You can restart all of them at once if you
launch KIAUH, and in the main menu type `restart moonraker` and hit Enter.

I hope I have covered the most important things. In case you need further
support, the official Klipper Discord is a good place to ask for help.

### 2022-08-15

Support for "Obico for Klipper" was added! Huge thanks
to [kennethjiang](https://github.com/kennethjiang) for helping me with the
implementation!

### 2022-05-29

KIAUH has now reached major version 4 !

* feat: Klipper can be installed under Python3 (still considered as
  experimental)
* feat: Klipper can be installed from custom repositories / inofficial forks
* feat: Custom instance name for multi instance installations of Klipper
    * Any other multi instance will share the same name given to the
      corresponding Klipper instance
    * E.g. klipper-voron2 -> moonraker-voron2 -> moonraker-telegram-bot-voron2
* feat: Option to allow installation of / updating to unstable Mainsail and
  Fluidd versions
    * by default only stable versions get installed/updated
* feat: Multi-Instance OctoPrint installations now each have their own virtual
  python environment
    * allows independent installation of plugins for each instance
* feat: Implementing the use of shellcheck during development
* feat: Implementing a simple logging mechanic
* feat: Log-upload function now also allows uploading other logfiles (kiauh.log,
  webcamd.log etc.)
* feat: added several new help dialogs which try to explain various functions
* fix: During Klipper installation, checks for group membership of `tty` and
  `dialout` are made
* refactor: rework of the settings menu for better control the new KIAUH
  features
* refactor: Support for DWC and DWC-for-Klipper has been removed
* refactor: The backup before update settings were moved to the KIAUH settings
  menu
* refactor: Switch branch function has been removed (was replaced by the custom
  Klipper repo feature)
* refactor: The update manager sections for Mainsail, Fluidd and KlipperScreen
  were removed from the moonraker.conf template
    * They will now be individually added during installation of the
      corresponding interface
* refactor: The rollback function was reworked and now also allows rollbacks of
  Moonraker
    * It now takes numerical inputs and reverts the corresponding repository by
      the given amount instead
    * KIAUH does not save previous states to its config anymore like it did with
      the previous approach

### 2022-01-29

* Starting from the 28th of January, Moonraker can make use of PackageKit and
  PolicyKit.\
  More details on that can be found [here](
  https://github.com/Arksine/moonraker/issues/349)
  and [here](https://github.com/Arksine/moonraker/pull/346)
* KIAUH will install Moonrakers PolicyKit rules by default when __installing__
  Moonraker
* KIAUH will also install Moonrakers PolicyKit rules when __updating__ Moonraker
  __via KIAUH__ as of now

### 2021-12-30

* Updated the doc for the usage of
  the [G-Code Shell Command Extension](docs/gcode_shell_command.md)
* It became apparent, that some user groups are missing on some systems. A
  missing video group \
  membership for example caused issues when installing mjpg-streamer while not
  using the default pi user. \
  Other issues could occur when trying to flash an MCU on Debian or Ubuntu
  distributions where a user might not be part
  of the dialout group by default. A check for the tty group is also done. The
  tty group is needed for setting
  up a linux MCU (currently not yet supported by KIAUH).
* There is an issue when trying to install Mainsail or Fluidd on Ubuntu 21.10.
  Permissions on that distro seem to have seen a rework
  in comparison to 20.04 and users will be greeted with an "Error 403 -
  Permission denied" message after installing one of Klippers webinterfaces.
  I still have to figure out a viable solution for that.

### 2021-09-28

* New Feature! Added an installer for the Telegram Bot for Moonraker
  by [nlef](https://github.com/nlef).
  Checkout his project! Remember to report all issues and/or bugs regarding that
  project in its corresponding repo and not here 😛.\
  You can find it here: https://github.com/nlef/moonraker-telegram-bot

### 2021-09-24

* The flashing function got adjusted a bit. It is now possible to also flash
  controllers which are connected over UART and thus accessible via
  `/dev/ttyAMA0`. You now have to select a connection methop prior flashing
  which is either USB or UART.
* Due to several requests over time I have now created a Ko-fi account for those
  who want to support this project and my work with a small donation. Many
  thanks in advance to all future donors. You can support me on Ko-fi with this
  link: https://ko-fi.com/th33xitus
* As usual, if you find any bugs or issues please report them. I tested the
  little rework i did with the hardware i have available and haven't encountered
  any malfunctions of flashing them yet.

### 2021-08-10

* KIAUH now supports the installation of the "PrettyGCode for Klipper"
  GCode-Viewer created by [Kragrathea](https://github.com/Kragrathea)!
  Installation, updating and removal are possible with KIAUH. For more details
  to this cool piece of software, please have a look
  here: https://github.com/Kragrathea/pgcode

### 2021-07-10

* The NGINX configuration files got updated to be in sync with MainsailOS and
  FluiddPi. Issues with the NGINX service not starting up due to wrong
  configuration should be resolved now. To get the updated configuration files,
  please remove Moonraker and Mainsail / Fluidd with KIAUH first and then
  re-install it. An automated file check for those configuration files might
  follow in the future which then automates updating those files if there were
  important changes.

* The default `moonraker.conf` was updated to reflect the recent changes to the
  update manager section. The update channel is set to `dev`.

### 2021-06-29

* KIAUH will now patch the new `log_path` to existing moonraker.conf files when
  updating Moonraker and the entry is missing. Before that, it was necessary
  that the user provided that path manually to make Fluidd display the logfiles
  in its interface. This issue should be resolved now.

### 2021-06-15

* Moonraker introduced an optional `log_path` which clients can make use of to
  show log files located in that folder to their users. More info
  here: https://github.com/Arksine/moonraker/commit/829b3a4ee80579af35dd64a37ccc092a1f67682a \
  Client developers agreed upon using `~/klipper_logs` as the new default log
  path.\
  That means, from now on, Klipper and Moonraker services installed with KIAUH
  will place their logfiles in that mentioned folder.
* Additionally, KIAUH will now detect Klipper and Moonraker systemd services
  that still use the old default location of `/tmp/<service>.log` and will
  update them next time the user updates Klipper and/or Moonraker with the KIAUH
  update function.
* Additional symlinks for the following logfiles will get created along those
  update procedures to make them accessible through the webinterface once its
  supported:
    - webcamd.log
    - mainsail-access.log
    - mainsail-error.log
    - fluidd-access.log
    - fluidd-error.log
* For MainsailOS and FluiddPi users:\
  MainsailOS and FluiddPi will switch the shipped Klipper service from SysVinit
  to systemd probably with their next release. KIAUH can already help migrate
  older MainsailOS (0.4.0 and below) and FluiddPi (v1.13.0) releases to match
  their new service-, file- and folder-structure so you don't have to re-flash
  the SD-Card of your Raspberry Pi.\
  In detail here is what is going to happen when you use the new "CustomPiOS
  Migration Helper" from the Advanced Menu\
  `(Main Menu -> 4 -> Enter -> 10 -> Enter)` in a short summary:
    * The Klipper SysVinit service will get replaced by a Klipper systemd
      service
    * Klipper and Moonraker will use the new log-directory `~/klipper_logs`
    * The webcamd service gets updated
    * The webcamd script gets updated and moved from `/root/bin/webcamd` to
      `/usr/local/bin/webcamd`
    * The NGINX `upstreams.conf` gets updated to be able to configure up to 4
      webcams
    * The `mainsail.txt` / `fluiddpi.txt` gets moved from `/boot` to
      `~/klipper_config` and renamed to `webcam.txt`
    * Symlinks for the webcamd.log and various NGINX logs get created in
      `~/klipper_config`
    * Configuration files for Klipper, Moonraker and webcamd get added to
      `/etc/logrotate.d`
    * If they still exist, two lines will be removed from the mainsail.cfg or
      client_macros.cfg macro configurations:\
      `SAVE_GCODE_STATE NAME=PAUSE_state` and
      `RESTORE_GCODE_STATE NAME=PAUSE_state`
* **Please note:**\
  The "CustomPiOS Migration Helper" is intended to only work on "vanilla"
  MainsailOS and FluiddPi systems. Do not try to migrate a modified MainsailOS
  or FluiddPi system (for example if you already used KIAUH to re-install
  services or to set up a multi-instance installation for Klipper / Moonraker).
  This won't work.

### 2021-01-31

* **This is a big one... KIAUH v3.0 is out.**\
  With this update you can now install multiple instances of Klipper, Moonraker,
  Duet Web Control or Octoprint on the same Pi. This was quite a big rework of
  the whole script. So bugs can appear but with the help of some testers, i
  think there shouldn't be any critical ones anymore. In this regards thanks to
  @lixxbox and @zellneralex for testing.

* Important changes to how installations are set up now: All components get
  installed as systemd services. Installation via init.d was dropped completely!
  This shouldn't affect you at all, since the common linux distributions like
  RaspberryPi OS or custom distributions like MainsailOS, FluiddPi or OctoPi
  support both ways of installing services. I just wanted to mention it here.

* Now with KIAUH v3.0 and multi-instance installation capabilities, there are
  some things to point out. You will now need to tell KIAUH where your printers
  configurations are located when installing Klipper for the first time. Even
  though it is not recommended, you can change this location with the help of
  KIAUH and rewrite Klipper and Moonraker to use the new location.

* When setting up a multi-instance system, the folder structure will only change
  slightly. The goal was to keep it as compatible as possible with the custom
  distributions like mainsailOS and FluiddPi. This should help converting a
  single-instance setup of mainsailOS/FluiddPi to a multi-instance setup in no
  time, but keeping single-instance backwards compatibility if needed at a later
  point in time.

* The folder structure is as follows when setting up multi-instances:\
  Each printer instance will get its own folder within your configuration
  location. The decision to this specific structure was made to make it as
  painless and easy as possible to convert to a multi-instance setup.
  Here is an example:
    ```shell
    /home/<username>
              └── klipper_config
                  ├── printer_1
                  │   ├── printer.cfg
                  │   └── moonraker.conf
                  ├── printer_2
                  │   ├── printer.cfg
                  │   └── moonraker.conf
                  └── printer_n
                      ├── printer.cfg
                      └── moonraker.conf
    ```
* Also when setting up multi-instances of each service, the name of each service
  slightly changes.
  Each service gets its corresponding instance added to the service filename.

  **This only applies to multi-instances! Single instance installations with
  KIAUH will keep their original names!**

  Corresponding to the filetree example from above that would mean:
    ```
    Klipper services:
            --> klipper-1.service
            --> klipper-2.service
            --> klipper-n.service

    Moonraker services:
            --> moonraker-1.service
            --> moonraker-2.service
            --> moonraker-n.service
    ```
* The same service file rules from above apply to OctoPrint even though only
  Klipper and Moonraker are shown in this example.

* You can start, stop and restart all Klipper, Moonraker and OctoPrint instances
  from the KIAUH main menu. For doing this, just type "stop klipper", "start
  moonraker", "restart octoprint" and so on.

* KIAUH v3.0 relocated its ini-file. It is now a hidden file in the users
  home-directory calles `.kiauh.ini`. This has the benefit of keeping all values
  in that file between possible re-installations of KIAUH. Otherwise that file
  would be lost.

* The option of adding more trusted clients to the moonraker.conf file was
  dropped. Since you can edit this file right inside of Mainsail or Fluidd, only
  some basic entries are made which get you running.

* I bet i have missed mentioning other stuff as well because it took me quite
  some time to re-write many functions. So i just hope you like the new version
  😄

### 2020-11-28

* KIAUH now supports the installation, update and removal
  of [KlipperScreen](https://github.com/jordanruthe/KlipperScreen). This feature
  was was provided by [jordanruthe](https://github.com/jordanruthe)! Thank you!

### 2020-11-18

* Some changes to Fluidd caused a little rework on how KIAUH will install/update
  Fluidd from now on. Please see
  the [fluidd v1.0.0-rc0 release notes](https://github.com/cadriel/fluidd/releases/tag/v1.0.0-rc.0)
  for further information about what modifications to the moonraker.conf file
  exactly had to be done. In a nutshell, KIAUH will now always patch the
  required entries to the moonraker.conf if not already there.

### 2020-10-30:

* The user can now choose to install Klipper as a systemd service.

* The Shell Command extension and `shell_command.py` got renamed to G-Code Shell
  Command extension and `gcode_shell_command.py`. In case
  the [pending PR](https://github.com/KevinOConnor/klipper/pull/2173) will be
  merged in the future, this was an early attempt to dodge possible
  incompatibilities. The [G-Code Shell Command docs](gcode_shell_command.md) has
  been updated accordingly.

* The way how KIAUH interacts and writes to the users printer.cfg got changed.
  Usually KIAUH wrote everything directly into the printer.cfg. The way it will
  work from now on is, that a new file called `kiauh.cfg` will be created if
  there is something that needs to be written to the printer.cfg and everything
  gets written to `kiauh.cfg` instead. The only thing which then gets written to
  the users printer.cfg is `[include kiauh.cfg]`. This line will be located at
  the very top of the existing printer.cfg with a little comment as a note. The
  user can then decide to either keep the `kiauh.cfg` or take its content,
  places it into the printer.cfg directly and remove the `[include kiauh.cfg]`.

* The `mainsail_macros.cfg` got renamed to `webui_macros.cfg`. Since Mainsail
  and Fluidd both use the same kind of pause, cancel and resume macros, a more
  generic name was chosen for the file containing the example macros one can
  choose to install when installing those webinterfaces.

### 2020-10-10:

* Support for changing the Klipper branch to the moonraker-dev branch from
  @Arksine has been dropped. Support for Moonraker has been merged into Klipper
  mainline a long time ago.

* A new function is available from the main menu. You can now upload your log
  files to http://paste.c-net.org/ to share them for debugging purposes.

### 2020-10-06:

* Fluidd, a new Klipper interface got added to the list of available installers.
  At the same time some installation routines have changed or have seen some
  rework. Changes were made to the installation of NGINX configurations. A
  method was introduced to change the listen port of a webinterface
  configuration if there is already another webinterface listening on the
  default port (80).

* At the moment, the Moonraker installer no longer asks you whether you want to
  install a web interface too. For now you therefore have to install them with
  their respective installers. Please report any bugs or issues you encounter.

### 2020-09-17:

* The dev-2.0 branch will be abandoned as of today. If you did a checkout to
  that branch in the past, you have to checkout back to master to receive
  updates.

### 2020-09-12:

* The old [dwc2-for-klipper](https://github.com/Stephan3/dwc2-for-klipper) won't
  be supported anymore!\
  The is a new, fully rewritten project
  available: [dwc2-for-klipper-socket](https://github.com/Stephan3/dwc2-for-klipper-socket).\
  The installer of this script also got rewritten to make use of that new
  project. You will not be able to install or remove the
  old [dwc2-for-klipper](https://github.com/Stephan3/dwc2-for-klipper) with
  KIAUH anymore if you updated KIAUH to the newest version.

---

### Gcode Shell Command (`docs/gcode_shell_command.md`)

# G-Code Shell Command Extension

### Creator of this extension is [Arksine](https://github.com/Arksine).

This is a brief explanation of how to use the shell command extension for Klipper, which you can install with KIAUH.

After installing the extension you can execute linux commands or even scripts from within Klipper with custom commands defined in your printer.cfg.

#### How to configure a shell command:

```shell
# Runs a linux command or script from within klipper.  Note that sudo commands
# that require password authentication are disallowed. All executable scripts
# should include a shebang.
# [gcode_shell_command my_shell_cmd]
#command:
#  The linux shell command/script to be executed.  This parameter must be
#  provided
#timeout: 2.
#  The timeout in seconds until the command is forcably terminated.  Default
#  is 2 seconds.
#verbose: True
#  If enabled, the command's output will be forwarded to the terminal.  Its
#  recommended to set this to false for commands that my run in quick
#  succession.  Default is True.
```

Once you have set up a shell command with the given parameters from above in your printer.cfg you can run the command as follows:
`RUN_SHELL_COMMAND CMD=name`

Example:

```
[gcode_shell_command hello_world]
command: echo hello world
timeout: 2.
verbose: True
```

Execute with:
`RUN_SHELL_COMMAND CMD=hello_world`

### Passing parameters:
As of commit [f231fa9](https://github.com/dw-0/kiauh/commit/f231fa9c69191f23277b4e3319f6b675bfa0ee42) it is also possible to pass optional parameters to a `gcode_shell_command`.
The following short example shows storing the extruder temperature into a variable, passing that value with a parameter to a `gcode_shell_command`, which then, 
once the gcode_macro runs and the gcode_shell_command gets called, executes the `script.sh`. The script then echoes a message to the console (if `verbose: True`) 
and writes the value of the parameter into a textfile called `test.txt` located in the home directory.

Content of the `gcode_shell_command` and the `gcode_macro`:
```
[gcode_shell_command print_to_file]
command: sh /home/pi/klipper_config/script.sh
timeout: 30.
verbose: True

[gcode_macro GET_TEMP]
gcode:
    {% set temp = printer.extruder.temperature %}
    { action_respond_info("%s" % (temp)) }
    RUN_SHELL_COMMAND CMD=print_to_file PARAMS={temp}
```

Content of `script.sh`:
```shell
#!/bin/sh

echo "temp is: $1"
echo "$1" >> "${HOME}/test.txt"
```

## Warning

This extension may have a high potential for abuse if not used carefully! Also, depending on the command you execute, high system loads may occur and can cause system instabilities.
Use this extension at your own risk and only if you know what you are doing!

---

--- METRICS ---
- Files Extracted: 4
- Estimated Token Budget: ~10222 tokens
- Canonical Reference: https://codewiki.google/github.com/dw-0/kiauh
