Compare commits
28 Commits
master
...
CODeRUS/in
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70c316b512 | ||
|
|
4bbab899e7 | ||
|
|
c148b0e8ac | ||
|
|
38090816ca | ||
|
|
2b168e2463 | ||
|
|
37f673dde9 | ||
|
|
516af17df0 | ||
|
|
4543ccff20 | ||
|
|
4c2d834560 | ||
|
|
176c44d6e4 | ||
|
|
b11fbdb953 | ||
|
|
e0d65cc447 | ||
|
|
7c1c1d8f21 | ||
|
|
00a3fbe43b | ||
|
|
d02fc2e01f | ||
|
|
26d27a03ec | ||
|
|
57e7b476fa | ||
|
|
3071e1e037 | ||
|
|
2b53e005e6 | ||
|
|
937ad4cffd | ||
|
|
40fee65bf4 | ||
|
|
3b68783f3b | ||
|
|
72b5038e71 | ||
|
|
3556a009ec | ||
|
|
b131cf56ef | ||
|
|
c07c17e8c9 | ||
|
|
810fcde5c1 | ||
|
|
ea5219ddc9 |
4
.github/FUNDING.yml
vendored
4
.github/FUNDING.yml
vendored
@@ -3,10 +3,10 @@
|
|||||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||||
patreon: # Replace with a single Patreon username
|
patreon: # Replace with a single Patreon username
|
||||||
open_collective: # Replace with a single Open Collective username
|
open_collective: # Replace with a single Open Collective username
|
||||||
ko_fi: dw__0
|
ko_fi: th33xitus
|
||||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||||
liberapay: # Replace with a single Liberapay username
|
liberapay: # Replace with a single Liberapay username
|
||||||
issuehunt: # Replace with a single IssueHunt username
|
issuehunt: # Replace with a single IssueHunt username
|
||||||
otechie: # Replace with a single Otechie username
|
otechie: # Replace with a single Otechie username
|
||||||
custom: https://paypal.me/dwillner0
|
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||||
|
|||||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,4 +1 @@
|
|||||||
.idea
|
klipper_repos.txt
|
||||||
.vscode
|
|
||||||
*.code-workspace
|
|
||||||
klipper_repos.txt
|
|
||||||
66
README.md
66
README.md
@@ -1,6 +1,6 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<a>
|
<a>
|
||||||
<img src="https://raw.githubusercontent.com/dw-0/kiauh/master/resources/screenshots/kiauh.png" alt="KIAUH logo" height="181">
|
<img src="https://raw.githubusercontent.com/th33xitus/kiauh/master/resources/screenshots/kiauh.png" alt="KIAUH logo" height="181">
|
||||||
<h1 align="center">Klipper Installation And Update Helper</h1>
|
<h1 align="center">Klipper Installation And Update Helper</h1>
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
@@ -10,14 +10,14 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a><img src="https://img.shields.io/github/license/dw-0/kiauh"></a>
|
<a><img src="https://img.shields.io/github/license/th33xitus/kiauh"></a>
|
||||||
<a><img src="https://img.shields.io/github/stars/dw-0/kiauh"></a>
|
<a><img src="https://img.shields.io/github/stars/th33xitus/kiauh"></a>
|
||||||
<a><img src="https://img.shields.io/github/forks/dw-0/kiauh"></a>
|
<a><img src="https://img.shields.io/github/forks/th33xitus/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/languages/top/th33xitus/kiauh?logo=gnubash&logoColor=white"></a>
|
||||||
<a><img src="https://img.shields.io/github/v/tag/dw-0/kiauh"></a>
|
<a><img src="https://img.shields.io/github/v/tag/th33xitus/kiauh"></a>
|
||||||
<br />
|
<br />
|
||||||
<a><img src="https://img.shields.io/github/last-commit/dw-0/kiauh"></a>
|
<a><img src="https://img.shields.io/github/last-commit/th33xitus/kiauh"></a>
|
||||||
<a><img src="https://img.shields.io/github/contributors/dw-0/kiauh"></a>
|
<a><img src="https://img.shields.io/github/contributors/th33xitus/kiauh"></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
@@ -29,25 +29,25 @@
|
|||||||
### 📋 Prerequisites
|
### 📋 Prerequisites
|
||||||
KIAUH is a script that assists you in installing Klipper on a Linux operating system that has
|
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
|
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
|
that you have a functional Linux system on hand. `Raspberry Pi OS Lite (32bit)` is a recommended Linux image
|
||||||
if you are using a Raspberry Pi. The [official Raspberry Pi Imager](https://www.raspberrypi.com/software/)
|
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.
|
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,
|
* Once you downloaded, installed and launched the Raspberry Pi Imager
|
||||||
select `Choose OS -> Raspberry Pi OS (other)`: \
|
select `Choose OS -> Raspberry Pi OS (other)`: \
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://raw.githubusercontent.com/dw-0/kiauh/master/resources/screenshots/rpi_imager1.png" alt="KIAUH logo" height="350">
|
<img src="https://raw.githubusercontent.com/th33xitus/kiauh/master/resources/screenshots/rpi_imager1.png" alt="KIAUH logo" height="350">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
* Then select `Raspberry Pi OS Lite (32bit)` (or 64bit if you want to use that instead):
|
* Then select `Raspberry Pi OS Lite (32bit)`:
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://raw.githubusercontent.com/dw-0/kiauh/master/resources/screenshots/rpi_imager2.png" alt="KIAUH logo" height="350">
|
<img src="https://raw.githubusercontent.com/th33xitus/kiauh/master/resources/screenshots/rpi_imager2.png" alt="KIAUH logo" height="350">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
* Back in the Raspberry Pi Imager's main menu, select the corresponding SD card to which
|
* Back in the Raspberry Pi Imager's main menu, select the corresponding SD card to which
|
||||||
you want to flash the image.
|
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)
|
* Make sure to go into the Advaced Option (the cog icon in the lower left corner of the main menu)
|
||||||
and enable SSH and configure Wi-Fi.
|
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).
|
* 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).
|
||||||
@@ -64,18 +64,18 @@ distributions based on Debian 11 Bullseye. Read the notes further down below in
|
|||||||
* **Step 1:** \
|
* **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:
|
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
|
```shell
|
||||||
sudo apt-get update && sudo apt-get install git -y
|
sudo apt-get install git -y
|
||||||
```
|
```
|
||||||
|
|
||||||
* **Step 2:** \
|
* **Step 2:** \
|
||||||
Once git is installed, use the following command to download KIAUH into your home-directory:
|
Once git is installed, use the following command to download KIAUH into your home-directoy:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
cd ~ && git clone https://github.com/dw-0/kiauh.git
|
cd ~ && git clone https://github.com/th33xitus/kiauh.git
|
||||||
```
|
```
|
||||||
|
|
||||||
* **Step 3:** \
|
* **Step 3:** \
|
||||||
Finally, start KIAUH by running the next command:
|
Finally start KIAUH by running the next command:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
./kiauh/kiauh.sh
|
./kiauh/kiauh.sh
|
||||||
@@ -125,7 +125,7 @@ prompt and confirm by hitting ENTER.
|
|||||||
<tr>
|
<tr>
|
||||||
<th><img src="https://raw.githubusercontent.com/fluidd-core/fluidd/master/docs/assets/images/logo.svg" alt="Fluidd Logo" height="64"></th>
|
<th><img src="https://raw.githubusercontent.com/fluidd-core/fluidd/master/docs/assets/images/logo.svg" alt="Fluidd Logo" height="64"></th>
|
||||||
<th><img src="https://avatars.githubusercontent.com/u/31575189?v=4" alt="jordanruthe avatar" height="64"></th>
|
<th><img src="https://avatars.githubusercontent.com/u/31575189?v=4" alt="jordanruthe avatar" height="64"></th>
|
||||||
<th><img src="https://raw.githubusercontent.com/OctoPrint/OctoPrint/master/docs/images/octoprint-logo.png" alt="OctoPrint Logo" height="64"></th>
|
<th><img src="https://camo.githubusercontent.com/627be7fc67195b626b298af9b9677d7c58e698c67305e54324cffbe06130d4a4/68747470733a2f2f6f63746f7072696e742e6f72672f6173736574732f696d672f6c6f676f2e706e67" alt="OctoPrint Logo" height="64"></th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>by <a href="https://github.com/fluidd-core">fluidd-core</a></th>
|
<th>by <a href="https://github.com/fluidd-core">fluidd-core</a></th>
|
||||||
@@ -152,25 +152,22 @@ prompt and confirm by hitting ENTER.
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th><h3><a href="https://github.com/Clon1998/mobileraker_companion">Mobileraker's Companion</a></h3></th>
|
<th><h3></h3></th>
|
||||||
<th><h3><a href="https://octoeverywhere.com/?source=kiauh_readme">OctoEverywhere For Klipper</a></h3></th>
|
<th><h3><a href="https://octoeverywhere.com/?source=kiauh_readme">OctoEverywhere For Klipper</a></h3></th>
|
||||||
<th><h3><a href="https://github.com/crysxd/OctoPrint-OctoApp">OctoApp For Klipper</a></h3></th>
|
|
||||||
<th><h3></h3></th>
|
<th><h3></h3></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th><a href="https://github.com/Clon1998/mobileraker_companion"><img src="https://raw.githubusercontent.com/Clon1998/mobileraker/master/assets/icon/mr_appicon.png" alt="OctoEverywhere Logo" height="64"></th>
|
<th></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>
|
<th><a href="https://octoeverywhere.com/?source=kiauh_readme"><img src="https://octoeverywhere.com/img/logo.svg" alt="OctoEverywhere Logo" height="64"></a></th>
|
||||||
<th><a href="https://octoapp.eu/?source=kiauh_readme"><img src="https://octoapp.eu/octoapp.webp" alt="OctoApp Logo" height="64"></a></th>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<th>by <a href="https://github.com/Clon1998">Patrick Schmidt</a></th>
|
|
||||||
<th>by <a href="https://github.com/QuinnDamerell">Quinn Damerell</a></th>
|
|
||||||
<th>by <a href="https://github.com/crysxd">Christian Würthner</a></th>
|
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th>by <a href="https://github.com/QuinnDamerell">Quinn Damerell</a></th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
@@ -179,14 +176,5 @@ prompt and confirm by hitting ENTER.
|
|||||||
<h2 align="center">✨ Credits ✨</h2>
|
<h2 align="center">✨ Credits ✨</h2>
|
||||||
|
|
||||||
* A big thank you to [lixxbox](https://github.com/lixxbox) for that awesome KIAUH-Logo!
|
* 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) !
|
* Also, a big thank you to everyone who supported my work with a [Ko-fi](https://ko-fi.com/th33xitus) !
|
||||||
* Last but not least: Thank you to all contributors and members of the Klipper Community who like and share this project!
|
* Last but not least: Thank you to all contributors and members of the Klipper Community who like and share this project!
|
||||||
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
<h4 align="center">A special thank you to JetBrains for sponsoring this project with their incredible software!</h4>
|
|
||||||
<p align="center">
|
|
||||||
<a href="https://www.jetbrains.com/community/opensource/#support" target="_blank">
|
|
||||||
<img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.png" alt="JetBrains Logo (Main) logo." height="128">
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
|
|||||||
@@ -2,11 +2,6 @@
|
|||||||
|
|
||||||
This document covers possible important changes to KIAUH.
|
This document covers possible important changes to KIAUH.
|
||||||
|
|
||||||
### 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
|
### 2023-02-03
|
||||||
The installer for MJPG-Streamer got replaced by crowsnest. It is an improved webcam service, utilizing ustreamer.
|
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 \
|
Please have a look here for additional info about crowsnest and how to configure it: https://github.com/mainsail-crew/crowsnest \
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ Execute with:
|
|||||||
`RUN_SHELL_COMMAND CMD=hello_world`
|
`RUN_SHELL_COMMAND CMD=hello_world`
|
||||||
|
|
||||||
### Passing parameters:
|
### 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`.
|
As of commit [f231fa9](https://github.com/th33xitus/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,
|
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`)
|
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.
|
and writes the value of the parameter into a textfile called `test.txt` located in the home directory.
|
||||||
|
|||||||
8
kiauh.sh
8
kiauh.sh
@@ -1,14 +1,18 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
|
|
||||||
|
# TODO: upload_log
|
||||||
|
# TODO: all backup functions
|
||||||
|
# TODO: doublecheck that nothing got missed!
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
clear
|
clear
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
[mcu]
|
[mcu]
|
||||||
serial: /dev/serial/by-id/<your-mcu-id>
|
serial: /dev/serial/by-id/<your-mcu-id>
|
||||||
|
|
||||||
[virtual_sdcard]
|
|
||||||
path: %GCODES_DIR%
|
|
||||||
on_error_gcode: CANCEL_PRINT
|
|
||||||
|
|
||||||
[printer]
|
[printer]
|
||||||
kinematics: none
|
kinematics: none
|
||||||
max_velocity: 1000
|
max_velocity: 1000
|
||||||
max_accel: 1000
|
max_accel: 1000
|
||||||
@@ -1 +1 @@
|
|||||||
KLIPPER_ARGS="%KLIPPER_DIR%/klippy/klippy.py %CFG% -I %PRINTER% -l %LOG% -a %UDS%"
|
KLIPPER_ARGS="/home/%USER%/klipper/klippy/klippy.py %CFG% -I %PRINTER% -l %LOG% -a %UDS%"
|
||||||
@@ -10,8 +10,7 @@ WantedBy=multi-user.target
|
|||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
User=%USER%
|
User=%USER%
|
||||||
RemainAfterExit=yes
|
WorkingDirectory=/home/%USER%/klipper
|
||||||
WorkingDirectory=%KLIPPER_DIR%
|
|
||||||
EnvironmentFile=%ENV_FILE%
|
EnvironmentFile=%ENV_FILE%
|
||||||
ExecStart=%ENV%/bin/python $KLIPPER_ARGS
|
ExecStart=%ENV%/bin/python $KLIPPER_ARGS
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
TELEGRAM_BOT_ARGS="%TELEGRAM_BOT_DIR%/bot/main.py -c %CFG% -l %LOG%"
|
TELEGRAM_BOT_ARGS="/home/%USER%/moonraker-telegram-bot/bot/main.py -c %CFG% -l %LOG%"
|
||||||
@@ -9,7 +9,7 @@ WantedBy=multi-user.target
|
|||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
User=%USER%
|
User=%USER%
|
||||||
WorkingDirectory=%TELEGRAM_BOT_DIR%
|
WorkingDirectory=/home/%USER%/moonraker-telegram-bot
|
||||||
EnvironmentFile=%ENV_FILE%
|
EnvironmentFile=%ENV_FILE%
|
||||||
ExecStart=%ENV%/bin/python $TELEGRAM_BOT_ARGS
|
ExecStart=%ENV%/bin/python $TELEGRAM_BOT_ARGS
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
MOONRAKER_ARGS="%MOONRAKER_DIR%/moonraker/moonraker.py -d %PRINTER_DATA%"
|
MOONRAKER_ARGS="/home/%USER%/moonraker/moonraker/moonraker.py -d %PRINTER_DATA%"
|
||||||
@@ -11,8 +11,7 @@ WantedBy=multi-user.target
|
|||||||
Type=simple
|
Type=simple
|
||||||
User=%USER%
|
User=%USER%
|
||||||
SupplementaryGroups=moonraker-admin
|
SupplementaryGroups=moonraker-admin
|
||||||
RemainAfterExit=yes
|
WorkingDirectory=/home/%USER%/moonraker
|
||||||
WorkingDirectory=%MOONRAKER_DIR%
|
|
||||||
EnvironmentFile=%ENV_FILE%
|
EnvironmentFile=%ENV_FILE%
|
||||||
ExecStart=%ENV%/bin/python $MOONRAKER_ARGS
|
ExecStart=%ENV%/bin/python $MOONRAKER_ARGS
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -31,30 +31,21 @@ function backup_before_update() {
|
|||||||
backup_"${1}"
|
backup_"${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function backup_config_dir() {
|
function backup_klipper_config_dir() {
|
||||||
check_for_backup_dir
|
check_for_backup_dir
|
||||||
local current_date config_pathes
|
local current_date config_folder_name
|
||||||
|
|
||||||
config_pathes=$(get_config_folders)
|
if [[ -d "${KLIPPER_CONFIG}" ]]; then
|
||||||
|
|
||||||
if [[ -n "${config_pathes}" ]]; then
|
|
||||||
current_date=$(get_date)
|
current_date=$(get_date)
|
||||||
status_msg "Timestamp: ${current_date}"
|
config_folder_name="$(echo "${KLIPPER_CONFIG}" | rev | cut -d"/" -f1 | rev)"
|
||||||
|
|
||||||
local i=0 folder folder_name target_dir
|
status_msg "Timestamp: ${current_date}"
|
||||||
for folder in ${config_pathes}; do
|
status_msg "Create backup of the Klipper config directory ..."
|
||||||
if [[ -d ${folder} ]]; then
|
|
||||||
status_msg "Create backup of ${folder} ..."
|
mkdir -p "${BACKUP_DIR}/${config_folder_name}/${current_date}"
|
||||||
|
cp -r "${KLIPPER_CONFIG}" "${_}"
|
||||||
folder_name=$(echo "${folder}" | rev | cut -d"/" -f2 | rev)
|
|
||||||
target_dir="${BACKUP_DIR}/configs/${current_date}/${folder_name}"
|
print_confirm "Configuration directory backup complete!"
|
||||||
mkdir -p "${target_dir}"
|
|
||||||
cp -r "${folder}" "${target_dir}"
|
|
||||||
i=$(( i + 1 ))
|
|
||||||
|
|
||||||
ok_msg "Backup created in:\n${target_dir}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
else
|
else
|
||||||
ok_msg "No config directory found! Skipping backup ..."
|
ok_msg "No config directory found! Skipping backup ..."
|
||||||
fi
|
fi
|
||||||
@@ -62,29 +53,27 @@ function backup_config_dir() {
|
|||||||
|
|
||||||
function backup_moonraker_database() {
|
function backup_moonraker_database() {
|
||||||
check_for_backup_dir
|
check_for_backup_dir
|
||||||
local current_date db_pathes
|
local current_date databases target_dir regex=".moonraker_database(_[0-9a-zA-Z]+)?"
|
||||||
|
databases=$(find "${HOME}" -maxdepth 1 -type d -regextype posix-extended -regex "${HOME}/${regex}" | sort)
|
||||||
|
|
||||||
db_pathes=$(get_instance_folder_path "database")
|
if [[ -n ${databases} ]]; then
|
||||||
|
|
||||||
if [[ -n ${db_pathes} ]]; then
|
|
||||||
current_date=$(get_date)
|
current_date=$(get_date)
|
||||||
|
target_dir="${BACKUP_DIR}/moonraker_database_backup/${current_date}"
|
||||||
|
|
||||||
status_msg "Timestamp: ${current_date}"
|
status_msg "Timestamp: ${current_date}"
|
||||||
|
mkdir -p "${target_dir}"
|
||||||
|
|
||||||
local i=0 database folder_name target_dir
|
for database in ${databases}; do
|
||||||
for database in ${db_pathes}; do
|
|
||||||
status_msg "Create backup of ${database} ..."
|
status_msg "Create backup of ${database} ..."
|
||||||
|
|
||||||
folder_name=$(echo "${database}" | rev | cut -d"/" -f2 | rev)
|
|
||||||
target_dir="${BACKUP_DIR}/moonraker_databases/${current_date}/${folder_name}"
|
|
||||||
mkdir -p "${target_dir}"
|
|
||||||
cp -r "${database}" "${target_dir}"
|
cp -r "${database}" "${target_dir}"
|
||||||
i=$(( i + 1 ))
|
ok_msg "Done!"
|
||||||
|
|
||||||
ok_msg "Backup created in:\n${target_dir}"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
print_confirm "Moonraker database backup complete!"
|
||||||
else
|
else
|
||||||
print_error "No Moonraker database found! Skipping backup ..."
|
print_error "No Moonraker database found! Skipping backup ..."
|
||||||
fi
|
fi
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
function backup_klipper() {
|
function backup_klipper() {
|
||||||
@@ -197,19 +186,3 @@ function backup_telegram_bot() {
|
|||||||
print_error "Can't back up MoonrakerTelegramBot directory!\n Not found!"
|
print_error "Can't back up MoonrakerTelegramBot directory!\n Not found!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function backup_octoeverywhere() {
|
|
||||||
local current_date
|
|
||||||
|
|
||||||
if [[ -d ${OCTOEVERYWHERE_DIR} ]] ; then
|
|
||||||
status_msg "Creating OctoEverywhere backup ..."
|
|
||||||
check_for_backup_dir
|
|
||||||
current_date=$(get_date)
|
|
||||||
status_msg "Timestamp: ${current_date}"
|
|
||||||
mkdir -p "${BACKUP_DIR}/OctoEverywhere-backups/${current_date}"
|
|
||||||
cp -r "${OCTOEVERYWHERE_DIR}" "${_}" && cp -r "${OCTOEVERYWHERE_ENV}" "${_}"
|
|
||||||
print_confirm "OctoEverywhere backup complete!"
|
|
||||||
else
|
|
||||||
print_error "Can't back up OctoEverywhere directory!\n Not found!"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -105,7 +105,7 @@ function install_crowsnest(){
|
|||||||
pushd "${HOME}/crowsnest" &> /dev/null || exit 1
|
pushd "${HOME}/crowsnest" &> /dev/null || exit 1
|
||||||
title_msg "Installer will prompt you for sudo password!"
|
title_msg "Installer will prompt you for sudo password!"
|
||||||
status_msg "Launching crowsnest installer ..."
|
status_msg "Launching crowsnest installer ..."
|
||||||
if ! sudo make install BASE_USER=$USER; then
|
if ! sudo make install; then
|
||||||
error_msg "Something went wrong! Please try again..."
|
error_msg "Something went wrong! Please try again..."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -117,22 +117,18 @@ function install_crowsnest(){
|
|||||||
|
|
||||||
# Remove func
|
# Remove func
|
||||||
function remove_crowsnest(){
|
function remove_crowsnest(){
|
||||||
if [[ -d "${CROWSNEST_DIR}" ]]; then
|
pushd "${HOME}/crowsnest" &> /dev/null || exit 1
|
||||||
pushd "${HOME}/crowsnest" &> /dev/null || exit 1
|
title_msg "Uninstaller will prompt you for sudo password!"
|
||||||
title_msg "Uninstaller will prompt you for sudo password!"
|
status_msg "Launching crowsnest uninstaller ..."
|
||||||
status_msg "Launching crowsnest uninstaller ..."
|
if ! make uninstall; then
|
||||||
|
error_msg "Something went wrong! Please try again..."
|
||||||
if ! make uninstall; then
|
exit 1
|
||||||
error_msg "Something went wrong! Please try again..."
|
fi
|
||||||
exit 1
|
if [[ -e "${CROWSNEST_DIR}" ]]; then
|
||||||
fi
|
|
||||||
|
|
||||||
status_msg "Removing crowsnest directory ..."
|
status_msg "Removing crowsnest directory ..."
|
||||||
rm -rf "${CROWSNEST_DIR}"
|
rm -rf "${CROWSNEST_DIR}"
|
||||||
ok_msg "Directory removed!"
|
ok_msg "Directory removed!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print_confirm "Crowsnest successfully removed!"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Status funcs
|
# Status funcs
|
||||||
@@ -201,7 +197,7 @@ function compare_crowsnest_versions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function install_crowsnest_dependencies() {
|
function install_crowsnest_dependencies() {
|
||||||
local packages log_name="Crowsnest"
|
local packages
|
||||||
local install_script="${CROWSNEST_DIR}/tools/install.sh"
|
local install_script="${CROWSNEST_DIR}/tools/install.sh"
|
||||||
|
|
||||||
### read PKGLIST from official install-script
|
### read PKGLIST from official install-script
|
||||||
@@ -212,11 +208,21 @@ function install_crowsnest_dependencies() {
|
|||||||
echo "${cyan}${packages}${white}" | tr '[:space:]' '\n'
|
echo "${cyan}${packages}${white}" | tr '[:space:]' '\n'
|
||||||
read -r -a packages <<< "${packages}"
|
read -r -a packages <<< "${packages}"
|
||||||
|
|
||||||
### Update system package lists if stale
|
### Update system package info
|
||||||
update_system_package_lists
|
status_msg "Updating package lists..."
|
||||||
|
if ! sudo apt-get update --allow-releaseinfo-change; then
|
||||||
|
log_error "failure while updating package lists"
|
||||||
|
error_msg "Updating package lists failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
### Install required packages
|
### Install required packages
|
||||||
install_system_packages "${log_name}" "packages[@]"
|
status_msg "Installing required packages..."
|
||||||
|
if ! sudo apt-get install --yes "${packages[@]}"; then
|
||||||
|
log_error "failure while installing required crowsnest packages"
|
||||||
|
error_msg "Installing required packages failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_crowsnest() {
|
function update_crowsnest() {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -52,57 +52,16 @@ function init_flash_process() {
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
### step 2: select how the mcu is flashed (flash/serialflash)
|
### step 2: select how the mcu is connected to the host
|
||||||
select_flash_command
|
|
||||||
|
|
||||||
### step 3: select how the mcu is connected to the host
|
|
||||||
select_mcu_connection
|
select_mcu_connection
|
||||||
|
|
||||||
### step 4: select which detected mcu should be flashed
|
### step 3: select which detected mcu should be flashed
|
||||||
select_mcu_id "${method}"
|
select_mcu_id "${method}"
|
||||||
}
|
}
|
||||||
|
|
||||||
#================================================#
|
#================================================#
|
||||||
#=================== STEP 2 =====================#
|
#=================== STEP 2 =====================#
|
||||||
#================================================#
|
#================================================#
|
||||||
function select_flash_command() {
|
|
||||||
unset flash_command
|
|
||||||
|
|
||||||
top_border
|
|
||||||
echo -e "| How to flash MCU? |"
|
|
||||||
echo -e "| 1) make flash (default) |"
|
|
||||||
echo -e "| 2) make serialflash (stm32flash) |"
|
|
||||||
blank_line
|
|
||||||
back_help_footer
|
|
||||||
|
|
||||||
local choice
|
|
||||||
while true; do
|
|
||||||
read -p "${cyan}###### Flashing command:${white} " -i "1" -e choice
|
|
||||||
case "${choice}" in
|
|
||||||
1)
|
|
||||||
select_msg "Selected 'make flash' command"
|
|
||||||
flash_command="flash"
|
|
||||||
break;;
|
|
||||||
2)
|
|
||||||
select_msg "Selected 'make serialflash' command"
|
|
||||||
flash_command="serialflash"
|
|
||||||
break;;
|
|
||||||
B|b)
|
|
||||||
advanced_menu
|
|
||||||
break;;
|
|
||||||
H|h)
|
|
||||||
clear && print_header
|
|
||||||
show_mcu_flash_command_help
|
|
||||||
break;;
|
|
||||||
*)
|
|
||||||
error_msg "Invalid command!";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
#================================================#
|
|
||||||
#=================== STEP 3 =====================#
|
|
||||||
#================================================#
|
|
||||||
function select_mcu_connection() {
|
function select_mcu_connection() {
|
||||||
top_border
|
top_border
|
||||||
echo -e "| ${yellow}Make sure that the controller board is connected now!${white} |"
|
echo -e "| ${yellow}Make sure that the controller board is connected now!${white} |"
|
||||||
@@ -111,7 +70,6 @@ function select_mcu_connection() {
|
|||||||
echo -e "| How is the controller board connected to the host? |"
|
echo -e "| How is the controller board connected to the host? |"
|
||||||
echo -e "| 1) USB |"
|
echo -e "| 1) USB |"
|
||||||
echo -e "| 2) UART |"
|
echo -e "| 2) UART |"
|
||||||
echo -e "| 3) USB (DFU mode) |"
|
|
||||||
blank_line
|
blank_line
|
||||||
back_help_footer
|
back_help_footer
|
||||||
|
|
||||||
@@ -127,10 +85,6 @@ function select_mcu_connection() {
|
|||||||
status_msg "Identifying MCU possibly connected via UART ...\n"
|
status_msg "Identifying MCU possibly connected via UART ...\n"
|
||||||
get_uart_id || true # continue even after exit code 1
|
get_uart_id || true # continue even after exit code 1
|
||||||
break;;
|
break;;
|
||||||
3)
|
|
||||||
status_msg "Identifying MCU connected via USB in DFU mode ...\n"
|
|
||||||
get_dfu_id || true # continue even after exit code 1
|
|
||||||
break;;
|
|
||||||
B|b)
|
B|b)
|
||||||
advanced_menu
|
advanced_menu
|
||||||
break;;
|
break;;
|
||||||
@@ -153,6 +107,7 @@ function print_detected_mcu_to_screen() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
for mcu in "${mcu_list[@]}"; do
|
for mcu in "${mcu_list[@]}"; do
|
||||||
|
mcu=$(echo "${mcu}" | rev | cut -d"/" -f1 | rev)
|
||||||
echo -e " ● MCU #${i}: ${cyan}${mcu}${white}"
|
echo -e " ● MCU #${i}: ${cyan}${mcu}${white}"
|
||||||
i=$(( i + 1 ))
|
i=$(( i + 1 ))
|
||||||
done
|
done
|
||||||
@@ -160,7 +115,7 @@ function print_detected_mcu_to_screen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#================================================#
|
#================================================#
|
||||||
#=================== STEP 4 =====================#
|
#=================== STEP 3 =====================#
|
||||||
#================================================#
|
#================================================#
|
||||||
function select_mcu_id() {
|
function select_mcu_id() {
|
||||||
local i=0 sel_index=0 method=${1}
|
local i=0 sel_index=0 method=${1}
|
||||||
@@ -235,7 +190,7 @@ function start_flash_mcu() {
|
|||||||
local device=${1}
|
local device=${1}
|
||||||
do_action_service "stop" "klipper"
|
do_action_service "stop" "klipper"
|
||||||
|
|
||||||
if make ${flash_command} FLASH_DEVICE="${device}"; then
|
if make flash FLASH_DEVICE="${device}"; then
|
||||||
ok_msg "Flashing successfull!"
|
ok_msg "Flashing successfull!"
|
||||||
else
|
else
|
||||||
warn_msg "Flashing failed!"
|
warn_msg "Flashing failed!"
|
||||||
@@ -374,16 +329,6 @@ function get_uart_id() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_dfu_id() {
|
|
||||||
unset mcu_list
|
|
||||||
sleep 1
|
|
||||||
mcus=$(lsusb | grep "DFU" | cut -d " " -f 6 2>/dev/null)
|
|
||||||
|
|
||||||
for mcu in ${mcus}; do
|
|
||||||
mcu_list+=("${mcu}")
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_flash_method_help() {
|
function show_flash_method_help() {
|
||||||
top_border
|
top_border
|
||||||
echo -e "| ~~~~~~~~ < ? > Help: Flash MCU < ? > ~~~~~~~~ |"
|
echo -e "| ~~~~~~~~ < ? > Help: Flash MCU < ? > ~~~~~~~~ |"
|
||||||
@@ -427,36 +372,6 @@ function show_flash_method_help() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_mcu_flash_command_help() {
|
|
||||||
top_border
|
|
||||||
echo -e "| ~~~~~~~~ < ? > Help: Flash MCU < ? > ~~~~~~~~ |"
|
|
||||||
hr
|
|
||||||
echo -e "| ${cyan}make flash:${white} |"
|
|
||||||
echo -e "| The default command to flash controller board, it |"
|
|
||||||
echo -e "| will detect selected microcontroller and use suitable |"
|
|
||||||
echo -e "| tool for flashing it. |"
|
|
||||||
blank_line
|
|
||||||
echo -e "| ${cyan}make serialflash:${white} |"
|
|
||||||
echo -e "| Special command to flash STM32 microcontrollers in |"
|
|
||||||
echo -e "| DFU mode but connected via serial. stm32flash command |"
|
|
||||||
echo -e "| will be used internally. |"
|
|
||||||
blank_line
|
|
||||||
back_footer
|
|
||||||
|
|
||||||
local choice
|
|
||||||
while true; do
|
|
||||||
read -p "${cyan}###### Please select:${white} " choice
|
|
||||||
case "${choice}" in
|
|
||||||
B|b)
|
|
||||||
clear && print_header
|
|
||||||
select_flash_command
|
|
||||||
break;;
|
|
||||||
*)
|
|
||||||
error_msg "Invalid command!";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_mcu_connection_help() {
|
function show_mcu_connection_help() {
|
||||||
top_border
|
top_border
|
||||||
echo -e "| ~~~~~~~~ < ? > Help: Flash MCU < ? > ~~~~~~~~ |"
|
echo -e "| ~~~~~~~~ < ? > Help: Flash MCU < ? > ~~~~~~~~ |"
|
||||||
@@ -491,4 +406,4 @@ function show_mcu_connection_help() {
|
|||||||
error_msg "Invalid command!";;
|
error_msg "Invalid command!";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -16,35 +16,21 @@ set -e
|
|||||||
#===================================================#
|
#===================================================#
|
||||||
|
|
||||||
function install_fluidd() {
|
function install_fluidd() {
|
||||||
|
### exit early if moonraker not found
|
||||||
if [[ -z $(moonraker_systemd) ]]; then
|
if [[ -z $(moonraker_systemd) ]]; then
|
||||||
local error="Moonraker not installed! It's recommended to install Moonraker first!"
|
local error="Moonraker not installed! Please install Moonraker first!"
|
||||||
print_error "${error}"
|
print_error "${error}" && return
|
||||||
while true; do
|
|
||||||
local yn
|
|
||||||
read -p "${cyan}###### Proceed to install Fluidd without installing Moonraker? (y/N):${white} " yn
|
|
||||||
case "${yn}" in
|
|
||||||
Y|y|Yes|yes)
|
|
||||||
select_msg "Yes"
|
|
||||||
break;;
|
|
||||||
N|n|No|no|"")
|
|
||||||
select_msg "No"
|
|
||||||
abort_msg "Exiting Fluidd setup ...\n"
|
|
||||||
return;;
|
|
||||||
*)
|
|
||||||
error_msg "Invalid Input!";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### checking dependencies
|
### checking dependencies
|
||||||
local dep=(wget nginx unzip)
|
local dep=(wget nginx)
|
||||||
dependency_check "${dep[@]}"
|
dependency_check "${dep[@]}"
|
||||||
### detect conflicting Haproxy and Apache2 installations
|
### detect conflicting Haproxy and Apache2 installations
|
||||||
detect_conflicting_packages
|
detect_conflicting_packages
|
||||||
|
|
||||||
status_msg "Initializing Fluidd installation ..."
|
status_msg "Initializing Fluidd installation ..."
|
||||||
### first, we create a backup of the full klipper_config dir - safety first!
|
### first, we create a backup of the full klipper_config dir - safety first!
|
||||||
backup_config_dir
|
backup_klipper_config_dir
|
||||||
|
|
||||||
### check for other enabled web interfaces
|
### check for other enabled web interfaces
|
||||||
unset SET_LISTEN_PORT
|
unset SET_LISTEN_PORT
|
||||||
@@ -317,25 +303,19 @@ function get_fluidd_status() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function get_local_fluidd_version() {
|
function get_local_fluidd_version() {
|
||||||
local versionfile="${FLUIDD_DIR}/.version"
|
[[ ! -f "${FLUIDD_DIR}/.version" ]] && return
|
||||||
local relinfofile="${FLUIDD_DIR}/release_info.json"
|
|
||||||
local version
|
local version
|
||||||
|
version=$(head -n 1 "${FLUIDD_DIR}/.version")
|
||||||
if [[ -f ${relinfofile} ]]; then
|
|
||||||
version=$(grep -o '"version":"[^"]*' "${relinfofile}" | grep -o '[^"]*$')
|
|
||||||
elif [[ -f ${versionfile} ]]; then
|
|
||||||
version=$(head -n 1 "${versionfile}")
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "${version}"
|
echo "${version}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_remote_fluidd_version() {
|
function get_remote_fluidd_version() {
|
||||||
[[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]] && return
|
[[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]] && return
|
||||||
|
|
||||||
local tags
|
local version
|
||||||
tags=$(curl -s "https://api.github.com/repos/fluidd-core/fluidd/tags" | grep "name" | cut -d'"' -f4)
|
version=$(get_fluidd_download_url | rev | cut -d"/" -f2 | rev)
|
||||||
echo "${tags}" | head -1
|
echo "${version}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function compare_fluidd_versions() {
|
function compare_fluidd_versions() {
|
||||||
@@ -361,28 +341,27 @@ function compare_fluidd_versions() {
|
|||||||
#================================================#
|
#================================================#
|
||||||
|
|
||||||
function get_fluidd_download_url() {
|
function get_fluidd_download_url() {
|
||||||
local releases_by_tag tags tag unstable_url url
|
local fl_tags tags latest_tag latest_url stable_tag stable_url url
|
||||||
|
|
||||||
### latest stable download url
|
fl_tags="https://api.github.com/repos/fluidd-core/fluidd/tags"
|
||||||
url="https://github.com/fluidd-core/fluidd/releases/latest/download/fluidd.zip"
|
tags=$(curl -s "${fl_tags}" | grep "name" | cut -d'"' -f4)
|
||||||
|
|
||||||
|
### latest download url including pre-releases (alpha, beta, rc)
|
||||||
|
latest_tag=$(echo "${tags}" | head -1)
|
||||||
|
latest_url="https://github.com/fluidd-core/fluidd/releases/download/${latest_tag}/fluidd.zip"
|
||||||
|
|
||||||
|
### get stable fluidd download url
|
||||||
|
stable_tag=$(echo "${tags}" | grep -E "^v([0-9]+\.?){3}$" | head -1)
|
||||||
|
stable_url="https://github.com/fluidd-core/fluidd/releases/download/${stable_tag}/fluidd.zip"
|
||||||
|
|
||||||
read_kiauh_ini "${FUNCNAME[0]}"
|
read_kiauh_ini "${FUNCNAME[0]}"
|
||||||
if [[ ${fluidd_install_unstable} == "true" ]]; then
|
if [[ ${fluidd_install_unstable} == "true" ]]; then
|
||||||
releases_by_tag="https://api.github.com/repos/fluidd-core/fluidd/tags"
|
url="${latest_url}"
|
||||||
tags=$(curl -s "${releases_by_tag}" | grep "name" | cut -d'"' -f4)
|
echo "${url}"
|
||||||
tag=$(echo "${tags}" | head -1)
|
else
|
||||||
|
url="${stable_url}"
|
||||||
### latest unstable download url including pre-releases (alpha, beta, rc)
|
echo "${url}"
|
||||||
unstable_url="https://github.com/fluidd-core/fluidd/releases/download/${tag}/fluidd.zip"
|
|
||||||
|
|
||||||
if [[ ${unstable_url} == *"download//"* ]]; then
|
|
||||||
warn_msg "Download URL broken! Falling back to URL of latest stable release!"
|
|
||||||
else
|
|
||||||
url=${unstable_url}
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${url}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function fluidd_port_check() {
|
function fluidd_port_check() {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -103,7 +103,7 @@ function install_gcode_shell_command() {
|
|||||||
|
|
||||||
function create_example_shell_command() {
|
function create_example_shell_command() {
|
||||||
### create a backup of the config folder
|
### create a backup of the config folder
|
||||||
backup_config_dir
|
backup_klipper_config_dir
|
||||||
|
|
||||||
local configs regex path
|
local configs regex path
|
||||||
regex="${HOME//\//\\/}\/([A-Za-z0-9_]+)\/config\/printer\.cfg"
|
regex="${HOME//\//\\/}\/([A-Za-z0-9_]+)\/config\/printer\.cfg"
|
||||||
@@ -120,4 +120,4 @@ function create_example_shell_command() {
|
|||||||
sed -i "1 i [include shell_command.cfg]" "${cfg}"
|
sed -i "1 i [include shell_command.cfg]" "${cfg}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -78,13 +78,4 @@ function set_globals() {
|
|||||||
CROWSNEST_DIR="${HOME}/crowsnest"
|
CROWSNEST_DIR="${HOME}/crowsnest"
|
||||||
CROWSNEST_REPO="https://github.com/mainsail-crew/crowsnest.git"
|
CROWSNEST_REPO="https://github.com/mainsail-crew/crowsnest.git"
|
||||||
|
|
||||||
#=============== Mobileraker ================#
|
|
||||||
MOBILERAKER_ENV="${HOME}/mobileraker-env"
|
|
||||||
MOBILERAKER_DIR="${HOME}/mobileraker_companion"
|
|
||||||
MOBILERAKER_REPO="https://github.com/Clon1998/mobileraker_companion.git"
|
|
||||||
|
|
||||||
#=============== OCTOAPP ================#
|
|
||||||
OCTOAPP_ENV="${HOME}/octoapp-env"
|
|
||||||
OCTOAPP_DIR="${HOME}/octoapp"
|
|
||||||
OCTOAPP_REPO="https://github.com/crysxd/OctoApp-Plugin.git"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -43,59 +43,84 @@ function klipper_systemd() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function start_klipper_setup() {
|
function start_klipper_setup() {
|
||||||
local klipper_systemd_services
|
local is_multi_instance_setup="false"
|
||||||
|
local adding_instances="false"
|
||||||
|
local use_custom_names="false"
|
||||||
|
local klipper_count=0
|
||||||
|
|
||||||
|
local klipper_instances
|
||||||
local python_version
|
local python_version
|
||||||
local instance_count
|
local instance_count
|
||||||
local instance_names
|
local instance_names
|
||||||
local use_custom_names
|
|
||||||
local input
|
local input
|
||||||
local regex
|
local regex
|
||||||
local blacklist
|
local blacklist
|
||||||
local error
|
|
||||||
|
|
||||||
status_msg "Initializing Klipper installation ...\n"
|
status_msg "Initializing Klipper installation ...\n"
|
||||||
|
|
||||||
### return early if klipper already exists
|
klipper_instances=$(klipper_systemd)
|
||||||
klipper_systemd_services=$(klipper_systemd)
|
[[ -n ${klipper_instances} ]] && is_multi_instance_setup="true"
|
||||||
|
|
||||||
if [[ -n ${klipper_systemd_services} ]]; then
|
if [[ ${is_multi_instance_setup} == "true" ]]; then
|
||||||
error="At least one Klipper service is already installed:"
|
klipper_count=$(echo "${klipper_instances}" | wc -w)
|
||||||
|
python_version=$(get_klipper_python_ver)
|
||||||
|
adding_instances="true"
|
||||||
|
|
||||||
for s in ${klipper_systemd_services}; do
|
# print list of already installed instances
|
||||||
log_info "Found Klipper service: ${s}"
|
top_border
|
||||||
error="${error}\n ➔ ${s}"
|
printf "|${green}%-55s${white}|\n" " ${klipper_count} Klipper instances are already installed!"
|
||||||
|
local klipper_folder
|
||||||
|
for s in ${klipper_instances}; do
|
||||||
|
klipper_folder="$(get_data_folder "$(basename "${s}")" klipper)"
|
||||||
|
printf "|${cyan}%-57s${white}|\n" " ● klipper-$(get_instance_name "${s}") - ${klipper_folder}"
|
||||||
done
|
done
|
||||||
|
bottom_border && echo
|
||||||
|
|
||||||
|
else
|
||||||
|
top_border
|
||||||
|
echo -e "| Please select your preferred Python version. | "
|
||||||
|
echo -e "| The recommended version is Python 3.x. | "
|
||||||
|
hr
|
||||||
|
echo -e "| 1) [Python 3.x] (recommended) | "
|
||||||
|
echo -e "| 2) [Python 2.7] ${yellow}(legacy)${white} | "
|
||||||
|
back_footer
|
||||||
|
while true; do
|
||||||
|
read -p "${cyan}###### Select Python version:${white} " -e -i 1 input
|
||||||
|
case "${input}" in
|
||||||
|
1)
|
||||||
|
select_msg "Python 3.x\n"
|
||||||
|
python_version=3
|
||||||
|
break;;
|
||||||
|
2)
|
||||||
|
select_msg "Python 2.7\n"
|
||||||
|
python_version=2
|
||||||
|
break;;
|
||||||
|
B|b)
|
||||||
|
clear; install_menu; break;;
|
||||||
|
*)
|
||||||
|
error_msg "Invalid Input!\n";;
|
||||||
|
esac
|
||||||
|
done && input=""
|
||||||
fi
|
fi
|
||||||
[[ -n ${error} ]] && print_error "${error}" && return
|
|
||||||
|
|
||||||
### user selection for python version
|
top_border
|
||||||
print_dialog_user_select_python_version
|
echo -e "| Please select the number of Klipper instances to set |"
|
||||||
while true; do
|
echo -e "| up. The number of Klipper instances will determine |"
|
||||||
read -p "${cyan}###### Select Python version:${white} " -i "1" -e input
|
echo -e "| the amount of printers you can run from this host. |"
|
||||||
case "${input}" in
|
blank_line
|
||||||
1)
|
echo -e "| ${yellow}WARNING:${white} |"
|
||||||
select_msg "Python 3.x\n"
|
echo -e "| ${yellow}Setting up too many instances may crash your system.${white} |"
|
||||||
python_version=3
|
back_footer
|
||||||
break;;
|
|
||||||
2)
|
|
||||||
select_msg "Python 2.7\n"
|
|
||||||
python_version=2
|
|
||||||
break;;
|
|
||||||
B|b)
|
|
||||||
clear; install_menu; break;;
|
|
||||||
*)
|
|
||||||
error_msg "Invalid Input!\n";;
|
|
||||||
esac
|
|
||||||
done && input=""
|
|
||||||
|
|
||||||
### user selection for instance count
|
|
||||||
print_dialog_user_select_instance_count
|
|
||||||
regex="^[1-9][0-9]*$"
|
regex="^[1-9][0-9]*$"
|
||||||
while [[ ! ${input} =~ ${regex} ]]; do
|
while [[ ! ${input} =~ ${regex} ]]; do
|
||||||
read -p "${cyan}###### Number of Klipper instances to set up:${white} " -i "1" -e input
|
local x=""
|
||||||
|
[[ ${adding_instances} == "true" ]] && x="additional"
|
||||||
|
read -p "${cyan}###### Number of ${x} Klipper instances to set up:${white} " -i "1" -e input
|
||||||
|
|
||||||
if [[ ${input} =~ ${regex} ]]; then
|
if [[ ${input} =~ ${regex} ]]; then
|
||||||
instance_count="${input}"
|
instance_count="${input}"
|
||||||
|
(( instance_count > 1 )) && is_multi_instance_setup="true"
|
||||||
select_msg "Instance count: ${instance_count}\n"
|
select_msg "Instance count: ${instance_count}\n"
|
||||||
break
|
break
|
||||||
elif [[ ${input} == "B" || ${input} == "b" ]]; then
|
elif [[ ${input} == "B" || ${input} == "b" ]]; then
|
||||||
@@ -105,10 +130,15 @@ function start_klipper_setup() {
|
|||||||
fi
|
fi
|
||||||
done && input=""
|
done && input=""
|
||||||
|
|
||||||
### user selection for custom names
|
if [[ ${is_multi_instance_setup} == "true" ]]; then
|
||||||
use_custom_names="false"
|
top_border
|
||||||
if (( instance_count > 1 )); then
|
echo -e "| You can now give each instance a custom name. If you |"
|
||||||
print_dialog_user_select_custom_name_bool
|
echo -e "| select 'N', each instance will get an index assigned |"
|
||||||
|
echo -e "| in ascending order, starting at index '$((klipper_count + 1))'. |"
|
||||||
|
blank_line
|
||||||
|
echo -e "| ${yellow}Info:${white} |"
|
||||||
|
echo -e "| ${yellow}Only alphanumeric characters are allowed!${white} |"
|
||||||
|
back_footer
|
||||||
while true; do
|
while true; do
|
||||||
read -p "${cyan}###### Assign custom names? (y/N):${white} " input
|
read -p "${cyan}###### Assign custom names? (y/N):${white} " input
|
||||||
case "${input}" in
|
case "${input}" in
|
||||||
@@ -131,86 +161,67 @@ function start_klipper_setup() {
|
|||||||
|
|
||||||
### user selection for setting the actual custom names
|
### user selection for setting the actual custom names
|
||||||
shopt -s nocasematch
|
shopt -s nocasematch
|
||||||
if (( instance_count > 1 )) && [[ ${use_custom_names} == "true" ]]; then
|
if [[ ${use_custom_names} == "true" ]]; then
|
||||||
local i
|
|
||||||
|
|
||||||
i=1
|
|
||||||
regex="^[0-9a-zA-Z]+$"
|
regex="^[0-9a-zA-Z]+$"
|
||||||
blacklist="mcu"
|
blacklist="mcu"
|
||||||
while [[ ! ${input} =~ ${regex} || ${input} =~ ${blacklist} || ${i} -le ${instance_count} ]]; do
|
|
||||||
read -p "${cyan}###### Name for instance #${i}:${white} " input
|
|
||||||
|
|
||||||
if [[ ${input} =~ ${blacklist} ]]; then
|
local i=1
|
||||||
error_msg "Name not allowed! You are trying to use a reserved name."
|
while [[ ! ${input} =~ ${regex} || ${input} =~ ${blacklist} || ${i} -le ${instance_count} ]]; do
|
||||||
|
read -p "${cyan}###### Name for instance #$((klipper_count + i)):${white} " input
|
||||||
|
|
||||||
|
if [[ ! ${input} =~ ${regex} ]]; then
|
||||||
|
error_msg "Invalid Input!\n"
|
||||||
|
elif [[ ${input} =~ ${blacklist} ]]; then
|
||||||
|
error_msg "Name not allowed! You are trying to use a reserved name.\n"
|
||||||
|
elif get_multi_instance_names | grep -q "${input}"; then
|
||||||
|
error_msg "Instance with name '${input}' already exists. Please choose a different name.\n"
|
||||||
|
elif echo "${instance_names[@]}" | grep -q "${input}"; then
|
||||||
|
error_msg "Name already assigned. Please choose a different name.\n"
|
||||||
elif [[ ${input} =~ ${regex} && ! ${input} =~ ${blacklist} ]]; then
|
elif [[ ${input} =~ ${regex} && ! ${input} =~ ${blacklist} ]]; then
|
||||||
select_msg "Name: ${input}\n"
|
select_msg "Name: ${input}\n"
|
||||||
|
local instance_name
|
||||||
if [[ ${input} =~ ^[0-9]+$ ]]; then
|
if [[ ${input} =~ ^[0-9]+$ ]]; then
|
||||||
instance_names+=("printer_${input}")
|
instance_name="printer_${input}"
|
||||||
else
|
else
|
||||||
instance_names+=("${input}")
|
instance_name="${input}"
|
||||||
fi
|
fi
|
||||||
|
instance_names+=("${instance_name}")
|
||||||
i=$(( i + 1 ))
|
i=$(( i + 1 ))
|
||||||
else
|
else
|
||||||
error_msg "Invalid Input!\n"
|
error_msg "Invalid Input!\n"
|
||||||
fi
|
fi
|
||||||
done && input=""
|
done && input=""
|
||||||
elif (( instance_count > 1 )) && [[ ${use_custom_names} == "false" ]]; then
|
|
||||||
for (( i=1; i <= instance_count; i++ )); do
|
elif [[ ${is_multi_instance_setup} == "true" && ${use_custom_names} == "false" ]]; then
|
||||||
|
for (( i=klipper_count+1; i <= instance_count+klipper_count; ++i )); do
|
||||||
instance_names+=("printer_${i}")
|
instance_names+=("printer_${i}")
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
shopt -u nocasematch
|
shopt -u nocasematch
|
||||||
|
|
||||||
(( instance_count > 1 )) && status_msg "Installing ${instance_count} Klipper instances ..."
|
local msg="Installing Klipper ..."
|
||||||
(( instance_count == 1 )) && status_msg "Installing single Klipper instance ..."
|
if [[ ${is_multi_instance_setup} == "true" && ${adding_instances} == "false" ]]; then
|
||||||
|
msg="Installing ${instance_count} Klipper instances ..."
|
||||||
|
elif [[ ${adding_instances} == "true" ]]; then
|
||||||
|
msg="Installing ${instance_count} additional Klipper instances ..."
|
||||||
|
fi
|
||||||
|
status_msg "${msg}"
|
||||||
|
|
||||||
run_klipper_setup "${python_version}" "${instance_names[@]}"
|
run_klipper_setup "${python_version}" "${adding_instances}" "${instance_names[@]}"
|
||||||
}
|
|
||||||
|
|
||||||
function print_dialog_user_select_python_version() {
|
|
||||||
top_border
|
|
||||||
echo -e "| Please select your preferred Python version. | "
|
|
||||||
echo -e "| The recommended version is Python 3.x. | "
|
|
||||||
hr
|
|
||||||
echo -e "| 1) [Python 3.x] (recommended) | "
|
|
||||||
echo -e "| 2) [Python 2.7] ${yellow}(legacy)${white} | "
|
|
||||||
back_footer
|
|
||||||
}
|
|
||||||
|
|
||||||
function print_dialog_user_select_instance_count() {
|
|
||||||
top_border
|
|
||||||
echo -e "| Please select the number of Klipper instances to set |"
|
|
||||||
echo -e "| up. The number of Klipper instances will determine |"
|
|
||||||
echo -e "| the amount of printers you can run from this host. |"
|
|
||||||
blank_line
|
|
||||||
echo -e "| ${yellow}WARNING:${white} |"
|
|
||||||
echo -e "| ${yellow}Setting up too many instances may crash your system.${white} |"
|
|
||||||
back_footer
|
|
||||||
}
|
|
||||||
|
|
||||||
function print_dialog_user_select_custom_name_bool() {
|
|
||||||
top_border
|
|
||||||
echo -e "| You can now assign a custom name to each instance. |"
|
|
||||||
echo -e "| If skipped, each instance will get an index assigned |"
|
|
||||||
echo -e "| in ascending order, starting at index '1'. |"
|
|
||||||
blank_line
|
|
||||||
echo -e "| Info: |"
|
|
||||||
echo -e "| Only alphanumeric characters for names are allowed! |"
|
|
||||||
back_footer
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_klipper_setup() {
|
function run_klipper_setup() {
|
||||||
read_kiauh_ini "${FUNCNAME[0]}"
|
read_kiauh_ini "${FUNCNAME[0]}"
|
||||||
|
|
||||||
local python_version=${1}
|
local python_version=${1}
|
||||||
|
local adding_instances=${2}
|
||||||
local instance_names
|
local instance_names
|
||||||
local confirm
|
local confirm
|
||||||
local custom_repo
|
local custom_repo
|
||||||
local custom_branch
|
local custom_branch
|
||||||
local dep
|
local dep
|
||||||
|
|
||||||
shift 1
|
shift 2 && read -r -a instance_names <<< "${@}"
|
||||||
read -r -a instance_names <<< "${@}"
|
|
||||||
|
|
||||||
custom_repo="${custom_klipper_repo}"
|
custom_repo="${custom_klipper_repo}"
|
||||||
custom_branch="${custom_klipper_repo_branch}"
|
custom_branch="${custom_klipper_repo_branch}"
|
||||||
@@ -219,12 +230,14 @@ function run_klipper_setup() {
|
|||||||
### checking dependencies
|
### checking dependencies
|
||||||
dependency_check "${dep[@]}"
|
dependency_check "${dep[@]}"
|
||||||
|
|
||||||
### step 1: clone klipper
|
if [[ "${adding_instances}" == "false" ]]; then
|
||||||
clone_klipper "${custom_repo}" "${custom_branch}"
|
### step 1: clone klipper
|
||||||
|
clone_klipper "${custom_repo}" "${custom_branch}"
|
||||||
|
|
||||||
### step 2: install klipper dependencies and create python virtualenv
|
### step 2: install klipper dependencies and create python virtualenv
|
||||||
install_klipper_packages "${python_version}"
|
install_klipper_packages "${python_version}"
|
||||||
create_klipper_virtualenv "${python_version}"
|
create_klipper_virtualenv "${python_version}"
|
||||||
|
fi
|
||||||
|
|
||||||
### step 3: create klipper instances
|
### step 3: create klipper instances
|
||||||
for instance in "${instance_names[@]}"; do
|
for instance in "${instance_names[@]}"; do
|
||||||
@@ -244,7 +257,6 @@ function run_klipper_setup() {
|
|||||||
|
|
||||||
### finalizing the setup with writing instance names to the kiauh.ini
|
### finalizing the setup with writing instance names to the kiauh.ini
|
||||||
set_multi_instance_names
|
set_multi_instance_names
|
||||||
mask_disrupting_services
|
|
||||||
|
|
||||||
print_confirm "${confirm}" && return
|
print_confirm "${confirm}" && return
|
||||||
}
|
}
|
||||||
@@ -296,7 +308,7 @@ function create_klipper_virtualenv() {
|
|||||||
# @param {string}: python_version - klipper-env python version
|
# @param {string}: python_version - klipper-env python version
|
||||||
#
|
#
|
||||||
function install_klipper_packages() {
|
function install_klipper_packages() {
|
||||||
local packages log_name="Klipper" python_version="${1}"
|
local packages python_version="${1}"
|
||||||
local install_script="${KLIPPER_DIR}/scripts/install-debian.sh"
|
local install_script="${KLIPPER_DIR}/scripts/install-debian.sh"
|
||||||
|
|
||||||
status_msg "Reading dependencies..."
|
status_msg "Reading dependencies..."
|
||||||
@@ -322,11 +334,21 @@ function install_klipper_packages() {
|
|||||||
echo "${cyan}${packages}${white}" | tr '[:space:]' '\n'
|
echo "${cyan}${packages}${white}" | tr '[:space:]' '\n'
|
||||||
read -r -a packages <<< "${packages}"
|
read -r -a packages <<< "${packages}"
|
||||||
|
|
||||||
### Update system package lists if stale
|
### Update system package info
|
||||||
update_system_package_lists
|
status_msg "Updating package lists..."
|
||||||
|
if ! sudo apt-get update --allow-releaseinfo-change; then
|
||||||
|
log_error "failure while updating package lists"
|
||||||
|
error_msg "Updating package lists failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
### Install required packages
|
### Install required packages
|
||||||
install_system_packages "${log_name}" "packages[@]"
|
status_msg "Installing required packages..."
|
||||||
|
if ! sudo apt-get install --yes "${packages[@]}"; then
|
||||||
|
log_error "failure while installing required klipper packages"
|
||||||
|
error_msg "Installing required packages failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_klipper_service() {
|
function create_klipper_service() {
|
||||||
@@ -334,7 +356,6 @@ function create_klipper_service() {
|
|||||||
|
|
||||||
local printer_data
|
local printer_data
|
||||||
local cfg_dir
|
local cfg_dir
|
||||||
local gcodes_dir
|
|
||||||
local cfg
|
local cfg
|
||||||
local log
|
local log
|
||||||
local klippy_serial
|
local klippy_serial
|
||||||
@@ -347,7 +368,6 @@ function create_klipper_service() {
|
|||||||
|
|
||||||
printer_data="${HOME}/${instance_name}_data"
|
printer_data="${HOME}/${instance_name}_data"
|
||||||
cfg_dir="${printer_data}/config"
|
cfg_dir="${printer_data}/config"
|
||||||
gcodes_dir="${printer_data}/gcodes"
|
|
||||||
cfg="${cfg_dir}/printer.cfg"
|
cfg="${cfg_dir}/printer.cfg"
|
||||||
log="${printer_data}/logs/klippy.log"
|
log="${printer_data}/logs/klippy.log"
|
||||||
klippy_serial="${printer_data}/comms/klippy.serial"
|
klippy_serial="${printer_data}/comms/klippy.serial"
|
||||||
@@ -371,27 +391,25 @@ function create_klipper_service() {
|
|||||||
|
|
||||||
sudo cp "${service_template}" "${service}"
|
sudo cp "${service_template}" "${service}"
|
||||||
sudo cp "${env_template}" "${env_file}"
|
sudo cp "${env_template}" "${env_file}"
|
||||||
sudo sed -i "s|%USER%|${USER}|g; s|%KLIPPER_DIR%|${KLIPPER_DIR}|; s|%ENV%|${KLIPPY_ENV}|; s|%ENV_FILE%|${env_file}|" "${service}"
|
sudo sed -i "s|%USER%|${USER}|g; s|%ENV%|${KLIPPY_ENV}|; s|%ENV_FILE%|${env_file}|" "${service}"
|
||||||
sudo sed -i "s|%USER%|${USER}|; s|%KLIPPER_DIR%|${KLIPPER_DIR}|; s|%LOG%|${log}|; s|%CFG%|${cfg}|; s|%PRINTER%|${klippy_serial}|; s|%UDS%|${klippy_socket}|" "${env_file}"
|
sudo sed -i "s|%USER%|${USER}|; s|%LOG%|${log}|; s|%CFG%|${cfg}|; s|%PRINTER%|${klippy_serial}|; s|%UDS%|${klippy_socket}|" "${env_file}"
|
||||||
|
|
||||||
ok_msg "Klipper service file created!"
|
ok_msg "Klipper service file created!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -f ${cfg} ]]; then
|
if [[ ! -f ${cfg} ]]; then
|
||||||
write_example_printer_cfg "${cfg}" "${gcodes_dir}"
|
write_example_printer_cfg "${cfg}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function write_example_printer_cfg() {
|
function write_example_printer_cfg() {
|
||||||
local cfg=${1}
|
local cfg=${1}
|
||||||
local gcodes_dir=${2}
|
|
||||||
local cfg_template
|
local cfg_template
|
||||||
|
|
||||||
cfg_template="${KIAUH_SRCDIR}/resources/example.printer.cfg"
|
cfg_template="${KIAUH_SRCDIR}/resources/example.printer.cfg"
|
||||||
|
|
||||||
status_msg "Creating minimal example printer.cfg ..."
|
status_msg "Creating minimal example printer.cfg ..."
|
||||||
if cp "${cfg_template}" "${cfg}"; then
|
if cp "${cfg_template}" "${cfg}"; then
|
||||||
sed -i "s|%GCODES_DIR%|${gcodes_dir}|" "${cfg}"
|
|
||||||
ok_msg "Minimal example printer.cfg created!"
|
ok_msg "Minimal example printer.cfg created!"
|
||||||
else
|
else
|
||||||
error_msg "Couldn't create minimal example printer.cfg!"
|
error_msg "Couldn't create minimal example printer.cfg!"
|
||||||
@@ -403,28 +421,28 @@ function write_example_printer_cfg() {
|
|||||||
#================================================#
|
#================================================#
|
||||||
|
|
||||||
function remove_klipper_service() {
|
function remove_klipper_service() {
|
||||||
[[ -z $(klipper_systemd) ]] && return
|
|
||||||
|
|
||||||
status_msg "Removing Klipper services ..."
|
status_msg "Removing Klipper services ..."
|
||||||
|
|
||||||
for service in $(klipper_systemd | cut -d"/" -f5); do
|
for service in "${@}"; do
|
||||||
status_msg "Removing ${service} ..."
|
status_msg "Removing ${service} ..."
|
||||||
sudo systemctl stop "${service}"
|
sudo systemctl stop "${service}"
|
||||||
sudo systemctl disable "${service}"
|
sudo systemctl disable "${service}"
|
||||||
sudo rm -f "${SYSTEMD}/${service}"
|
sudo rm -f "${SYSTEMD}/${service}"
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl reset-failed
|
|
||||||
done
|
done
|
||||||
|
|
||||||
ok_msg "All Klipper services removed!"
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl reset-failed
|
||||||
|
|
||||||
|
ok_msg "Selected Klipper services removed!"
|
||||||
}
|
}
|
||||||
|
|
||||||
function find_instance_files() {
|
function find_instance_files() {
|
||||||
local target_folder=${1}
|
local data_folder=${1}
|
||||||
local target_name=${2}
|
local target_folder=${2}
|
||||||
|
local target_name=${3}
|
||||||
local files
|
local files
|
||||||
|
|
||||||
readarray -t files < <(find "${HOME}" -regex "${HOME}/[A-Za-z0-9_]+_data/${target_folder}/${target_name}" | sort)
|
readarray -t files < <(find "${HOME}" -regex "${data_folder}/${target_folder}/${target_name}" | sort)
|
||||||
|
|
||||||
echo -e "${files[@]}"
|
echo -e "${files[@]}"
|
||||||
}
|
}
|
||||||
@@ -478,25 +496,95 @@ function remove_files() {
|
|||||||
if (( ${#files[@]} > 0 )); then
|
if (( ${#files[@]} > 0 )); then
|
||||||
for file in "${files[@]}"; do
|
for file in "${files[@]}"; do
|
||||||
status_msg "Removing ${file} ..."
|
status_msg "Removing ${file} ..."
|
||||||
rm -f "${file}"
|
if rm -f "${file}"; then
|
||||||
ok_msg "${file} removed!"
|
ok_msg "${file} removed!"
|
||||||
|
else
|
||||||
|
error_msg "${file} could not be removed! Please remove it manually!"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function remove_klipper_files() {
|
||||||
|
status_msg "Removing Klipper files ..."
|
||||||
|
|
||||||
|
for service in "${@}"; do
|
||||||
|
local data_folder
|
||||||
|
data_folder=$(get_data_folder "${service}")
|
||||||
|
remove_files "$(find_instance_files "${data_folder}" "systemd" "klipper.env")"
|
||||||
|
remove_files "$(find_instance_files "${data_folder}" "logs" "klippy.log.*")"
|
||||||
|
remove_files "$(find_instance_files "${data_folder}" "comms" "klippy.sock")"
|
||||||
|
remove_files "$(find_instance_files "${data_folder}" "comms" "klippy.serial")"
|
||||||
|
done
|
||||||
|
|
||||||
|
ok_msg "Files removed!"
|
||||||
|
}
|
||||||
|
|
||||||
function remove_klipper() {
|
function remove_klipper() {
|
||||||
remove_klipper_service
|
local klipper_systemd_services
|
||||||
remove_files "$(find_instance_files "systemd" "klipper.env")"
|
local klipper_services_count
|
||||||
remove_files "$(find_instance_files "logs" "klippy.log.*")"
|
local user_input=()
|
||||||
remove_files "$(find_instance_files "comms" "klippy.sock")"
|
local klipper_names=()
|
||||||
remove_files "$(find_instance_files "comms" "klippy.serial")"
|
local service_name
|
||||||
|
|
||||||
|
klipper_systemd_services=$(klipper_systemd)
|
||||||
|
if [[ -z ${klipper_systemd_services} ]]; then
|
||||||
|
print_error "Klipper not installed, nothing to do!"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
remove_files "$(find_legacy_klipper_logs)"
|
remove_files "$(find_legacy_klipper_logs)"
|
||||||
remove_files "$(find_legacy_klipper_uds)"
|
remove_files "$(find_legacy_klipper_uds)"
|
||||||
remove_files "$(find_legacy_klipper_printer)"
|
remove_files "$(find_legacy_klipper_printer)"
|
||||||
|
|
||||||
remove_klipper_dir
|
top_border
|
||||||
remove_klipper_env
|
echo -e "| ${red}~~~~~~~~ [ Klipper instance remover ] ~~~~~~~${white} |"
|
||||||
|
hr
|
||||||
|
|
||||||
|
klipper_services_count="$(echo "${klipper_systemd_services}" | wc -w)"
|
||||||
|
if (( klipper_services_count == 1 )); then
|
||||||
|
service_name=$(basename "${klipper_systemd_services}")
|
||||||
|
klipper_names+=( "${service_name}" )
|
||||||
|
printf "| 0) %-51s|\n" "${service_name}"
|
||||||
|
else
|
||||||
|
printf "| 0) %-51s|\n" "Remove all"
|
||||||
|
local i=1
|
||||||
|
for name in ${klipper_systemd_services}; do
|
||||||
|
service_name=$(basename "${name}")
|
||||||
|
klipper_names+=( "${service_name}" )
|
||||||
|
printf "| ${i}) %-51s|\n" "${service_name}"
|
||||||
|
i=$(( i + 1 ))
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
back_footer
|
||||||
|
|
||||||
|
local option
|
||||||
|
while true; do
|
||||||
|
read -p "${cyan}Instance to remove:${white} " option
|
||||||
|
if [[ ${option} == "B" || ${option} == "b" ]]; then
|
||||||
|
return
|
||||||
|
elif [[ $((option)) != "${option}" ]]; then
|
||||||
|
error_msg "Invalid command!"
|
||||||
|
elif (( option >= 0 && option <= ${#klipper_names[@]} )); then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
error_msg "Invalid command!"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if (( option == 0 )); then
|
||||||
|
user_input=( "${klipper_names[@]}" )
|
||||||
|
else
|
||||||
|
user_input=( "${klipper_names[(( option - 1 ))]}" )
|
||||||
|
fi
|
||||||
|
|
||||||
|
remove_klipper_service "${user_input[@]}"
|
||||||
|
remove_klipper_files "${user_input[@]}"
|
||||||
|
|
||||||
|
if (( klipper_services_count == 1 )) || [[ "${option}" == "0" ]]; then
|
||||||
|
remove_klipper_dir
|
||||||
|
remove_klipper_env
|
||||||
|
fi
|
||||||
|
|
||||||
print_confirm "Klipper was successfully removed!" && return
|
print_confirm "Klipper was successfully removed!" && return
|
||||||
}
|
}
|
||||||
@@ -585,14 +673,8 @@ function get_remote_klipper_commit() {
|
|||||||
[[ ! -d ${KLIPPER_DIR} || ! -d "${KLIPPER_DIR}/.git" ]] && return
|
[[ ! -d ${KLIPPER_DIR} || ! -d "${KLIPPER_DIR}/.git" ]] && return
|
||||||
|
|
||||||
local commit
|
local commit
|
||||||
local branch
|
|
||||||
|
|
||||||
read_kiauh_ini "${FUNCNAME[0]}"
|
|
||||||
branch="${custom_klipper_repo_branch}"
|
|
||||||
[[ -z ${branch} ]] && branch="master"
|
|
||||||
|
|
||||||
cd "${KLIPPER_DIR}" && git fetch origin -q
|
cd "${KLIPPER_DIR}" && git fetch origin -q
|
||||||
commit=$(git describe "origin/${branch}" --always --tags | cut -d "-" -f 1,2)
|
commit=$(git describe origin/master --always --tags | cut -d "-" -f 1,2)
|
||||||
echo "${commit}"
|
echo "${commit}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -630,34 +712,3 @@ function get_klipper_python_ver() {
|
|||||||
version=$("${KLIPPY_ENV}"/bin/python --version 2>&1 | cut -d" " -f2 | cut -d"." -f1)
|
version=$("${KLIPPY_ENV}"/bin/python --version 2>&1 | cut -d" " -f2 | cut -d"." -f1)
|
||||||
echo "${version}"
|
echo "${version}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function mask_disrupting_services() {
|
|
||||||
local brltty="false"
|
|
||||||
local brltty_udev="false"
|
|
||||||
local modem_manager="false"
|
|
||||||
|
|
||||||
[[ $(dpkg -s brltty 2>/dev/null | grep "Status") = *\ installed ]] && brltty="true"
|
|
||||||
[[ $(dpkg -s brltty-udev 2>/dev/null | grep "Status") = *\ installed ]] && brltty_udev="true"
|
|
||||||
[[ $(dpkg -s ModemManager 2>/dev/null | grep "Status") = *\ installed ]] && modem_manager="true"
|
|
||||||
|
|
||||||
status_msg "Installed brltty package detected, masking brltty service ..."
|
|
||||||
if [[ ${brltty} == "true" ]]; then
|
|
||||||
sudo systemctl stop brltty
|
|
||||||
sudo systemctl mask brltty
|
|
||||||
fi
|
|
||||||
ok_msg "brltty service masked!"
|
|
||||||
|
|
||||||
status_msg "Installed brltty-udev package detected, masking brltty-udev service ..."
|
|
||||||
if [[ ${brltty_udev} == "true" ]]; then
|
|
||||||
sudo systemctl stop brltty-udev
|
|
||||||
sudo systemctl mask brltty-udev
|
|
||||||
fi
|
|
||||||
ok_msg "brltty-udev service masked!"
|
|
||||||
|
|
||||||
status_msg "Installed ModemManager package detected, masking ModemManager service ..."
|
|
||||||
if [[ ${modem_manager} == "true" ]]; then
|
|
||||||
sudo systemctl stop ModemManager
|
|
||||||
sudo systemctl mask ModemManager
|
|
||||||
fi
|
|
||||||
ok_msg "ModemManager service masked!"
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -30,7 +30,7 @@ function install_klipperscreen() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
### first, we create a backup of the full klipper_config dir - safety first!
|
### first, we create a backup of the full klipper_config dir - safety first!
|
||||||
backup_config_dir
|
backup_klipper_config_dir
|
||||||
|
|
||||||
### install KlipperScreen
|
### install KlipperScreen
|
||||||
klipperscreen_setup
|
klipperscreen_setup
|
||||||
@@ -119,8 +119,6 @@ function update_klipperscreen() {
|
|||||||
old_md5=$(md5sum "${KLIPPERSCREEN_DIR}/scripts/KlipperScreen-requirements.txt" | cut -d " " -f1)
|
old_md5=$(md5sum "${KLIPPERSCREEN_DIR}/scripts/KlipperScreen-requirements.txt" | cut -d " " -f1)
|
||||||
|
|
||||||
do_action_service "stop" "KlipperScreen"
|
do_action_service "stop" "KlipperScreen"
|
||||||
backup_before_update "klipperscreen"
|
|
||||||
|
|
||||||
cd "${KLIPPERSCREEN_DIR}"
|
cd "${KLIPPERSCREEN_DIR}"
|
||||||
git pull origin master -q && ok_msg "Fetch successfull!"
|
git pull origin master -q && ok_msg "Fetch successfull!"
|
||||||
git checkout -f master && ok_msg "Checkout successfull"
|
git checkout -f master && ok_msg "Checkout successfull"
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -16,35 +16,21 @@ set -e
|
|||||||
#===================================================#
|
#===================================================#
|
||||||
|
|
||||||
function install_mainsail() {
|
function install_mainsail() {
|
||||||
|
### exit early if moonraker not found
|
||||||
if [[ -z $(moonraker_systemd) ]]; then
|
if [[ -z $(moonraker_systemd) ]]; then
|
||||||
local error="Moonraker not installed! It's recommended to install Moonraker first!"
|
local error="Moonraker not installed! Please install Moonraker first!"
|
||||||
print_error "${error}"
|
print_error "${error}" && return
|
||||||
while true; do
|
|
||||||
local yn
|
|
||||||
read -p "${cyan}###### Proceed to install Mainsail without installing Moonraker? (y/N):${white} " yn
|
|
||||||
case "${yn}" in
|
|
||||||
Y|y|Yes|yes)
|
|
||||||
select_msg "Yes"
|
|
||||||
break;;
|
|
||||||
N|n|No|no|"")
|
|
||||||
select_msg "No"
|
|
||||||
abort_msg "Exiting Mainsail setup ...\n"
|
|
||||||
return;;
|
|
||||||
*)
|
|
||||||
error_msg "Invalid Input!";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### checking dependencies
|
### checking dependencies
|
||||||
local dep=(wget nginx unzip)
|
local dep=(wget nginx)
|
||||||
dependency_check "${dep[@]}"
|
dependency_check "${dep[@]}"
|
||||||
### detect conflicting Haproxy and Apache2 installations
|
### detect conflicting Haproxy and Apache2 installations
|
||||||
detect_conflicting_packages
|
detect_conflicting_packages
|
||||||
|
|
||||||
status_msg "Initializing Mainsail installation ..."
|
status_msg "Initializing Mainsail installation ..."
|
||||||
### first, we create a backup of the full klipper_config dir - safety first!
|
### first, we create a backup of the full klipper_config dir - safety first!
|
||||||
backup_config_dir
|
#backup_klipper_config_dir
|
||||||
|
|
||||||
### check for other enabled web interfaces
|
### check for other enabled web interfaces
|
||||||
unset SET_LISTEN_PORT
|
unset SET_LISTEN_PORT
|
||||||
@@ -171,7 +157,6 @@ function download_mainsail_macros() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function download_mainsail() {
|
function download_mainsail() {
|
||||||
local services
|
|
||||||
local url
|
local url
|
||||||
url=$(get_mainsail_download_url)
|
url=$(get_mainsail_download_url)
|
||||||
|
|
||||||
@@ -194,9 +179,8 @@ function download_mainsail() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### check for moonraker multi-instance and if no-instance or multi-instance was found, enable mainsails remoteMode
|
### check for moonraker multi-instance and if multi-instance was found, enable mainsails remoteMode
|
||||||
services=$(moonraker_systemd)
|
if [[ $(moonraker_systemd | wc -w) -gt 1 ]]; then
|
||||||
if [[ ( -z "${services}" ) || ( $(echo "${services}" | wc -w) -gt 1 ) ]]; then
|
|
||||||
enable_mainsail_remotemode
|
enable_mainsail_remotemode
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -324,25 +308,19 @@ function get_mainsail_status() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function get_local_mainsail_version() {
|
function get_local_mainsail_version() {
|
||||||
local versionfile="${MAINSAIL_DIR}/.version"
|
[[ ! -f "${MAINSAIL_DIR}/.version" ]] && return
|
||||||
local relinfofile="${MAINSAIL_DIR}/release_info.json"
|
|
||||||
local version
|
local version
|
||||||
|
version=$(head -n 1 "${MAINSAIL_DIR}/.version")
|
||||||
if [[ -f ${relinfofile} ]]; then
|
|
||||||
version=$(grep -o '"version":"[^"]*' "${relinfofile}" | grep -o '[^"]*$')
|
|
||||||
elif [[ -f ${versionfile} ]]; then
|
|
||||||
version=$(head -n 1 "${versionfile}")
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "${version}"
|
echo "${version}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_remote_mainsail_version() {
|
function get_remote_mainsail_version() {
|
||||||
[[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]] && return
|
[[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]] && return
|
||||||
|
|
||||||
local tags
|
local version
|
||||||
tags=$(curl -s "https://api.github.com/repos/mainsail-crew/mainsail/tags" | grep "name" | cut -d'"' -f4)
|
version=$(get_mainsail_download_url | rev | cut -d"/" -f2 | rev)
|
||||||
echo "${tags}" | head -1
|
echo "${version}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function compare_mainsail_versions() {
|
function compare_mainsail_versions() {
|
||||||
@@ -380,7 +358,7 @@ function print_theme_list() {
|
|||||||
|
|
||||||
function ms_theme_installer_menu() {
|
function ms_theme_installer_menu() {
|
||||||
local theme_list theme_author theme_repo theme_name theme_note theme_url
|
local theme_list theme_author theme_repo theme_name theme_note theme_url
|
||||||
local theme_csv_url="https://raw.githubusercontent.com/mainsail-crew/gb-docs/main/_data/themes.csv"
|
local theme_csv_url="https://raw.githubusercontent.com/mainsail-crew/docs/master/_data/themes.csv"
|
||||||
theme_list=$(curl -s -L "${theme_csv_url}")
|
theme_list=$(curl -s -L "${theme_csv_url}")
|
||||||
|
|
||||||
top_border
|
top_border
|
||||||
@@ -533,28 +511,27 @@ function ms_theme_delete() {
|
|||||||
#================================================#
|
#================================================#
|
||||||
|
|
||||||
function get_mainsail_download_url() {
|
function get_mainsail_download_url() {
|
||||||
local releases_by_tag tags tag unstable_url url
|
local ms_tags tags latest_tag latest_url stable_tag stable_url url
|
||||||
|
|
||||||
### latest stable download url
|
ms_tags="https://api.github.com/repos/mainsail-crew/mainsail/tags"
|
||||||
url="https://github.com/mainsail-crew/mainsail/releases/latest/download/mainsail.zip"
|
tags=$(curl -s "${ms_tags}" | grep "name" | cut -d'"' -f4)
|
||||||
|
|
||||||
|
### latest download url including pre-releases (alpha, beta, rc)
|
||||||
|
latest_tag=$(echo "${tags}" | head -1)
|
||||||
|
latest_url="https://github.com/mainsail-crew/mainsail/releases/download/${latest_tag}/mainsail.zip"
|
||||||
|
|
||||||
|
### get stable mainsail download url
|
||||||
|
stable_tag=$(echo "${tags}" | grep -E "^v([0-9]+\.?){3}$" | head -1)
|
||||||
|
stable_url="https://github.com/mainsail-crew/mainsail/releases/download/${stable_tag}/mainsail.zip"
|
||||||
|
|
||||||
read_kiauh_ini "${FUNCNAME[0]}"
|
read_kiauh_ini "${FUNCNAME[0]}"
|
||||||
if [[ ${mainsail_install_unstable} == "true" ]]; then
|
if [[ ${mainsail_install_unstable} == "true" ]]; then
|
||||||
releases_by_tag="https://api.github.com/repos/mainsail-crew/mainsail/tags"
|
url="${latest_url}"
|
||||||
tags=$(curl -s "${releases_by_tag}" | grep "name" | cut -d'"' -f4)
|
echo "${url}"
|
||||||
tag=$(echo "${tags}" | head -1)
|
else
|
||||||
|
url="${stable_url}"
|
||||||
### latest unstable download url including pre-releases (alpha, beta, rc)
|
echo "${url}"
|
||||||
unstable_url="https://github.com/mainsail-crew/mainsail/releases/download/${tag}/mainsail.zip"
|
|
||||||
|
|
||||||
if [[ ${unstable_url} == *"download//"* ]]; then
|
|
||||||
warn_msg "Download URL broken! Falling back to URL of latest stable release!"
|
|
||||||
else
|
|
||||||
url=${unstable_url}
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${url}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mainsail_port_check() {
|
function mainsail_port_check() {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -190,4 +190,4 @@ function remove_mjpg-streamer() {
|
|||||||
[[ -L "${KLIPPER_LOGS}/webcamd.log" ]] && rm -f "${KLIPPER_LOGS}/webcamd.log"
|
[[ -L "${KLIPPER_LOGS}/webcamd.log" ]] && rm -f "${KLIPPER_LOGS}/webcamd.log"
|
||||||
|
|
||||||
print_confirm "MJPG-Streamer successfully removed!"
|
print_confirm "MJPG-Streamer successfully removed!"
|
||||||
}
|
}
|
||||||
@@ -1,247 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
#=======================================================================#
|
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
|
||||||
# #
|
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
|
||||||
# https://github.com/dw-0/kiauh #
|
|
||||||
# #
|
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
|
||||||
#=======================================================================#
|
|
||||||
|
|
||||||
#
|
|
||||||
# This file is written and maintained by Patrick Schmidt author of Mobileraker
|
|
||||||
# It is based of the kliperscreen.sh install script!
|
|
||||||
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
#===================================================#
|
|
||||||
#========== INSTALL MOBILERAKER COMPANION ==========#
|
|
||||||
#===================================================#
|
|
||||||
|
|
||||||
function mobileraker_systemd() {
|
|
||||||
local services
|
|
||||||
services=$(find "${SYSTEMD}" -maxdepth 1 -regextype posix-extended -regex "${SYSTEMD}/mobileraker.service")
|
|
||||||
echo "${services}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function install_mobileraker() {
|
|
||||||
### return early if python version check fails
|
|
||||||
if [[ $(python3_check) == "false" ]]; then
|
|
||||||
local error="Versioncheck failed! Python 3.7 or newer required!\n"
|
|
||||||
error="${error} Please upgrade Python."
|
|
||||||
print_error "${error}" && return
|
|
||||||
fi
|
|
||||||
|
|
||||||
### first, we create a backup of the full klipper_config dir - safety first!
|
|
||||||
backup_config_dir
|
|
||||||
|
|
||||||
### install Mobileraker's Companion
|
|
||||||
mobileraker_setup
|
|
||||||
|
|
||||||
### add Mobileraker's Companion to the update manager in moonraker.conf
|
|
||||||
patch_mobileraker_update_manager
|
|
||||||
|
|
||||||
do_action_service "restart" "mobileraker"
|
|
||||||
}
|
|
||||||
|
|
||||||
function mobileraker_setup() {
|
|
||||||
local dep=(wget curl unzip dfu-util)
|
|
||||||
dependency_check "${dep[@]}"
|
|
||||||
status_msg "Cloning Mobileraker's companion from ${MOBILERAKER_REPO} ..."
|
|
||||||
|
|
||||||
# force remove existing Mobileraker's companion dir
|
|
||||||
[[ -d ${MOBILERAKER_DIR} ]] && rm -rf "${MOBILERAKER_DIR}"
|
|
||||||
|
|
||||||
# clone into fresh Mobileraker's companion dir
|
|
||||||
cd "${HOME}" || exit 1
|
|
||||||
if ! git clone "${MOBILERAKER_REPO}" "${MOBILERAKER_DIR}"; then
|
|
||||||
print_error "Cloning mobileraker's companion from\n ${MOBILERAKER_REPO}\n failed!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
status_msg "Starting installer of Mobileraker's companion ..."
|
|
||||||
if "${MOBILERAKER_DIR}"/scripts/install.sh; then
|
|
||||||
ok_msg "Mobileraker's companion successfully installed!"
|
|
||||||
else
|
|
||||||
print_error "Mobileraker's companion installation failed!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#===================================================#
|
|
||||||
#=========== REMOVE MOBILERAKER COMPANION ==========#
|
|
||||||
#===================================================#
|
|
||||||
|
|
||||||
function remove_mobileraker() {
|
|
||||||
### remove Mobileraker's companion dir
|
|
||||||
if [[ -d ${MOBILERAKER_DIR} ]]; then
|
|
||||||
status_msg "Removing Mobileraker's companion directory ..."
|
|
||||||
rm -rf "${MOBILERAKER_DIR}" && ok_msg "Directory removed!"
|
|
||||||
fi
|
|
||||||
|
|
||||||
### remove Mobileraker's companion VENV dir
|
|
||||||
if [[ -d ${MOBILERAKER_ENV} ]]; then
|
|
||||||
status_msg "Removing Mobileraker's companion VENV directory ..."
|
|
||||||
rm -rf "${MOBILERAKER_ENV}" && ok_msg "Directory removed!"
|
|
||||||
fi
|
|
||||||
|
|
||||||
### remove Mobileraker's companion service
|
|
||||||
if [[ -e "${SYSTEMD}/mobileraker.service" ]]; then
|
|
||||||
status_msg "Removing mobileraker service ..."
|
|
||||||
do_action_service "stop" "mobileraker"
|
|
||||||
do_action_service "disable" "mobileraker"
|
|
||||||
sudo rm -f "${SYSTEMD}/mobileraker.service"
|
|
||||||
|
|
||||||
###reloading units
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl reset-failed
|
|
||||||
ok_msg "Mobileraker's companion Service removed!"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
remove_mobileraker_logs
|
|
||||||
|
|
||||||
print_confirm "Mobileraker's companion successfully removed!"
|
|
||||||
}
|
|
||||||
|
|
||||||
function remove_mobileraker_logs() {
|
|
||||||
local files regex="${HOME//\//\\/}\/([A-Za-z0-9_]+)\/logs\/mobileraker\.log.*"
|
|
||||||
files=$(find "${HOME}" -maxdepth 3 -regextype posix-extended -regex "${regex}" | sort)
|
|
||||||
|
|
||||||
if [[ -n ${files} ]]; then
|
|
||||||
for file in ${files}; do
|
|
||||||
status_msg "Removing ${file} ..."
|
|
||||||
rm -f "${file}"
|
|
||||||
ok_msg "${file} removed!"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#===================================================#
|
|
||||||
#=========== UPDATE MOBILERAKER COMPANION ==========#
|
|
||||||
#===================================================#
|
|
||||||
|
|
||||||
function update_mobileraker() {
|
|
||||||
local old_md5
|
|
||||||
old_md5=$(md5sum "${MOBILERAKER_DIR}/scripts/mobileraker-requirements.txt" | cut -d " " -f1)
|
|
||||||
|
|
||||||
do_action_service "stop" "mobileraker"
|
|
||||||
cd "${MOBILERAKER_DIR}"
|
|
||||||
git pull origin main -q && ok_msg "Fetch successfull!"
|
|
||||||
git checkout -f main && ok_msg "Checkout successfull"
|
|
||||||
|
|
||||||
if [[ $(md5sum "${MOBILERAKER_DIR}/scripts/mobileraker-requirements.txt" | cut -d " " -f1) != "${old_md5}" ]]; then
|
|
||||||
status_msg "New dependecies detected..."
|
|
||||||
"${MOBILERAKER_ENV}"/bin/pip install -r "${MOBILERAKER_DIR}/scripts/mobileraker-requirements.txt"
|
|
||||||
ok_msg "Dependencies have been installed!"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ok_msg "Update complete!"
|
|
||||||
do_action_service "start" "mobileraker"
|
|
||||||
}
|
|
||||||
|
|
||||||
#===================================================#
|
|
||||||
#=========== MOBILERAKER COMPANION STATUS ==========#
|
|
||||||
#===================================================#
|
|
||||||
|
|
||||||
function get_mobileraker_status() {
|
|
||||||
local sf_count status
|
|
||||||
sf_count="$(mobileraker_systemd | wc -w)"
|
|
||||||
|
|
||||||
### remove the "SERVICE" entry from the data array if a moonraker service is installed
|
|
||||||
local data_arr=(SERVICE "${MOBILERAKER_DIR}" "${MOBILERAKER_ENV}")
|
|
||||||
(( sf_count > 0 )) && unset "data_arr[0]"
|
|
||||||
|
|
||||||
### count+1 for each found data-item from array
|
|
||||||
local filecount=0
|
|
||||||
for data in "${data_arr[@]}"; do
|
|
||||||
[[ -e ${data} ]] && filecount=$(( filecount + 1 ))
|
|
||||||
done
|
|
||||||
|
|
||||||
if (( filecount == ${#data_arr[*]} )); then
|
|
||||||
status="Installed!"
|
|
||||||
elif (( filecount == 0 )); then
|
|
||||||
status="Not installed!"
|
|
||||||
else
|
|
||||||
status="Incomplete!"
|
|
||||||
fi
|
|
||||||
echo "${status}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_local_mobileraker_commit() {
|
|
||||||
[[ ! -d ${MOBILERAKER_DIR} || ! -d "${MOBILERAKER_DIR}/.git" ]] && return
|
|
||||||
|
|
||||||
local commit
|
|
||||||
cd "${MOBILERAKER_DIR}"
|
|
||||||
commit="$(git describe HEAD --always --tags | cut -d "-" -f 1,2)"
|
|
||||||
echo "${commit}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_remote_mobileraker_commit() {
|
|
||||||
[[ ! -d ${MOBILERAKER_DIR} || ! -d "${MOBILERAKER_DIR}/.git" ]] && return
|
|
||||||
|
|
||||||
local commit
|
|
||||||
cd "${MOBILERAKER_DIR}" && git fetch origin -q
|
|
||||||
commit=$(git describe origin/main --always --tags | cut -d "-" -f 1,2)
|
|
||||||
echo "${commit}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function compare_mobileraker_versions() {
|
|
||||||
local versions local_ver remote_ver
|
|
||||||
local_ver="$(get_local_mobileraker_commit)"
|
|
||||||
remote_ver="$(get_remote_mobileraker_commit)"
|
|
||||||
|
|
||||||
if [[ ${local_ver} != "${remote_ver}" ]]; then
|
|
||||||
versions="${yellow}$(printf " %-14s" "${local_ver}")${white}"
|
|
||||||
versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}"
|
|
||||||
# add moonraker to application_updates_available in kiauh.ini
|
|
||||||
add_to_application_updates "mobileraker"
|
|
||||||
else
|
|
||||||
versions="${green}$(printf " %-14s" "${local_ver}")${white}"
|
|
||||||
versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "${versions}"
|
|
||||||
}
|
|
||||||
|
|
||||||
#================================================#
|
|
||||||
#=================== HELPERS ====================#
|
|
||||||
#================================================#
|
|
||||||
|
|
||||||
function patch_mobileraker_update_manager() {
|
|
||||||
local patched moonraker_configs regex
|
|
||||||
regex="${HOME//\//\\/}\/([A-Za-z0-9_]+)\/config\/moonraker\.conf"
|
|
||||||
moonraker_configs=$(find "${HOME}" -maxdepth 3 -type f -regextype posix-extended -regex "${regex}" | sort)
|
|
||||||
|
|
||||||
patched="false"
|
|
||||||
for conf in ${moonraker_configs}; do
|
|
||||||
if ! grep -Eq "^\[update_manager mobileraker\]\s*$" "${conf}"; then
|
|
||||||
### add new line to conf if it doesn't end with one
|
|
||||||
[[ $(tail -c1 "${conf}" | wc -l) -eq 0 ]] && echo "" >> "${conf}"
|
|
||||||
|
|
||||||
### add Mobileraker's Companion update manager section to moonraker.conf
|
|
||||||
status_msg "Adding Mobileraker's Companion to update manager in file:\n ${conf}"
|
|
||||||
/bin/sh -c "cat >> ${conf}" << MOONRAKER_CONF
|
|
||||||
|
|
||||||
[update_manager mobileraker]
|
|
||||||
type: git_repo
|
|
||||||
path: ${HOME}/mobileraker_companion
|
|
||||||
origin: https://github.com/Clon1998/mobileraker_companion.git
|
|
||||||
primary_branch:main
|
|
||||||
managed_services: mobileraker
|
|
||||||
env: ${HOME}/mobileraker-env/bin/python
|
|
||||||
requirements: scripts/mobileraker-requirements.txt
|
|
||||||
install_script: scripts/install.sh
|
|
||||||
MOONRAKER_CONF
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
patched="true"
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ ${patched} == "true" ]]; then
|
|
||||||
do_action_service "restart" "moonraker"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -33,7 +33,7 @@ function telegram_bot_setup_dialog() {
|
|||||||
|
|
||||||
status_msg "Initializing Telegram Bot installation ..."
|
status_msg "Initializing Telegram Bot installation ..."
|
||||||
### first, we create a backup of the full klipper_config dir - safety first!
|
### first, we create a backup of the full klipper_config dir - safety first!
|
||||||
backup_config_dir
|
backup_klipper_config_dir
|
||||||
|
|
||||||
local moonraker_count user_input=() moonraker_names=()
|
local moonraker_count user_input=() moonraker_names=()
|
||||||
moonraker_count=$(echo "${moonraker_services}" | wc -w )
|
moonraker_count=$(echo "${moonraker_services}" | wc -w )
|
||||||
@@ -110,7 +110,7 @@ function telegram_bot_setup_dialog() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function install_telegram_bot_dependencies() {
|
function install_telegram_bot_dependencies() {
|
||||||
local packages log_name="Telegram Bot"
|
local packages
|
||||||
local install_script="${TELEGRAM_BOT_DIR}/scripts/install.sh"
|
local install_script="${TELEGRAM_BOT_DIR}/scripts/install.sh"
|
||||||
|
|
||||||
### read PKGLIST from official install-script
|
### read PKGLIST from official install-script
|
||||||
@@ -121,11 +121,21 @@ function install_telegram_bot_dependencies() {
|
|||||||
echo "${cyan}${packages}${white}" | tr '[:space:]' '\n'
|
echo "${cyan}${packages}${white}" | tr '[:space:]' '\n'
|
||||||
read -r -a packages <<< "${packages}"
|
read -r -a packages <<< "${packages}"
|
||||||
|
|
||||||
### Update system package lists if stale
|
### Update system package info
|
||||||
update_system_package_lists
|
status_msg "Updating package lists..."
|
||||||
|
if ! sudo apt-get update --allow-releaseinfo-change; then
|
||||||
|
log_error "failure while updating package lists"
|
||||||
|
error_msg "Updating package lists failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
### Install required packages
|
### Install required packages
|
||||||
install_system_packages "${log_name}" "packages[@]"
|
status_msg "Installing required packages..."
|
||||||
|
if ! sudo apt-get install --yes "${packages[@]}"; then
|
||||||
|
log_error "failure while installing required moonraker-telegram-bot packages"
|
||||||
|
error_msg "Installing required packages failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_telegram_bot_virtualenv() {
|
function create_telegram_bot_virtualenv() {
|
||||||
@@ -318,11 +328,11 @@ function write_telegram_bot_service() {
|
|||||||
else
|
else
|
||||||
sudo sed -i "s|%INST%|${i}|" "${service}"
|
sudo sed -i "s|%INST%|${i}|" "${service}"
|
||||||
fi
|
fi
|
||||||
sudo sed -i "s|%USER%|${USER}|g; s|%TELEGRAM_BOT_DIR%|${TELEGRAM_BOT_DIR}|; s|%ENV%|${TELEGRAM_BOT_ENV}|; s|%ENV_FILE%|${env_file}|" "${service}"
|
sudo sed -i "s|%USER%|${USER}|g; s|%ENV%|${TELEGRAM_BOT_ENV}|; s|%ENV_FILE%|${env_file}|" "${service}"
|
||||||
|
|
||||||
status_msg "Creating environment file for instance ${i} ..."
|
status_msg "Creating environment file for instance ${i} ..."
|
||||||
cp "${env_template}" "${env_file}"
|
cp "${env_template}" "${env_file}"
|
||||||
sed -i "s|%USER%|${USER}|; s|%TELEGRAM_BOT_DIR%|${TELEGRAM_BOT_DIR}|; s|%CFG%|${cfg}|; s|%LOG%|${log}|" "${env_file}"
|
sed -i "s|%USER%|${USER}|; s|%CFG%|${cfg}|; s|%LOG%|${log}|" "${env_file}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -37,8 +37,6 @@ function moonraker_systemd() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function moonraker_setup_dialog() {
|
function moonraker_setup_dialog() {
|
||||||
status_msg "Initializing Moonraker installation ..."
|
|
||||||
|
|
||||||
### return early if python version check fails
|
### return early if python version check fails
|
||||||
if [[ $(python3_check) == "false" ]]; then
|
if [[ $(python3_check) == "false" ]]; then
|
||||||
local error="Versioncheck failed! Python 3.7 or newer required!\n"
|
local error="Versioncheck failed! Python 3.7 or newer required!\n"
|
||||||
@@ -46,102 +44,90 @@ function moonraker_setup_dialog() {
|
|||||||
print_error "${error}" && return
|
print_error "${error}" && return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### return early if moonraker already exists
|
local klipper_services=$(klipper_systemd)
|
||||||
local moonraker_services
|
local klipper_count=$(echo "${klipper_services}" | wc -w )
|
||||||
moonraker_services=$(moonraker_systemd)
|
for service in ${klipper_services}; do
|
||||||
if [[ -n ${moonraker_services} ]]; then
|
klipper_names+=( "$(get_instance_name "${service}")" )
|
||||||
local error="At least one Moonraker service is already installed:"
|
done
|
||||||
for s in ${moonraker_services}; do
|
|
||||||
log_info "Found Moonraker service: ${s}"
|
local moonraker_services=$(moonraker_systemd)
|
||||||
error="${error}\n ➔ ${s}"
|
local moonraker_count=$(echo "${moonraker_services}" | wc -w )
|
||||||
done
|
for service in ${moonraker_services}; do
|
||||||
print_error "${error}" && return
|
moonraker_names+=( "$(get_instance_name "${service}")" )
|
||||||
fi
|
done
|
||||||
|
|
||||||
### return early if klipper is not installed
|
### return early if klipper is not installed
|
||||||
local klipper_services
|
|
||||||
klipper_services=$(klipper_systemd)
|
|
||||||
if [[ -z ${klipper_services} ]]; then
|
if [[ -z ${klipper_services} ]]; then
|
||||||
local error="Klipper not installed! Please install Klipper first!"
|
local error="Klipper not installed! Please install Klipper first!"
|
||||||
log_error "Moonraker setup started without Klipper being installed. Aborting setup."
|
log_error "Moonraker setup started without Klipper being installed. Aborting setup."
|
||||||
print_error "${error}" && return
|
print_error "${error}" && return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local klipper_count user_input=() klipper_names=()
|
top_border
|
||||||
klipper_count=$(echo "${klipper_services}" | wc -w )
|
echo -e "| ${red}~~~~~~~~~ [ Moonraker installation ] ~~~~~~~~${white} |"
|
||||||
for service in ${klipper_services}; do
|
hr
|
||||||
klipper_names+=( "$(get_instance_name "${service}")" )
|
|
||||||
|
printf "|${green}%-55s${white}|\n" " ${moonraker_count} Moonraker services found!"
|
||||||
|
local moonraker_folders=()
|
||||||
|
for name in ${moonraker_services}; do
|
||||||
|
local moonraker_folder=$(get_data_folder $(basename ${name}) moonraker)
|
||||||
|
printf "|${cyan}%-57s${white}|\n" " ● $(basename ${name}) - $(get_moonraker_address $(basename ${name}))"
|
||||||
|
moonraker_folders+=( "${moonraker_folder}" )
|
||||||
done
|
done
|
||||||
|
blank_line
|
||||||
|
printf "|${green}%-55s${white}|\n" " ${klipper_count} Klipper services found!"
|
||||||
|
local klipper_available=()
|
||||||
|
for name in ${klipper_services}; do
|
||||||
|
local klipper_folder=$(get_data_folder $(basename ${name}) klipper)
|
||||||
|
printf "|${cyan}%-57s${white}|\n" " ● $(basename ${name}) - ${klipper_folder}"
|
||||||
|
if [[ ! " ${moonraker_folders[*]} " =~ " ${klipper_folder} " ]]; then
|
||||||
|
klipper_available+=( "$(basename ${name})" )
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
local klipper_available_count=${#klipper_available[@]}
|
||||||
|
hr
|
||||||
|
|
||||||
local moonraker_count
|
printf "|${green}%-55s${white}|\n" " ${klipper_available_count} Moonraker services can be installed:"
|
||||||
if (( klipper_count == 1 )); then
|
local service_name
|
||||||
ok_msg "Klipper installation found!\n"
|
if (( klipper_available_count == 1 )); then
|
||||||
moonraker_count=1
|
service_name=$(basename "${klipper_available[@]}")
|
||||||
elif (( klipper_count > 1 )); then
|
printf "| 0) %-51s|\n" "${service_name}"
|
||||||
top_border
|
|
||||||
printf "|${green}%-55s${white}|\n" " ${klipper_count} Klipper instances found!"
|
|
||||||
for name in "${klipper_names[@]}"; do
|
|
||||||
printf "|${cyan}%-57s${white}|\n" " ● klipper-${name}"
|
|
||||||
done
|
|
||||||
blank_line
|
|
||||||
echo -e "| The setup will apply the same names to Moonraker! |"
|
|
||||||
blank_line
|
|
||||||
echo -e "| Please select the number of Moonraker instances to |"
|
|
||||||
echo -e "| install. Usually one Moonraker instance per Klipper |"
|
|
||||||
echo -e "| instance is required, but you may not install more |"
|
|
||||||
echo -e "| Moonraker instances than available Klipper instances. |"
|
|
||||||
bottom_border
|
|
||||||
|
|
||||||
### ask for amount of instances
|
|
||||||
local re="^[1-9][0-9]*$"
|
|
||||||
while [[ ! ${moonraker_count} =~ ${re} || ${moonraker_count} -gt ${klipper_count} ]]; do
|
|
||||||
read -p "${cyan}###### Number of Moonraker instances to set up:${white} " -i "${klipper_count}" -e moonraker_count
|
|
||||||
### break if input is valid
|
|
||||||
[[ ${moonraker_count} =~ ${re} && ${moonraker_count} -le ${klipper_count} ]] && break
|
|
||||||
### conditional error messages
|
|
||||||
[[ ! ${moonraker_count} =~ ${re} ]] && error_msg "Input not a number"
|
|
||||||
(( moonraker_count > klipper_count )) && error_msg "Number of Moonraker instances larger than installed Klipper instances"
|
|
||||||
done && select_msg "${moonraker_count}"
|
|
||||||
else
|
else
|
||||||
log_error "Internal error. klipper_count of '${klipper_count}' not equal or grather than one!"
|
printf "| 0) %-51s|\n" "Install all"
|
||||||
return 1
|
local i=1
|
||||||
fi
|
for name in "${klipper_available[@]}"; do
|
||||||
|
printf "| ${i}) %-51s|\n" "${name}"
|
||||||
user_input+=("${moonraker_count}")
|
(( i=i+1 ))
|
||||||
|
|
||||||
### confirm instance amount
|
|
||||||
local yn
|
|
||||||
while true; do
|
|
||||||
(( moonraker_count == 1 )) && local question="Install Moonraker?"
|
|
||||||
(( moonraker_count > 1 )) && local question="Install ${moonraker_count} Moonraker instances?"
|
|
||||||
read -p "${cyan}###### ${question} (Y/n):${white} " yn
|
|
||||||
case "${yn}" in
|
|
||||||
Y|y|Yes|yes|"")
|
|
||||||
select_msg "Yes"
|
|
||||||
break;;
|
|
||||||
N|n|No|no)
|
|
||||||
select_msg "No"
|
|
||||||
abort_msg "Exiting Moonraker setup ...\n"
|
|
||||||
return;;
|
|
||||||
*)
|
|
||||||
error_msg "Invalid Input!";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
### write existing klipper names into user_input array to use them as names for moonraker
|
|
||||||
if (( klipper_count > 1 )); then
|
|
||||||
for name in "${klipper_names[@]}"; do
|
|
||||||
user_input+=("${name}")
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
back_footer
|
||||||
|
|
||||||
(( moonraker_count > 1 )) && status_msg "Installing ${moonraker_count} Moonraker instances ..."
|
local option
|
||||||
(( moonraker_count == 1 )) && status_msg "Installing Moonraker ..."
|
while true; do
|
||||||
|
read -p "${cyan}Install moonraker for:${white} " option
|
||||||
|
if [[ ${option} == "B" || ${option} == "b" ]]; then
|
||||||
|
return
|
||||||
|
elif [[ $((option)) != $option ]]; then
|
||||||
|
error_msg "Invalid command!"
|
||||||
|
elif (( option >= 0 && option < ${#klipper_available[@]} )); then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
error_msg "Invalid command!"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if (( option == 0 )); then
|
||||||
|
user_input=( ${klipper_available[@]} )
|
||||||
|
else
|
||||||
|
user_input=( "${klipper_available[(( option-1 ))]}" )
|
||||||
|
fi
|
||||||
|
|
||||||
|
status_msg "Installing Moonraker ..."
|
||||||
moonraker_setup "${user_input[@]}"
|
moonraker_setup "${user_input[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_moonraker_dependencies() {
|
function install_moonraker_dependencies() {
|
||||||
local packages log_name="Moonraker"
|
local packages
|
||||||
local install_script="${MOONRAKER_DIR}/scripts/install-moonraker.sh"
|
local install_script="${MOONRAKER_DIR}/scripts/install-moonraker.sh"
|
||||||
|
|
||||||
### read PKGLIST from official install-script
|
### read PKGLIST from official install-script
|
||||||
@@ -152,11 +138,21 @@ function install_moonraker_dependencies() {
|
|||||||
echo "${cyan}${packages}${white}" | tr '[:space:]' '\n'
|
echo "${cyan}${packages}${white}" | tr '[:space:]' '\n'
|
||||||
read -r -a packages <<< "${packages}"
|
read -r -a packages <<< "${packages}"
|
||||||
|
|
||||||
### Update system package lists if stale
|
### Update system package info
|
||||||
update_system_package_lists
|
status_msg "Updating package lists..."
|
||||||
|
if ! sudo apt-get update --allow-releaseinfo-change; then
|
||||||
|
log_error "failure while updating package lists"
|
||||||
|
error_msg "Updating package lists failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
### Install required packages
|
### Install required packages
|
||||||
install_system_packages "${log_name}" "packages[@]"
|
status_msg "Installing required packages..."
|
||||||
|
if ! sudo apt-get install --yes "${packages[@]}"; then
|
||||||
|
log_error "failure while installing required moonraker packages"
|
||||||
|
error_msg "Installing required packages failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_moonraker_virtualenv() {
|
function create_moonraker_virtualenv() {
|
||||||
@@ -189,7 +185,10 @@ function moonraker_setup() {
|
|||||||
### step 2: install moonraker dependencies and create python virtualenv
|
### step 2: install moonraker dependencies and create python virtualenv
|
||||||
status_msg "Installing dependencies ..."
|
status_msg "Installing dependencies ..."
|
||||||
install_moonraker_dependencies
|
install_moonraker_dependencies
|
||||||
create_moonraker_virtualenv
|
if [[ "${moonraker_clone_result}" == "0" ]]; then
|
||||||
|
create_moonraker_virtualenv
|
||||||
|
fi
|
||||||
|
unset moonraker_clone_result
|
||||||
|
|
||||||
### step 3: create moonraker.conf
|
### step 3: create moonraker.conf
|
||||||
create_moonraker_conf "${instance_arr[@]}"
|
create_moonraker_conf "${instance_arr[@]}"
|
||||||
@@ -206,9 +205,10 @@ function moonraker_setup() {
|
|||||||
|
|
||||||
### confirm message
|
### confirm message
|
||||||
local confirm=""
|
local confirm=""
|
||||||
(( instance_arr[0] == 1 )) && confirm="Moonraker has been set up!"
|
(( ${#instance_arr[@]} == 1 )) && confirm="Moonraker has been set up!"
|
||||||
(( instance_arr[0] > 1 )) && confirm="${instance_arr[0]} Moonraker instances have been set up!"
|
(( ${#instance_arr[@]} > 1 )) && confirm="${#instance_arr[@]} Moonraker instances have been set up!"
|
||||||
print_confirm "${confirm}" && print_mr_ip_list "${instance_arr[0]}" && return
|
print_confirm "${confirm}"
|
||||||
|
print_moonraker_addresses
|
||||||
}
|
}
|
||||||
|
|
||||||
function clone_moonraker() {
|
function clone_moonraker() {
|
||||||
@@ -216,6 +216,15 @@ function clone_moonraker() {
|
|||||||
|
|
||||||
status_msg "Cloning Moonraker from ${repo} ..."
|
status_msg "Cloning Moonraker from ${repo} ..."
|
||||||
|
|
||||||
|
if [[ -d ${MOONRAKER_DIR} ]]
|
||||||
|
then
|
||||||
|
status_msg "Moonraker already cloned, pulling recent changes ..."
|
||||||
|
git -C ${MOONRAKER_DIR} stash
|
||||||
|
git -C ${MOONRAKER_DIR} pull --ff-only
|
||||||
|
moonraker_clone_result="1"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
### force remove existing moonraker dir and clone into fresh moonraker dir
|
### force remove existing moonraker dir and clone into fresh moonraker dir
|
||||||
[[ -d ${MOONRAKER_DIR} ]] && rm -rf "${MOONRAKER_DIR}"
|
[[ -d ${MOONRAKER_DIR} ]] && rm -rf "${MOONRAKER_DIR}"
|
||||||
|
|
||||||
@@ -224,50 +233,29 @@ function clone_moonraker() {
|
|||||||
print_error "Cloning Moonraker from\n ${repo}\n failed!"
|
print_error "Cloning Moonraker from\n ${repo}\n failed!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
moonraker_clone_result="0"
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_moonraker_conf() {
|
function create_moonraker_conf() {
|
||||||
local input=("${@}")
|
local names=("${@}")
|
||||||
local moonraker_count=${input[0]} && unset "input[0]"
|
local moonraker_count=${#names[@]}
|
||||||
local names=("${input[@]}") && unset "input[@]"
|
local lan printer_data cfg_dir cfg uds
|
||||||
local port lan printer_data cfg_dir cfg uds
|
local port=$(get_moonraker_next_port)
|
||||||
|
|
||||||
port=7125
|
|
||||||
lan="$(hostname -I | cut -d" " -f1 | cut -d"." -f1-2).0.0/16"
|
lan="$(hostname -I | cut -d" " -f1 | cut -d"." -f1-2).0.0/16"
|
||||||
|
|
||||||
if (( moonraker_count == 1 )); then
|
for service in "${names[@]}"; do
|
||||||
printer_data="${HOME}/printer_data"
|
### overwrite config folder if name is only a number
|
||||||
|
printer_data=$(get_data_folder "${service}" "klipper")
|
||||||
|
|
||||||
cfg_dir="${printer_data}/config"
|
cfg_dir="${printer_data}/config"
|
||||||
cfg="${cfg_dir}/moonraker.conf"
|
cfg="${cfg_dir}/moonraker.conf"
|
||||||
uds="${printer_data}/comms/klippy.sock"
|
uds="${printer_data}/comms/klippy.sock"
|
||||||
|
|
||||||
### write single instance config
|
### write multi instance config
|
||||||
write_moonraker_conf "${cfg_dir}" "${cfg}" "${port}" "${uds}" "${lan}"
|
write_moonraker_conf "${cfg_dir}" "${cfg}" "${port}" "${uds}" "${lan}"
|
||||||
|
(( port=port+1 ))
|
||||||
elif (( moonraker_count > 1 )); then
|
done && unset j
|
||||||
local j=0 re="^[1-9][0-9]*$"
|
|
||||||
|
|
||||||
for (( i=1; i <= moonraker_count; i++ )); do
|
|
||||||
### overwrite config folder if name is only a number
|
|
||||||
if [[ ${names[j]} =~ ${re} ]]; then
|
|
||||||
printer_data="${HOME}/printer_${names[${j}]}_data"
|
|
||||||
else
|
|
||||||
printer_data="${HOME}/${names[${j}]}_data"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cfg_dir="${printer_data}/config"
|
|
||||||
cfg="${cfg_dir}/moonraker.conf"
|
|
||||||
uds="${printer_data}/comms/klippy.sock"
|
|
||||||
|
|
||||||
### write multi instance config
|
|
||||||
write_moonraker_conf "${cfg_dir}" "${cfg}" "${port}" "${uds}" "${lan}"
|
|
||||||
port=$(( port + 1 ))
|
|
||||||
j=$(( j + 1 ))
|
|
||||||
done && unset j
|
|
||||||
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function write_moonraker_conf() {
|
function write_moonraker_conf() {
|
||||||
@@ -294,56 +282,29 @@ function write_moonraker_conf() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function configure_moonraker_service() {
|
function configure_moonraker_service() {
|
||||||
local input=("${@}")
|
local names=("${@}")
|
||||||
local moonraker_count=${input[0]} && unset "input[0]"
|
local moonraker_count=${#names[@]}
|
||||||
local names=("${input[@]}") && unset "input[@]"
|
local printer_data cfg_dir service env_file service_name
|
||||||
local printer_data cfg_dir service env_file
|
|
||||||
|
for service in "${names[@]}"; do
|
||||||
|
printer_data=$(get_data_folder "${service}" "klipper")
|
||||||
|
|
||||||
if (( moonraker_count == 1 )) && [[ ${#names[@]} -eq 0 ]]; then
|
|
||||||
i=""
|
|
||||||
printer_data="${HOME}/printer_data"
|
|
||||||
cfg_dir="${printer_data}/config"
|
cfg_dir="${printer_data}/config"
|
||||||
service="${SYSTEMD}/moonraker.service"
|
service_name="${service/"klipper"/"moonraker"}"
|
||||||
|
service="${SYSTEMD}/${service_name}"
|
||||||
env_file="${printer_data}/systemd/moonraker.env"
|
env_file="${printer_data}/systemd/moonraker.env"
|
||||||
|
|
||||||
### create required folder structure
|
### create required folder structure
|
||||||
create_required_folders "${printer_data}"
|
create_required_folders "${printer_data}"
|
||||||
|
|
||||||
### write single instance service
|
### write multi instance service
|
||||||
write_moonraker_service "" "${printer_data}" "${service}" "${env_file}"
|
write_moonraker_service "${service_name}" "${printer_data}" "${service}" "${env_file}"
|
||||||
ok_msg "Moonraker instance created!"
|
ok_msg "Moonraker instance '${service_name}' created!"
|
||||||
|
done && unset i
|
||||||
|
|
||||||
elif (( moonraker_count > 1 )) && [[ ${#names[@]} -gt 0 ]]; then
|
### enable mainsails remoteMode if mainsail is found
|
||||||
local j=0 re="^[1-9][0-9]*$"
|
if [[ -d ${MAINSAIL_DIR} ]]; then
|
||||||
|
enable_mainsail_remotemode
|
||||||
for (( i=1; i <= moonraker_count; i++ )); do
|
|
||||||
### overwrite config folder if name is only a number
|
|
||||||
if [[ ${names[j]} =~ ${re} ]]; then
|
|
||||||
printer_data="${HOME}/printer_${names[${j}]}_data"
|
|
||||||
else
|
|
||||||
printer_data="${HOME}/${names[${j}]}_data"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cfg_dir="${printer_data}/config"
|
|
||||||
service="${SYSTEMD}/moonraker-${names[${j}]}.service"
|
|
||||||
env_file="${printer_data}/systemd/moonraker.env"
|
|
||||||
|
|
||||||
### create required folder structure
|
|
||||||
create_required_folders "${printer_data}"
|
|
||||||
|
|
||||||
### write multi instance service
|
|
||||||
write_moonraker_service "${names[${j}]}" "${printer_data}" "${service}" "${env_file}"
|
|
||||||
ok_msg "Moonraker instance 'moonraker-${names[${j}]}' created!"
|
|
||||||
j=$(( j + 1 ))
|
|
||||||
done && unset i
|
|
||||||
|
|
||||||
### enable mainsails remoteMode if mainsail is found
|
|
||||||
if [[ -d ${MAINSAIL_DIR} ]]; then
|
|
||||||
enable_mainsail_remotemode
|
|
||||||
fi
|
|
||||||
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,6 +312,7 @@ function write_moonraker_service() {
|
|||||||
local i=${1} printer_data=${2} service=${3} env_file=${4}
|
local i=${1} printer_data=${2} service=${3} env_file=${4}
|
||||||
local service_template="${KIAUH_SRCDIR}/resources/moonraker.service"
|
local service_template="${KIAUH_SRCDIR}/resources/moonraker.service"
|
||||||
local env_template="${KIAUH_SRCDIR}/resources/moonraker.env"
|
local env_template="${KIAUH_SRCDIR}/resources/moonraker.env"
|
||||||
|
local instance_name=$(get_instance_name "${i}")
|
||||||
|
|
||||||
### replace all placeholders
|
### replace all placeholders
|
||||||
if [[ ! -f ${service} ]]; then
|
if [[ ! -f ${service} ]]; then
|
||||||
@@ -358,10 +320,9 @@ function write_moonraker_service() {
|
|||||||
sudo cp "${service_template}" "${service}"
|
sudo cp "${service_template}" "${service}"
|
||||||
sudo cp "${env_template}" "${env_file}"
|
sudo cp "${env_template}" "${env_file}"
|
||||||
|
|
||||||
[[ -z ${i} ]] && sudo sed -i "s| %INST%||" "${service}"
|
sudo sed -i "s|%INST%|${instance_name}|" "${service}"
|
||||||
[[ -n ${i} ]] && sudo sed -i "s|%INST%|${i}|" "${service}"
|
sudo sed -i "s|%USER%|${USER}|g; s|%ENV%|${MOONRAKER_ENV}|; s|%ENV_FILE%|${env_file}|" "${service}"
|
||||||
sudo sed -i "s|%USER%|${USER}|g; s|%MOONRAKER_DIR%|${MOONRAKER_DIR}|; s|%ENV%|${MOONRAKER_ENV}|; s|%ENV_FILE%|${env_file}|" "${service}"
|
sudo sed -i "s|%USER%|${USER}|; s|%PRINTER_DATA%|${printer_data}|" "${env_file}"
|
||||||
sudo sed -i "s|%USER%|${USER}|; s|%MOONRAKER_DIR%|${MOONRAKER_DIR}|; s|%PRINTER_DATA%|${printer_data}|" "${env_file}"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,6 +336,45 @@ function print_mr_ip_list() {
|
|||||||
done && echo
|
done && echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_moonraker_next_port() {
|
||||||
|
local port=7125
|
||||||
|
local moonraker_services=$(moonraker_systemd) moonraker_ports=()
|
||||||
|
for service in ${moonraker_services}
|
||||||
|
do
|
||||||
|
service_name=$(basename ${service})
|
||||||
|
moonraker_ports+=( "$(get_moonraker_port ${service_name})" )
|
||||||
|
done
|
||||||
|
while true; do
|
||||||
|
if [[ ! " ${moonraker_ports[*]} " =~ " ${port} " ]]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
(( port=port+1 ))
|
||||||
|
done
|
||||||
|
echo "${port}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_moonraker_port() {
|
||||||
|
local service=${1}
|
||||||
|
local printer_data=$(get_data_folder ${service} moonraker)
|
||||||
|
local port=$(grep "^port:" "${printer_data}/config/moonraker.conf" | cut -f 2 -d " ")
|
||||||
|
echo "${port}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_moonraker_address() {
|
||||||
|
local ip=$(hostname -I | cut -d" " -f1)
|
||||||
|
local port=$(get_moonraker_port ${1})
|
||||||
|
echo "${ip}:${port}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function print_moonraker_addresses() {
|
||||||
|
local service_name moonraker_services=$(moonraker_systemd)
|
||||||
|
for service in ${moonraker_services}
|
||||||
|
do
|
||||||
|
service_name=$(basename ${service})
|
||||||
|
echo " ${cyan}● ${service_name}:${white} $(get_moonraker_address ${service_name})"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
### introduced due to
|
### introduced due to
|
||||||
### https://github.com/Arksine/moonraker/issues/349
|
### https://github.com/Arksine/moonraker/issues/349
|
||||||
### https://github.com/Arksine/moonraker/pull/346
|
### https://github.com/Arksine/moonraker/pull/346
|
||||||
@@ -425,22 +425,10 @@ function install_moonraker_polkit() {
|
|||||||
#================ REMOVE MOONRAKER ================#
|
#================ REMOVE MOONRAKER ================#
|
||||||
#==================================================#
|
#==================================================#
|
||||||
|
|
||||||
function remove_moonraker_sysvinit() {
|
|
||||||
[[ ! -e "${INITD}/moonraker" ]] && return
|
|
||||||
|
|
||||||
status_msg "Removing Moonraker SysVinit service ..."
|
|
||||||
sudo systemctl stop moonraker
|
|
||||||
sudo update-rc.d -f moonraker remove
|
|
||||||
sudo rm -f "${INITD}/moonraker" "${ETCDEF}/moonraker"
|
|
||||||
ok_msg "Moonraker SysVinit service removed!"
|
|
||||||
}
|
|
||||||
|
|
||||||
function remove_moonraker_systemd() {
|
function remove_moonraker_systemd() {
|
||||||
[[ -z $(moonraker_systemd) ]] && return
|
|
||||||
|
|
||||||
status_msg "Removing Moonraker Systemd Services ..."
|
status_msg "Removing Moonraker Systemd Services ..."
|
||||||
|
|
||||||
for service in $(moonraker_systemd | cut -d"/" -f5); do
|
for service in "${@}"; do
|
||||||
status_msg "Removing ${service} ..."
|
status_msg "Removing ${service} ..."
|
||||||
sudo systemctl stop "${service}"
|
sudo systemctl stop "${service}"
|
||||||
sudo systemctl disable "${service}"
|
sudo systemctl disable "${service}"
|
||||||
@@ -455,29 +443,25 @@ function remove_moonraker_systemd() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function remove_moonraker_env_file() {
|
function remove_moonraker_env_file() {
|
||||||
local files regex="${HOME//\//\\/}\/([A-Za-z0-9_]+)\/systemd\/moonraker\.env"
|
local printer_data file
|
||||||
files=$(find "${HOME}" -maxdepth 3 -regextype posix-extended -regex "${regex}" | sort)
|
for service in "${@}"; do
|
||||||
|
printer_data=$(get_data_folder ${service} moonraker)
|
||||||
if [[ -n ${files} ]]; then
|
file="${printer_data}/systemd/moonraker.env"
|
||||||
for file in ${files}; do
|
status_msg "Removing ${file} ..."
|
||||||
status_msg "Removing ${file} ..."
|
rm -f "${file}"
|
||||||
rm -f "${file}"
|
ok_msg "${file} removed!"
|
||||||
ok_msg "${file} removed!"
|
done
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_moonraker_logs() {
|
function remove_moonraker_logs() {
|
||||||
local files regex="${HOME//\//\\/}\/([A-Za-z0-9_]+)\/logs\/moonraker\.log.*"
|
local printer_data file
|
||||||
files=$(find "${HOME}" -maxdepth 3 -regextype posix-extended -regex "${regex}" | sort)
|
for service in "${@}"; do
|
||||||
|
printer_data=$(get_data_folder ${service} moonraker)
|
||||||
if [[ -n ${files} ]]; then
|
file="${printer_data}/systemd/moonraker.lo"*
|
||||||
for file in ${files}; do
|
status_msg "Removing ${file} ..."
|
||||||
status_msg "Removing ${file} ..."
|
rm -f "${file}"
|
||||||
rm -f "${file}"
|
ok_msg "${file} removed!"
|
||||||
ok_msg "${file} removed!"
|
done
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_legacy_moonraker_logs() {
|
function remove_legacy_moonraker_logs() {
|
||||||
@@ -534,15 +518,72 @@ function remove_moonraker_polkit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function remove_moonraker() {
|
function remove_moonraker() {
|
||||||
remove_moonraker_sysvinit
|
local moonraker_services=$(moonraker_systemd)
|
||||||
remove_moonraker_systemd
|
if [[ -z ${moonraker_services} ]]; then
|
||||||
remove_moonraker_env_file
|
print_error "Moonraker not installed, nothing to do!"
|
||||||
remove_moonraker_logs
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local moonraker_services=$(moonraker_systemd)
|
||||||
|
if [[ -z ${moonraker_services} ]]; then
|
||||||
|
print_error "Moonraker not installed, nothing to do!"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
top_border
|
||||||
|
echo -e "| ${red}~~~~~~~ [ Moonraker instance remover ] ~~~~~~${white} |"
|
||||||
|
hr
|
||||||
|
|
||||||
|
local user_input=() moonraker_names=()
|
||||||
|
local moonraker_services_count="$(moonraker_systemd | wc -w)"
|
||||||
|
if (( moonraker_services_count == 1 )); then
|
||||||
|
service_name=$(basename ${moonraker_services})
|
||||||
|
moonraker_names+=( "${service_name}" )
|
||||||
|
printf "| 0) %-51s|\n" "${service_name}"
|
||||||
|
else
|
||||||
|
printf "| 0) %-51s|\n" "Remove all"
|
||||||
|
local i=1 service_name
|
||||||
|
for name in ${moonraker_services}; do
|
||||||
|
service_name=$(basename ${name})
|
||||||
|
moonraker_names+=( "${service_name}" )
|
||||||
|
printf "| ${i}) %-51s|\n" "${service_name}"
|
||||||
|
(( i=i+1 ))
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
back_footer
|
||||||
|
|
||||||
|
local option
|
||||||
|
while true; do
|
||||||
|
read -p "${cyan}Remove Moonraker instance:${white} " option
|
||||||
|
if [[ ${option} == "B" || ${option} == "b" ]]; then
|
||||||
|
return
|
||||||
|
elif [[ $((option)) != $option ]]; then
|
||||||
|
error_msg "Invalid command!"
|
||||||
|
elif (( option >= 0 && option < ${#moonraker_names[@]} )); then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
error_msg "Invalid command!"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if (( option == 0 )); then
|
||||||
|
user_input=( ${moonraker_names[@]} )
|
||||||
|
else
|
||||||
|
user_input=( "${moonraker_names[(( option-1 ))]}" )
|
||||||
|
fi
|
||||||
|
|
||||||
|
remove_moonraker_systemd "${user_input[@]}"
|
||||||
|
remove_moonraker_env_file "${user_input[@]}"
|
||||||
|
remove_moonraker_logs "${user_input[@]}"
|
||||||
|
|
||||||
remove_legacy_moonraker_logs
|
remove_legacy_moonraker_logs
|
||||||
remove_moonraker_api_key
|
|
||||||
remove_moonraker_polkit
|
if (( ${moonraker_services_count} == 1 )) || [[ "${option}" == "0" ]]; then
|
||||||
remove_moonraker_dir
|
remove_moonraker_api_key
|
||||||
remove_moonraker_env
|
remove_moonraker_polkit
|
||||||
|
remove_moonraker_dir
|
||||||
|
remove_moonraker_env
|
||||||
|
fi
|
||||||
|
|
||||||
print_confirm "Moonraker was successfully removed!"
|
print_confirm "Moonraker was successfully removed!"
|
||||||
return
|
return
|
||||||
@@ -556,7 +597,8 @@ function update_moonraker() {
|
|||||||
do_action_service "stop" "moonraker"
|
do_action_service "stop" "moonraker"
|
||||||
|
|
||||||
if [[ ! -d ${MOONRAKER_DIR} ]]; then
|
if [[ ! -d ${MOONRAKER_DIR} ]]; then
|
||||||
clone_moonraker "${MOONRAKER_REPO}"
|
error_msg "Nothing to update, Moonraker directory doesn't exists! Please install Moonraker first."
|
||||||
|
return
|
||||||
else
|
else
|
||||||
backup_before_update "moonraker"
|
backup_before_update "moonraker"
|
||||||
status_msg "Updating Moonraker ..."
|
status_msg "Updating Moonraker ..."
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -357,4 +357,4 @@ function detect_enabled_sites() {
|
|||||||
FLUIDD_PORT=$(read_listen_port "fluidd")
|
FLUIDD_PORT=$(read_listen_port "fluidd")
|
||||||
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -63,7 +63,7 @@ function obico_server_url_prompt() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function moonraker_obico_setup_dialog() {
|
function moonraker_obico_setup_dialog() {
|
||||||
status_msg "Initializing Obico installation ..."
|
status_msg "Initializing Moonraker-obico installation ..."
|
||||||
|
|
||||||
local moonraker_count
|
local moonraker_count
|
||||||
local moonraker_names
|
local moonraker_names
|
||||||
@@ -73,7 +73,7 @@ function moonraker_obico_setup_dialog() {
|
|||||||
if (( moonraker_count == 0 )); then
|
if (( moonraker_count == 0 )); then
|
||||||
### return early if moonraker is not installed
|
### return early if moonraker is not installed
|
||||||
local error="Moonraker not installed! Please install Moonraker first!"
|
local error="Moonraker not installed! Please install Moonraker first!"
|
||||||
log_error "Obico setup started without Moonraker being installed. Aborting setup."
|
log_error "Moonraker-obico setup started without Moonraker being installed. Aborting setup."
|
||||||
print_error "${error}" && return
|
print_error "${error}" && return
|
||||||
elif (( moonraker_count > 1 )); then
|
elif (( moonraker_count > 1 )); then
|
||||||
# moonraker_names is valid only in case of multi-instance
|
# moonraker_names is valid only in case of multi-instance
|
||||||
@@ -85,32 +85,6 @@ function moonraker_obico_setup_dialog() {
|
|||||||
moonraker_obico_services=$(moonraker_obico_systemd)
|
moonraker_obico_services=$(moonraker_obico_systemd)
|
||||||
existing_moonraker_obico_count=$(echo "${moonraker_obico_services}" | wc -w )
|
existing_moonraker_obico_count=$(echo "${moonraker_obico_services}" | wc -w )
|
||||||
local allowed_moonraker_obico_count=$(( moonraker_count - existing_moonraker_obico_count ))
|
local allowed_moonraker_obico_count=$(( moonraker_count - existing_moonraker_obico_count ))
|
||||||
|
|
||||||
# Allow user to reinstall an incomplete installation.
|
|
||||||
if (( allowed_moonraker_obico_count == 0 && moonraker_count > 0 )) && [[ $(get_moonraker_obico_status) != "Not linked!" ]]; then
|
|
||||||
local yn
|
|
||||||
while true; do
|
|
||||||
echo "${yellow}Obico is already installed.${white}"
|
|
||||||
echo "It is safe to run the install again to repair any issues."
|
|
||||||
echo ""
|
|
||||||
local question="Do you want to reinstall Obico?"
|
|
||||||
read -p "${cyan}###### ${question} (Y/n):${white} " yn
|
|
||||||
case "${yn}" in
|
|
||||||
Y|y|Yes|yes|"")
|
|
||||||
select_msg "Yes"
|
|
||||||
break;;
|
|
||||||
N|n|No|no)
|
|
||||||
select_msg "No"
|
|
||||||
abort_msg "Exiting Obico installation...\n"
|
|
||||||
return;;
|
|
||||||
*)
|
|
||||||
error_msg "Invalid Input!";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
# The user responded yes, allow the install to run again.
|
|
||||||
allowed_moonraker_obico_count=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (( allowed_moonraker_obico_count > 0 )); then
|
if (( allowed_moonraker_obico_count > 0 )); then
|
||||||
local new_moonraker_obico_count
|
local new_moonraker_obico_count
|
||||||
|
|
||||||
@@ -126,30 +100,31 @@ function moonraker_obico_setup_dialog() {
|
|||||||
done
|
done
|
||||||
blank_line
|
blank_line
|
||||||
if (( existing_moonraker_obico_count > 0 )); then
|
if (( existing_moonraker_obico_count > 0 )); then
|
||||||
printf "|${green}%-55s${white}|\n" " ${existing_moonraker_obico_count} Obico instances already installed!"
|
printf "|${green}%-55s${white}|\n" " ${existing_moonraker_obico_count} Moonraker-obico instances already installed!"
|
||||||
for svc in ${moonraker_obico_services}; do
|
for svc in ${moonraker_obico_services}; do
|
||||||
printf "|${cyan}%-57s${white}|\n" " ● moonraker-obco-$(get_instance_name "${svc}")"
|
printf "|${cyan}%-57s${white}|\n" " ● moonraker-obco-$(get_instance_name "${svc}")"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
blank_line
|
blank_line
|
||||||
echo -e "| The setup will apply the same names to Obico! |"
|
echo -e "| The setup will apply the same names to |"
|
||||||
|
echo -e "| Moonraker-obico! |"
|
||||||
blank_line
|
blank_line
|
||||||
echo -e "| Please select the number of Obico instances |"
|
echo -e "| Please select the number of Moonraker-obico instances |"
|
||||||
echo -e "| to install. Usually one Obico instance per |"
|
echo -e "| to install. Usually one Moonraker-obico instance per |"
|
||||||
echo -e "| Moonraker instance is required, but you may not |"
|
echo -e "| Moonraker instance is required, but you may not |"
|
||||||
echo -e "| install more Obico instances than available |"
|
echo -e "| install more Moonraker-obico instances than available |"
|
||||||
echo -e "| Moonraker instances. |"
|
echo -e "| Moonraker instances. |"
|
||||||
bottom_border
|
bottom_border
|
||||||
|
|
||||||
### ask for amount of instances
|
### ask for amount of instances
|
||||||
local re="^[1-9][0-9]*$"
|
local re="^[1-9][0-9]*$"
|
||||||
while [[ ! ${new_moonraker_obico_count} =~ ${re} || ${new_moonraker_obico_count} -gt ${allowed_moonraker_obico_count} ]]; do
|
while [[ ! ${new_moonraker_obico_count} =~ ${re} || ${new_moonraker_obico_count} -gt ${allowed_moonraker_obico_count} ]]; do
|
||||||
read -p "${cyan}###### Number of new Obico instances to set up:${white} " -i "${allowed_moonraker_obico_count}" -e new_moonraker_obico_count
|
read -p "${cyan}###### Number of new Moonraker-obico instances to set up:${white} " -i "${allowed_moonraker_obico_count}" -e new_moonraker_obico_count
|
||||||
### break if input is valid
|
### break if input is valid
|
||||||
[[ ${new_moonraker_obico_count} =~ ${re} && ${new_moonraker_obico_count} -le ${allowed_moonraker_obico_count} ]] && break
|
[[ ${new_moonraker_obico_count} =~ ${re} && ${new_moonraker_obico_count} -le ${allowed_moonraker_obico_count} ]] && break
|
||||||
### conditional error messages
|
### conditional error messages
|
||||||
[[ ! ${new_moonraker_obico_count} =~ ${re} ]] && error_msg "Input not a number"
|
[[ ! ${new_moonraker_obico_count} =~ ${re} ]] && error_msg "Input not a number"
|
||||||
(( new_moonraker_obico_count > allowed_moonraker_obico_count )) && error_msg "Number of Obico instances larger than installed Moonraker instances"
|
(( new_moonraker_obico_count > allowed_moonraker_obico_count )) && error_msg "Number of Moonraker-obico instances larger than installed Moonraker instances"
|
||||||
done && select_msg "${new_moonraker_obico_count}"
|
done && select_msg "${new_moonraker_obico_count}"
|
||||||
else
|
else
|
||||||
log_error "Internal error. moonraker_count of '${moonraker_count}' not equal or grather than one!"
|
log_error "Internal error. moonraker_count of '${moonraker_count}' not equal or grather than one!"
|
||||||
@@ -159,8 +134,8 @@ function moonraker_obico_setup_dialog() {
|
|||||||
### Step 2: Confirm instance amount
|
### Step 2: Confirm instance amount
|
||||||
local yn
|
local yn
|
||||||
while true; do
|
while true; do
|
||||||
(( new_moonraker_obico_count == 1 )) && local question="Install Obico?"
|
(( new_moonraker_obico_count == 1 )) && local question="Install Moonraker-obico?"
|
||||||
(( new_moonraker_obico_count > 1 )) && local question="Install ${new_moonraker_obico_count} Obico instances?"
|
(( new_moonraker_obico_count > 1 )) && local question="Install ${new_moonraker_obico_count} Moonraker-obico instances?"
|
||||||
read -p "${cyan}###### ${question} (Y/n):${white} " yn
|
read -p "${cyan}###### ${question} (Y/n):${white} " yn
|
||||||
case "${yn}" in
|
case "${yn}" in
|
||||||
Y|y|Yes|yes|"")
|
Y|y|Yes|yes|"")
|
||||||
@@ -168,7 +143,7 @@ function moonraker_obico_setup_dialog() {
|
|||||||
break;;
|
break;;
|
||||||
N|n|No|no)
|
N|n|No|no)
|
||||||
select_msg "No"
|
select_msg "No"
|
||||||
abort_msg "Exiting Obico setup ...\n"
|
abort_msg "Exiting Moonraker-obico setup ...\n"
|
||||||
return;;
|
return;;
|
||||||
*)
|
*)
|
||||||
error_msg "Invalid Input!";;
|
error_msg "Invalid Input!";;
|
||||||
@@ -190,8 +165,12 @@ function moonraker_obico_setup_dialog() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
(( new_moonraker_obico_count > 1 )) && status_msg "Installing ${new_moonraker_obico_count} Obico instances ..."
|
(( new_moonraker_obico_count > 1 )) && status_msg "Installing ${new_moonraker_obico_count} Moonraker-obico instances ..."
|
||||||
(( new_moonraker_obico_count == 1 )) && status_msg "Installing Obico ..."
|
(( new_moonraker_obico_count == 1 )) && status_msg "Installing Moonraker-obico ..."
|
||||||
|
|
||||||
|
### Step 4: Install dependencies
|
||||||
|
local dep=(git dfu-util virtualenv python3 python3-pip python3-venv ffmpeg)
|
||||||
|
dependency_check "${dep[@]}"
|
||||||
|
|
||||||
### Step 5: Clone the moonraker-obico repo
|
### Step 5: Clone the moonraker-obico repo
|
||||||
clone_moonraker_obico "${MOONRAKER_OBICO_REPO}"
|
clone_moonraker_obico "${MOONRAKER_OBICO_REPO}"
|
||||||
@@ -243,16 +222,17 @@ function moonraker_obico_setup_dialog() {
|
|||||||
if (( ${#not_linked_instances[@]} > 0 )); then
|
if (( ${#not_linked_instances[@]} > 0 )); then
|
||||||
top_border
|
top_border
|
||||||
if (( moonraker_count == 1 )); then
|
if (( moonraker_count == 1 )); then
|
||||||
printf "|${green}%-55s${white}|\n" " Obico not linked to the server!"
|
printf "|${green}%-55s${white}|\n" " Moonraker-obico not linked to the server!"
|
||||||
else
|
else
|
||||||
printf "|${green}%-55s${white}|\n" " ${#not_linked_instances[@]} Obico instances not linked to the server!"
|
printf "|${green}%-55s${white}|\n" " ${#not_linked_instances[@]} Moonraker-obico instances not linked to the server!"
|
||||||
for i in "${not_linked_instances[@]}"; do
|
for i in "${not_linked_instances[@]}"; do
|
||||||
printf "|${cyan}%-57s${white}|\n" " ● moonraker-obico-${moonraker_names[${i}]}"
|
printf "|${cyan}%-57s${white}|\n" " ● moonraker-obico-${moonraker_names[${i}]}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
blank_line
|
blank_line
|
||||||
echo -e "| It will take only 10 seconds to link printer to Obico.|"
|
echo -e "| To link to your Obico Server account, you need to |"
|
||||||
echo -e "| For more information, visit: |"
|
echo -e "| obtain the 6-digit verification code in the Obico |"
|
||||||
|
echo -e "| mobile or web app. For more information, visit: |"
|
||||||
echo -e "| https://www.obico.io/docs/user-guides/klipper-setup/ |"
|
echo -e "| https://www.obico.io/docs/user-guides/klipper-setup/ |"
|
||||||
blank_line
|
blank_line
|
||||||
echo -e "| If you don't want to link the printer now, you can |"
|
echo -e "| If you don't want to link the printer now, you can |"
|
||||||
@@ -270,7 +250,7 @@ function moonraker_obico_setup_dialog() {
|
|||||||
break;;
|
break;;
|
||||||
N|n|No|no)
|
N|n|No|no)
|
||||||
select_msg "No"
|
select_msg "No"
|
||||||
abort_msg "Exiting Obico setup ...\n"
|
abort_msg "Exiting Moonraker-obico setup ...\n"
|
||||||
return;;
|
return;;
|
||||||
*)
|
*)
|
||||||
error_msg "Invalid Input!";;
|
error_msg "Invalid Input!";;
|
||||||
@@ -293,13 +273,13 @@ function moonraker_obico_setup_dialog() {
|
|||||||
function clone_moonraker_obico() {
|
function clone_moonraker_obico() {
|
||||||
local repo=${1}
|
local repo=${1}
|
||||||
|
|
||||||
status_msg "Cloning Obico from ${repo} ..."
|
status_msg "Cloning Moonraker-obico from ${repo} ..."
|
||||||
### force remove existing Obico dir
|
### force remove existing Moonraker-obico dir
|
||||||
[[ -d "${MOONRAKER_OBICO_DIR}" ]] && rm -rf "${MOONRAKER_OBICO_DIR}"
|
[[ -d "${MOONRAKER_OBICO_DIR}" ]] && rm -rf "${MOONRAKER_OBICO_DIR}"
|
||||||
|
|
||||||
cd "${HOME}" || exit 1
|
cd "${HOME}" || exit 1
|
||||||
if ! git clone "${repo}" "${MOONRAKER_OBICO_DIR}"; then
|
if ! git clone "${repo}" "${MOONRAKER_OBICO_DIR}"; then
|
||||||
print_error "Cloning Obico from\n ${repo}\n failed!"
|
print_error "Cloning Moonraker-obico from\n ${repo}\n failed!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -314,7 +294,7 @@ function moonraker_obico_install() {
|
|||||||
|
|
||||||
function remove_moonraker_obico_systemd() {
|
function remove_moonraker_obico_systemd() {
|
||||||
[[ -z $(moonraker_obico_systemd) ]] && return
|
[[ -z $(moonraker_obico_systemd) ]] && return
|
||||||
status_msg "Removing Obico Systemd Services ..."
|
status_msg "Removing Moonraker-obico Systemd Services ..."
|
||||||
|
|
||||||
for service in $(moonraker_obico_systemd | cut -d"/" -f5); do
|
for service in $(moonraker_obico_systemd | cut -d"/" -f5); do
|
||||||
status_msg "Removing ${service} ..."
|
status_msg "Removing ${service} ..."
|
||||||
@@ -327,7 +307,7 @@ function remove_moonraker_obico_systemd() {
|
|||||||
### reloading units
|
### reloading units
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl reset-failed
|
sudo systemctl reset-failed
|
||||||
ok_msg "Obico Services removed!"
|
ok_msg "Moonraker-obico Services removed!"
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_moonraker_obico_logs() {
|
function remove_moonraker_obico_logs() {
|
||||||
@@ -359,7 +339,7 @@ function remove_legacy_moonraker_obico_logs() {
|
|||||||
function remove_moonraker_obico_dir() {
|
function remove_moonraker_obico_dir() {
|
||||||
[[ ! -d ${MOONRAKER_OBICO_DIR} ]] && return
|
[[ ! -d ${MOONRAKER_OBICO_DIR} ]] && return
|
||||||
|
|
||||||
status_msg "Removing Obico directory ..."
|
status_msg "Removing Moonraker-obico directory ..."
|
||||||
rm -rf "${MOONRAKER_OBICO_DIR}"
|
rm -rf "${MOONRAKER_OBICO_DIR}"
|
||||||
ok_msg "Directory removed!"
|
ok_msg "Directory removed!"
|
||||||
}
|
}
|
||||||
@@ -378,7 +358,7 @@ function remove_moonraker_obico() {
|
|||||||
remove_moonraker_obico_dir
|
remove_moonraker_obico_dir
|
||||||
remove_moonraker_obico_env
|
remove_moonraker_obico_env
|
||||||
|
|
||||||
print_confirm "Obico was successfully removed!"
|
print_confirm "Moonraker-obico was successfully removed!"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -392,12 +372,10 @@ function update_moonraker_obico() {
|
|||||||
if [[ ! -d ${MOONRAKER_OBICO_DIR} ]]; then
|
if [[ ! -d ${MOONRAKER_OBICO_DIR} ]]; then
|
||||||
clone_moonraker_obico "${MOONRAKER_OBICO_REPO}"
|
clone_moonraker_obico "${MOONRAKER_OBICO_REPO}"
|
||||||
else
|
else
|
||||||
status_msg "Updating Obico ..."
|
status_msg "Updating Moonraker-obico ..."
|
||||||
cd "${MOONRAKER_OBICO_DIR}" && git pull
|
cd "${MOONRAKER_OBICO_DIR}" && git pull
|
||||||
fi
|
fi
|
||||||
|
|
||||||
"${MOONRAKER_OBICO_DIR}/install.sh" -U
|
|
||||||
|
|
||||||
ok_msg "Update complete!"
|
ok_msg "Update complete!"
|
||||||
do_action_service "restart" "moonraker-obico"
|
do_action_service "restart" "moonraker-obico"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,369 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
#=======================================================================#
|
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
|
||||||
# #
|
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
|
||||||
# https://github.com/dw-0/kiauh #
|
|
||||||
# #
|
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
|
||||||
#=======================================================================#
|
|
||||||
|
|
||||||
#
|
|
||||||
# This file is written and maintained by Christian Würthner from OctoApp
|
|
||||||
# Please contact me if you need any help!
|
|
||||||
# hello@octoapp.eu
|
|
||||||
#
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
#===================================================#
|
|
||||||
#============== Install ============#
|
|
||||||
#===================================================#
|
|
||||||
|
|
||||||
function octoapp_systemd() {
|
|
||||||
local services
|
|
||||||
services=$(find "${SYSTEMD}" -maxdepth 1 -regextype posix-extended -regex "${SYSTEMD}/octoapp(-[0-9a-zA-Z]+)?.service")
|
|
||||||
echo "${services}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function octoapp_setup_dialog() {
|
|
||||||
status_msg "Initializing OctoApp for Klipper installation ..."
|
|
||||||
|
|
||||||
# First, check for moonraker service instances.
|
|
||||||
local moonraker_count
|
|
||||||
local moonraker_names
|
|
||||||
moonraker_count=$(moonraker_systemd | wc -w)
|
|
||||||
if (( moonraker_count == 0 )); then
|
|
||||||
### return early if moonraker is not installed
|
|
||||||
local error="Moonraker not installed! Please install Moonraker first!"
|
|
||||||
log_error "OctoApp setup started without Moonraker being installed. Aborting setup."
|
|
||||||
print_error "${error}" && return
|
|
||||||
elif (( moonraker_count > 1 )); then
|
|
||||||
# moonraker_names is valid only in case of multi-instance
|
|
||||||
read -r -a moonraker_names <<< "$(get_multi_instance_names)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Next, check for any existing OctoApp services.
|
|
||||||
local octoapp_services
|
|
||||||
local existing_octoapp_count
|
|
||||||
octoapp_services=$(octoapp_systemd)
|
|
||||||
existing_octoapp_count=$(echo "${octoapp_services}" | wc -w )
|
|
||||||
|
|
||||||
# We need to make the moonraker instance count to the OctoApp service count.
|
|
||||||
local allowed_octoapp_count=$(( moonraker_count - existing_octoapp_count ))
|
|
||||||
if (( allowed_octoapp_count > 0 )); then
|
|
||||||
local new_octoapp_count
|
|
||||||
|
|
||||||
### Step 1: Ask for the number of OctoApp instances to install
|
|
||||||
if (( moonraker_count == 1 )); then
|
|
||||||
ok_msg "Moonraker installation found!\n"
|
|
||||||
new_octoapp_count=1
|
|
||||||
elif (( moonraker_count > 1 )); then
|
|
||||||
top_border
|
|
||||||
printf "|${green}%-55s${white}|\n" " ${moonraker_count} Moonraker instances found!"
|
|
||||||
for name in "${moonraker_names[@]}"; do
|
|
||||||
printf "|${cyan}%-57s${white}|\n" " ● moonraker-${name}"
|
|
||||||
done
|
|
||||||
blank_line
|
|
||||||
if (( existing_octoapp_count > 0 )); then
|
|
||||||
printf "|${green}%-55s${white}|\n" " ${existing_octoapp_count} OctoApp instances already installed!"
|
|
||||||
for svc in ${octoapp_services}; do
|
|
||||||
printf "|${cyan}%-57s${white}|\n" " ● octoapp-$(get_instance_name "${svc}")"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
blank_line
|
|
||||||
echo -e "| The setup will apply the same names to OctoApp |"
|
|
||||||
blank_line
|
|
||||||
echo -e "| Please select the number of OctoApp instances to |"
|
|
||||||
echo -e "| install. Usually one OctoApp instance per Moonraker |"
|
|
||||||
echo -e "| instance is required, but you may not install more |"
|
|
||||||
echo -e "| OctoApp instances than available Moonraker instances. |"
|
|
||||||
bottom_border
|
|
||||||
|
|
||||||
### ask for amount of instances
|
|
||||||
local re="^[1-9][0-9]*$"
|
|
||||||
while [[ ! ${new_octoapp_count} =~ ${re} || ${new_octoapp_count} -gt ${allowed_octoapp_count} ]]; do
|
|
||||||
read -p "${cyan}###### Number of new OctoApp instances to set up:${white} " -i "${allowed_octoapp_count}" -e new_octoapp_count
|
|
||||||
### break if input is valid
|
|
||||||
[[ ${new_octoapp_count} =~ ${re} && ${new_octoapp_count} -le ${allowed_octoapp_count} ]] && break
|
|
||||||
### conditional error messages
|
|
||||||
[[ ! ${new_octoapp_count} =~ ${re} ]] && error_msg "Input not a number"
|
|
||||||
(( new_octoapp_count > allowed_octoapp_count )) && error_msg "Number of OctoApp instances larger than installed Moonraker instances"
|
|
||||||
done && select_msg "${new_octoapp_count}"
|
|
||||||
else
|
|
||||||
log_error "Internal error. moonraker_count of '${moonraker_count}' not equal or grater than one!"
|
|
||||||
return 1
|
|
||||||
fi # (( moonraker_count == 1 ))
|
|
||||||
fi # (( allowed_octoapp_count > 0 ))
|
|
||||||
|
|
||||||
# Special case for one moonraker instance with OctoApp already installed.
|
|
||||||
# If the user selects the install option again, they might be trying to recover the install
|
|
||||||
# or complete a printer link they didn't finish in the past.
|
|
||||||
# So in this case, we will allow them to run the install script again, since it's safe to run
|
|
||||||
# if the service is already installed, it will repair any missing issues.
|
|
||||||
if (( allowed_octoapp_count == 0 && moonraker_count == 1 )); then
|
|
||||||
local yn
|
|
||||||
while true; do
|
|
||||||
echo "${yellow}OctoApp is already installed.${white}"
|
|
||||||
echo "It is safe to run the install again to repair any issues or if the printer isn't linked, run the printer linking logic again."
|
|
||||||
echo ""
|
|
||||||
local question="Do you want to run the OctoApp recovery or linking logic again?"
|
|
||||||
read -p "${cyan}###### ${question} (Y/n):${white} " yn
|
|
||||||
case "${yn}" in
|
|
||||||
Y|y|Yes|yes|"")
|
|
||||||
select_msg "Yes"
|
|
||||||
break;;
|
|
||||||
N|n|No|no)
|
|
||||||
select_msg "No"
|
|
||||||
abort_msg "Exiting OctoApp setup ...\n"
|
|
||||||
return;;
|
|
||||||
*)
|
|
||||||
error_msg "Invalid Input!";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
# The user responded yes, allow the install to run again.
|
|
||||||
allowed_octoapp_count=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If there's something to install, do it!
|
|
||||||
if (( allowed_octoapp_count > 0 )); then
|
|
||||||
|
|
||||||
(( new_octoapp_count > 1 )) && status_msg "Installing ${new_octoapp_count} OctoApp instances ..."
|
|
||||||
(( new_octoapp_count == 1 )) && status_msg "Installing OctoApp ..."
|
|
||||||
|
|
||||||
# Ensure the basic system dependencies are installed.
|
|
||||||
local dep=(git dfu-util virtualenv python3 python3-pip python3-venv)
|
|
||||||
dependency_check "${dep[@]}"
|
|
||||||
|
|
||||||
# Close the repo
|
|
||||||
clone_octoapp "${OCTOAPP_REPO}"
|
|
||||||
|
|
||||||
# Call install with the correct args.
|
|
||||||
local instance_cfg_dirs
|
|
||||||
read -r -a instance_cfg_dirs <<< "$(get_instance_folder_path "config")"
|
|
||||||
echo instance_cfg_dirs[0]
|
|
||||||
|
|
||||||
if (( moonraker_count == 1 )); then
|
|
||||||
"${OCTOAPP_DIR}/install.sh" "${instance_cfg_dirs[0]}/moonraker.conf"
|
|
||||||
elif (( moonraker_count > 1 )); then
|
|
||||||
local j=${existing_octoapp_count}
|
|
||||||
|
|
||||||
for (( i=1; i <= new_octoapp_count; i++ )); do
|
|
||||||
"${OCTOAPP_DIR}/install.sh" "${instance_cfg_dirs[${j}]}/moonraker.conf"
|
|
||||||
j=$(( j + 1 ))
|
|
||||||
done && unset j
|
|
||||||
fi # (( moonraker_count == 1 ))
|
|
||||||
fi # (( allowed_octoapp_count > 0 ))
|
|
||||||
}
|
|
||||||
|
|
||||||
function octoapp_install() {
|
|
||||||
"${OCTOAPP_DIR}/install.sh" "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
#===================================================#
|
|
||||||
#============= Remove ==============#
|
|
||||||
#===================================================#
|
|
||||||
|
|
||||||
function remove_octoapp_systemd() {
|
|
||||||
[[ -z $(octoapp_systemd) ]] && return
|
|
||||||
status_msg "Removing OctoApp Systemd Services ..."
|
|
||||||
|
|
||||||
for service in $(octoapp_systemd | cut -d"/" -f5); do
|
|
||||||
status_msg "Removing ${service} ..."
|
|
||||||
sudo systemctl stop "${service}"
|
|
||||||
sudo systemctl disable "${service}"
|
|
||||||
sudo rm -f "${SYSTEMD}/${service}"
|
|
||||||
ok_msg "Done!"
|
|
||||||
done
|
|
||||||
|
|
||||||
### reloading units
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl reset-failed
|
|
||||||
ok_msg "OctoApp Services removed!"
|
|
||||||
}
|
|
||||||
|
|
||||||
function remove_octoapp_logs() {
|
|
||||||
local files regex="${HOME//\//\\/}\/([A-Za-z0-9_]+)\/logs\/octoapp(-[0-9a-zA-Z]+)?\.log(.*)?"
|
|
||||||
files=$(find "${HOME}" -maxdepth 3 -regextype posix-extended -regex "${regex}" | sort)
|
|
||||||
|
|
||||||
if [[ -n ${files} ]]; then
|
|
||||||
for file in ${files}; do
|
|
||||||
status_msg "Removing ${file} ..."
|
|
||||||
rm -f "${file}"
|
|
||||||
ok_msg "${file} removed!"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function remove_octoapp_dir() {
|
|
||||||
[[ ! -d ${OCTOAPP_DIR} ]] && return
|
|
||||||
|
|
||||||
status_msg "Removing OctoApp directory ..."
|
|
||||||
rm -rf "${OCTOAPP_DIR}"
|
|
||||||
ok_msg "Directory removed!"
|
|
||||||
}
|
|
||||||
|
|
||||||
function remove_octoapp_config() {
|
|
||||||
# Remove the system config but not the main config, so the printer id doesn't get lost.
|
|
||||||
local files regex="${HOME//\//\\/}\/([A-Za-z0-9_]+)\/config\/octoapp-system(-[0-9a-zA-Z]+)?\.cfg(.*)?"
|
|
||||||
files=$(find "${HOME}" -maxdepth 4 -regextype posix-extended -regex "${regex}" | sort)
|
|
||||||
|
|
||||||
if [[ -n ${files} ]]; then
|
|
||||||
for file in ${files}; do
|
|
||||||
status_msg "Removing ${file} ..."
|
|
||||||
rm -f "${file}"
|
|
||||||
ok_msg "${file} removed!"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function remove_octoapp_store_dir() {
|
|
||||||
local files regex="${HOME//\//\\/}\/([A-Za-z0-9_]+)\/octoapp-store"
|
|
||||||
files=$(find "${HOME}" -maxdepth 2 -type d -regextype posix-extended -regex "${regex}" | sort)
|
|
||||||
|
|
||||||
if [[ -n ${files} ]]; then
|
|
||||||
for file in ${files}; do
|
|
||||||
status_msg "Removing ${file} ..."
|
|
||||||
rm -rf "${file}"
|
|
||||||
ok_msg "${file} removed!"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function remove_octoapp_env() {
|
|
||||||
[[ ! -d "${HOME}/octoapp-env" ]] && return
|
|
||||||
|
|
||||||
status_msg "Removing octoapp-env directory ..."
|
|
||||||
rm -rf "${HOME}/octoapp-env"
|
|
||||||
ok_msg "Directory removed!"
|
|
||||||
}
|
|
||||||
|
|
||||||
function remove_octoapp()
|
|
||||||
{
|
|
||||||
remove_octoapp_systemd
|
|
||||||
remove_octoapp_logs
|
|
||||||
remove_octoapp_dir
|
|
||||||
remove_octoapp_env
|
|
||||||
remove_octoapp_config
|
|
||||||
remove_octoapp_store_dir
|
|
||||||
|
|
||||||
print_confirm "OctoApp was successfully removed!"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
#===================================================#
|
|
||||||
#============= UPDATE ==============#
|
|
||||||
#===================================================#
|
|
||||||
|
|
||||||
function update_octoapp() {
|
|
||||||
do_action_service "stop" "octoapp"
|
|
||||||
|
|
||||||
if [[ ! -d ${OCTOAPP_DIR} ]]; then
|
|
||||||
clone_octoapp "${OCTOAPP_REPO}"
|
|
||||||
else
|
|
||||||
backup_before_update "octoapp"
|
|
||||||
status_msg "Updating OctoApp for Klipper ..."
|
|
||||||
cd "${OCTOAPP_DIR}" && git pull
|
|
||||||
### read PKGLIST and install possible new dependencies
|
|
||||||
install_octoapp_dependencies
|
|
||||||
### install possible new python dependencies
|
|
||||||
"${OCTOAPP_ENV}"/bin/pip install -r "${OCTOAPP_DIR}/requirements.txt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ok_msg "Update complete!"
|
|
||||||
do_action_service "restart" "octoapp"
|
|
||||||
}
|
|
||||||
|
|
||||||
function clone_octoapp() {
|
|
||||||
local repo=${1}
|
|
||||||
|
|
||||||
status_msg "Cloning OctoApp from ${repo} ..."
|
|
||||||
|
|
||||||
### force remove existing octoapp dir and clone into fresh octoapp dir
|
|
||||||
[[ -d ${OCTOAPP_DIR} ]] && rm -rf "${OCTOAPP_DIR}"
|
|
||||||
|
|
||||||
cd "${HOME}" || exit 1
|
|
||||||
if ! git clone "${OCTOAPP_REPO}" "${OCTOAPP_DIR}"; then
|
|
||||||
print_error "Cloning OctoApp from\n ${repo}\n failed!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function install_octoapp_dependencies() {
|
|
||||||
local packages log_name="OctoApp"
|
|
||||||
local install_script="${OCTOAPP_DIR}/install.sh"
|
|
||||||
|
|
||||||
### read PKGLIST from official install-script
|
|
||||||
status_msg "Reading dependencies..."
|
|
||||||
# shellcheck disable=SC2016
|
|
||||||
packages="$(grep "PKGLIST=" "${install_script}" | cut -d'"' -f2 | sed 's/\${PKGLIST}//g' | tr -d '\n')"
|
|
||||||
|
|
||||||
echo "${cyan}${packages}${white}" | tr '[:space:]' '\n'
|
|
||||||
read -r -a packages <<< "${packages}"
|
|
||||||
|
|
||||||
### Update system package lists if stale
|
|
||||||
update_system_package_lists
|
|
||||||
|
|
||||||
### Install required packages
|
|
||||||
install_system_packages "${log_name}" "packages[@]"
|
|
||||||
}
|
|
||||||
|
|
||||||
#===================================================#
|
|
||||||
#============= STATUS ==============#
|
|
||||||
#===================================================#
|
|
||||||
|
|
||||||
function get_octoapp_status() {
|
|
||||||
local status
|
|
||||||
local service_count
|
|
||||||
local octoapp_services
|
|
||||||
|
|
||||||
octoapp_services=$(octoapp_systemd)
|
|
||||||
service_count=$(echo "${octoapp_services}" | wc -w )
|
|
||||||
|
|
||||||
if (( service_count == 0 )); then
|
|
||||||
status="Not installed!"
|
|
||||||
elif [[ ! -d "${OCTOAPP_DIR}" ]]; then
|
|
||||||
status="Incomplete!"
|
|
||||||
else
|
|
||||||
status="Installed!"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "${status}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_local_octoapp_commit() {
|
|
||||||
[[ ! -d ${OCTOAPP_DIR} || ! -d "${OCTOAPP_DIR}/.git" ]] && return
|
|
||||||
|
|
||||||
local commit
|
|
||||||
cd "${OCTOAPP_DIR}"
|
|
||||||
commit="$(git describe HEAD --always --tags | cut -d "-" -f 1,2)"
|
|
||||||
echo "${commit}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_remote_octoapp_commit() {
|
|
||||||
[[ ! -d ${OCTOAPP_DIR} || ! -d "${OCTOAPP_DIR}/.git" ]] && return
|
|
||||||
|
|
||||||
local commit
|
|
||||||
cd "${OCTOAPP_DIR}" && git fetch origin -q
|
|
||||||
commit=$(git describe origin/release --always --tags | cut -d "-" -f 1,2)
|
|
||||||
echo "${commit}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function compare_octoapp_versions() {
|
|
||||||
local versions local_ver remote_ver
|
|
||||||
local_ver="$(get_local_octoapp_commit)"
|
|
||||||
remote_ver="$(get_remote_octoapp_commit)"
|
|
||||||
|
|
||||||
if [[ ${local_ver} != "${remote_ver}" ]]; then
|
|
||||||
versions="${yellow}$(printf " %-14s" "${local_ver}")${white}"
|
|
||||||
versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}"
|
|
||||||
# Add us to the update file, so if the user selects "update all" it includes us.
|
|
||||||
add_to_application_updates "octoapp"
|
|
||||||
else
|
|
||||||
versions="${green}$(printf " %-14s" "${local_ver}")${white}"
|
|
||||||
versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "${versions}"
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -307,7 +307,7 @@ function clone_octoeverywhere() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function install_octoeverywhere_dependencies() {
|
function install_octoeverywhere_dependencies() {
|
||||||
local packages log_name="OctoEverywhere"
|
local packages
|
||||||
local install_script="${OCTOEVERYWHERE_DIR}/install.sh"
|
local install_script="${OCTOEVERYWHERE_DIR}/install.sh"
|
||||||
|
|
||||||
### read PKGLIST from official install-script
|
### read PKGLIST from official install-script
|
||||||
@@ -318,11 +318,21 @@ function install_octoeverywhere_dependencies() {
|
|||||||
echo "${cyan}${packages}${white}" | tr '[:space:]' '\n'
|
echo "${cyan}${packages}${white}" | tr '[:space:]' '\n'
|
||||||
read -r -a packages <<< "${packages}"
|
read -r -a packages <<< "${packages}"
|
||||||
|
|
||||||
### Update system package lists if stale
|
### Update system package info
|
||||||
update_system_package_lists
|
status_msg "Updating package lists..."
|
||||||
|
if ! sudo apt-get update --allow-releaseinfo-change; then
|
||||||
|
log_error "failure while updating package lists"
|
||||||
|
error_msg "Updating package lists failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
### Install required packages
|
### Install required packages
|
||||||
install_system_packages "${log_name}" "packages[@]"
|
status_msg "Installing required packages..."
|
||||||
|
if ! sudo apt-get install --yes "${packages[@]}"; then
|
||||||
|
log_error "failure while installing required octoeverywhere packages"
|
||||||
|
error_msg "Installing required packages failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#===================================================#
|
#===================================================#
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -124,4 +124,4 @@ function compare_prettygcode_versions() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${versions}"
|
echo "${versions}"
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -77,12 +77,10 @@ function change_klipper_repo_menu() {
|
|||||||
error_msg "Invalid command!";;
|
error_msg "Invalid command!";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
break
|
|
||||||
else
|
else
|
||||||
status_msg "Set custom Klipper repository to:\n ● Repository: ${repos[${option}]}\n ● Branch: ${branches[${option}]}"
|
status_msg "Set custom Klipper repository to:\n ● Repository: ${repos[${option}]}\n ● Branch: ${branches[${option}]}"
|
||||||
set_custom_klipper_repo "${repos[${option}]}" "${branches[${option}]}"
|
set_custom_klipper_repo "${repos[${option}]}" "${branches[${option}]}"
|
||||||
ok_msg "This repo will now be used for new Klipper installations!\n"
|
ok_msg "This repo will now be used for new Klipper installations!\n"
|
||||||
break
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elif [[ ${option} =~ ${back} ]]; then
|
elif [[ ${option} =~ ${back} ]]; then
|
||||||
@@ -141,4 +139,4 @@ function show_custom_klipper_repo_help() {
|
|||||||
deny_action "show_settings_help";;
|
deny_action "show_settings_help";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -66,4 +66,4 @@ function advanced_menu() {
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
advanced_menu
|
advanced_menu
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -20,12 +20,12 @@ function backup_ui() {
|
|||||||
echo -e "| Klipper & API: | Touchscreen GUI: |"
|
echo -e "| Klipper & API: | Touchscreen GUI: |"
|
||||||
echo -e "| 1) [Klipper] | 7) [KlipperScreen] |"
|
echo -e "| 1) [Klipper] | 7) [KlipperScreen] |"
|
||||||
echo -e "| 2) [Moonraker] | |"
|
echo -e "| 2) [Moonraker] | |"
|
||||||
echo -e "| 3) [Config Folder] | 3rd Party Webinterface: |"
|
echo -e "| 3) [Configuration Folder] | 3rd Party Webinterface: |"
|
||||||
echo -e "| 4) [Moonraker Database] | 8) [OctoPrint] |"
|
echo -e "| 4) [Moonraker Database] | 8) [OctoPrint] |"
|
||||||
echo -e "| | |"
|
echo -e "| | |"
|
||||||
echo -e "| Klipper Webinterface: | Other: |"
|
echo -e "| Klipper Webinterface: | Other: |"
|
||||||
echo -e "| 5) [Mainsail] | 9) [Telegram Bot] |"
|
echo -e "| 5) [Mainsail] | 9) [Telegram Bot] |"
|
||||||
echo -e "| 6) [Fluidd] | 10) [OctoEverywhere] |"
|
echo -e "| 6) [Fluidd] | |"
|
||||||
back_footer
|
back_footer
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ function backup_menu() {
|
|||||||
2)
|
2)
|
||||||
do_action "backup_moonraker" "backup_ui";;
|
do_action "backup_moonraker" "backup_ui";;
|
||||||
3)
|
3)
|
||||||
do_action "backup_config_dir" "backup_ui";;
|
do_action "backup_klipper_config_dir" "backup_ui";;
|
||||||
4)
|
4)
|
||||||
do_action "backup_moonraker_database" "backup_ui";;
|
do_action "backup_moonraker_database" "backup_ui";;
|
||||||
5)
|
5)
|
||||||
@@ -54,8 +54,6 @@ function backup_menu() {
|
|||||||
do_action "backup_octoprint" "backup_ui";;
|
do_action "backup_octoprint" "backup_ui";;
|
||||||
9)
|
9)
|
||||||
do_action "backup_telegram_bot" "backup_ui";;
|
do_action "backup_telegram_bot" "backup_ui";;
|
||||||
10)
|
|
||||||
do_action "backup_octoeverywhere" "backup_ui";;
|
|
||||||
B|b)
|
B|b)
|
||||||
clear; main_menu; break;;
|
clear; main_menu; break;;
|
||||||
*)
|
*)
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -27,17 +27,14 @@ function install_ui() {
|
|||||||
echo -e "| 3) [Mainsail] | 8) [Telegram Bot] |"
|
echo -e "| 3) [Mainsail] | 8) [Telegram Bot] |"
|
||||||
echo -e "| 4) [Fluidd] | 9) $(obico_install_title) |"
|
echo -e "| 4) [Fluidd] | 9) $(obico_install_title) |"
|
||||||
echo -e "| | 10) [OctoEverywhere] |"
|
echo -e "| | 10) [OctoEverywhere] |"
|
||||||
echo -e "| | 11) [Mobileraker] |"
|
echo -e "| Touchscreen GUI: | |"
|
||||||
echo -e "| Touchscreen GUI: | 12) [OctoApp for Klipper] |"
|
echo -e "| 5) [KlipperScreen] | Webcam Streamer: |"
|
||||||
echo -e "| 5) [KlipperScreen] | |"
|
echo -e "| | 11) [Crowsnest] |"
|
||||||
echo -e "| | Webcam Streamer: |"
|
|
||||||
echo -e "| | 13) [Crowsnest] |"
|
|
||||||
back_footer
|
back_footer
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_menu() {
|
function install_menu() {
|
||||||
clear -x && sudo true && clear -x # (re)cache sudo credentials so password prompt doesn't bork ui
|
clear && print_header
|
||||||
print_header
|
|
||||||
install_ui
|
install_ui
|
||||||
|
|
||||||
### save all installed webinterface ports to the ini file
|
### save all installed webinterface ports to the ini file
|
||||||
@@ -71,10 +68,6 @@ function install_menu() {
|
|||||||
10)
|
10)
|
||||||
do_action "octoeverywhere_setup_dialog" "install_ui";;
|
do_action "octoeverywhere_setup_dialog" "install_ui";;
|
||||||
11)
|
11)
|
||||||
do_action "install_mobileraker" "install_ui";;
|
|
||||||
12)
|
|
||||||
do_action "octoapp_setup_dialog" "install_ui";;
|
|
||||||
13)
|
|
||||||
do_action "install_crowsnest" "install_ui";;
|
do_action "install_crowsnest" "install_ui";;
|
||||||
B|b)
|
B|b)
|
||||||
clear; main_menu; break;;
|
clear; main_menu; break;;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -12,6 +12,10 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
function main_ui() {
|
function main_ui() {
|
||||||
|
echo -e "${yellow}/=======================================================\\"
|
||||||
|
echo -e "| Please read the newest changelog carefully: |"
|
||||||
|
echo -e "| https://git.io/JnmlX |"
|
||||||
|
echo -e "\=======================================================/${white}"
|
||||||
top_border
|
top_border
|
||||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~~ [ Main Menu ] ~~~~~~~~~~~~~~~") |"
|
echo -e "| $(title_msg "~~~~~~~~~~~~~~~ [ Main Menu ] ~~~~~~~~~~~~~~~") |"
|
||||||
hr
|
hr
|
||||||
@@ -21,18 +25,15 @@ function main_ui() {
|
|||||||
echo -e "| 2) [Update] | Moonraker: $(print_status "moonraker")|"
|
echo -e "| 2) [Update] | Moonraker: $(print_status "moonraker")|"
|
||||||
echo -e "| 3) [Remove] | |"
|
echo -e "| 3) [Remove] | |"
|
||||||
echo -e "| 4) [Advanced] | Mainsail: $(print_status "mainsail")|"
|
echo -e "| 4) [Advanced] | Mainsail: $(print_status "mainsail")|"
|
||||||
echo -e "| 5) [Backup] | Fluidd: $(print_status "fluidd")|"
|
# echo -e "| 5) [Backup] | Fluidd: $(print_status "fluidd")|"
|
||||||
|
echo -e "| | Fluidd: $(print_status "fluidd")|"
|
||||||
echo -e "| | KlipperScreen: $(print_status "klipperscreen")|"
|
echo -e "| | KlipperScreen: $(print_status "klipperscreen")|"
|
||||||
echo -e "| 6) [Settings] | Telegram Bot: $(print_status "telegram_bot")|"
|
echo -e "| 6) [Settings] | Telegram Bot: $(print_status "telegram_bot")|"
|
||||||
echo -e "| | Crowsnest: $(print_status "crowsnest")|"
|
echo -e "| | Crowsnest: $(print_status "crowsnest")|"
|
||||||
echo -e "| | Obico: $(print_status "moonraker_obico")|"
|
echo -e "| | Obico: $(print_status "moonraker_obico")|"
|
||||||
echo -e "| | OctoEverywhere: $(print_status "octoeverywhere")|"
|
echo -e "| | OctoEverywhere: $(print_status "octoeverywhere")|"
|
||||||
echo -e "| | Mobileraker: $(print_status "mobileraker")|"
|
|
||||||
echo -e "| | OctoApp: $(print_status "octoapp")|"
|
|
||||||
echo -e "| | |"
|
echo -e "| | |"
|
||||||
echo -e "| | Octoprint: $(print_status "octoprint")|"
|
echo -e "| $(print_kiauh_version)| Octoprint: $(print_status "octoprint")|"
|
||||||
hr
|
|
||||||
echo -e "| $(print_kiauh_version)| Changelog: ${magenta}https://git.io/JnmlX${white} |"
|
|
||||||
quit_footer
|
quit_footer
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +59,7 @@ function print_status() {
|
|||||||
elif [[ ${status} == "Incomplete!" ]]; then
|
elif [[ ${status} == "Incomplete!" ]]; then
|
||||||
status="${yellow}${status}${white}"
|
status="${yellow}${status}${white}"
|
||||||
elif [[ ${status} == "Not linked!" ]]; then
|
elif [[ ${status} == "Not linked!" ]]; then
|
||||||
### "Not linked!" is only required for Obico for Klipper
|
### "Not linked!" is only required for Moonraker-obico
|
||||||
status="${yellow}${status}${white}"
|
status="${yellow}${status}${white}"
|
||||||
else
|
else
|
||||||
status="${green}${status}${white}"
|
status="${green}${status}${white}"
|
||||||
@@ -113,7 +114,8 @@ function main_menu() {
|
|||||||
"restart crowsnest") do_action_service "restart" "crowsnest"; main_ui;;
|
"restart crowsnest") do_action_service "restart" "crowsnest"; main_ui;;
|
||||||
update) do_action "update_kiauh" "main_ui";;
|
update) do_action "update_kiauh" "main_ui";;
|
||||||
0)clear && print_header
|
0)clear && print_header
|
||||||
upload_selection
|
#upload_selection
|
||||||
|
print_error "Function currently disabled! Sorry!"
|
||||||
main_ui;;
|
main_ui;;
|
||||||
1)clear && print_header
|
1)clear && print_header
|
||||||
install_menu
|
install_menu
|
||||||
@@ -128,7 +130,8 @@ function main_menu() {
|
|||||||
advanced_menu
|
advanced_menu
|
||||||
break;;
|
break;;
|
||||||
5)clear && print_header
|
5)clear && print_header
|
||||||
backup_menu
|
#backup_menu
|
||||||
|
print_error "Function currently disabled! Sorry!"
|
||||||
main_ui;;
|
main_ui;;
|
||||||
6)clear && print_header
|
6)clear && print_header
|
||||||
settings_menu
|
settings_menu
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -29,9 +29,7 @@ function remove_ui() {
|
|||||||
echo -e "| | 12) [Telegram Bot] |"
|
echo -e "| | 12) [Telegram Bot] |"
|
||||||
echo -e "| Touchscreen GUI: | 13) [Obico for Klipper] |"
|
echo -e "| Touchscreen GUI: | 13) [Obico for Klipper] |"
|
||||||
echo -e "| 7) [KlipperScreen] | 14) [OctoEverywhere] |"
|
echo -e "| 7) [KlipperScreen] | 14) [OctoEverywhere] |"
|
||||||
echo -e "| | 15) [Mobileraker] |"
|
echo -e "| | 15) [NGINX] |"
|
||||||
echo -e "| | 16) [NGINX] |"
|
|
||||||
echo -e "| | 17) [OctoApp] |"
|
|
||||||
back_footer
|
back_footer
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,11 +69,7 @@ function remove_menu() {
|
|||||||
14)
|
14)
|
||||||
do_action "remove_octoeverywhere" "remove_ui";;
|
do_action "remove_octoeverywhere" "remove_ui";;
|
||||||
15)
|
15)
|
||||||
do_action "remove_mobileraker" "remove_ui";;
|
|
||||||
16)
|
|
||||||
do_action "remove_nginx" "remove_ui";;
|
do_action "remove_nginx" "remove_ui";;
|
||||||
17)
|
|
||||||
do_action "remove_octoapp" "remove_ui";;
|
|
||||||
B|b)
|
B|b)
|
||||||
clear; main_menu; break;;
|
clear; main_menu; break;;
|
||||||
*)
|
*)
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -33,16 +33,13 @@ function update_ui() {
|
|||||||
echo -e "| 7) [Telegram Bot] |$(compare_telegram_bot_versions)|"
|
echo -e "| 7) [Telegram Bot] |$(compare_telegram_bot_versions)|"
|
||||||
echo -e "| 8) [Obico for Klipper]|$(compare_moonraker_obico_versions)|"
|
echo -e "| 8) [Obico for Klipper]|$(compare_moonraker_obico_versions)|"
|
||||||
echo -e "| 9) [OctoEverywhere] |$(compare_octoeverywhere_versions)|"
|
echo -e "| 9) [OctoEverywhere] |$(compare_octoeverywhere_versions)|"
|
||||||
echo -e "| 10) [Mobileraker] |$(compare_mobileraker_versions)|"
|
echo -e "| 10) [Crowsnest] |$(compare_crowsnest_versions)|"
|
||||||
echo -e "| 11) [Crowsnest] |$(compare_crowsnest_versions)|"
|
|
||||||
echo -e "| 12) [OctoApp] |$(compare_octoapp_versions)|"
|
|
||||||
echo -e "| |------------------------------|"
|
echo -e "| |------------------------------|"
|
||||||
echo -e "| 13) [System] | $(check_system_updates) |"
|
echo -e "| 11) [System] | $(check_system_updates) |"
|
||||||
back_footer
|
back_footer
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_menu() {
|
function update_menu() {
|
||||||
clear -x && sudo true && clear -x # (re)cache sudo credentials so password prompt doesn't bork ui
|
|
||||||
do_action "" "update_ui"
|
do_action "" "update_ui"
|
||||||
|
|
||||||
local action
|
local action
|
||||||
@@ -70,13 +67,9 @@ function update_menu() {
|
|||||||
9)
|
9)
|
||||||
do_action "update_octoeverywhere" "update_ui";;
|
do_action "update_octoeverywhere" "update_ui";;
|
||||||
10)
|
10)
|
||||||
do_action "update_mobileraker" "update_ui";;
|
|
||||||
11)
|
|
||||||
do_action "update_crowsnest" "update_ui";;
|
do_action "update_crowsnest" "update_ui";;
|
||||||
12)
|
11)
|
||||||
do_action "update_octoapp" "update_ui";;
|
do_action "update_system" "update_ui";;
|
||||||
13)
|
|
||||||
do_action "upgrade_system_packages" "update_ui";;
|
|
||||||
a)
|
a)
|
||||||
do_action "update_all" "update_ui";;
|
do_action "update_all" "update_ui";;
|
||||||
B|b)
|
B|b)
|
||||||
@@ -130,12 +123,6 @@ function update_all() {
|
|||||||
[[ "${update_arr[*]}" =~ "octoeverywhere" ]] && \
|
[[ "${update_arr[*]}" =~ "octoeverywhere" ]] && \
|
||||||
echo -e "| ${cyan}● OctoEverywhere${white} |"
|
echo -e "| ${cyan}● OctoEverywhere${white} |"
|
||||||
|
|
||||||
[[ "${update_arr[*]}" =~ "mobileraker" ]] && \
|
|
||||||
echo -e "| ${cyan}● Mobileraker${white} |"
|
|
||||||
|
|
||||||
[[ "${update_arr[*]}" =~ "octoapp" ]] && \
|
|
||||||
echo -e "| ${cyan}● OctoApp${white} |"
|
|
||||||
|
|
||||||
[[ "${update_arr[*]}" =~ "system" ]] && \
|
[[ "${update_arr[*]}" =~ "system" ]] && \
|
||||||
echo -e "| ${cyan}● System${white} |"
|
echo -e "| ${cyan}● System${white} |"
|
||||||
|
|
||||||
@@ -145,14 +132,8 @@ function update_all() {
|
|||||||
read -p "${cyan}###### Do you want to proceed? (Y/n):${white} " yn
|
read -p "${cyan}###### Do you want to proceed? (Y/n):${white} " yn
|
||||||
case "${yn}" in
|
case "${yn}" in
|
||||||
Y|y|Yes|yes|"")
|
Y|y|Yes|yes|"")
|
||||||
local component
|
for app in "${update_arr[@]}"; do
|
||||||
local update
|
local update="update_${app}"
|
||||||
for component in "${update_arr[@]}"; do
|
|
||||||
if [[ ${component} == "system" ]]; then
|
|
||||||
update="upgrade_system_packages"
|
|
||||||
else
|
|
||||||
update="update_${component}"
|
|
||||||
fi
|
|
||||||
#shellcheck disable=SC2250
|
#shellcheck disable=SC2250
|
||||||
$update
|
$update
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -54,6 +54,7 @@ function upload_selection() {
|
|||||||
[[ ${upload_agreed} == "false" ]] && accept_upload_conditions
|
[[ ${upload_agreed} == "false" ]] && accept_upload_conditions
|
||||||
|
|
||||||
local logfiles
|
local logfiles
|
||||||
|
local logs_dir="${KLIPPER_LOGS}"
|
||||||
local webif_logs="/var/log/nginx"
|
local webif_logs="/var/log/nginx"
|
||||||
|
|
||||||
function find_logfile() {
|
function find_logfile() {
|
||||||
@@ -63,18 +64,14 @@ function upload_selection() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
local logdir log_dirs
|
find_logfile "kiauh\.log" "/tmp"
|
||||||
log_dirs=$(get_instance_folder_path "logs")
|
find_logfile "klippy(-[0-9a-zA-Z]+)?\.log" "${logs_dir}"
|
||||||
for logdir in ${log_dirs}; do
|
find_logfile "moonraker(-[0-9a-zA-Z]+)?\.log" "${logs_dir}"
|
||||||
find_logfile "klippy(-[0-9a-zA-Z]+)?\.log" "${logdir}"
|
find_logfile "telegram(-[0-9a-zA-Z]+)?\.log" "${logs_dir}"
|
||||||
find_logfile "moonraker(-[0-9a-zA-Z]+)?\.log" "${logdir}"
|
|
||||||
find_logfile "telegram(-[0-9a-zA-Z]+)?\.log" "${logdir}"
|
|
||||||
done
|
|
||||||
find_logfile "mainsail.*" "${webif_logs}"
|
find_logfile "mainsail.*" "${webif_logs}"
|
||||||
find_logfile "fluidd.*" "${webif_logs}"
|
find_logfile "fluidd.*" "${webif_logs}"
|
||||||
find_logfile "KlipperScreen.log" "/tmp"
|
find_logfile "KlipperScreen.log" "/tmp"
|
||||||
find_logfile "webcamd\.log(\.[0-9]+)?$" "/var/log"
|
find_logfile "webcamd\.log(\.[0-9]+)?$" "/var/log"
|
||||||
find_logfile "kiauh\.log" "/tmp"
|
|
||||||
|
|
||||||
### draw interface
|
### draw interface
|
||||||
local i=0
|
local i=0
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/th33xitus/kiauh #
|
||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
@@ -20,8 +20,6 @@ function check_euid() {
|
|||||||
echo -e "${red}"
|
echo -e "${red}"
|
||||||
top_border
|
top_border
|
||||||
echo -e "| !!! THIS SCRIPT MUST NOT RUN AS ROOT !!! |"
|
echo -e "| !!! THIS SCRIPT MUST NOT RUN AS ROOT !!! |"
|
||||||
echo -e "| |"
|
|
||||||
echo -e "| It will ask for credentials as needed. |"
|
|
||||||
bottom_border
|
bottom_border
|
||||||
echo -e "${white}"
|
echo -e "${white}"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -136,7 +134,7 @@ function init_ini() {
|
|||||||
echo -e "# File creation date: $(date)"
|
echo -e "# File creation date: $(date)"
|
||||||
echo -e "#=================================================#"
|
echo -e "#=================================================#"
|
||||||
echo -e "# KIAUH - Klipper Installation And Update Helper #"
|
echo -e "# KIAUH - Klipper Installation And Update Helper #"
|
||||||
echo -e "# https://github.com/dw-0/kiauh #"
|
echo -e "# https://github.com/th33xitus/kiauh #"
|
||||||
echo -e "# DO NOT edit this file! #"
|
echo -e "# DO NOT edit this file! #"
|
||||||
echo -e "#=================================================#"
|
echo -e "#=================================================#"
|
||||||
echo -e "# KIAUH v4.0.0"
|
echo -e "# KIAUH v4.0.0"
|
||||||
@@ -287,7 +285,7 @@ function python3_check() {
|
|||||||
|
|
||||||
function dependency_check() {
|
function dependency_check() {
|
||||||
local dep=( "${@}" )
|
local dep=( "${@}" )
|
||||||
local packages log_name="dependencies"
|
local packages
|
||||||
status_msg "Checking for the following dependencies:"
|
status_msg "Checking for the following dependencies:"
|
||||||
|
|
||||||
#check if package is installed, if not write its name into array
|
#check if package is installed, if not write its name into array
|
||||||
@@ -305,12 +303,12 @@ function dependency_check() {
|
|||||||
done
|
done
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# update system package lists if stale
|
if sudo apt-get update --allow-releaseinfo-change && sudo apt-get install "${packages[@]}" -y; then
|
||||||
update_system_package_lists
|
ok_msg "Dependencies installed!"
|
||||||
|
else
|
||||||
# install required packages
|
error_msg "Installing dependencies failed!"
|
||||||
install_system_packages "${log_name}" "packages[@]"
|
return 1 # exit kiauh
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
ok_msg "Dependencies already met!"
|
ok_msg "Dependencies already met!"
|
||||||
return
|
return
|
||||||
@@ -360,78 +358,27 @@ function create_required_folders() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_system_package_lists() {
|
|
||||||
local cache_mtime update_age update_interval silent
|
|
||||||
|
|
||||||
if [[ $1 == '--silent' ]]; then silent="true"; fi
|
|
||||||
|
|
||||||
if [[ -e /var/lib/apt/periodic/update-success-stamp ]]; then
|
|
||||||
cache_mtime="$(stat -c %Y /var/lib/apt/periodic/update-success-stamp)"
|
|
||||||
elif [[ -e /var/lib/apt/lists ]]; then
|
|
||||||
cache_mtime="$(stat -c %Y /var/lib/apt/lists)"
|
|
||||||
else
|
|
||||||
log_warning "Failure determining package cache age, forcing update"
|
|
||||||
cache_mtime=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
update_age="$(($(date +'%s') - cache_mtime))"
|
|
||||||
update_interval=$((48*60*60)) # 48hrs
|
|
||||||
|
|
||||||
# update if cache is greater than update_interval
|
|
||||||
if (( update_age > update_interval )); then
|
|
||||||
if [[ ! ${silent} == "true" ]]; then status_msg "Updating package lists..."; fi
|
|
||||||
if ! sudo apt-get update --allow-releaseinfo-change &>/dev/null; then
|
|
||||||
log_error "Failure while updating package lists!"
|
|
||||||
if [[ ! ${silent} == "true" ]]; then error_msg "Updating package lists failed!"; fi
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
log_info "Package lists updated successfully"
|
|
||||||
if [[ ! ${silent} == "true" ]]; then status_msg "Updated package lists."; fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log_info "Package lists updated recently, skipping update..."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function check_system_updates() {
|
function check_system_updates() {
|
||||||
local updates_avail status
|
local updates_avail info_msg
|
||||||
if ! update_system_package_lists --silent; then
|
updates_avail=$(apt list --upgradeable 2>/dev/null | sed "1d")
|
||||||
status="${red}Update check failed! ${white}"
|
|
||||||
|
if [[ -n ${updates_avail} ]]; then
|
||||||
|
info_msg="${yellow}System upgrade available!${white}"
|
||||||
|
# add system to application_updates_available in kiauh.ini
|
||||||
|
add_to_application_updates "system"
|
||||||
else
|
else
|
||||||
updates_avail="$(apt list --upgradeable 2>/dev/null | sed "1d")"
|
info_msg="${green}System up to date! ${white}"
|
||||||
|
|
||||||
if [[ -n ${updates_avail} ]]; then
|
|
||||||
status="${yellow}System upgrade available!${white}"
|
|
||||||
# add system to application_updates_available in kiauh.ini
|
|
||||||
add_to_application_updates "system"
|
|
||||||
else
|
|
||||||
status="${green}System up to date! ${white}"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${status}"
|
echo "${info_msg}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function upgrade_system_packages() {
|
function update_system() {
|
||||||
status_msg "Upgrading System ..."
|
status_msg "Updating System ..."
|
||||||
update_system_package_lists
|
if sudo apt-get update --allow-releaseinfo-change && sudo apt-get upgrade -y; then
|
||||||
if sudo apt-get upgrade -y; then
|
print_confirm "Update complete! Check the log above!\n ${yellow}KIAUH will not install any dist-upgrades or\n any packages which have been kept back!${green}"
|
||||||
print_confirm "Upgrade complete! Check the log above!\n ${yellow}KIAUH will not install any dist-upgrades or\n any packages which have been held back!${green}"
|
|
||||||
else
|
else
|
||||||
print_error "System upgrade failed! Please look for any errors printed above!"
|
print_error "System update failed! Please watch for any errors printed above!"
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function install_system_packages() {
|
|
||||||
local log_name="$1"
|
|
||||||
local packages=("${!2}")
|
|
||||||
status_msg "Installing packages..."
|
|
||||||
if sudo apt-get install -y "${packages[@]}"; then
|
|
||||||
ok_msg "${log_name^} packages installed!"
|
|
||||||
else
|
|
||||||
log_error "Failure while installing ${log_name,,} packages"
|
|
||||||
error_msg "Installing ${log_name} packages failed!"
|
|
||||||
exit 1 # exit kiauh
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -682,6 +629,30 @@ function get_multi_instance_names() {
|
|||||||
echo "${instance_names[@]}"
|
echo "${instance_names[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
###
|
||||||
|
# helper function that returns klipper data directory
|
||||||
|
# path based on systemd service name.
|
||||||
|
#
|
||||||
|
# => return an empty string if klipper is not installed
|
||||||
|
# => return absolute config directory path
|
||||||
|
#
|
||||||
|
function get_data_folder() {
|
||||||
|
local service_name=${1}
|
||||||
|
local service_type=${2}
|
||||||
|
local instance_name
|
||||||
|
|
||||||
|
if [[ "${service_name}" == "${service_type}.service" ]]; then
|
||||||
|
echo "${HOME}/printer_data"
|
||||||
|
else
|
||||||
|
instance_name=$(get_instance_name "${service_name}")
|
||||||
|
if [[ ${instance_name} =~ ^[0-9]+$ ]]; then
|
||||||
|
echo "${HOME}/printer_${instance_name}_data"
|
||||||
|
else
|
||||||
|
echo "${HOME}/${instance_name}_data"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
###
|
###
|
||||||
# helper function that returns all possibly available absolute
|
# helper function that returns all possibly available absolute
|
||||||
# klipper config directory paths based on their instance name.
|
# klipper config directory paths based on their instance name.
|
||||||
|
|||||||
Reference in New Issue
Block a user