mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-14 11:04:29 +05:00
Compare commits
170 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4bf9e8f0a8 | ||
|
|
dd58229fee | ||
|
|
6c4635fa4e | ||
|
|
4517415e9d | ||
|
|
5c45bc7617 | ||
|
|
d8ce465126 | ||
|
|
2f8c95a8c7 | ||
|
|
4c083ceade | ||
|
|
259a6919f0 | ||
|
|
4f7a49d85a | ||
|
|
005a5061a7 | ||
|
|
634d795557 | ||
|
|
a14e321df9 | ||
|
|
1682642e47 | ||
|
|
7e9d18b54c | ||
|
|
d049d4c770 | ||
|
|
108cda3cd6 | ||
|
|
d7de58f538 | ||
|
|
572afa0396 | ||
|
|
63a5e1e323 | ||
|
|
8c68eaa995 | ||
|
|
e8c0b3cf39 | ||
|
|
cfad7a1fb0 | ||
|
|
4113732daa | ||
|
|
95808a0d5b | ||
|
|
e551c02507 | ||
|
|
1f40686ea1 | ||
|
|
9b3d96545b | ||
|
|
a632fae8f6 | ||
|
|
4e3a701db4 | ||
|
|
0c760b5aa2 | ||
|
|
3bc2f3b498 | ||
|
|
b92cfc3984 | ||
|
|
01790b5c11 | ||
|
|
8c7891e360 | ||
|
|
852f7c056a | ||
|
|
8cffd07aef | ||
|
|
40745e90df | ||
|
|
a43645cca0 | ||
|
|
4d834db5df | ||
|
|
771191ab69 | ||
|
|
7afe943ecc | ||
|
|
b06c17c184 | ||
|
|
3af46b45ee | ||
|
|
b58e79634c | ||
|
|
1ef9b0f58f | ||
|
|
8333ae1dc4 | ||
|
|
e0ae312a9e | ||
|
|
4ce1ce72d3 | ||
|
|
60842a330d | ||
|
|
05a59e9261 | ||
|
|
36a8757cfd | ||
|
|
fe4625d3e1 | ||
|
|
19ddf3e023 | ||
|
|
ba888b1f97 | ||
|
|
0284a36e7f | ||
|
|
22f705e06c | ||
|
|
4c34245da0 | ||
|
|
f7cb3d6c97 | ||
|
|
aaf4f7dd5c | ||
|
|
26bac791aa | ||
|
|
aa4bdfc7b2 | ||
|
|
311f3be864 | ||
|
|
511df1a889 | ||
|
|
8d3ddc273a | ||
|
|
f231fa9c69 | ||
|
|
9b6925e9c4 | ||
|
|
7f8ee7939c | ||
|
|
4d4c49d4c9 | ||
|
|
7692227946 | ||
|
|
3da993a67c | ||
|
|
6b74c59d15 | ||
|
|
9cd27f7052 | ||
|
|
fc4fe130cd | ||
|
|
2a46b00cda | ||
|
|
560186a40b | ||
|
|
75bca847f8 | ||
|
|
bb1f2eadca | ||
|
|
6d87716b1d | ||
|
|
1e8c379623 | ||
|
|
6a8991d51e | ||
|
|
fb4367bb41 | ||
|
|
9463b719e4 | ||
|
|
65bf3d5251 | ||
|
|
68327262fc | ||
|
|
14ef39b87c | ||
|
|
969d3b5dab | ||
|
|
05842f8e1d | ||
|
|
39219c105e | ||
|
|
7984c28fe5 | ||
|
|
b44e855a98 | ||
|
|
52ab909ba5 | ||
|
|
4d7e10e5c3 | ||
|
|
d3726733e5 | ||
|
|
765f016ea2 | ||
|
|
5deb987b8a | ||
|
|
47d1321979 | ||
|
|
b47a9cf7ed | ||
|
|
a9f23e9b23 | ||
|
|
814acbe92a | ||
|
|
991dd79d01 | ||
|
|
40875dfe49 | ||
|
|
806c6fd275 | ||
|
|
e9706b52d8 | ||
|
|
412e084d6d | ||
|
|
3ebee823ad | ||
|
|
72312422e3 | ||
|
|
54089582e4 | ||
|
|
9fd3f930df | ||
|
|
98f0aa4b8f | ||
|
|
19b37e4dc4 | ||
|
|
d344b1c5f6 | ||
|
|
f804fcb65d | ||
|
|
0edfc746d4 | ||
|
|
02ef0578e3 | ||
|
|
5d11cd212a | ||
|
|
bf33c77db7 | ||
|
|
0815d7778c | ||
|
|
9a3814f480 | ||
|
|
a83585fb06 | ||
|
|
dc27fe47e1 | ||
|
|
11b3d7a961 | ||
|
|
9e0cdb0715 | ||
|
|
8abda56749 | ||
|
|
cf20fc3c48 | ||
|
|
6c8845d7b4 | ||
|
|
fb0a30814d | ||
|
|
87f229c62d | ||
|
|
5b1da45688 | ||
|
|
545b978e80 | ||
|
|
44f5609de6 | ||
|
|
f2a26d9b3d | ||
|
|
bb2cdab02b | ||
|
|
d6596d0a3d | ||
|
|
865fbc07dc | ||
|
|
40ba33eb19 | ||
|
|
49b77162b0 | ||
|
|
adf087e3e5 | ||
|
|
8220647564 | ||
|
|
57075ff525 | ||
|
|
2f9de620bc | ||
|
|
d658c3a4cd | ||
|
|
67f6a2c599 | ||
|
|
f369c132d2 | ||
|
|
cce6ac3c88 | ||
|
|
b9fe29068d | ||
|
|
104089ea3d | ||
|
|
48d97dab01 | ||
|
|
e4a56564a1 | ||
|
|
6de8ce3278 | ||
|
|
b46457328f | ||
|
|
7c7dd4ec3c | ||
|
|
749293dde0 | ||
|
|
85f8ab4f24 | ||
|
|
e894496a6e | ||
|
|
19b220b772 | ||
|
|
a4eaa8952a | ||
|
|
74a9bf783b | ||
|
|
7597e999a1 | ||
|
|
64d73ca86a | ||
|
|
d3283f7ab7 | ||
|
|
cb443f6fee | ||
|
|
7162256e3f | ||
|
|
938b9d24f5 | ||
|
|
38a3517c89 | ||
|
|
0b15cd0d9b | ||
|
|
9d7752a6c5 | ||
|
|
d1dff4d3b5 | ||
|
|
49b7fe395b | ||
|
|
51469d8992 |
12
.github/FUNDING.yml
vendored
Normal file
12
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: th33xitus
|
||||
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
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
50
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
50
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
name: Bug report
|
||||
description: Create a report to help us improve
|
||||
labels: ["bug"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
This issue form is for reporting bugs only!
|
||||
If you have a feature request, please use [feature_request](/new?template=feature_request.yml)
|
||||
- type: textarea
|
||||
id: distro
|
||||
attributes:
|
||||
label: Linux Distribution
|
||||
description: >-
|
||||
The linux distribution the issue occured on
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: what-happened
|
||||
attributes:
|
||||
label: What happened
|
||||
description: >-
|
||||
A clear and concise description of what the bug is.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected-behavior
|
||||
attributes:
|
||||
label: What did you expect to happen
|
||||
description: >-
|
||||
A clear and concise description of what you expected to happen.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: repro-steps
|
||||
attributes:
|
||||
label: How to reproduce
|
||||
description: >-
|
||||
Minimal and precise steps to reproduce this bug.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: additional-info
|
||||
attributes:
|
||||
label: Additional information
|
||||
description: |
|
||||
If you have any additional information for us, use the field below.
|
||||
|
||||
Please note, you can attach screenshots or screen recordings here, by
|
||||
dragging and dropping files in the field below.
|
||||
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Klipper Discord
|
||||
url: https://discord.klipper3d.org/
|
||||
about: Quickest way to get in contact
|
||||
40
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
40
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
name: Feature request
|
||||
description: Suggest an idea for this project
|
||||
labels: ["feature request"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
This issue form is for feature requests only!
|
||||
If you've found a bug, please use [bug_report](/new?template=bug_report.yml)
|
||||
- type: textarea
|
||||
id: problem-description
|
||||
attributes:
|
||||
label: Is your feature request related to a problem? Please describe
|
||||
description: >-
|
||||
A clear and concise description of what the problem is.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: solution-description
|
||||
attributes:
|
||||
label: Describe the solution you'd like
|
||||
description: >-
|
||||
A clear and concise description of what you want to happen.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: possible-alternatives
|
||||
attributes:
|
||||
label: Describe alternatives you've considered
|
||||
description: >-
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
- type: textarea
|
||||
id: additional-info
|
||||
attributes:
|
||||
label: Additional information
|
||||
description: |
|
||||
If you have any additional information for us, use the field below.
|
||||
|
||||
Please note, you can attach screenshots or screen recordings here, by
|
||||
dragging and dropping files in the field below.
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
kiauh.ini
|
||||
.idea
|
||||
.shellcheckrc
|
||||
128
README.md
128
README.md
@@ -1,54 +1,34 @@
|
||||
# **KIAUH - Klipper Installation And Update Helper**
|
||||

|
||||
# Klipper Installation And Update Helper
|
||||
     
|
||||
|
||||

|
||||
### **📋 Please see the [Changelog](docs/changelog.md) for possible important information !**
|
||||
|
||||
---
|
||||
**📢 Disclaimer: Usage of this script happens at your own risk!**
|
||||
|
||||
## **📋 Please see the [Changelog](docs/changelog.md) for possible important information !**
|
||||
|
||||
---
|
||||
|
||||
## **📢 Disclaimer: Usage of this script happens at your own risk!**
|
||||
|
||||
This script acts as a helping hand for you to get set up in a fast and comfortable way.\
|
||||
**This does not mean, it will relieve you of using your brain.exe! 🧠**\
|
||||
Please also always pay attention to the individual component repositories (all linked below).\
|
||||
Feel free to give it a try. If you have suggestions or encounter any problems, please report them.
|
||||
|
||||
---
|
||||
|
||||
## **🛠️ Instructions:**
|
||||
|
||||
For downloading this script it is necessary to have git installed.\
|
||||
If you haven't, please run `sudo apt-get install git -y` to install git first.\
|
||||
You will need it anyways! 😄
|
||||
|
||||
After git is installed, use the following commands in the given order to download and execute the script:
|
||||
|
||||
```shell
|
||||
cd ~
|
||||
|
||||
git clone https://github.com/th33xitus/kiauh.git
|
||||
|
||||
./kiauh/kiauh.sh
|
||||
```
|
||||
|
||||
## Additional Instructions:
|
||||
|
||||
If you need some more detailed instructions on how to install Klipper and Mainsail with KIAUH, check out this website:\
|
||||
[Installing Klipper and Mainsail](https://3dp.tumbleweedlabs.com/firmware/klipper-firmware/installing-klipper-and-mainsail-on-your-raspberry-pi)\
|
||||
Credits for these instructions go to [@tumbleweedlabs](https://github.com/tumbleweedlabs).\
|
||||
Feel free to check out his work.
|
||||
|
||||
---
|
||||
|
||||
## **🧰 Functions and Features:**
|
||||
|
||||
- **New in v3.0** You can now install multiple instances (Klipper/Moonraker/DWC/Octoprint) on the same Pi!
|
||||
---
|
||||
### **Core Functions:**
|
||||
|
||||
- **Installing** Klipper to your Raspberry Pi or other Debian based Linux Distribution.
|
||||
- **Installing** of the Moonraker API (needed for Mainsail, Fluidd and KlipperScreen)
|
||||
- **Installing** several different web interfaces such as Mainsail, Fluidd, Duet Web Control or OctoPrint including their dependencies.
|
||||
- **Installing** several web interfaces such as Mainsail, Fluidd, Duet Web Control or OctoPrint including their dependencies.
|
||||
- **Installing** of KlipperScreen (OctoScreen but for Klipper!)
|
||||
- **Updating** of all the listed installations above excluding OctoPrint. For updating OctoPrint, please use the OctoPrint interface!
|
||||
- **Removing** of all the listed installations above.
|
||||
@@ -63,84 +43,30 @@ Feel free to check out his work.
|
||||
|
||||
### **For a list of additional features please see: [Feature List](docs/features.md)**
|
||||
|
||||
---
|
||||
## **❗ Notes:**
|
||||
|
||||
## **📝 Notes:**
|
||||
|
||||
- Tested **only** on Raspberry Pi OS Lite (Debian Buster)
|
||||
- ( Although similar Debian based distributions might also work... )
|
||||
- Tested **only** on Raspberry Pi OS Lite (Debian 10 Buster)
|
||||
- Other Debian based distributions can work
|
||||
- Reported to work on Armbian too
|
||||
- During the use of this script you might be asked for your sudo password. There are several functions involved which need sudo privileges.
|
||||
|
||||
---
|
||||
|
||||
## **🛈 Sources & Further Information**
|
||||
|
||||
If you need some more detailed instructions on how to install Klipper and Mainsail with KIAUH, check out this website:\
|
||||
[Installing Klipper and Mainsail](https://3dp.tumbleweedlabs.com/firmware/klipper-firmware/installing-klipper-and-mainsail-on-your-raspberry-pi)\
|
||||
Credits for these instructions go to [@tumbleweedlabs](https://github.com/tumbleweedlabs).
|
||||
## **🌐 Sources & Further Information**
|
||||
|
||||
For more information or instructions to the various components KIAUH can install, please check out the corresponding repositories listed below:
|
||||
|
||||
---
|
||||
* ⛵[Klipper](https://github.com/Klipper3d/klipper) by [KevinOConnor](https://github.com/KevinOConnor)
|
||||
* 🌙[Moonraker](https://github.com/Arksine/moonraker) by [Arksine](https://github.com/Arksine)
|
||||
* 💨[Mainsail](https://github.com/mainsail-crew/mainsail) by [mainsail-crew](https://github.com/mainsail-crew)
|
||||
* 🌊[Fluidd](https://github.com/fluidd-core/fluidd) by [fluidd-core](https://github.com/fluidd-core)
|
||||
* 🕸️[Duet Web Control](https://github.com/Duet3D/DuetWebControl) by [Duet3D](https://github.com/Duet3D)
|
||||
* 🕸️[DWC2-for-Klipper-Socket](https://github.com/Stephan3/dwc2-for-klipper-socket) by [Stephan3](https://github.com/Stephan3)
|
||||
* 🖥️[KlipperScreen](https://github.com/jordanruthe/KlipperScreen) by [jordanruthe](https://github.com/jordanruthe)
|
||||
* 🐙[OctoPrint](https://github.com/OctoPrint/OctoPrint) by [OctoPrint](https://github.com/OctoPrint)
|
||||
* 🔬[PrettyGCode](https://github.com/Kragrathea/pgcode) by [Kragrathea](https://github.com/Kragrathea)
|
||||
* 🤖[Moonraker-Telegram-Bot](https://github.com/nlef/moonraker-telegram-bot) by [nlef](https://github.com/nlef)
|
||||
|
||||
### **⛵Klipper** by [KevinOConnor](https://github.com/KevinOConnor) :
|
||||
## **Credits**
|
||||
|
||||
https://github.com/KevinOConnor/klipper
|
||||
|
||||
---
|
||||
|
||||
### **⛵Klipper S-Curve fork** by [dmbutyugin](https://github.com/dmbutyugin) :
|
||||
|
||||
https://github.com/dmbutyugin/klipper/tree/scurve-smoothing \
|
||||
https://github.com/dmbutyugin/klipper/tree/scurve-shaping
|
||||
|
||||
---
|
||||
|
||||
### **🌙Moonraker** by [Arksine](https://github.com/Arksine) :
|
||||
|
||||
https://github.com/Arksine/moonraker
|
||||
|
||||
---
|
||||
|
||||
### **💨Mainsail Webinterface** by [meteyou](https://github.com/meteyou) :
|
||||
|
||||
https://github.com/meteyou/mainsail
|
||||
|
||||
---
|
||||
|
||||
### **🌊Fluidd Webinterface** by [cadriel](https://github.com/cadriel) :
|
||||
|
||||
https://github.com/cadriel/fluidd
|
||||
|
||||
---
|
||||
|
||||
### **🕸️Duet Web Control** by [Duet3D](https://github.com/Duet3D) :
|
||||
|
||||
https://github.com/Duet3D/DuetWebControl
|
||||
|
||||
---
|
||||
|
||||
### **🕸️DWC2-for-Klipper-Socket** by [Stephan3](https://github.com/Stephan3) :
|
||||
|
||||
https://github.com/Stephan3/dwc2-for-klipper-socket
|
||||
|
||||
---
|
||||
|
||||
### **🖥️KlipperScreen** by [jordanruthe](https://github.com/jordanruthe) :
|
||||
|
||||
https://github.com/jordanruthe/KlipperScreen
|
||||
|
||||
---
|
||||
|
||||
### **🐙OctoPrint Webinterface** by [OctoPrint](https://github.com/OctoPrint) :
|
||||
|
||||
https://octoprint.org \
|
||||
https://github.com/OctoPrint/OctoPrint
|
||||
|
||||
---
|
||||
|
||||
## **❓ FAQ**
|
||||
|
||||
**_Q: Can i use this script to install multiple instances of Klipper on the same Pi? (Multisession?)_**
|
||||
|
||||
**A:** Yes, it is finally possible 🙂
|
||||
* 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/th33xitus) !
|
||||
* Last but not least: Thank you to all contributors and members of the Klipper Community who like and share this project!
|
||||
|
||||
@@ -2,6 +2,74 @@
|
||||
|
||||
This document covers possible important changes to KIAUH.
|
||||
|
||||
### 2022-01-29
|
||||
* Starting from the 28th of January, Moonraker can make use of PackageKit and PolicyKit.\
|
||||
More details on that can be found [here](
|
||||
https://github.com/Arksine/moonraker/issues/349) and [here](https://github.com/Arksine/moonraker/pull/346)
|
||||
* KIAUH will install Moonrakers PolicyKit rules by default when __installing__ Moonraker
|
||||
* KIAUH will also install Moonrakers PolicyKit rules when __updating__ Moonraker __via KIAUH__ as of now
|
||||
|
||||
### 2021-12-30
|
||||
* Updated the doc for the usage of the [G-Code Shell Command Extension](docs/gcode_shell_command.md)
|
||||
* It became apparent, that some user groups are missing on some systems. A missing video group \
|
||||
membership for example caused issues when installing mjpg-streamer while not using the default pi user. \
|
||||
Other issues could occur when trying to flash an MCU on Debian or Ubuntu distributions where a user might not be part
|
||||
of the dialout group by default. A check for the tty group is also done. The tty group is needed for setting
|
||||
up a linux MCU (currently not yet supported by KIAUH).
|
||||
* There is an issue when trying to install Mainsail or Fluidd on Ubuntu 21.10. Permissions on that distro seem to have seen a rework
|
||||
in comparison to 20.04 and users will be greeted with an "Error 403 - Permission denied" message after installing one of Klippers webinterfaces.
|
||||
I still have to figure out a viable solution for that.
|
||||
|
||||
### 2021-09-28
|
||||
* New Feature! Added an installer for the Telegram Bot for Moonraker by [nlef](https://github.com/nlef).
|
||||
Checkout his project! Remember to report all issues and/or bugs regarding that project in its corresponding repo and not here 😛.\
|
||||
You can find it here: https://github.com/nlef/moonraker-telegram-bot
|
||||
|
||||
### 2021-09-24
|
||||
* The flashing function got adjusted a bit. It is now possible to also flash controllers which are connected over UART and thus accessible via `/dev/ttyAMA0`. You now have to select a connection methop prior flashing which is either USB or UART.
|
||||
* Due to several requests over time I have now created a Ko-fi account for those who want to support this project and my work with a small donation. Many thanks in advance to all future donors. You can support me on Ko-fi with this link: https://ko-fi.com/th33xitus
|
||||
* As usual, if you find any bugs or issues please report them. I tested the little rework i did with the hardware i have available and haven't encountered any malfunctions of flashing them yet.
|
||||
|
||||
### 2021-08-10
|
||||
* KIAUH now supports the installation of the "PrettyGCode for Klipper" GCode-Viewer created by [Kragrathea](https://github.com/Kragrathea)! Installation, updating and removal are possible with KIAUH. For more details to this cool piece of software, please have a look here: https://github.com/Kragrathea/pgcode
|
||||
|
||||
### 2021-07-10
|
||||
* The NGINX configuration files got updated to be in sync with MainsailOS and FluiddPi. Issues with the NGINX service not starting up due to wrong configuration should be resolved now. To get the updated configuration files, please remove Moonraker and Mainsail / Fluidd with KIAUH first and then re-install it. An automated file check for those configuration files might follow in the future which then automates updating those files if there were important changes.
|
||||
|
||||
* The default `moonraker.conf` was updated to reflect the recent changes to the update manager section. The update channel is set to `dev`.
|
||||
|
||||
### 2021-06-29
|
||||
* KIAUH will now patch the new `log_path` to existing moonraker.conf files when updating Moonraker and the entry is missing. Before that, it was necessary that the user provided that path manually to make Fluidd display the logfiles in its interface. This issue should be resolved now.
|
||||
|
||||
### 2021-06-15
|
||||
|
||||
* Moonraker introduced an optional `log_path` which clients can make use of to show log files located in that folder to their users. More info here: https://github.com/Arksine/moonraker/commit/829b3a4ee80579af35dd64a37ccc092a1f67682a \
|
||||
Client developers agreed upon using `~/klipper_logs` as the new default log path.\
|
||||
That means, from now on, Klipper and Moonraker services installed with KIAUH will place their logfiles in that mentioned folder.
|
||||
* Additionally, KIAUH will now detect Klipper and Moonraker systemd services that still use the old default location of `/tmp/<service>.log` and will update them next time the user updates Klipper and/or Moonraker with the KIAUH update function.
|
||||
* Additional symlinks for the following logfiles will get created along those update procedures to make them accessible through the webinterface once its supported:
|
||||
- webcamd.log
|
||||
- mainsail-access.log
|
||||
- mainsail-error.log
|
||||
- fluidd-access.log
|
||||
- fluidd-error.log
|
||||
* For MainsailOS and FluiddPi users:\
|
||||
MainsailOS and FluiddPi will switch the shipped Klipper service from SysVinit to systemd probably with their next release. KIAUH can already help migrate older MainsailOS (0.4.0 and below) and FluiddPi (v1.13.0) releases to match their new service-, file- and folder-structure so you don't have to re-flash the SD-Card of your Raspberry Pi.\
|
||||
In detail here is what is going to happen when you use the new "CustomPiOS Migration Helper" from the Advanced Menu\
|
||||
`(Main Menu -> 4 -> Enter -> 10 -> Enter)` in a short summary:
|
||||
* The Klipper SysVinit service will get replaced by a Klipper systemd service
|
||||
* Klipper and Moonraker will use the new log-directory `~/klipper_logs`
|
||||
* The webcamd service gets updated
|
||||
* The webcamd script gets updated and moved from `/root/bin/webcamd` to `/usr/local/bin/webcamd`
|
||||
* The NGINX `upstreams.conf` gets updated to be able to configure up to 4 webcams
|
||||
* The `mainsail.txt` / `fluiddpi.txt` gets moved from `/boot` to `~/klipper_config` and renamed to `webcam.txt`
|
||||
* Symlinks for the webcamd.log and various NGINX logs get created in `~/klipper_config`
|
||||
* Configuration files for Klipper, Moonraker and webcamd get added to `/etc/logrotate.d`
|
||||
* If they still exist, two lines will be removed from the mainsail.cfg or client_macros.cfg macro configurations:\
|
||||
`SAVE_GCODE_STATE NAME=PAUSE_state` and `RESTORE_GCODE_STATE NAME=PAUSE_state`
|
||||
* **Please note:**\
|
||||
The "CustomPiOS Migration Helper" is intended to only work on "vanilla" MainsailOS and FluiddPi systems. Do not try to migrate a modified MainsailOS or FluiddPi system (for example if you already used KIAUH to re-install services or to set up a multi-instance installation for Klipper / Moonraker). This won't work.
|
||||
|
||||
### 2021-01-31
|
||||
|
||||
* **This is a big one... KIAUH v3.0 is out.**\
|
||||
|
||||
@@ -40,6 +40,34 @@ verbose: True
|
||||
Execute with:
|
||||
`RUN_SHELL_COMMAND CMD=hello_world`
|
||||
|
||||
### Passing parameters:
|
||||
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,
|
||||
once the gcode_macro runs and the gcode_shell_command gets called, executes the `script.sh`. The script then echoes a message to the console (if `verbose: True`)
|
||||
and writes the value of the parameter into a textfile called `test.txt` located in the home directory.
|
||||
|
||||
Content of the `gcode_shell_command` and the `gcode_macro`:
|
||||
```
|
||||
[gcode_shell_command print_to_file]
|
||||
command: sh /home/pi/klipper_config/script.sh
|
||||
timeout: 30.
|
||||
verbose: True
|
||||
|
||||
[gcode_macro GET_TEMP]
|
||||
gcode:
|
||||
{% set temp = printer.extruder.temperature %}
|
||||
{ action_respond_info("%s" % (temp)) }
|
||||
RUN_SHELL_COMMAND CMD=print_to_file PARAMS={temp}
|
||||
```
|
||||
|
||||
Content of `script.sh`:
|
||||
```shell
|
||||
#!/bin/sh
|
||||
|
||||
echo "temp is: $1"
|
||||
echo "$1" >> "${HOME}/test.txt"
|
||||
```
|
||||
|
||||
## Warning
|
||||
|
||||
This extension may have a high potential for abuse if not used carefully! Also, depending on the command you execute, high system loads may occur and can cause system instabilities.
|
||||
|
||||
8
kiauh.sh
8
kiauh.sh
@@ -35,20 +35,24 @@ DWC_ENV_DIR=${HOME}/dwc-env
|
||||
DWC2_DIR=${HOME}/duetwebcontrol
|
||||
#octoprint
|
||||
OCTOPRINT_DIR=${HOME}/OctoPrint
|
||||
OCTOPRINT_CFG_DIR=${HOME}/.octoprint
|
||||
#KlipperScreen
|
||||
KLIPPERSCREEN_DIR=${HOME}/KlipperScreen
|
||||
KLIPPERSCREEN_ENV_DIR=${HOME}/.KlipperScreen-env
|
||||
#MoonrakerTelegramBot
|
||||
MOONRAKER_TELEGRAM_BOT_DIR=${HOME}/moonraker-telegram-bot
|
||||
MOONRAKER_TELEGRAM_BOT_ENV_DIR=${HOME}/moonraker-telegram-bot-env
|
||||
#misc
|
||||
INI_FILE=${HOME}/.kiauh.ini
|
||||
BACKUP_DIR=${HOME}/kiauh-backups
|
||||
|
||||
### set github repos
|
||||
KLIPPER_REPO=https://github.com/KevinOConnor/klipper.git
|
||||
KLIPPER_REPO=https://github.com/Klipper3d/klipper.git
|
||||
ARKSINE_REPO=https://github.com/Arksine/klipper.git
|
||||
DMBUTYUGIN_REPO=https://github.com/dmbutyugin/klipper.git
|
||||
DWC2FK_REPO=https://github.com/Stephan3/dwc2-for-klipper-socket.git
|
||||
MOONRAKER_REPO=https://github.com/Arksine/moonraker.git
|
||||
KLIPPERSCREEN_REPO=https://github.com/jordanruthe/KlipperScreen.git
|
||||
NLEF_REPO=https://github.com/nlef/moonraker-telegram-bot.git
|
||||
#branches
|
||||
BRANCH_SCURVE_SMOOTHING=dmbutyugin/scurve-smoothing
|
||||
BRANCH_SCURVE_SHAPING=dmbutyugin/scurve-shaping
|
||||
|
||||
@@ -40,13 +40,11 @@ grab_version(){
|
||||
cd ..
|
||||
fi
|
||||
if [ ! -z "$mainsail_folder" ]; then
|
||||
mainsail_file=$(find $mainsail_folder/js -name "app.*.js" 2>/dev/null)
|
||||
mainsail_ver=$(grep -o -E 'state:{packageVersion:.+' $mainsail_file | cut -d'"' -f2)
|
||||
mainsail_ver=$(head -n 1 $mainsail_folder/.version)
|
||||
m3="Mainsail version: $mainsail_ver"
|
||||
fi
|
||||
if [ ! -z "$fluidd_folder" ]; then
|
||||
fluidd_file=$(find $fluidd_folder/js -name "app.*.js" 2>/dev/null)
|
||||
fluidd_ver=$(grep -o -E '"setVersion",".+"' $fluidd_file | cut -d'"' -f4)
|
||||
fluidd_ver=$(head -n 1 $fluidd_folder/.version)
|
||||
m4="Fluidd version: $fluidd_ver"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -1,83 +1,87 @@
|
||||
# Run a shell command via gcode
|
||||
#
|
||||
# Copyright (C) 2019 Eric Callahan <arksine.code@gmail.com>
|
||||
#
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
import os
|
||||
import shlex
|
||||
import subprocess
|
||||
import logging
|
||||
|
||||
class ShellCommand:
|
||||
def __init__(self, config):
|
||||
self.name = config.get_name().split()[-1]
|
||||
self.printer = config.get_printer()
|
||||
self.gcode = self.printer.lookup_object('gcode')
|
||||
cmd = config.get('command')
|
||||
cmd = os.path.expanduser(cmd)
|
||||
self.command = shlex.split(cmd)
|
||||
self.timeout = config.getfloat('timeout', 2., above=0.)
|
||||
self.verbose = config.getboolean('verbose', True)
|
||||
self.proc_fd = None
|
||||
self.partial_output = ""
|
||||
self.gcode.register_mux_command(
|
||||
"RUN_SHELL_COMMAND", "CMD", self.name,
|
||||
self.cmd_RUN_SHELL_COMMAND,
|
||||
desc=self.cmd_RUN_SHELL_COMMAND_help)
|
||||
|
||||
def _process_output(self, eventime):
|
||||
if self.proc_fd is None:
|
||||
return
|
||||
try:
|
||||
data = os.read(self.proc_fd, 4096)
|
||||
except Exception:
|
||||
pass
|
||||
data = self.partial_output + data
|
||||
if '\n' not in data:
|
||||
self.partial_output = data
|
||||
return
|
||||
elif data[-1] != '\n':
|
||||
split = data.rfind('\n') + 1
|
||||
self.partial_output = data[split:]
|
||||
data = data[:split]
|
||||
self.gcode.respond_info(data)
|
||||
|
||||
cmd_RUN_SHELL_COMMAND_help = "Run a linux shell command"
|
||||
def cmd_RUN_SHELL_COMMAND(self, params):
|
||||
reactor = self.printer.get_reactor()
|
||||
try:
|
||||
proc = subprocess.Popen(
|
||||
self.command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
except Exception:
|
||||
logging.exception(
|
||||
"shell_command: Command {%s} failed" % (self.name))
|
||||
raise self.gcode.error("Error running command {%s}" % (self.name))
|
||||
if self.verbose:
|
||||
self.proc_fd = proc.stdout.fileno()
|
||||
self.gcode.respond_info("Running Command {%s}...:" % (self.name))
|
||||
hdl = reactor.register_fd(self.proc_fd, self._process_output)
|
||||
eventtime = reactor.monotonic()
|
||||
endtime = eventtime + self.timeout
|
||||
complete = False
|
||||
while eventtime < endtime:
|
||||
eventtime = reactor.pause(eventtime + .05)
|
||||
if proc.poll() is not None:
|
||||
complete = True
|
||||
break
|
||||
if not complete:
|
||||
proc.terminate()
|
||||
if self.verbose:
|
||||
if self.partial_output:
|
||||
self.gcode.respond_info(self.partial_output)
|
||||
self.partial_output = ""
|
||||
if complete:
|
||||
msg = "Command {%s} finished\n" % (self.name)
|
||||
else:
|
||||
msg = "Command {%s} timed out" % (self.name)
|
||||
self.gcode.respond_info(msg)
|
||||
reactor.unregister_fd(hdl)
|
||||
self.proc_fd = None
|
||||
|
||||
|
||||
def load_config_prefix(config):
|
||||
return ShellCommand(config)
|
||||
# Run a shell command via gcode
|
||||
#
|
||||
# Copyright (C) 2019 Eric Callahan <arksine.code@gmail.com>
|
||||
#
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
import os
|
||||
import shlex
|
||||
import subprocess
|
||||
import logging
|
||||
|
||||
class ShellCommand:
|
||||
def __init__(self, config):
|
||||
self.name = config.get_name().split()[-1]
|
||||
self.printer = config.get_printer()
|
||||
self.gcode = self.printer.lookup_object('gcode')
|
||||
cmd = config.get('command')
|
||||
cmd = os.path.expanduser(cmd)
|
||||
self.command = shlex.split(cmd)
|
||||
self.timeout = config.getfloat('timeout', 2., above=0.)
|
||||
self.verbose = config.getboolean('verbose', True)
|
||||
self.proc_fd = None
|
||||
self.partial_output = ""
|
||||
self.gcode.register_mux_command(
|
||||
"RUN_SHELL_COMMAND", "CMD", self.name,
|
||||
self.cmd_RUN_SHELL_COMMAND,
|
||||
desc=self.cmd_RUN_SHELL_COMMAND_help)
|
||||
|
||||
def _process_output(self, eventime):
|
||||
if self.proc_fd is None:
|
||||
return
|
||||
try:
|
||||
data = os.read(self.proc_fd, 4096)
|
||||
except Exception:
|
||||
pass
|
||||
data = self.partial_output + data.decode()
|
||||
if '\n' not in data:
|
||||
self.partial_output = data
|
||||
return
|
||||
elif data[-1] != '\n':
|
||||
split = data.rfind('\n') + 1
|
||||
self.partial_output = data[split:]
|
||||
data = data[:split]
|
||||
else:
|
||||
self.partial_output = ""
|
||||
self.gcode.respond_info(data)
|
||||
|
||||
cmd_RUN_SHELL_COMMAND_help = "Run a linux shell command"
|
||||
def cmd_RUN_SHELL_COMMAND(self, params):
|
||||
gcode_params = params.get('PARAMS','')
|
||||
gcode_params = shlex.split(gcode_params)
|
||||
reactor = self.printer.get_reactor()
|
||||
try:
|
||||
proc = subprocess.Popen(
|
||||
self.command + gcode_params, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
except Exception:
|
||||
logging.exception(
|
||||
"shell_command: Command {%s} failed" % (self.name))
|
||||
raise self.gcode.error("Error running command {%s}" % (self.name))
|
||||
if self.verbose:
|
||||
self.proc_fd = proc.stdout.fileno()
|
||||
self.gcode.respond_info("Running Command {%s}...:" % (self.name))
|
||||
hdl = reactor.register_fd(self.proc_fd, self._process_output)
|
||||
eventtime = reactor.monotonic()
|
||||
endtime = eventtime + self.timeout
|
||||
complete = False
|
||||
while eventtime < endtime:
|
||||
eventtime = reactor.pause(eventtime + .05)
|
||||
if proc.poll() is not None:
|
||||
complete = True
|
||||
break
|
||||
if not complete:
|
||||
proc.terminate()
|
||||
if self.verbose:
|
||||
if self.partial_output:
|
||||
self.gcode.respond_info(self.partial_output)
|
||||
self.partial_output = ""
|
||||
if complete:
|
||||
msg = "Command {%s} finished\n" % (self.name)
|
||||
else:
|
||||
msg = "Command {%s} timed out" % (self.name)
|
||||
self.gcode.respond_info(msg)
|
||||
reactor.unregister_fd(hdl)
|
||||
self.proc_fd = None
|
||||
|
||||
|
||||
def load_config_prefix(config):
|
||||
return ShellCommand(config)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#########################################################################################
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ AUTOCREATED WITH KIAUH ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
#########################################################################################
|
||||
# Those are the recommended macros and config entries if you use Mainsail or Fluidd! #
|
||||
# Feel free to edit or delete those macros if you already have them defined elsewhere! #
|
||||
#########################################################################################
|
||||
################################################################################
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~ AUTOCREATED WITH KIAUH ~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
################################################################################
|
||||
# Recommended macros and config entries if you use Mainsail or Fluidd! #
|
||||
# You can edit or delete those macros if you already defined them elsewhere! #
|
||||
################################################################################
|
||||
|
||||
[pause_resume]
|
||||
|
||||
@@ -19,20 +19,18 @@ gcode:
|
||||
|
||||
[gcode_macro PAUSE]
|
||||
rename_existing: BASE_PAUSE
|
||||
# change this if you need more or less extrusion
|
||||
variable_extrude: 1.0
|
||||
gcode:
|
||||
##### read E from pause macro #####
|
||||
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
|
||||
##### set park positon for x and y #####
|
||||
# default is your max posion from your printer.cfg
|
||||
{% set x_park = printer.toolhead.axis_maximum.x|float - 5.0 %}
|
||||
{% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %}
|
||||
##### set defaults #####
|
||||
{% set x = params.X|default(230) %} #edit to your park position
|
||||
{% set y = params.Y|default(230) %} #edit to your park position
|
||||
{% set z = params.Z|default(10)|float %} #edit to your park position
|
||||
{% set e = params.E|default(1) %} #edit to your retract length
|
||||
##### calculate save lift position #####
|
||||
{% set max_z = printer.toolhead.axis_maximum.z|float %}
|
||||
{% set act_z = printer.toolhead.position.x|float %}
|
||||
{% if act_z < (max_z - 2.0) %}
|
||||
{% set z_safe = 2.0 %}
|
||||
{% set act_z = printer.toolhead.position.z|float %}
|
||||
{% set lift_z = z|abs %}
|
||||
{% if act_z < (max_z - lift_z) %}
|
||||
{% set z_safe = lift_z %}
|
||||
{% else %}
|
||||
{% set z_safe = max_z - act_z %}
|
||||
{% endif %}
|
||||
@@ -40,21 +38,22 @@ gcode:
|
||||
SAVE_GCODE_STATE NAME=PAUSE_state
|
||||
BASE_PAUSE
|
||||
G91
|
||||
G1 E-{E} F2100
|
||||
G1 Z{z_safe} F900
|
||||
G1 E-{e} F2100
|
||||
G1 Z{z_safe}
|
||||
G90
|
||||
G1 X{x_park} Y{y_park} F6000
|
||||
G1 X{x} Y{y} F6000
|
||||
|
||||
|
||||
[gcode_macro RESUME]
|
||||
rename_existing: BASE_RESUME
|
||||
gcode:
|
||||
##### read E from pause macro #####
|
||||
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
|
||||
##### end of definitions #####
|
||||
##### set defaults #####
|
||||
{% set e = params.E|default(1) %} #edit to your retract length
|
||||
G91
|
||||
G1 E{E} F2100
|
||||
RESTORE_GCODE_STATE NAME=PAUSE_state
|
||||
G1 E{e} F2100
|
||||
G90
|
||||
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
|
||||
BASE_RESUME
|
||||
|
||||
#########################################################################################
|
||||
#########################################################################################
|
||||
################################################################################
|
||||
################################################################################
|
||||
|
||||
15
resources/klipper.service
Normal file
15
resources/klipper.service
Normal file
@@ -0,0 +1,15 @@
|
||||
#Systemd service file for klipper
|
||||
[Unit]
|
||||
Description=Starts klipper instance %INST% on startup
|
||||
After=network.target
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=%USER%
|
||||
RemainAfterExit=yes
|
||||
ExecStart=%KL_ENV%/bin/python %KL_DIR%/klippy/klippy.py %P_CFG% -I %P_TMP% -l %KL_LOG% -a %KL_UDS%
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
@@ -2,12 +2,11 @@
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
access_log /var/log/nginx/<<UI>>-access.log;
|
||||
error_log /var/log/nginx/<<UI>>-error.log;
|
||||
|
||||
#disable this section on smaller hardware like a pi zero
|
||||
# disable this section on smaller hardware like a pi zero
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
@@ -15,17 +14,20 @@ server {
|
||||
gzip_comp_level 4;
|
||||
gzip_buffers 16 8k;
|
||||
gzip_http_version 1.1;
|
||||
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/json application/xml;
|
||||
gzip_types text/plain text/css text/xml text/javascript application/javascript application/x-javascript application/json application/xml;
|
||||
|
||||
#web_path from <<UI>> static files
|
||||
# web_path from <<UI>> static files
|
||||
root /home/pi/<<UI>>;
|
||||
|
||||
index index.html;
|
||||
server_name _;
|
||||
|
||||
#max upload size for gcodes (0 = no limit)
|
||||
# disable max upload size checks
|
||||
client_max_body_size 0;
|
||||
|
||||
# disable proxy request buffering
|
||||
proxy_request_buffering off;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
@@ -47,6 +49,8 @@ server {
|
||||
|
||||
location ~ ^/(printer|api|access|machine|server)/ {
|
||||
proxy_pass http://apiserver$request_uri;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
@@ -54,6 +58,38 @@ server {
|
||||
}
|
||||
|
||||
location /webcam/ {
|
||||
proxy_pass http://mjpgstreamer/;
|
||||
postpone_output 0;
|
||||
proxy_buffering off;
|
||||
proxy_ignore_headers X-Accel-Buffering;
|
||||
access_log off;
|
||||
error_log off;
|
||||
proxy_pass http://mjpgstreamer1/;
|
||||
}
|
||||
}
|
||||
|
||||
location /webcam2/ {
|
||||
postpone_output 0;
|
||||
proxy_buffering off;
|
||||
proxy_ignore_headers X-Accel-Buffering;
|
||||
access_log off;
|
||||
error_log off;
|
||||
proxy_pass http://mjpgstreamer2/;
|
||||
}
|
||||
|
||||
location /webcam3/ {
|
||||
postpone_output 0;
|
||||
proxy_buffering off;
|
||||
proxy_ignore_headers X-Accel-Buffering;
|
||||
access_log off;
|
||||
error_log off;
|
||||
proxy_pass http://mjpgstreamer3/;
|
||||
}
|
||||
|
||||
location /webcam4/ {
|
||||
postpone_output 0;
|
||||
proxy_buffering off;
|
||||
proxy_ignore_headers X-Accel-Buffering;
|
||||
access_log off;
|
||||
error_log off;
|
||||
proxy_pass http://mjpgstreamer4/;
|
||||
}
|
||||
}
|
||||
|
||||
56
resources/moonraker.conf
Normal file
56
resources/moonraker.conf
Normal file
@@ -0,0 +1,56 @@
|
||||
[server]
|
||||
host: 0.0.0.0
|
||||
port: %PORT%
|
||||
enable_debug_logging: False
|
||||
klippy_uds_address: %UDS%
|
||||
|
||||
[database]
|
||||
database_path: %MR_DB%
|
||||
|
||||
[authorization]
|
||||
trusted_clients:
|
||||
%LAN%
|
||||
10.0.0.0/8
|
||||
127.0.0.0/8
|
||||
169.254.0.0/16
|
||||
172.16.0.0/12
|
||||
192.168.0.0/16
|
||||
FE80::/10
|
||||
::1/128
|
||||
cors_domains:
|
||||
http://*.lan
|
||||
http://*.local
|
||||
https://my.mainsail.xyz
|
||||
http://my.mainsail.xyz
|
||||
https://app.fluidd.xyz
|
||||
http://app.fluidd.xyz
|
||||
|
||||
[file_manager]
|
||||
config_path: %CFG%
|
||||
log_path: %LOG%
|
||||
|
||||
[octoprint_compat]
|
||||
|
||||
[history]
|
||||
|
||||
[update_manager]
|
||||
channel: dev
|
||||
refresh_interval: 168
|
||||
|
||||
[update_manager mainsail]
|
||||
type: web
|
||||
repo: mainsail-crew/mainsail
|
||||
path: ~/mainsail
|
||||
|
||||
[update_manager fluidd]
|
||||
type: web
|
||||
repo: fluidd-core/fluidd
|
||||
path: ~/fluidd
|
||||
|
||||
#[update_manager KlipperScreen]
|
||||
#type: git_repo
|
||||
#path: /home/%USER%/KlipperScreen
|
||||
#origin: https://github.com/jordanruthe/KlipperScreen.git
|
||||
#env: /home/%USER%/.KlipperScreen-env/bin/python
|
||||
#requirements: scripts/KlipperScreen-requirements.txt
|
||||
#install_script: scripts/KlipperScreen-install.sh
|
||||
16
resources/moonraker.service
Normal file
16
resources/moonraker.service
Normal file
@@ -0,0 +1,16 @@
|
||||
#Systemd service file for moonraker
|
||||
[Unit]
|
||||
Description=Starts Moonraker %INST% on startup
|
||||
After=network.target
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
SupplementaryGroups=moonraker-admin
|
||||
User=%USER%
|
||||
RemainAfterExit=yes
|
||||
ExecStart=%MR_ENV%/bin/python %MR_DIR%/moonraker/moonraker.py -l %MR_LOG% -c %MR_CONF%
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
14
resources/printer.cfg
Normal file
14
resources/printer.cfg
Normal file
@@ -0,0 +1,14 @@
|
||||
[mcu]
|
||||
serial: /dev/serial/by-id/<your-mcu-id>
|
||||
|
||||
[pause_resume]
|
||||
|
||||
[display_status]
|
||||
|
||||
[virtual_sdcard]
|
||||
path: ~/gcode_files
|
||||
|
||||
[printer]
|
||||
kinematics: none
|
||||
max_velocity: 1000
|
||||
max_accel: 1000
|
||||
BIN
resources/screenshots/kiauh.png
Normal file
BIN
resources/screenshots/kiauh.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB |
@@ -1,13 +1,25 @@
|
||||
# /etc/nginx/conf.d/upstreams.conf
|
||||
|
||||
upstream apiserver {
|
||||
#edit your api port here
|
||||
ip_hash;
|
||||
server 127.0.0.1:7125;
|
||||
}
|
||||
|
||||
upstream mjpgstreamer {
|
||||
#edit your webcam port here
|
||||
upstream mjpgstreamer1 {
|
||||
ip_hash;
|
||||
server 127.0.0.1:8080;
|
||||
}
|
||||
|
||||
upstream mjpgstreamer2 {
|
||||
ip_hash;
|
||||
server 127.0.0.1:8081;
|
||||
}
|
||||
|
||||
upstream mjpgstreamer3 {
|
||||
ip_hash;
|
||||
server 127.0.0.1:8082;
|
||||
}
|
||||
|
||||
upstream mjpgstreamer4 {
|
||||
ip_hash;
|
||||
server 127.0.0.1:8083;
|
||||
}
|
||||
15
resources/webcamd.service
Normal file
15
resources/webcamd.service
Normal file
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Starts mjpg-streamer on startup
|
||||
After=network.target
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
User=%USER%
|
||||
WorkingDirectory=/usr/local/bin
|
||||
StandardOutput=append:/var/log/webcamd.log
|
||||
StandardError=append:/var/log/webcamd.log
|
||||
ExecStart=/usr/local/bin/webcamd
|
||||
Restart=always
|
||||
@@ -35,9 +35,9 @@ read_bb4u_stat(){
|
||||
fi
|
||||
}
|
||||
|
||||
##############################################################################################
|
||||
#********************************************************************************************#
|
||||
##############################################################################################
|
||||
################################################################################
|
||||
#******************************************************************************#
|
||||
################################################################################
|
||||
|
||||
backup_printer_cfg(){
|
||||
check_for_backup_dir
|
||||
@@ -68,17 +68,21 @@ backup_klipper_config_dir(){
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
###TODO re-evaluate if this function is still needed (just backup the full klipper_config dir instead?)
|
||||
backup_moonraker_conf(){
|
||||
backup_moonraker_database(){
|
||||
check_for_backup_dir
|
||||
if [ -f ${HOME}/moonraker.conf ]; then
|
||||
if ls -d ${HOME}/.moonraker_database* 2>/dev/null 1>&2; then
|
||||
get_date
|
||||
status_msg "Timestamp: $current_date"
|
||||
status_msg "Create backup of moonraker.conf ..."
|
||||
cp ${HOME}/moonraker.conf $BACKUP_DIR/moonraker.conf."$current_date".backup && ok_msg "Backup complete!"
|
||||
mkdir -p "$BACKUP_DIR/mr_db_backup/$current_date"
|
||||
for database in $(ls -d ${HOME}/.moonraker_database*)
|
||||
do
|
||||
status_msg "Create backup of $database ..."
|
||||
cp -r $database "$BACKUP_DIR/mr_db_backup/$current_date"
|
||||
ok_msg "Done!"
|
||||
done
|
||||
ok_msg "Backup complete!\n"
|
||||
else
|
||||
ok_msg "No moonraker.conf found! Skipping backup ..."
|
||||
ok_msg "No Moonraker database found! Skipping backup ..."
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -175,3 +179,17 @@ backup_klipperscreen(){
|
||||
ERROR_MSG=" Can't backup KlipperScreen directory!\n Not found!"
|
||||
fi
|
||||
}
|
||||
|
||||
backup_MoonrakerTelegramBot(){
|
||||
if [ -d $MOONRAKER_TELEGRAM_BOT_DIR ] ; then
|
||||
status_msg "Creating MoonrakerTelegramBot backup ..."
|
||||
check_for_backup_dir
|
||||
get_date
|
||||
status_msg "Timestamp: $current_date"
|
||||
mkdir -p $BACKUP_DIR/MoonrakerTelegramBot-backups/"$current_date"
|
||||
cp -r $MOONRAKER_TELEGRAM_BOT_DIR $_
|
||||
ok_msg "Backup complete!"
|
||||
else
|
||||
ERROR_MSG=" Can't backup MoonrakerTelegramBot directory!\n Not found!"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ install_packages()
|
||||
|
||||
# Update system package info
|
||||
report_status "Running apt-get update..."
|
||||
sudo apt-get update
|
||||
sudo apt-get update --allow-releaseinfo-change
|
||||
|
||||
# Install desired packages
|
||||
report_status "Installing packages..."
|
||||
|
||||
@@ -25,7 +25,7 @@ install_packages()
|
||||
|
||||
# Update system package info
|
||||
report_status "Running apt-get update..."
|
||||
sudo apt-get update
|
||||
sudo apt-get update --allow-releaseinfo-change
|
||||
|
||||
# Install desired packages
|
||||
report_status "Installing packages..."
|
||||
|
||||
334
scripts/flash_mcu.sh
Executable file
334
scripts/flash_mcu.sh
Executable file
@@ -0,0 +1,334 @@
|
||||
#!/bin/bash
|
||||
|
||||
show_flash_method_help(){
|
||||
top_border
|
||||
echo -e "| ~~~~~~~~ < ? > Help: Flash MCU < ? > ~~~~~~~~ |"
|
||||
hr
|
||||
echo -e "| ${cyan}Regular flashing method:${default} |"
|
||||
echo -e "| The default method to flash controller boards which |"
|
||||
echo -e "| are connected and updated over USB and not by placing |"
|
||||
echo -e "| a compiled firmware file onto an internal SD-Card. |"
|
||||
blank_line
|
||||
echo -e "| Common controllers that get flashed that way are: |"
|
||||
echo -e "| - Arduino Mega 2560 |"
|
||||
echo -e "| - Fysetc F6 / S6 (used without a Display + SD-Slot) |"
|
||||
blank_line
|
||||
echo -e "| ${cyan}Updating via SD-Card Update:${default} |"
|
||||
echo -e "| Many popular controller boards ship with a bootloader |"
|
||||
echo -e "| capable of updating the firmware via SD-Card. |"
|
||||
echo -e "| Choose this method if your controller board supports |"
|
||||
echo -e "| this way of updating. This method ONLY works for up- |"
|
||||
echo -e "| grading firmware. The initial flashing procedure must |"
|
||||
echo -e "| be done manually per the instructions that apply to |"
|
||||
echo -e "| your controller board. |"
|
||||
blank_line
|
||||
echo -e "| Common controllers that can be flashed that way are: |"
|
||||
echo -e "| - BigTreeTech SKR 1.3 / 1.4 (Turbo) / E3 / Mini E3 |"
|
||||
echo -e "| - Fysetc F6 / S6 (used with a Display + SD-Slot) |"
|
||||
echo -e "| - Fysetc Spider |"
|
||||
blank_line
|
||||
back_footer
|
||||
while true; do
|
||||
read -p "${cyan}###### Please select:${default} " choice
|
||||
case "$choice" in
|
||||
B|b)
|
||||
clear && print_header
|
||||
select_flash_method
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
select_flash_method(){
|
||||
top_border
|
||||
echo -e "| ~~~~~~~~~~~~ [ Flash MCU ] ~~~~~~~~~~~~ |"
|
||||
hr
|
||||
echo -e "| Please select the flashing method to flash your MCU. |"
|
||||
echo -e "| Make sure to only select a method your MCU supports. |"
|
||||
echo -e "| Not all MCUs support both methods! |"
|
||||
hr
|
||||
blank_line
|
||||
echo -e "| 1) Regular flashing method |"
|
||||
echo -e "| 2) Updating via SD-Card Update |"
|
||||
blank_line
|
||||
back_help_footer
|
||||
while true; do
|
||||
read -p "${cyan}###### Please select:${default} " choice
|
||||
case "$choice" in
|
||||
1)
|
||||
echo -e "###### > Regular flashing method"
|
||||
select_mcu_connection
|
||||
select_mcu_id
|
||||
[[ "$CONFIRM_FLASH" == true ]] && flash_mcu
|
||||
break;;
|
||||
2)
|
||||
echo -e "###### > SD-Card Update"
|
||||
select_mcu_connection
|
||||
select_mcu_id
|
||||
[[ "$CONFIRM_FLASH" == true ]] && flash_mcu_sd
|
||||
break;;
|
||||
B|b)
|
||||
advanced_menu
|
||||
break;;
|
||||
H|h)
|
||||
clear && print_header
|
||||
show_flash_method_help
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
select_mcu_id(){
|
||||
if [ ${#mcu_list[@]} -ge 1 ]; then
|
||||
top_border
|
||||
echo -e "| ${red}!!! ATTENTION !!!${default} |"
|
||||
hr
|
||||
echo -e "| Make sure, to select the correct MCU! |"
|
||||
echo -e "| ${red}ONLY flash a firmware created for the respective MCU!${default} |"
|
||||
bottom_border
|
||||
echo -e "${cyan}###### List of available MCU:${default}"
|
||||
### list all mcus
|
||||
id=0
|
||||
for mcu in ${mcu_list[@]}; do
|
||||
let id++
|
||||
echo -e " $id) $mcu"
|
||||
done
|
||||
### verify user input
|
||||
sel_index=""
|
||||
while [[ ! ($sel_index =~ ^[1-9]+$) ]] || [ "$sel_index" -gt "$id" ]; do
|
||||
echo
|
||||
read -p "${cyan}###### Select MCU to flash:${default} " sel_index
|
||||
if [[ ! ($sel_index =~ ^[1-9]+$) ]]; then
|
||||
warn_msg "Invalid input!"
|
||||
elif [ "$sel_index" -lt 1 ] || [ "$sel_index" -gt "$id" ]; then
|
||||
warn_msg "Please select a number between 1 and $id!"
|
||||
fi
|
||||
mcu_index=$(echo $((sel_index - 1)))
|
||||
selected_mcu_id="${mcu_list[$mcu_index]}"
|
||||
done
|
||||
### confirm selection
|
||||
while true; do
|
||||
echo -e "\n###### You selected:\n ● MCU #$sel_index: $selected_mcu_id\n"
|
||||
read -p "${cyan}###### Continue? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
echo -e "###### > Yes"
|
||||
status_msg "Flashing $selected_mcu_id ..."
|
||||
CONFIRM_FLASH=true
|
||||
break;;
|
||||
N|n|No|no)
|
||||
echo -e "###### > No"
|
||||
CONFIRM_FLASH=false
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
flash_mcu(){
|
||||
do_action_service "stop" "klipper"
|
||||
make flash FLASH_DEVICE="${mcu_list[$mcu_index]}"
|
||||
### evaluate exit code of make flash
|
||||
if [ ! $? -eq 0 ]; then
|
||||
warn_msg "Flashing failed!"
|
||||
warn_msg "Please read the console output above!"
|
||||
else
|
||||
ok_msg "Flashing successfull!"
|
||||
fi
|
||||
do_action_service "start" "klipper"
|
||||
}
|
||||
|
||||
flash_mcu_sd(){
|
||||
flash_script="${HOME}/klipper/scripts/flash-sdcard.sh"
|
||||
|
||||
### write each supported board to the array to make it selectable
|
||||
board_list=()
|
||||
for board in $("$flash_script" -l | tail -n +2); do
|
||||
board_list+=($board)
|
||||
done
|
||||
|
||||
i=0
|
||||
top_border
|
||||
echo -e "| Please select the type of board that corresponds to |"
|
||||
echo -e "| the currently selected MCU ID you chose before. |"
|
||||
blank_line
|
||||
echo -e "| The following boards are currently supported: |"
|
||||
hr
|
||||
### display all supported boards to the user
|
||||
for board in ${board_list[@]}; do
|
||||
if [ $i -lt 10 ]; then
|
||||
printf "| $i) %-50s|\n" "${board_list[$i]}"
|
||||
else
|
||||
printf "| $i) %-49s|\n" "${board_list[$i]}"
|
||||
fi
|
||||
i=$((i + 1))
|
||||
done
|
||||
quit_footer
|
||||
|
||||
### make the user select one of the boards
|
||||
while true; do
|
||||
read -p "${cyan}###### Please select board type:${default} " choice
|
||||
if [ "$choice" = "q" ] || [ "$choice" = "Q" ]; then
|
||||
clear && advanced_menu && break
|
||||
elif [ "$choice" -le ${#board_list[@]} ]; then
|
||||
selected_board="${board_list[$choice]}"
|
||||
break
|
||||
else
|
||||
clear && print_header
|
||||
ERROR_MSG="Invalid choice!" && print_msg && clear_msg
|
||||
flash_mcu_sd
|
||||
fi
|
||||
done
|
||||
|
||||
while true; do
|
||||
top_border
|
||||
echo -e "| If your board is flashed with firmware that connects |"
|
||||
echo -e "| at a custom baud rate, please change it now. |"
|
||||
blank_line
|
||||
echo -e "| If you are unsure, stick to the default 250000! |"
|
||||
bottom_border
|
||||
echo -e "${cyan}###### Please set the baud rate:${default} "
|
||||
unset baud_rate
|
||||
while [[ ! $baud_rate =~ ^[0-9]+$ ]]; do
|
||||
read -e -i "250000" -e baud_rate
|
||||
selected_baud_rate=$baud_rate
|
||||
break
|
||||
done
|
||||
break
|
||||
done
|
||||
|
||||
###flash process
|
||||
do_action_service "stop" "klipper"
|
||||
"$flash_script" -b "$selected_baud_rate" "$selected_mcu_id" "$selected_board"
|
||||
### evaluate exit code of flash-sdcard.sh execution
|
||||
if [ ! $? -eq 0 ]; then
|
||||
warn_msg "Flashing failed!"
|
||||
warn_msg "Please read the console output above!"
|
||||
else
|
||||
ok_msg "Flashing successfull!"
|
||||
fi
|
||||
do_action_service "start" "klipper"
|
||||
}
|
||||
|
||||
build_fw(){
|
||||
if [ -d "$KLIPPER_DIR" ]; then
|
||||
cd "$KLIPPER_DIR"
|
||||
status_msg "Initializing firmware build ..."
|
||||
dep=(build-essential dpkg-dev make)
|
||||
dependency_check
|
||||
make clean && make menuconfig
|
||||
status_msg "Building firmware ..."
|
||||
make && ok_msg "Firmware built!"
|
||||
else
|
||||
ERROR_MSG="Klipper was not found!\n Can not build firmware without Klipper!"
|
||||
print_msg && clear_msg && return 1
|
||||
fi
|
||||
}
|
||||
|
||||
select_mcu_connection(){
|
||||
echo
|
||||
top_border
|
||||
echo -e "| ${yellow}Make sure to have the controller board connected now!${default} |"
|
||||
blank_line
|
||||
echo -e "| How is the controller board connected to the host? |"
|
||||
echo -e "| 1) USB |"
|
||||
echo -e "| 2) UART |"
|
||||
bottom_border
|
||||
while true; do
|
||||
read -p "${cyan}###### Connection method:${default} " choice
|
||||
case "$choice" in
|
||||
1)
|
||||
retrieve_id "USB"
|
||||
break;;
|
||||
2)
|
||||
retrieve_id "UART"
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
unset mcu_count
|
||||
|
||||
if [[ "${#mcu_list[@]}" -lt 1 ]]; then
|
||||
warn_msg "No MCU found!"
|
||||
warn_msg "MCU not plugged in or not detectable!"
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
retrieve_id(){
|
||||
status_msg "Identifying MCU ..."
|
||||
sleep 1
|
||||
mcu_list=()
|
||||
mcu_count=1
|
||||
[ "$1" = "USB" ] && path="/dev/serial/by-id/*"
|
||||
[ "$1" = "UART" ] && path="/dev/ttyAMA0"
|
||||
if [[ "$(ls $path)" != "" ]] ; then
|
||||
for mcu in $path; do
|
||||
declare "mcu_id_$mcu_count"="$mcu"
|
||||
mcu_id="mcu_id_$mcu_count"
|
||||
mcu_list+=("${!mcu_id}")
|
||||
echo -e " ● ($1) MCU #$mcu_count: ${cyan}$mcu${default}\n"
|
||||
let mcu_count++
|
||||
done
|
||||
fi 2>/dev/null
|
||||
}
|
||||
|
||||
check_usergroup_dialout(){
|
||||
if grep -q "dialout" </etc/group && ! grep -q "dialout" <(groups "${USER}"); then
|
||||
group_dialout=false
|
||||
else
|
||||
group_dialout=true
|
||||
fi
|
||||
if grep -q "tty" </etc/group && ! grep -q "tty" <(groups "${USER}"); then
|
||||
group_tty=false
|
||||
else
|
||||
group_tty=true
|
||||
fi
|
||||
if [ "$group_dialout" == "false" ] || [ "$group_tty" == "false" ] ; then
|
||||
top_border
|
||||
echo -e "| ${yellow}WARNING: Your current user is not in group:${default} |"
|
||||
[ "$group_tty" == "false" ] && echo -e "| ${yellow}● tty${default} |"
|
||||
[ "$group_dialout" == "false" ] && echo -e "| ${yellow}● dialout${default} |"
|
||||
blank_line
|
||||
echo -e "| It is possible that you won't be able to successfully |"
|
||||
echo -e "| flash without your user being a member of that group. |"
|
||||
echo -e "| If you want to add the current user to the group(s) |"
|
||||
echo -e "| listed above, answer with 'Y'. Else skip with 'n'. |"
|
||||
blank_line
|
||||
echo -e "| ${yellow}INFO:${default} |"
|
||||
echo -e "| ${yellow}Relog required for group assignments to take effect!${default} |"
|
||||
bottom_border
|
||||
while true; do
|
||||
read -p "${cyan}###### Add user '${USER}' to group(s) now? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
echo -e "###### > Yes"
|
||||
status_msg "Adding user '${USER}' to group(s) ..."
|
||||
if [ "$group_tty" == "false" ]; then
|
||||
sudo usermod -a -G tty "${USER}" && ok_msg "Group 'tty' assigned!"
|
||||
fi
|
||||
if [ "$group_dialout" == "false" ]; then
|
||||
sudo usermod -a -G dialout "${USER}" && ok_msg "Group 'dialout' assigned!"
|
||||
fi
|
||||
ok_msg "You need to relog/restart for the group(s) to be applied!" && exit 0;;
|
||||
N|n|No|no)
|
||||
echo -e "###### > No"
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
### base variables
|
||||
SYSTEMDDIR="/etc/systemd/system"
|
||||
|
||||
# setting up some frequently used functions
|
||||
check_euid(){
|
||||
if [ "$EUID" -eq 0 ]
|
||||
@@ -77,54 +80,57 @@ change_klipper_cfg_path(){
|
||||
done
|
||||
}
|
||||
|
||||
###? if path was changed in 'change_klipper_cfg_path', we need to edit the service files
|
||||
###? and set the new path. after that, rename the old folder and reload service units.
|
||||
###! users shouldn't try and move the files into subfolders with this function! as the mv command will fail
|
||||
###! but the new path still gets written to the service files. if they really need to, they need to move all
|
||||
###! config files or printer folder into that subfolder (still not recommended!)
|
||||
set_klipper_cfg_path(){
|
||||
### stop services
|
||||
klipper_service "stop" && moonraker_service "stop"
|
||||
do_action_service "stop" "klipper"
|
||||
do_action_service "stop" "moonraker"
|
||||
|
||||
### rename the klipper config folder
|
||||
### copy config files to new klipper config folder
|
||||
if [ ! -z "$old_klipper_cfg_loc" ] && [ -d "$old_klipper_cfg_loc" ]; then
|
||||
status_msg "Renaming '$old_klipper_cfg_loc' to '$new_klipper_cfg_loc'!"; echo
|
||||
mv -v "$old_klipper_cfg_loc" "$new_klipper_cfg_loc" && ok_msg "Done!"
|
||||
if [ ! -d "$new_klipper_cfg_loc" ]; then
|
||||
status_msg "Copy config files to '$new_klipper_cfg_loc' ..."
|
||||
mkdir -p "$new_klipper_cfg_loc"
|
||||
cd $old_klipper_cfg_loc
|
||||
cp -r -v ./* "$new_klipper_cfg_loc"
|
||||
ok_msg "Done!"
|
||||
fi
|
||||
fi
|
||||
|
||||
SERVICE_FILES=$(find "$SYSTEMDDIR" -regextype posix-extended -regex "$SYSTEMDDIR/klipper(-[^0])+[0-9]*.service")
|
||||
### handle single klipper instance service file
|
||||
if [ -f /etc/systemd/system/klipper.service ]; then
|
||||
if [ -f $SYSTEMDDIR/klipper.service ]; then
|
||||
status_msg "Configuring Klipper for new path ..."
|
||||
sudo sed -i "/ExecStart=/ s|$old_klipper_cfg_loc/printer.cfg|$new_klipper_cfg_loc/printer.cfg|" /etc/systemd/system/klipper.service
|
||||
sudo sed -i -r "/ExecStart=/ s|klippy.py (.+)\/printer.cfg|klippy.py $new_klipper_cfg_loc/printer.cfg|" $SYSTEMDDIR/klipper.service
|
||||
ok_msg "OK!"
|
||||
fi
|
||||
### handle multi klipper instance service file
|
||||
if ls /etc/systemd/system/klipper-*.service 2>/dev/null 1>&2; then
|
||||
elif [ -n "$SERVICE_FILES" ]; then
|
||||
### handle multi klipper instance service file
|
||||
status_msg "Configuring Klipper for new path ..."
|
||||
for service in $(find /etc/systemd/system/klipper-*.service); do
|
||||
sudo sed -i "/ExecStart=/ s|$old_klipper_cfg_loc/printer_|$new_klipper_cfg_loc/printer_|" $service
|
||||
for service in $SERVICE_FILES; do
|
||||
sudo sed -i -r "/ExecStart=/ s|klippy.py (.+)\/printer_|klippy.py $new_klipper_cfg_loc/printer_|" "$service"
|
||||
done
|
||||
ok_msg "OK!"
|
||||
fi
|
||||
|
||||
SERVICE_FILES=$(find "$SYSTEMDDIR" -regextype posix-extended -regex "$SYSTEMDDIR/moonraker(-[^0])+[0-9]*.service")
|
||||
### handle single moonraker instance service and moonraker.conf file
|
||||
if [ -f /etc/systemd/system/moonraker.service ]; then
|
||||
if [ -f $SYSTEMDDIR/moonraker.service ]; then
|
||||
status_msg "Configuring Moonraker for new path ..."
|
||||
sudo sed -i "/ExecStart=/ s|$old_klipper_cfg_loc/moonraker.conf|$new_klipper_cfg_loc/moonraker.conf|" /etc/systemd/system/moonraker.service
|
||||
sudo sed -i -r "/ExecStart=/ s|-c (.+)\/moonraker\.conf|-c $new_klipper_cfg_loc/moonraker.conf|" $SYSTEMDDIR/moonraker.service
|
||||
|
||||
### replace old file path with new one in moonraker.conf
|
||||
sed -i "/config_path:/ s|config_path:.*|config_path: $new_klipper_cfg_loc|" $new_klipper_cfg_loc/moonraker.conf
|
||||
sed -i -r "/config_path:/ s|config_path:.*|config_path: $new_klipper_cfg_loc|" $new_klipper_cfg_loc/moonraker.conf
|
||||
ok_msg "OK!"
|
||||
fi
|
||||
### handle multi moonraker instance service file
|
||||
if ls /etc/systemd/system/moonraker-*.service 2>/dev/null 1>&2; then
|
||||
elif [ -n "$SERVICE_FILES" ]; then
|
||||
### handle multi moonraker instance service file
|
||||
status_msg "Configuring Moonraker for new path ..."
|
||||
for service in $(find /etc/systemd/system/moonraker-*.service); do
|
||||
sudo sed -i "/ExecStart=/ s|$old_klipper_cfg_loc/printer_|$new_klipper_cfg_loc/printer_|" $service
|
||||
for service in $SERVICE_FILES; do
|
||||
sudo sed -i -r "/ExecStart=/ s|-c (.+)\/printer_|-c $new_klipper_cfg_loc/printer_|" "$service"
|
||||
done
|
||||
MR_CONFS=$(find "$new_klipper_cfg_loc" -regextype posix-extended -regex "$new_klipper_cfg_loc/printer_[1-9]+/moonraker.conf")
|
||||
### replace old file path with new one in moonraker.conf
|
||||
for moonraker_conf in $(find $new_klipper_cfg_loc/printer_*/moonraker.conf); do
|
||||
for moonraker_conf in $MR_CONFS; do
|
||||
loc=$(echo "$moonraker_conf" | rev | cut -d"/" -f2- | rev)
|
||||
sed -i "/config_path:/ s|config_path:.*|config_path: $loc|" $moonraker_conf
|
||||
sed -i -r "/config_path:/ s|config_path:.*|config_path: $loc|" "$moonraker_conf"
|
||||
done
|
||||
ok_msg "OK!"
|
||||
fi
|
||||
@@ -133,77 +139,17 @@ set_klipper_cfg_path(){
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
### restart services
|
||||
klipper_service "restart" && moonraker_service "restart"
|
||||
do_action_service "restart" "klipper"
|
||||
do_action_service "restart" "moonraker"
|
||||
}
|
||||
|
||||
source_kiauh_ini(){
|
||||
source $INI_FILE
|
||||
}
|
||||
|
||||
klipper_service(){
|
||||
### set a variable for the ok and status messages
|
||||
[ "$1" == "start" ] && ACTION1="started" && ACTION2="Starting"
|
||||
[ "$1" == "stop" ] && ACTION1="stopped" && ACTION2="Stopping"
|
||||
[ "$1" == "restart" ] && ACTION1="restarted" && ACTION2="Restarting"
|
||||
|
||||
if ls /etc/systemd/system/klipper-*.service 2>/dev/null 1>&2; then
|
||||
INSTANCE_COUNT=$(systemctl list-units --full -all -t service --no-legend | grep -E "klipper-[[:digit:]].service" | wc -l)
|
||||
INSTANCE=1
|
||||
status_msg "$ACTION2 $INSTANCE_COUNT Klipper Services ..."
|
||||
while [ $INSTANCE -le $INSTANCE_COUNT ]; do
|
||||
sudo systemctl $1 klipper-$INSTANCE && ok_msg "Klipper Service #$INSTANCE $ACTION1!"
|
||||
### instance counter +1
|
||||
INSTANCE=$(expr $INSTANCE + 1)
|
||||
done
|
||||
elif [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "klipper.service")" ]; then
|
||||
status_msg "$ACTION2 Klipper Service ..."
|
||||
sudo systemctl $1 klipper && ok_msg "Klipper Service $ACTION1!"
|
||||
fi
|
||||
}
|
||||
|
||||
moonraker_service(){
|
||||
### set a variable for the ok and status messages
|
||||
[ "$1" == "start" ] && ACTION1="started" && ACTION2="Starting"
|
||||
[ "$1" == "stop" ] && ACTION1="stopped" && ACTION2="Stopping"
|
||||
[ "$1" == "restart" ] && ACTION1="restarted" && ACTION2="Restarting"
|
||||
|
||||
if ls /etc/systemd/system/moonraker-*.service 2>/dev/null 1>&2; then
|
||||
INSTANCE_COUNT=$(systemctl list-units --full -all -t service --no-legend | grep -E "moonraker-[[:digit:]].service" | wc -l)
|
||||
INSTANCE=1
|
||||
status_msg "$ACTION2 $INSTANCE_COUNT Moonraker Services ..."
|
||||
while [ $INSTANCE -le $INSTANCE_COUNT ]; do
|
||||
sudo systemctl $1 moonraker-$INSTANCE && ok_msg "Moonraker Service #$INSTANCE $ACTION1!"
|
||||
### instance counter +1
|
||||
INSTANCE=$(expr $INSTANCE + 1)
|
||||
done
|
||||
elif [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "moonraker.service")" ]; then
|
||||
status_msg "$ACTION2 Moonraker Service ..."
|
||||
sudo systemctl $1 moonraker && ok_msg "Moonraker Service $ACTION1!"
|
||||
fi
|
||||
}
|
||||
|
||||
dwc_service(){
|
||||
### set a variable for the ok and status messages
|
||||
[ "$1" == "start" ] && ACTION1="started" && ACTION2="Starting"
|
||||
[ "$1" == "stop" ] && ACTION1="stopped" && ACTION2="Stopping"
|
||||
[ "$1" == "restart" ] && ACTION1="restarted" && ACTION2="Restarting"
|
||||
|
||||
if ls /etc/systemd/system/dwc-*.service 2>/dev/null 1>&2; then
|
||||
INSTANCE_COUNT=$(systemctl list-units --full -all -t service --no-legend | grep -E "dwc-[[:digit:]].service" | wc -l)
|
||||
INSTANCE=1
|
||||
status_msg "$ACTION2 $INSTANCE_COUNT DWC-for-Klipper-Socket Services ..."
|
||||
while [ $INSTANCE -le $INSTANCE_COUNT ]; do
|
||||
sudo systemctl $1 dwc-$INSTANCE && ok_msg "DWC-for-Klipper-Socket Service #$INSTANCE $ACTION1!"
|
||||
### instance counter +1
|
||||
INSTANCE=$(expr $INSTANCE + 1)
|
||||
done
|
||||
elif [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "dwc.service")" ]; then
|
||||
status_msg "$ACTION2 DWC-for-Klipper-Socket Service ..."
|
||||
sudo systemctl $1 dwc && ok_msg "DWC-for-Klipper-Socket Service $ACTION1!"
|
||||
fi
|
||||
}
|
||||
|
||||
octoprint_service(){
|
||||
do_action_service(){
|
||||
shopt -s extglob # enable extended globbing
|
||||
SERVICES="$SYSTEMDDIR/$2?(-*([0-9])).service"
|
||||
### set a variable for the ok and status messages
|
||||
[ "$1" == "start" ] && ACTION1="started" && ACTION2="Starting"
|
||||
[ "$1" == "stop" ] && ACTION1="stopped" && ACTION2="Stopping"
|
||||
@@ -211,30 +157,25 @@ octoprint_service(){
|
||||
[ "$1" == "enable" ] && ACTION1="enabled" && ACTION2="Enabling"
|
||||
[ "$1" == "disable" ] && ACTION1="disabled" && ACTION2="Disabling"
|
||||
|
||||
if ls /etc/systemd/system/octoprint-*.service 2>/dev/null 1>&2; then
|
||||
INSTANCE=1
|
||||
INSTANCE_COUNT=$(systemctl list-unit-files | grep -E "octoprint.*" | wc -l)
|
||||
status_msg "$ACTION2 $INSTANCE_COUNT OctoPrint Services ..."
|
||||
while [ $INSTANCE -le $INSTANCE_COUNT ]; do
|
||||
sudo systemctl $1 octoprint-$INSTANCE && ok_msg "OctoPrint Service #$INSTANCE $ACTION1!"
|
||||
### instance counter +1
|
||||
INSTANCE=$(expr $INSTANCE + 1)
|
||||
if ls $SERVICES 2>/dev/null 1>&2; then
|
||||
for service in $(ls $SERVICES | rev | cut -d"/" -f1 | rev); do
|
||||
status_msg "$ACTION2 $service ..."
|
||||
sudo systemctl $1 "$service"
|
||||
ok_msg "$service $ACTION1!"
|
||||
done
|
||||
elif [ "$(systemctl list-unit-files | grep -E "octoprint.*")" ]; then
|
||||
status_msg "$ACTION2 OctoPrint Service ..."
|
||||
sudo systemctl $1 octoprint && ok_msg "OctoPrint Service $ACTION1!"
|
||||
fi
|
||||
shopt -u extglob # disable extended globbing
|
||||
}
|
||||
|
||||
toggle_octoprint_service(){
|
||||
if systemctl list-unit-files | grep -E "octoprint.*" | grep "enabled" &>/dev/null; then
|
||||
octoprint_service "stop"
|
||||
octoprint_service "disable"
|
||||
do_action_service "stop" "octoprint"
|
||||
do_action_service "disable" "octoprint"
|
||||
sleep 2
|
||||
CONFIRM_MSG=" OctoPrint Service is now >>> DISABLED <<< !"
|
||||
elif systemctl list-unit-files | grep -E "octoprint.*" | grep "disabled" &>/dev/null; then
|
||||
octoprint_service "enable"
|
||||
octoprint_service "start"
|
||||
do_action_service "enable" "octoprint"
|
||||
do_action_service "start" "octoprint"
|
||||
sleep 2
|
||||
CONFIRM_MSG=" OctoPrint Service is now >>> ENABLED <<< !"
|
||||
else
|
||||
@@ -244,6 +185,9 @@ toggle_octoprint_service(){
|
||||
|
||||
read_octoprint_service_status(){
|
||||
unset OPRINT_SERVICE_STATUS
|
||||
if [ ! -f "/etc/systemd/system/octoprint.service" ]; then
|
||||
return 0
|
||||
fi
|
||||
if systemctl list-unit-files | grep -E "octoprint*" | grep "enabled" &>/dev/null; then
|
||||
OPRINT_SERVICE_STATUS="${red}[Disable]${default} OctoPrint Service "
|
||||
else
|
||||
@@ -266,8 +210,23 @@ restart_klipperscreen(){
|
||||
sudo systemctl restart KlipperScreen && ok_msg "KlipperScreen Service restarted!"
|
||||
}
|
||||
|
||||
start_MoonrakerTelegramBot(){
|
||||
status_msg "Starting MoonrakerTelegramBot Service ..."
|
||||
sudo systemctl start moonraker-telegram-bot && ok_msg "MoonrakerTelegramBot Service started!"
|
||||
}
|
||||
|
||||
stop_MoonrakerTelegramBot(){
|
||||
status_msg "Stopping MoonrakerTelegramBot Service ..."
|
||||
sudo systemctl stop moonraker-telegram-bot && ok_msg "MoonrakerTelegramBot Service stopped!"
|
||||
}
|
||||
|
||||
restart_MoonrakerTelegramBot(){
|
||||
status_msg "Restarting MoonrakerTelegramBot Service ..."
|
||||
sudo systemctl restart moonraker-telegram-bot && ok_msg "MoonrakerTelegramBot Service restarted!"
|
||||
}
|
||||
|
||||
restart_nginx(){
|
||||
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "nginx.service")" ]; then
|
||||
if ls /lib/systemd/system/nginx.service 2>/dev/null 1>&2; then
|
||||
status_msg "Restarting NGINX Service ..."
|
||||
sudo systemctl restart nginx && ok_msg "NGINX Service restarted!"
|
||||
fi
|
||||
@@ -291,7 +250,7 @@ dependency_check(){
|
||||
echo -e "${cyan}● $element ${default}"
|
||||
done
|
||||
echo
|
||||
sudo apt-get install ${inst[@]} -y
|
||||
sudo apt-get update --allow-releaseinfo-change && sudo apt-get install ${inst[@]} -y
|
||||
ok_msg "Dependencies installed!"
|
||||
#clearing the array
|
||||
unset inst
|
||||
@@ -333,10 +292,8 @@ setup_gcode_shell_command(){
|
||||
Y|y|Yes|yes|"")
|
||||
if [ -d $KLIPPER_DIR/klippy/extras ]; then
|
||||
status_msg "Installing gcode shell command extension ..."
|
||||
status_msg "Copy gcode_shell_command.py to '$KLIPPER_DIR/klippy/extras' ..."
|
||||
if [ -f $KLIPPER_DIR/klippy/extras/gcode_shell_command.py ]; then
|
||||
warn_msg "There is already a file named 'gcode_shell_command.py'"
|
||||
warn_msg "in the destination location!"
|
||||
warn_msg "There is already a file named 'gcode_shell_command.py'\nin the destination location!"
|
||||
while true; do
|
||||
read -p "${cyan}###### Do you want to overwrite it? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
@@ -365,11 +322,11 @@ setup_gcode_shell_command(){
|
||||
}
|
||||
|
||||
install_gcode_shell_command(){
|
||||
klipper_service "stop"
|
||||
status_msg "Copy 'gcode_shell_command.py' to $KLIPPER_DIR/klippy/extras"
|
||||
do_action_service "stop" "klipper"
|
||||
status_msg "Copy 'gcode_shell_command.py' to '$KLIPPER_DIR/klippy/extras' ..."
|
||||
cp ${SRCDIR}/kiauh/resources/gcode_shell_command.py $KLIPPER_DIR/klippy/extras
|
||||
echo
|
||||
while true; do
|
||||
echo
|
||||
read -p "${cyan}###### Do you want to create the example shell command? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
@@ -407,7 +364,7 @@ install_gcode_shell_command(){
|
||||
esac
|
||||
done
|
||||
ok_msg "Shell command extension installed!"
|
||||
klipper_service "restart"
|
||||
do_action_service "restart" "klipper"
|
||||
}
|
||||
|
||||
create_minimal_cfg(){
|
||||
@@ -431,49 +388,6 @@ EOF
|
||||
fi
|
||||
}
|
||||
|
||||
read_printer_cfg(){
|
||||
KIAUH_CFG="$(dirname $PRINTER_CFG)/kiauh.cfg"
|
||||
[ ! -f $KIAUH_CFG ] && KIAUH_CFG_FOUND="false" || KIAUH_CFG_FOUND="true"
|
||||
if [ -f $PRINTER_CFG ]; then
|
||||
if [ "$1" = "moonraker" ]; then
|
||||
[ ! "$(grep '^\[virtual_sdcard\]$' $PRINTER_CFG)" ] && VSD="false" && EDIT_CFG="true"
|
||||
[ ! "$(grep '^\[pause_resume\]$' $PRINTER_CFG)" ] && PAUSE_RESUME="false" && EDIT_CFG="true"
|
||||
[ ! "$(grep '^\[display_status\]$' $PRINTER_CFG)" ] && DISPLAY_STATUS="false" && EDIT_CFG="true"
|
||||
elif [ "$1" = "mainsail" ] || [ "$1" = "fluidd" ]; then
|
||||
[ ! "$(grep '^\[include webui_macros\.cfg\]$' $PRINTER_CFG)" ] && WEBUI_MACROS="false" && EDIT_CFG="true"
|
||||
elif [ "$1" = "dwc2" ]; then
|
||||
[ ! "$(grep '^\[virtual_sdcard\]$' $PRINTER_CFG)" ] && VSD="false" && EDIT_CFG="true"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
write_printer_cfg(){
|
||||
#backup printer.cfg if edits will be written
|
||||
[ "$EDIT_CFG" = "true" ] && backup_printer_cfg
|
||||
#create kiauh.cfg if its needed and doesn't exist
|
||||
if [ "$KIAUH_CFG_FOUND" = "false" ] && [ "$EDIT_CFG" = "true" ]; then
|
||||
status_msg "Creating kiauh.cfg ..."
|
||||
echo -e "##### AUTOCREATED BY KIAUH #####" > $KIAUH_CFG
|
||||
fi
|
||||
#write each entry to kiauh.cfg if it doesn't exist
|
||||
#Moonraker/DWC2 related config options
|
||||
if [ "$VSD" = "false" ] && [[ ! $(grep '^\[virtual_sdcard\]$' $KIAUH_CFG) ]]; then
|
||||
echo -e "\n[virtual_sdcard]\npath: ~/sdcard" >> $KIAUH_CFG
|
||||
fi
|
||||
if [ "$PAUSE_RESUME" = "false" ] && [[ ! $(grep '^\[pause_resume]$' $KIAUH_CFG) ]]; then
|
||||
echo -e "\n[pause_resume]" >> $KIAUH_CFG
|
||||
fi
|
||||
if [ "$DISPLAY_STATUS" = "false" ] && [[ ! $(grep '^\[display_status]$' $KIAUH_CFG) ]]; then
|
||||
echo -e "\n[display_status]" >> $KIAUH_CFG
|
||||
fi
|
||||
#including the kiauh.cfg into printer.cfg if not already done
|
||||
if [ ! "$(grep '^\[include kiauh\.cfg\]$' $PRINTER_CFG)" ] && [ "$EDIT_CFG" = "true" ]; then
|
||||
status_msg "Writing [include kiauh.cfg] to printer.cfg ..."
|
||||
sed -i '1 i ##### AUTOCREATED BY KIAUH #####\n[include kiauh.cfg]' $PRINTER_CFG
|
||||
fi
|
||||
ok_msg "Done!"
|
||||
}
|
||||
|
||||
init_ini(){
|
||||
### copy an existing kiauh.ini to its new location to keep all possible saved values
|
||||
if [ -f ${SRCDIR}/kiauh/kiauh.ini ] && [ ! -f $INI_FILE ]; then
|
||||
@@ -501,4 +415,5 @@ init_ini(){
|
||||
if [ ! $(grep -E "^klipper_cfg_loc=" $INI_FILE) ]; then
|
||||
echo -e "\nklipper_cfg_loc=\c" >> $INI_FILE
|
||||
fi
|
||||
fetch_webui_ports
|
||||
}
|
||||
|
||||
@@ -33,13 +33,13 @@ dwc_setup_dialog(){
|
||||
|
||||
### ask user how to handle OctoPrint, Haproxy and Lighttpd
|
||||
process_octoprint_dialog_dwc2
|
||||
process_haproxy_lighttpd_dialog
|
||||
process_services_dialog
|
||||
|
||||
### instance confirmation dialog
|
||||
while true; do
|
||||
echo
|
||||
top_border
|
||||
if [ $INSTANCE_COUNT -gt 1 ]; then
|
||||
if [ "$INSTANCE_COUNT" -gt 1 ]; then
|
||||
printf "|%-55s|\n" " $INSTANCE_COUNT Klipper instances were found!"
|
||||
else
|
||||
echo -e "| 1 Klipper instance was found! | "
|
||||
@@ -118,7 +118,7 @@ dwc_setup(){
|
||||
|
||||
### step 1: get dwc2-for-klipper
|
||||
status_msg "Downloading DWC2-for-Klipper-Socket ..."
|
||||
cd ${HOME} && git clone $DWC2FK_REPO
|
||||
cd "${HOME}" && git clone "$DWC2FK_REPO"
|
||||
ok_msg "Download complete!"
|
||||
|
||||
### step 2: install dwc2 dependencies and create python virtualenv
|
||||
@@ -127,7 +127,7 @@ dwc_setup(){
|
||||
create_dwc_virtualenv
|
||||
|
||||
### step 3: create dwc2.cfg folder and dwc2.cfg
|
||||
[ ! -d $DWC_CONF_LOC ] && mkdir -p $DWC_CONF_LOC
|
||||
[ ! -d "$DWC_CONF_LOC" ] && mkdir -p "$DWC_CONF_LOC"
|
||||
dwc_cfg_creation
|
||||
|
||||
### step 4: download Duet Web Control
|
||||
@@ -135,7 +135,7 @@ dwc_setup(){
|
||||
|
||||
### step 5: create dwc instances
|
||||
INSTANCE=1
|
||||
if [ $INSTANCE_COUNT -eq $INSTANCE ]; then
|
||||
if [ "$INSTANCE_COUNT" -eq $INSTANCE ]; then
|
||||
create_single_dwc_instance
|
||||
else
|
||||
#create_multi_dwc_instance
|
||||
@@ -147,18 +147,18 @@ download_dwc_webui(){
|
||||
#get Duet Web Control
|
||||
GET_DWC2_URL=$(curl -s https://api.github.com/repositories/28820678/releases/latest | grep browser_download_url | cut -d'"' -f4)
|
||||
status_msg "Downloading DWC2 Web UI ..."
|
||||
[ ! -d $DWC2_DIR ] && mkdir -p $DWC2_DIR
|
||||
cd $DWC2_DIR && wget $GET_DWC2_URL
|
||||
[ ! -d "$DWC2_DIR" ] && mkdir -p "$DWC2_DIR"
|
||||
cd "$DWC2_DIR" && wget "$GET_DWC2_URL"
|
||||
ok_msg "Download complete!"
|
||||
status_msg "Extracting archive ..."
|
||||
unzip -q -o *.zip
|
||||
for f_ in $(find . | grep '.gz')
|
||||
do
|
||||
gunzip -f ${f_}
|
||||
gunzip -f "${f_}"
|
||||
done
|
||||
ok_msg "Done!"
|
||||
status_msg "Writing DWC version to file ..."
|
||||
echo $GET_DWC2_URL | cut -d/ -f8 > $DWC2_DIR/.version
|
||||
echo "$GET_DWC2_URL" | cut -d/ -f8 > "$DWC2_DIR/.version"
|
||||
ok_msg "Done!"
|
||||
status_msg "Remove downloaded archive ..."
|
||||
rm -rf *.zip && ok_msg "Done!" && ok_msg "Duet Web Control installed!"
|
||||
@@ -174,11 +174,11 @@ install_dwc_packages()
|
||||
|
||||
# Update system package info
|
||||
status_msg "Running apt-get update..."
|
||||
sudo apt-get update
|
||||
sudo apt-get update --allow-releaseinfo-change
|
||||
|
||||
# Install desired packages
|
||||
status_msg "Installing packages..."
|
||||
sudo apt-get install --yes ${PKGLIST}
|
||||
sudo apt-get install --yes "${PKGLIST}"
|
||||
}
|
||||
|
||||
create_dwc_virtualenv()
|
||||
@@ -186,10 +186,10 @@ create_dwc_virtualenv()
|
||||
status_msg "Installing python virtual environment..."
|
||||
|
||||
# Create virtualenv if it doesn't already exist
|
||||
[ ! -d ${DWC_ENV} ] && virtualenv -p /usr/bin/python3 ${DWC_ENV}
|
||||
[ ! -d "${DWC_ENV}" ] && virtualenv -p /usr/bin/python3 "${DWC_ENV}"
|
||||
|
||||
# Install/update dependencies
|
||||
${DWC_ENV}/bin/pip install tornado==6.0.4
|
||||
"${DWC_ENV}"/bin/pip install tornado==6.0.4
|
||||
}
|
||||
|
||||
create_single_dwc_startscript(){
|
||||
@@ -303,7 +303,7 @@ create_single_dwc_instance(){
|
||||
|
||||
create_multi_dwc_instance(){
|
||||
status_msg "Setting up $INSTANCE_COUNT instances of Duet Web Control ..."
|
||||
while [ $INSTANCE -le $INSTANCE_COUNT ]; do
|
||||
while [ $INSTANCE -le "$INSTANCE_COUNT" ]; do
|
||||
### multi instance variables
|
||||
DWC_LOG=/tmp/dwc-$INSTANCE.log
|
||||
DWC_CFG="$DWC_CONF_LOC/printer_$INSTANCE/dwc2.cfg"
|
||||
@@ -348,7 +348,7 @@ dwc_cfg_creation(){
|
||||
dwc_ip_list=()
|
||||
|
||||
### create single instance dwc2.cfg file
|
||||
if [ $INSTANCE_COUNT -eq $INSTANCE ]; then
|
||||
if [ "$INSTANCE_COUNT" -eq $INSTANCE ]; then
|
||||
### set port
|
||||
PORT=$DEFAULT_PORT
|
||||
|
||||
@@ -356,8 +356,8 @@ dwc_cfg_creation(){
|
||||
dwc_ip_list+=("$HOSTNAME:$PORT")
|
||||
|
||||
status_msg "Creating dwc2.cfg in $DWC_CONF_LOC"
|
||||
[ ! -d $DWC_CONF_LOC ] && mkdir -p $DWC_CONF_LOC
|
||||
if [ ! -f $DWC_CONF_LOC/dwc2.cfg ]; then
|
||||
[ ! -d "$DWC_CONF_LOC" ] && mkdir -p "$DWC_CONF_LOC"
|
||||
if [ ! -f "$DWC_CONF_LOC/dwc2.cfg" ]; then
|
||||
create_single_dwcfk_cfg && ok_msg "dwc2.cfg created!"
|
||||
else
|
||||
warn_msg "There is already a file called 'dwc2.cfg'!"
|
||||
@@ -366,7 +366,7 @@ dwc_cfg_creation(){
|
||||
|
||||
### create multi instance moonraker.conf files
|
||||
else
|
||||
while [ $INSTANCE -le $INSTANCE_COUNT ]; do
|
||||
while [ $INSTANCE -le "$INSTANCE_COUNT" ]; do
|
||||
### set each instance to its own port
|
||||
PORT=$(expr $DEFAULT_PORT + $INSTANCE - 1)
|
||||
|
||||
@@ -375,8 +375,8 @@ dwc_cfg_creation(){
|
||||
|
||||
### start the creation of each instance
|
||||
status_msg "Creating dwc2.cfg for instance #$INSTANCE"
|
||||
[ ! -d $DWC_CONF_LOC/printer_$INSTANCE ] && mkdir -p $DWC_CONF_LOC/printer_$INSTANCE
|
||||
if [ ! -f $DWC_CONF_LOC/printer_$INSTANCE/dwc2.cfg ]; then
|
||||
[ ! -d "$DWC_CONF_LOC/printer_$INSTANCE" ] && mkdir -p "$DWC_CONF_LOC/printer_$INSTANCE"
|
||||
if [ ! -f "$DWC_CONF_LOC/printer_$INSTANCE/dwc2.cfg" ]; then
|
||||
create_multi_dwcfk_cfg && ok_msg "dwc2.cfg created!"
|
||||
else
|
||||
warn_msg "There is already a file called 'dwc2.cfg'!"
|
||||
|
||||
@@ -2,33 +2,49 @@
|
||||
SYSTEMDDIR="/etc/systemd/system"
|
||||
KLIPPY_ENV="${HOME}/klippy-env"
|
||||
KLIPPER_DIR="${HOME}/klipper"
|
||||
KLIPPER_REPO="https://github.com/Klipper3d/klipper.git"
|
||||
|
||||
klipper_setup_dialog(){
|
||||
status_msg "Initializing Klipper installation ..."
|
||||
|
||||
### check for existing klipper service installations
|
||||
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ] || [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "klipper-[[:digit:]].service")" ]; then
|
||||
ERROR_MSG="At least one Klipper service is already installed!\n Please remove Klipper first, before installing it again." && return 0
|
||||
SERVICE_FILES=""
|
||||
INITD_SERVICE_FILES=$(find "/etc/init.d" -regextype posix-extended -regex "/etc/init.d/klipper(-[^0])?[0-9]*")
|
||||
SYSTEMD_SERVICE_FILES=$(find "$SYSTEMDDIR" -regextype posix-extended -regex "$SYSTEMDDIR/klipper(-[^0])?[0-9]*.service")
|
||||
[ -n "$INITD_SERVICE_FILES" ] && SERVICE_FILES+="${INITD_SERVICE_FILES}"
|
||||
[ -n "$SYSTEMD_SERVICE_FILES" ] && SERVICE_FILES+=" ${SYSTEMD_SERVICE_FILES}"
|
||||
if [ -n "$SERVICE_FILES" ]; then
|
||||
ERROR_MSG="At least one Klipper service is already installed:"
|
||||
for service in $SERVICE_FILES; do
|
||||
ERROR_MSG="${ERROR_MSG}\n ➔ $service"
|
||||
done && return
|
||||
fi
|
||||
|
||||
status_msg "Initializing Klipper installation ..."
|
||||
|
||||
### initial printer.cfg path check
|
||||
check_klipper_cfg_path
|
||||
|
||||
### ask for amount of instances to create
|
||||
while true; do
|
||||
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 machine. |"
|
||||
blank_line
|
||||
echo -e "| ${yellow}WARNING: There is no limit on the number of instances${default} |"
|
||||
echo -e "| ${yellow}you can set up with this script.${default} |"
|
||||
bottom_border
|
||||
count=""
|
||||
while [[ ! ($count =~ ^[1-9]+((0)+)?$) ]]; do
|
||||
read -p "${cyan}###### Number of Klipper instances to set up:${default} " count
|
||||
if [[ ! ($count =~ ^[1-9]+((0)+)?$) ]]; then
|
||||
warn_msg "Invalid Input!" && echo
|
||||
else
|
||||
echo
|
||||
read -p "${cyan}###### How many Klipper instances do you want to set up?:${default} " INSTANCE_COUNT
|
||||
echo
|
||||
if [ $INSTANCE_COUNT == 1 ]; then
|
||||
read -p "${cyan}###### Create $INSTANCE_COUNT single instance? (Y/n):${default} " yn
|
||||
else
|
||||
read -p "${cyan}###### Create $INSTANCE_COUNT instances? (Y/n):${default} " yn
|
||||
fi
|
||||
read -p "${cyan}###### Install $count instance(s)? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
echo -e "###### > Yes"
|
||||
status_msg "Creating $INSTANCE_COUNT Klipper instances ..."
|
||||
klipper_setup
|
||||
status_msg "Installing $count Klipper instance(s) ..."
|
||||
klipper_setup "$count"
|
||||
break;;
|
||||
N|n|No|no)
|
||||
echo -e "###### > No"
|
||||
@@ -38,334 +54,142 @@ klipper_setup_dialog(){
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
esac
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
install_klipper_packages(){
|
||||
### Packages for python cffi
|
||||
PKGLIST="python-virtualenv virtualenv python-dev libffi-dev build-essential"
|
||||
### kconfig requirements
|
||||
PKGLIST="${PKGLIST} libncurses-dev"
|
||||
### hub-ctrl
|
||||
PKGLIST="${PKGLIST} libusb-dev"
|
||||
### AVR chip installation and building
|
||||
PKGLIST="${PKGLIST} avrdude gcc-avr binutils-avr avr-libc"
|
||||
### ARM chip installation and building
|
||||
PKGLIST="${PKGLIST} stm32flash libnewlib-arm-none-eabi"
|
||||
PKGLIST="${PKGLIST} gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0"
|
||||
### dbus requirement for DietPi
|
||||
PKGLIST="${PKGLIST} dbus"
|
||||
### read PKGLIST from official install script
|
||||
status_msg "Reading dependencies..."
|
||||
install_script="${HOME}/klipper/scripts/install-octopi.sh"
|
||||
#PKGLIST=$(grep "PKGLIST=" $install_script | sed 's/PKGLIST//g; s/[$={}\n"]//g')
|
||||
PKGLIST=$(grep "PKGLIST=" "$install_script" | sed 's/PKGLIST//g; s/[$"{}=]//g; s/\s\s*/ /g' | tr -d '\n')
|
||||
### add dbus requirement for DietPi distro
|
||||
[ -e "/boot/dietpi/.version" ] && PKGLIST+=" dbus"
|
||||
|
||||
for pkg in $PKGLIST; do
|
||||
echo "${cyan}$pkg${default}"
|
||||
done
|
||||
read -r -a PKGLIST <<< "$PKGLIST"
|
||||
|
||||
### Update system package info
|
||||
status_msg "Running apt-get update..."
|
||||
sudo apt-get update
|
||||
sudo apt-get update --allow-releaseinfo-change
|
||||
|
||||
### Install desired packages
|
||||
status_msg "Installing packages..."
|
||||
sudo apt-get install --yes ${PKGLIST}
|
||||
sudo apt-get install --yes "${PKGLIST[@]}"
|
||||
}
|
||||
|
||||
create_klipper_virtualenv(){
|
||||
status_msg "Installing python virtual environment..."
|
||||
# Create virtualenv if it doesn't already exist
|
||||
[ ! -d ${KLIPPY_ENV} ] && virtualenv -p python2 ${KLIPPY_ENV}
|
||||
[ ! -d "${KLIPPY_ENV}" ] && virtualenv -p python2 "${KLIPPY_ENV}"
|
||||
# Install/update dependencies
|
||||
${KLIPPY_ENV}/bin/pip install -r ${KLIPPER_DIR}/scripts/klippy-requirements.txt
|
||||
}
|
||||
|
||||
create_single_klipper_startscript(){
|
||||
### create systemd service file
|
||||
sudo /bin/sh -c "cat > $SYSTEMDDIR/klipper.service" << SINGLE_STARTSCRIPT
|
||||
#Systemd service file for klipper
|
||||
[Unit]
|
||||
Description=Starts klipper on startup
|
||||
After=network.target
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
[Service]
|
||||
Type=simple
|
||||
User=$USER
|
||||
RemainAfterExit=yes
|
||||
ExecStart=${KLIPPY_ENV}/bin/python ${KLIPPER_DIR}/klippy/klippy.py ${PRINTER_CFG} -l ${KLIPPER_LOG} -a ${KLIPPY_UDS}
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
SINGLE_STARTSCRIPT
|
||||
}
|
||||
|
||||
create_multi_klipper_startscript(){
|
||||
### create multi instance systemd service file
|
||||
sudo /bin/sh -c "cat > $SYSTEMDDIR/klipper-$INSTANCE.service" << MULTI_STARTSCRIPT
|
||||
#Systemd service file for klipper
|
||||
[Unit]
|
||||
Description=Starts klipper instance $INSTANCE on startup
|
||||
After=network.target
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
[Service]
|
||||
Type=simple
|
||||
User=$USER
|
||||
RemainAfterExit=yes
|
||||
ExecStart=${KLIPPY_ENV}/bin/python ${KLIPPER_DIR}/klippy/klippy.py ${PRINTER_CFG} -I ${TMP_PRINTER} -l ${KLIPPER_LOG} -a ${KLIPPY_UDS}
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
MULTI_STARTSCRIPT
|
||||
}
|
||||
|
||||
create_minimal_printer_cfg(){
|
||||
/bin/sh -c "cat > $1" << MINIMAL_CFG
|
||||
[mcu]
|
||||
serial: /dev/serial/by-id/<your-mcu-id>
|
||||
|
||||
[pause_resume]
|
||||
|
||||
[display_status]
|
||||
|
||||
[virtual_sdcard]
|
||||
path: ~/gcode_files
|
||||
|
||||
[printer]
|
||||
kinematics: none
|
||||
max_velocity: 1000
|
||||
max_accel: 1000
|
||||
MINIMAL_CFG
|
||||
"${KLIPPY_ENV}"/bin/pip install -r "${KLIPPER_DIR}"/scripts/klippy-requirements.txt
|
||||
}
|
||||
|
||||
klipper_setup(){
|
||||
### get printer config directory
|
||||
source_kiauh_ini
|
||||
PRINTER_CFG_LOC="$klipper_cfg_loc"
|
||||
INSTANCE_COUNT=$1
|
||||
### checking dependencies
|
||||
dep=(git)
|
||||
dependency_check
|
||||
|
||||
### clone klipper
|
||||
cd ${HOME}
|
||||
### step 1: clone klipper
|
||||
status_msg "Downloading Klipper ..."
|
||||
[ -d $KLIPPER_DIR ] && rm -rf $KLIPPER_DIR
|
||||
git clone $KLIPPER_REPO
|
||||
### force remove existing klipper dir and clone into fresh klipper dir
|
||||
[ -d "$KLIPPER_DIR" ] && rm -rf "$KLIPPER_DIR"
|
||||
cd "${HOME}" && git clone "$KLIPPER_REPO"
|
||||
status_msg "Download complete!"
|
||||
|
||||
### install klipper dependencies and create python virtualenv
|
||||
### step 2: install klipper dependencies and create python virtualenv
|
||||
status_msg "Installing dependencies ..."
|
||||
install_klipper_packages
|
||||
create_klipper_virtualenv
|
||||
|
||||
### create shared gcode_files folder
|
||||
[ ! -d ${HOME}/gcode_files ] && mkdir -p ${HOME}/gcode_files
|
||||
### create shared config folder
|
||||
[ ! -d $PRINTER_CFG_LOC ] && mkdir -p $PRINTER_CFG_LOC
|
||||
### step 3: create shared gcode_files and logs folder
|
||||
[ ! -d "${HOME}"/gcode_files ] && mkdir -p "${HOME}"/gcode_files
|
||||
[ ! -d "${HOME}"/klipper_logs ] && mkdir -p "${HOME}"/klipper_logs
|
||||
|
||||
### create klipper instances
|
||||
INSTANCE=1
|
||||
if [ $INSTANCE_COUNT -eq $INSTANCE ]; then
|
||||
create_single_klipper_instance
|
||||
else
|
||||
create_multi_klipper_instance
|
||||
fi
|
||||
}
|
||||
|
||||
create_single_klipper_instance(){
|
||||
status_msg "Setting up 1 Klipper instance ..."
|
||||
|
||||
### single instance variables
|
||||
KLIPPER_LOG=/tmp/klippy.log
|
||||
KLIPPY_UDS=/tmp/klippy_uds
|
||||
PRINTER_CFG="$PRINTER_CFG_LOC/printer.cfg"
|
||||
|
||||
### create instance
|
||||
status_msg "Creating single Klipper instance ..."
|
||||
status_msg "Installing system start script ..."
|
||||
create_single_klipper_startscript
|
||||
|
||||
### create printer config directory if missing
|
||||
[ ! -d $PRINTER_CFG_LOC ] && mkdir -p $PRINTER_CFG_LOC
|
||||
|
||||
### create basic configs if missing
|
||||
[ ! -f $PRINTER_CFG ] && create_minimal_printer_cfg "$PRINTER_CFG"
|
||||
|
||||
### enable instance
|
||||
sudo systemctl enable klipper.service
|
||||
ok_msg "Single Klipper instance created!"
|
||||
|
||||
### launching instance
|
||||
status_msg "Launching Klipper instance ..."
|
||||
sudo systemctl start klipper
|
||||
### step 4: create klipper instances
|
||||
create_klipper_service
|
||||
|
||||
### confirm message
|
||||
CONFIRM_MSG="Single Klipper instance has been set up!"
|
||||
print_msg && clear_msg
|
||||
if [[ $INSTANCE_COUNT -eq 1 ]]; then
|
||||
CONFIRM_MSG="Klipper has been set up!"
|
||||
elif [[ $INSTANCE_COUNT -gt 1 ]]; then
|
||||
CONFIRM_MSG="$INSTANCE_COUNT Klipper instances have been set up!"
|
||||
fi && print_msg && clear_msg
|
||||
}
|
||||
|
||||
create_multi_klipper_instance(){
|
||||
status_msg "Setting up $INSTANCE_COUNT instances of Klipper ..."
|
||||
while [ $INSTANCE -le $INSTANCE_COUNT ]; do
|
||||
### multi instance variables
|
||||
KLIPPER_LOG=/tmp/klippy-$INSTANCE.log
|
||||
KLIPPY_UDS=/tmp/klippy_uds-$INSTANCE
|
||||
TMP_PRINTER=/tmp/printer-$INSTANCE
|
||||
PRINTER_CFG="$PRINTER_CFG_LOC/printer_$INSTANCE/printer.cfg"
|
||||
create_klipper_service(){
|
||||
### get config directory
|
||||
source_kiauh_ini
|
||||
|
||||
### create instance
|
||||
status_msg "Creating instance #$INSTANCE ..."
|
||||
create_multi_klipper_startscript
|
||||
### set up default values
|
||||
SINGLE_INST=1
|
||||
CFG_PATH="$klipper_cfg_loc"
|
||||
KL_ENV=$KLIPPY_ENV
|
||||
KL_DIR=$KLIPPER_DIR
|
||||
KL_LOG="${HOME}/klipper_logs/klippy.log"
|
||||
KL_UDS="/tmp/klippy_uds"
|
||||
P_TMP="/tmp/printer"
|
||||
P_CFG="$CFG_PATH/printer.cfg"
|
||||
P_CFG_SRC="${SRCDIR}/kiauh/resources/printer.cfg"
|
||||
KL_SERV_SRC="${SRCDIR}/kiauh/resources/klipper.service"
|
||||
KL_SERV_TARGET="$SYSTEMDDIR/klipper.service"
|
||||
|
||||
### create printer config directory if missing
|
||||
[ ! -d $PRINTER_CFG_LOC/printer_$INSTANCE ] && mkdir -p $PRINTER_CFG_LOC/printer_$INSTANCE
|
||||
|
||||
### create basic configs if missing
|
||||
[ ! -f $PRINTER_CFG ] && create_minimal_printer_cfg "$PRINTER_CFG"
|
||||
write_kl_service(){
|
||||
[ ! -d "$CFG_PATH" ] && mkdir -p "$CFG_PATH"
|
||||
### create a minimal config if there is no printer.cfg
|
||||
[ ! -f "$P_CFG" ] && cp "$P_CFG_SRC" "$P_CFG"
|
||||
### replace placeholder
|
||||
if [ ! -f $KL_SERV_TARGET ]; then
|
||||
status_msg "Creating Klipper Service $i ..."
|
||||
sudo cp "$KL_SERV_SRC" $KL_SERV_TARGET
|
||||
sudo sed -i "s|%INST%|$i|" $KL_SERV_TARGET
|
||||
sudo sed -i "s|%USER%|${USER}|" $KL_SERV_TARGET
|
||||
sudo sed -i "s|%KL_ENV%|$KL_ENV|" $KL_SERV_TARGET
|
||||
sudo sed -i "s|%KL_DIR%|$KL_DIR|" $KL_SERV_TARGET
|
||||
sudo sed -i "s|%KL_LOG%|$KL_LOG|" $KL_SERV_TARGET
|
||||
sudo sed -i "s|%P_CFG%|$P_CFG|" $KL_SERV_TARGET
|
||||
sudo sed -i "s|%P_TMP%|$P_TMP|" $KL_SERV_TARGET
|
||||
sudo sed -i "s|%KL_UDS%|$KL_UDS|" $KL_SERV_TARGET
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ $SINGLE_INST -eq $INSTANCE_COUNT ]]; then
|
||||
### write single instance service
|
||||
write_kl_service
|
||||
### enable instance
|
||||
sudo systemctl enable klipper-$INSTANCE.service
|
||||
ok_msg "Klipper instance $INSTANCE created!"
|
||||
|
||||
sudo systemctl enable klipper.service
|
||||
ok_msg "Single Klipper instance created!"
|
||||
### launching instance
|
||||
status_msg "Launching Klipper instance $INSTANCE ..."
|
||||
sudo systemctl start klipper-$INSTANCE
|
||||
|
||||
### instance counter +1
|
||||
INSTANCE=$(expr $INSTANCE + 1)
|
||||
done
|
||||
|
||||
### confirm message
|
||||
CONFIRM_MSG="$INSTANCE_COUNT Klipper instances have been set up!"
|
||||
print_msg && clear_msg
|
||||
}
|
||||
|
||||
|
||||
##############################################################################################
|
||||
#********************************************************************************************#
|
||||
##############################################################################################
|
||||
|
||||
|
||||
flash_routine(){
|
||||
echo
|
||||
top_border
|
||||
echo -e "| ${red}~~~~~~~~~~~ [ ATTENTION! ] ~~~~~~~~~~~~${default} |"
|
||||
hr
|
||||
echo -e "| Flashing a Smoothie based board with this script will |"
|
||||
echo -e "| certainly fail. This applies to boards like the BTT |"
|
||||
echo -e "| SKR V1.3 or SKR V1.4(Turbo). You have to copy the |"
|
||||
echo -e "| firmware file to the microSD card manually and rename |"
|
||||
echo -e "| it to 'firmware.bin'. |"
|
||||
hr
|
||||
echo -e "| You can find the file in: ~/klipper/out/klipper.bin |"
|
||||
bottom_border
|
||||
while true; do
|
||||
read -p "${cyan}###### Do you want to continue? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
echo -e "###### > Yes"
|
||||
get_mcu_id
|
||||
break;;
|
||||
N|n|No|no)
|
||||
echo -e "###### > No"
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
flash_mcu(){
|
||||
if [ ${#mcu_list[@]} -ge 1 ]; then
|
||||
top_border
|
||||
echo -e "| ${red}!!! IMPORTANT WARNING !!!${default} |"
|
||||
hr
|
||||
echo -e "| Make sure, that you select the correct ID for the MCU |"
|
||||
echo -e "| you have build the firmware for in the previous step! |"
|
||||
blank_line
|
||||
echo -e "| This is especially important if you use different MCU |"
|
||||
echo -e "| models which each require their own firmware! |"
|
||||
blank_line
|
||||
echo -e "| ${red}ONLY flash a firmware created for the respective MCU!${default} |"
|
||||
bottom_border
|
||||
|
||||
### list all mcus
|
||||
status_msg "Launching Klipper instance ..."
|
||||
sudo systemctl start klipper
|
||||
else
|
||||
i=1
|
||||
for mcu in ${mcu_list[@]}; do
|
||||
echo -e "$i) ${cyan}$mcu${default}"
|
||||
i=$(expr $i + 1)
|
||||
done
|
||||
while true; do
|
||||
echo
|
||||
read -p "${cyan}###### Please select the ID for flashing:${default} " selected_id
|
||||
mcu_index=$(echo $((selected_id - 1)))
|
||||
echo -e "\nYou have selected to flash:\n● MCU #$selected_id: ${mcu_list[$mcu_index]}\n"
|
||||
while true; do
|
||||
read -p "${cyan}###### Do you want to continue? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
echo -e "###### > Yes"
|
||||
status_msg "Flashing ${mcu_list[$mcu_index]} ..."
|
||||
klipper_service "stop"
|
||||
if ! make flash FLASH_DEVICE="${mcu_list[$mcu_index]}" ; then
|
||||
warn_msg "Flashing failed!"
|
||||
warn_msg "Please read the console output above!"
|
||||
else
|
||||
ok_msg "Flashing successfull!"
|
||||
fi
|
||||
klipper_service "start"
|
||||
break;;
|
||||
N|n|No|no)
|
||||
echo -e "###### > No"
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
break
|
||||
while [[ $i -le $INSTANCE_COUNT ]]; do
|
||||
### rewrite default variables for multi instance cases
|
||||
CFG_PATH="$klipper_cfg_loc/printer_$i"
|
||||
KL_SERV_TARGET="$SYSTEMDDIR/klipper-$i.service"
|
||||
P_TMP="/tmp/printer-$i"
|
||||
P_CFG="$CFG_PATH/printer.cfg"
|
||||
KL_LOG="${HOME}/klipper_logs/klippy-$i.log"
|
||||
KL_UDS="/tmp/klippy_uds-$i"
|
||||
### write multi instance service
|
||||
write_kl_service
|
||||
### enable instance
|
||||
sudo systemctl enable klipper-$i.service
|
||||
ok_msg "Klipper instance #$i created!"
|
||||
### launching instance
|
||||
status_msg "Launching Klipper instance #$i ..."
|
||||
sudo systemctl start klipper-$i
|
||||
|
||||
### raise values by 1
|
||||
i=$((i+1))
|
||||
done
|
||||
unset i
|
||||
fi
|
||||
}
|
||||
|
||||
build_fw(){
|
||||
if [ -d $KLIPPER_DIR ]; then
|
||||
cd $KLIPPER_DIR
|
||||
status_msg "Initializing firmware Setup ..."
|
||||
make menuconfig
|
||||
status_msg "Building firmware ..."
|
||||
make clean && make && ok_msg "Firmware built!"
|
||||
else
|
||||
warn_msg "Can not build firmware without a Klipper directory!"
|
||||
fi
|
||||
}
|
||||
|
||||
### grab the mcu id
|
||||
get_mcu_id(){
|
||||
echo
|
||||
top_border
|
||||
echo -e "| Please make sure your MCU is connected to the Pi! |"
|
||||
echo -e "| If the MCU is not connected yet, connect it now. |"
|
||||
bottom_border
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Press any key to continue ... " yn
|
||||
echo -e "${default}"
|
||||
case "$yn" in
|
||||
*)
|
||||
break;;
|
||||
esac
|
||||
done
|
||||
status_msg "Identifying the ID of your MCU ..."
|
||||
sleep 2
|
||||
unset MCU_ID
|
||||
### if there are devices found, continue, else show warn message
|
||||
if ls /dev/serial/by-id/* 2>/dev/null 1>&2; then
|
||||
mcu_count=1
|
||||
mcu_list=()
|
||||
status_msg "The ID of your printers MCU is:"
|
||||
### loop over the IDs, write every ID as an item of the array 'mcu_list'
|
||||
for mcu in /dev/serial/by-id/*; do
|
||||
declare "mcu_id_$mcu_count"="$mcu"
|
||||
mcu_id="mcu_id_$mcu_count"
|
||||
mcu_list+=("${!mcu_id}")
|
||||
echo " ● MCU #$mcu_count: ${cyan}$mcu${default}"
|
||||
mcu_count=$(expr $mcu_count + 1)
|
||||
done
|
||||
unset mcu_count
|
||||
else
|
||||
warn_msg "Could not retrieve ID!"
|
||||
warn_msg "Printer not plugged in or not detectable!"
|
||||
fi
|
||||
}
|
||||
@@ -1,10 +1,57 @@
|
||||
check_moonraker(){
|
||||
status_msg "Checking for Moonraker service ..."
|
||||
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "moonraker.service")" ] || [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "moonraker-[[:digit:]].service")" ]; then
|
||||
MAINSAIL_REPO_API="https://api.github.com/repos/mainsail-crew/mainsail/releases"
|
||||
FLUIDD_REPO_API="https://api.github.com/repos/fluidd-core/fluidd/releases"
|
||||
|
||||
system_check_webui(){
|
||||
### check system for installed moonraker service
|
||||
if ls /etc/systemd/system/moonraker.service 2>/dev/null 1>&2 || ls /etc/systemd/system | grep -q -E "moonraker-[[:digit:]]+.service"; then
|
||||
moonraker_chk_ok="true"
|
||||
else
|
||||
moonraker_chk_ok="false"
|
||||
fi
|
||||
|
||||
### check system for an installed and enabled octoprint service
|
||||
if sudo systemctl list-unit-files | grep -E "octoprint.*" | grep "enabled" &>/dev/null; then
|
||||
OCTOPRINT_ENABLED="true"
|
||||
fi
|
||||
|
||||
### check system for an installed haproxy service
|
||||
if [[ $(dpkg-query -f'${Status}' --show haproxy 2>/dev/null) = *\ installed ]]; then
|
||||
HAPROXY_FOUND="true"
|
||||
fi
|
||||
|
||||
### check system for an installed lighttpd service
|
||||
if [[ $(dpkg-query -f'${Status}' --show lighttpd 2>/dev/null) = *\ installed ]]; then
|
||||
LIGHTTPD_FOUND="true"
|
||||
fi
|
||||
|
||||
### check system for an installed apache2 service
|
||||
if [[ $(dpkg-query -f'${Status}' --show apache2 2>/dev/null) = *\ installed ]]; then
|
||||
APACHE2_FOUND="true"
|
||||
fi
|
||||
}
|
||||
|
||||
get_user_selection_mjpg-streamer(){
|
||||
while true; do
|
||||
unset INSTALL_MJPG
|
||||
echo
|
||||
top_border
|
||||
echo -e "| Install MJGP-Streamer for webcam support? |"
|
||||
bottom_border
|
||||
read -p "${cyan}###### Install MJPG-Streamer? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
echo -e "###### > Yes"
|
||||
INSTALL_MJPG="true"
|
||||
break;;
|
||||
N|n|No|no)
|
||||
echo -e "###### > No"
|
||||
INSTALL_MJPG="false"
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
get_user_selection_kiauh_macros(){
|
||||
@@ -45,21 +92,28 @@ get_user_selection_kiauh_macros(){
|
||||
}
|
||||
|
||||
install_webui(){
|
||||
source_kiauh_ini
|
||||
### checking dependencies
|
||||
dep=(nginx)
|
||||
dependency_check
|
||||
### check if moonraker is already installed
|
||||
check_moonraker
|
||||
system_check_webui
|
||||
### ask user how to handle OctoPrint, Haproxy, Lighttpd, Apache2 if found
|
||||
process_octoprint_dialog
|
||||
process_services_dialog
|
||||
### process possible disruptive services
|
||||
process_disruptive_services
|
||||
|
||||
[ $1 == "mainsail" ] && IF_NAME1="Mainsail" && IF_NAME2="Mainsail "
|
||||
[ $1 == "fluidd" ] && IF_NAME1="Fluidd" && IF_NAME2="Fluidd "
|
||||
[ "$1" == "mainsail" ] && IF_NAME1="Mainsail" && IF_NAME2="Mainsail "
|
||||
[ "$1" == "fluidd" ] && IF_NAME1="Fluidd" && IF_NAME2="Fluidd "
|
||||
|
||||
### exit mainsail/fluidd setup if moonraker not found
|
||||
if [ $moonraker_chk_ok = "false" ]; then
|
||||
ERROR_MSG="Moonraker service not found!\n Please install Moonraker first!"
|
||||
print_msg && clear_msg && return 0
|
||||
else
|
||||
ok_msg "Moonraker service found!"
|
||||
status_msg "Initializing $IF_NAME1 installation ..."
|
||||
fi
|
||||
|
||||
status_msg "Initializing $IF_NAME1 installation ..."
|
||||
### check for other enabled web interfaces
|
||||
unset SET_LISTEN_PORT
|
||||
detect_enabled_sites
|
||||
@@ -67,17 +121,54 @@ install_webui(){
|
||||
### check if another site already listens to port 80
|
||||
$1_port_check
|
||||
|
||||
### ask user to install the recommended webinterface macros
|
||||
get_user_selection_kiauh_macros "$IF_NAME2"
|
||||
### ask user to install mjpg-streamer
|
||||
if ! ls /etc/systemd/system/webcamd.service 2>/dev/null 1>&2; then
|
||||
get_user_selection_mjpg-streamer
|
||||
fi
|
||||
|
||||
### creating the mainsail/fluidd nginx cfg
|
||||
### ask user to install the recommended webinterface macros
|
||||
if ! ls "$klipper_cfg_loc"/kiauh_macros.cfg 2>/dev/null 1>&2 || ! ls "$klipper_cfg_loc"/printer_*/kiauh_macros.cfg 2>/dev/null 1>&2; then
|
||||
get_user_selection_kiauh_macros "$IF_NAME2"
|
||||
fi
|
||||
### create /etc/nginx/conf.d/upstreams.conf
|
||||
set_upstream_nginx_cfg
|
||||
### create /etc/nginx/sites-available/<interface config>
|
||||
set_nginx_cfg "$1"
|
||||
|
||||
### symlink nginx log
|
||||
symlink_webui_nginx_log "$1"
|
||||
|
||||
### copy the kiauh_macros.cfg to the config location
|
||||
install_kiauh_macros
|
||||
|
||||
### install mainsail/fluidd
|
||||
$1_setup
|
||||
|
||||
### install mjpg-streamer
|
||||
[ "$INSTALL_MJPG" = "true" ] && install_mjpg-streamer
|
||||
|
||||
fetch_webui_ports #WIP
|
||||
|
||||
### confirm message
|
||||
CONFIRM_MSG="$IF_NAME1 has been set up!"
|
||||
print_msg && clear_msg
|
||||
}
|
||||
|
||||
symlink_webui_nginx_log(){
|
||||
LPATH="${HOME}/klipper_logs"
|
||||
UI_ACCESS_LOG="/var/log/nginx/$1-access.log"
|
||||
UI_ERROR_LOG="/var/log/nginx/$1-error.log"
|
||||
[ ! -d "$LPATH" ] && mkdir -p "$LPATH"
|
||||
if [ -f "$UI_ACCESS_LOG" ] && [ ! -L "$LPATH/$1-access.log" ]; then
|
||||
status_msg "Creating symlink for $UI_ACCESS_LOG ..."
|
||||
ln -s "$UI_ACCESS_LOG" "$LPATH"
|
||||
ok_msg "OK!"
|
||||
fi
|
||||
if [ -f "$UI_ERROR_LOG" ] && [ ! -L "$LPATH/$1-error.log" ]; then
|
||||
status_msg "Creating symlink for $UI_ERROR_LOG ..."
|
||||
ln -s "$UI_ERROR_LOG" "$LPATH"
|
||||
ok_msg "OK!"
|
||||
fi
|
||||
}
|
||||
|
||||
install_kiauh_macros(){
|
||||
@@ -87,27 +178,29 @@ install_kiauh_macros(){
|
||||
### create a backup of the config folder
|
||||
backup_klipper_config_dir
|
||||
### handle multi printer.cfg
|
||||
if ls $klipper_cfg_loc/printer_* 2>/dev/null 1>&2; then
|
||||
if ls "$klipper_cfg_loc"/printer_* 2>/dev/null 1>&2; then
|
||||
for config in $(find $klipper_cfg_loc/printer_*/printer.cfg); do
|
||||
path=$(echo $config | rev | cut -d"/" -f2- | rev)
|
||||
if [ ! -f $path/kiauh_macros.cfg ]; then
|
||||
path=$(echo "$config" | rev | cut -d"/" -f2- | rev)
|
||||
if [ ! -f "$path/kiauh_macros.cfg" ]; then
|
||||
### copy kiauh_macros.cfg to config location
|
||||
cp ${SRCDIR}/kiauh/resources/kiauh_macros.cfg $path
|
||||
ok_msg "$path/kiauh_macros.cfg created!"
|
||||
status_msg "Creating macro config file ..."
|
||||
cp "${SRCDIR}/kiauh/resources/kiauh_macros.cfg" "$path"
|
||||
### write the include to the very first line of the printer.cfg
|
||||
sed -i "1 i [include kiauh_macros.cfg]" $path/printer.cfg
|
||||
sed -i "1 i [include kiauh_macros.cfg]" "$path/printer.cfg"
|
||||
ok_msg "$path/kiauh_macros.cfg created!"
|
||||
fi
|
||||
done
|
||||
### handle single printer.cfg
|
||||
elif [ -f $klipper_cfg_loc/printer.cfg ] && [ ! -f $klipper_cfg_loc/kiauh_macros.cfg ]; then
|
||||
elif [ -f "$klipper_cfg_loc/printer.cfg" ] && [ ! -f "$klipper_cfg_loc/kiauh_macros.cfg" ]; then
|
||||
### copy kiauh_macros.cfg to config location
|
||||
cp ${SRCDIR}/kiauh/resources/kiauh_macros.cfg $klipper_cfg_loc
|
||||
ok_msg "$klipper_cfg_loc/kiauh_macros.cfg created!"
|
||||
status_msg "Creating macro config file ..."
|
||||
cp "${SRCDIR}/kiauh/resources/kiauh_macros.cfg" "$klipper_cfg_loc"
|
||||
### write the include to the very first line of the printer.cfg
|
||||
sed -i "1 i [include kiauh_macros.cfg]" $klipper_cfg_loc/printer.cfg
|
||||
sed -i "1 i [include kiauh_macros.cfg]" "$klipper_cfg_loc/printer.cfg"
|
||||
ok_msg "$klipper_cfg_loc/kiauh_macros.cfg created!"
|
||||
fi
|
||||
### restart klipper service to parse the modified printer.cfg
|
||||
klipper_service "restart"
|
||||
do_action_service "restart" "klipper"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -123,7 +216,7 @@ mainsail_port_check(){
|
||||
select_mainsail_port
|
||||
fi
|
||||
else
|
||||
DEFAULT_PORT=$(grep listen ${SRCDIR}/kiauh/resources/klipper_webui_nginx.cfg | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
|
||||
DEFAULT_PORT=$(grep listen "${SRCDIR}/kiauh/resources/klipper_webui_nginx.cfg" | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
|
||||
SET_LISTEN_PORT=$DEFAULT_PORT
|
||||
fi
|
||||
SET_NGINX_CFG="true"
|
||||
@@ -144,7 +237,7 @@ fluidd_port_check(){
|
||||
select_fluidd_port
|
||||
fi
|
||||
else
|
||||
DEFAULT_PORT=$(grep listen ${SRCDIR}/kiauh/resources/klipper_webui_nginx.cfg | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
|
||||
DEFAULT_PORT=$(grep listen "${SRCDIR}/kiauh/resources/klipper_webui_nginx.cfg" | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
|
||||
SET_LISTEN_PORT=$DEFAULT_PORT
|
||||
fi
|
||||
SET_NGINX_CFG="true"
|
||||
@@ -218,22 +311,22 @@ select_fluidd_port(){
|
||||
}
|
||||
|
||||
get_mainsail_ver(){
|
||||
MAINSAIL_VERSION=$(curl -s https://api.github.com/repositories/240875926/releases | grep tag_name | cut -d'"' -f4 | head -1)
|
||||
MAINSAIL_VERSION=$(curl -s $MAINSAIL_REPO_API | grep tag_name | cut -d'"' -f4 | head -1)
|
||||
}
|
||||
|
||||
get_fluidd_ver(){
|
||||
FLUIDD_VERSION=$(curl -s https://api.github.com/repositories/295836951/releases | grep tag_name | cut -d'"' -f4 | head -1)
|
||||
FLUIDD_VERSION=$(curl -s $FLUIDD_REPO_API | grep tag_name | cut -d'"' -f4 | head -1)
|
||||
}
|
||||
|
||||
mainsail_setup(){
|
||||
### get mainsail download url
|
||||
MAINSAIL_DL_URL=$(curl -s https://api.github.com/repositories/240875926/releases | grep browser_download_url | cut -d'"' -f4 | head -1)
|
||||
MAINSAIL_DL_URL=$(curl -s $MAINSAIL_REPO_API | grep browser_download_url | cut -d'"' -f4 | head -1)
|
||||
|
||||
### remove existing and create fresh mainsail folder, then download mainsail
|
||||
[ -d $MAINSAIL_DIR ] && rm -rf $MAINSAIL_DIR
|
||||
mkdir $MAINSAIL_DIR && cd $MAINSAIL_DIR
|
||||
[ -d "$MAINSAIL_DIR" ] && rm -rf "$MAINSAIL_DIR"
|
||||
mkdir "$MAINSAIL_DIR" && cd $MAINSAIL_DIR
|
||||
status_msg "Downloading Mainsail $MAINSAIL_VERSION ..."
|
||||
wget $MAINSAIL_DL_URL && ok_msg "Download complete!"
|
||||
wget "$MAINSAIL_DL_URL" && ok_msg "Download complete!"
|
||||
|
||||
### extract archive
|
||||
status_msg "Extracting archive ..."
|
||||
@@ -244,27 +337,25 @@ mainsail_setup(){
|
||||
rm -rf *.zip && ok_msg "Done!"
|
||||
|
||||
### check for moonraker multi-instance and if multi-instance was found, enable mainsails remoteMode
|
||||
if [ $(ls /etc/systemd/system/moonraker* | wc -l) -gt 1 ]; then
|
||||
if [ $(ls /etc/systemd/system/moonraker* | grep -E "moonraker(-[[:digit:]]+)?\.service" | wc -l) -gt 1 ]; then
|
||||
enable_mainsail_remotemode
|
||||
fi
|
||||
|
||||
ok_msg "Mainsail installation complete!\n"
|
||||
}
|
||||
|
||||
enable_mainsail_remotemode(){
|
||||
rm -f $MAINSAIL_DIR/config.json
|
||||
echo -e "{\n \"remoteMode\":true\n}" >> $MAINSAIL_DIR/config.json
|
||||
rm -f "$MAINSAIL_DIR/config.json"
|
||||
echo -e "{\n \"remoteMode\":true\n}" >> "$MAINSAIL_DIR/config.json"
|
||||
}
|
||||
|
||||
fluidd_setup(){
|
||||
### get fluidd download url
|
||||
FLUIDD_DL_URL=$(curl -s https://api.github.com/repositories/295836951/releases/latest | grep browser_download_url | cut -d'"' -f4)
|
||||
FLUIDD_DL_URL=$(curl -s $FLUIDD_REPO_API | grep browser_download_url | cut -d'"' -f4 | head -1)
|
||||
|
||||
### remove existing and create fresh fluidd folder, then download fluidd
|
||||
[ -d $FLUIDD_DIR ] && rm -rf $FLUIDD_DIR
|
||||
mkdir $FLUIDD_DIR && cd $FLUIDD_DIR
|
||||
[ -d "$FLUIDD_DIR" ] && rm -rf "$FLUIDD_DIR"
|
||||
mkdir "$FLUIDD_DIR" && cd $FLUIDD_DIR
|
||||
status_msg "Downloading Fluidd $FLUIDD_VERSION ..."
|
||||
wget $FLUIDD_DL_URL && ok_msg "Download complete!"
|
||||
wget "$FLUIDD_DL_URL" && ok_msg "Download complete!"
|
||||
|
||||
### extract archive
|
||||
status_msg "Extracting archive ..."
|
||||
@@ -272,6 +363,241 @@ fluidd_setup(){
|
||||
|
||||
### delete downloaded zip
|
||||
status_msg "Remove downloaded archive ..."
|
||||
rm -rf *.zip && ok_msg "Done!" && ok_msg "Fluidd installation complete!"
|
||||
echo
|
||||
}
|
||||
rm -rf *.zip && ok_msg "Done!"
|
||||
}
|
||||
|
||||
set_upstream_nginx_cfg(){
|
||||
get_date
|
||||
### backup existing nginx configs
|
||||
[ ! -d "$BACKUP_DIR/nginx_cfg" ] && mkdir -p "$BACKUP_DIR/nginx_cfg"
|
||||
[ -f "$NGINX_CONFD/upstreams.conf" ] && sudo mv "$NGINX_CONFD/upstreams.conf" "$BACKUP_DIR/nginx_cfg/${current_date}_upstreams.conf"
|
||||
[ -f "$NGINX_CONFD/common_vars.conf" ] && sudo mv "$NGINX_CONFD/common_vars.conf" "$BACKUP_DIR/nginx_cfg/${current_date}_common_vars.conf"
|
||||
### transfer ownership of backed up files from root to ${USER}
|
||||
for log in $(ls "$BACKUP_DIR/nginx_cfg"); do
|
||||
sudo chown "${USER}" "$BACKUP_DIR/nginx_cfg/$log"
|
||||
done
|
||||
### copy nginx configs to target destination
|
||||
if [ ! -f "$NGINX_CONFD/upstreams.conf" ]; then
|
||||
sudo cp "${SRCDIR}/kiauh/resources/upstreams.conf" "$NGINX_CONFD"
|
||||
fi
|
||||
if [ ! -f "$NGINX_CONFD/common_vars.conf" ]; then
|
||||
sudo cp "${SRCDIR}/kiauh/resources/common_vars.conf" "$NGINX_CONFD"
|
||||
fi
|
||||
}
|
||||
|
||||
fetch_webui_ports(){
|
||||
### read listen ports from possible installed interfaces
|
||||
### and write them to ~/.kiauh.ini
|
||||
WEBIFS=(mainsail fluidd octoprint dwc2)
|
||||
for interface in "${WEBIFS[@]}"; do
|
||||
if [ -f "/etc/nginx/sites-available/${interface}" ]; then
|
||||
port=$(grep -E "listen" "/etc/nginx/sites-available/$interface" | head -1 | sed 's/^\s*//' | sed 's/;$//' | cut -d" " -f2)
|
||||
if [ ! -n "$(grep -E "${interface}_port" "$INI_FILE")" ]; then
|
||||
sed -i '$a'"${interface}_port=${port}" "$INI_FILE"
|
||||
else
|
||||
sed -i "/^${interface}_port/d" "$INI_FILE"
|
||||
sed -i '$a'"${interface}_port=${port}" "$INI_FILE"
|
||||
fi
|
||||
else
|
||||
sed -i "/^${interface}_port/d" "$INI_FILE"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
match_nginx_configs(){
|
||||
### reinstall nginx configs if the amount of upstreams don't match anymore
|
||||
source_kiauh_ini
|
||||
cfg_updated="false"
|
||||
mainsail_nginx_cfg="/etc/nginx/sites-available/mainsail"
|
||||
fluidd_nginx_cfg="/etc/nginx/sites-available/fluidd"
|
||||
upstreams_webcams=$(grep -E "mjpgstreamer" /etc/nginx/conf.d/upstreams.conf | wc -l)
|
||||
status_msg "Checking validity of NGINX configurations ..."
|
||||
if [ -e "$mainsail_nginx_cfg" ]; then
|
||||
mainsail_webcams=$(grep -E "mjpgstreamer" "$mainsail_nginx_cfg" | wc -l)
|
||||
fi
|
||||
if [ -e "$fluidd_nginx_cfg" ]; then
|
||||
fluidd_webcams=$(grep -E "mjpgstreamer" "$fluidd_nginx_cfg" | wc -l)
|
||||
fi
|
||||
### check for outdated upstreams.conf
|
||||
if [[ "$upstreams_webcams" -lt "$mainsail_webcams" ]] || [[ "$upstreams_webcams" -lt "$fluidd_webcams" ]]; then
|
||||
status_msg "Outdated upstreams.conf found! Updating ..."
|
||||
sudo rm -f "$NGINX_CONFD/upstreams.conf"
|
||||
sudo rm -f "$NGINX_CONFD/common_vars.conf"
|
||||
set_upstream_nginx_cfg
|
||||
cfg_updated="true"
|
||||
fi
|
||||
### check for outdated mainsail config
|
||||
if [ -e "$mainsail_nginx_cfg" ]; then
|
||||
if [[ "$upstreams_webcams" -gt "$mainsail_webcams" ]]; then
|
||||
status_msg "Outdated Mainsail config found! Updating ..."
|
||||
sudo rm -f "$mainsail_nginx_cfg"
|
||||
sudo cp "${SRCDIR}/kiauh/resources/klipper_webui_nginx.cfg" "$mainsail_nginx_cfg"
|
||||
sudo sed -i "s/<<UI>>/mainsail/g" "$mainsail_nginx_cfg"
|
||||
sudo sed -i "/root/s/pi/${USER}/" "$mainsail_nginx_cfg"
|
||||
sudo sed -i "s/listen\s[0-9]*;/listen $mainsail_port;/" "$mainsail_nginx_cfg"
|
||||
sudo sed -i "s/listen\s\[\:*\]\:[0-9]*;/listen \[::\]\:$mainsail_port;/" "$mainsail_nginx_cfg"
|
||||
cfg_updated="true" && ok_msg "Done!"
|
||||
fi
|
||||
fi
|
||||
### check for outdated fluidd config
|
||||
if [ -e "$fluidd_nginx_cfg" ]; then
|
||||
if [[ "$upstreams_webcams" -gt "$fluidd_webcams" ]]; then
|
||||
status_msg "Outdated Fluidd config found! Updating ..."
|
||||
sudo rm -f "$fluidd_nginx_cfg"
|
||||
sudo cp "${SRCDIR}/kiauh/resources/klipper_webui_nginx.cfg" "$fluidd_nginx_cfg"
|
||||
sudo sed -i "s/<<UI>>/fluidd/g" "$fluidd_nginx_cfg"
|
||||
sudo sed -i "/root/s/pi/${USER}/" "$fluidd_nginx_cfg"
|
||||
sudo sed -i "s/listen\s[0-9]*;/listen $fluidd_port;/" "$fluidd_nginx_cfg"
|
||||
sudo sed -i "s/listen\s\[\:*\]\:[0-9]*;/listen \[::\]\:$fluidd_port;/" "$fluidd_nginx_cfg"
|
||||
cfg_updated="true" && ok_msg "Done!"
|
||||
fi
|
||||
fi
|
||||
### only restart nginx if configs were updated
|
||||
if [ "$cfg_updated" == "true" ]; then
|
||||
restart_nginx && unset cfg_updated
|
||||
fi
|
||||
}
|
||||
|
||||
process_octoprint_dialog(){
|
||||
#ask user to disable octoprint when its service was found
|
||||
if [ "$OCTOPRINT_ENABLED" = "true" ]; then
|
||||
while true; do
|
||||
echo
|
||||
top_border
|
||||
echo -e "| ${red}!!! WARNING - OctoPrint service found !!!${default} |"
|
||||
hr
|
||||
echo -e "| You might consider disabling the OctoPrint service, |"
|
||||
echo -e "| since an active OctoPrint service may lead to unex- |"
|
||||
echo -e "| pected behavior of the Klipper Webinterfaces. |"
|
||||
bottom_border
|
||||
read -p "${cyan}###### Do you want to disable OctoPrint now? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
echo -e "###### > Yes"
|
||||
status_msg "Stopping OctoPrint ..."
|
||||
do_action_service "stop" "octoprint" && ok_msg "OctoPrint service stopped!"
|
||||
status_msg "Disabling OctoPrint ..."
|
||||
do_action_service "disable" "octoprint" && ok_msg "OctoPrint service disabled!"
|
||||
break;;
|
||||
N|n|No|no)
|
||||
echo -e "###### > No"
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
process_disruptive_services(){
|
||||
#handle haproxy service
|
||||
if [ "$DISABLE_HAPROXY" = "true" ] || [ "$REMOVE_HAPROXY" = "true" ]; then
|
||||
if systemctl is-active haproxy -q; then
|
||||
status_msg "Stopping haproxy service ..."
|
||||
sudo systemctl stop haproxy && ok_msg "Service stopped!"
|
||||
fi
|
||||
|
||||
### disable haproxy
|
||||
if [ "$DISABLE_HAPROXY" = "true" ]; then
|
||||
status_msg "Disabling haproxy ..."
|
||||
sudo systemctl disable haproxy && ok_msg "Haproxy service disabled!"
|
||||
|
||||
### remove haproxy
|
||||
if [ "$REMOVE_HAPROXY" = "true" ]; then
|
||||
status_msg "Removing haproxy ..."
|
||||
sudo apt-get remove haproxy -y && sudo update-rc.d -f haproxy remove && ok_msg "Haproxy removed!"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
### handle lighttpd service
|
||||
if [ "$DISABLE_LIGHTTPD" = "true" ] || [ "$REMOVE_LIGHTTPD" = "true" ]; then
|
||||
if systemctl is-active lighttpd -q; then
|
||||
status_msg "Stopping lighttpd service ..."
|
||||
sudo systemctl stop lighttpd && ok_msg "Service stopped!"
|
||||
fi
|
||||
|
||||
### disable lighttpd
|
||||
if [ "$DISABLE_LIGHTTPD" = "true" ]; then
|
||||
status_msg "Disabling lighttpd ..."
|
||||
sudo systemctl disable lighttpd && ok_msg "Lighttpd service disabled!"
|
||||
|
||||
### remove lighttpd
|
||||
if [ "$REMOVE_LIGHTTPD" = "true" ]; then
|
||||
status_msg "Removing lighttpd ..."
|
||||
sudo apt-get remove lighttpd -y && sudo update-rc.d -f lighttpd remove && ok_msg "Lighttpd removed!"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
### handle apache2 service
|
||||
if [ "$DISABLE_APACHE2" = "true" ] || [ "$REMOVE_APACHE2" = "true" ]; then
|
||||
if systemctl is-active apache2 -q; then
|
||||
status_msg "Stopping apache2 service ..."
|
||||
sudo systemctl stop apache2 && ok_msg "Service stopped!"
|
||||
fi
|
||||
|
||||
### disable lighttpd
|
||||
if [ "$DISABLE_APACHE2" = "true" ]; then
|
||||
status_msg "Disabling lighttpd ..."
|
||||
sudo systemctl disable apache2 && ok_msg "Apache2 service disabled!"
|
||||
|
||||
### remove lighttpd
|
||||
if [ "$REMOVE_APACHE2" = "true" ]; then
|
||||
status_msg "Removing apache2 ..."
|
||||
sudo apt-get remove apache2 -y && sudo update-rc.d -f apache2 remove && ok_msg "Apache2 removed!"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
process_services_dialog(){
|
||||
#notify user about haproxy or lighttpd services found and possible issues
|
||||
if [ "$HAPROXY_FOUND" = "true" ] || [ "$LIGHTTPD_FOUND" = "true" ] || [ "$APACHE2_FOUND" = "true" ]; then
|
||||
while true; do
|
||||
echo
|
||||
top_border
|
||||
echo -e "| ${red}Possibly disruptive/incompatible services found!${default} |"
|
||||
hr
|
||||
if [ "$HAPROXY_FOUND" = "true" ]; then
|
||||
echo -e "| ● haproxy |"
|
||||
fi
|
||||
if [ "$LIGHTTPD_FOUND" = "true" ]; then
|
||||
echo -e "| ● lighttpd |"
|
||||
fi
|
||||
if [ "$APACHE2_FOUND" = "true" ]; then
|
||||
echo -e "| ● apache2 |"
|
||||
fi
|
||||
hr
|
||||
echo -e "| Having those packages installed can lead to unwanted |"
|
||||
echo -e "| behaviour. It is recommend to remove those packages. |"
|
||||
echo -e "| |"
|
||||
echo -e "| 1) Remove packages (recommend) |"
|
||||
echo -e "| 2) Disable only (may cause issues) |"
|
||||
echo -e "| ${red}3) Skip this step (not recommended)${default} |"
|
||||
bottom_border
|
||||
read -p "${cyan}###### Please choose:${default} " action
|
||||
case "$action" in
|
||||
1)
|
||||
echo -e "###### > Remove packages"
|
||||
REMOVE_HAPROXY="true"
|
||||
REMOVE_LIGHTTPD="true"
|
||||
REMOVE_APACHE2="true"
|
||||
break;;
|
||||
2)
|
||||
echo -e "###### > Disable only"
|
||||
DISABLE_HAPROXY="true"
|
||||
DISABLE_LIGHTTPD="true"
|
||||
DISABLE_APACHE2="true"
|
||||
break;;
|
||||
3)
|
||||
echo -e "###### > Skip"
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -2,13 +2,8 @@ install_klipperscreen(){
|
||||
python3_check
|
||||
if [ $py_chk_ok = "true" ]; then
|
||||
source_kiauh_ini
|
||||
system_check_klipperscreen
|
||||
#ask user for customization
|
||||
get_user_selections_klipperscreen
|
||||
#KlipperScreen main installation
|
||||
klipperscreen_setup
|
||||
#execute customizations
|
||||
symlinks_klipperscreen
|
||||
#after install actions
|
||||
restart_klipperscreen
|
||||
else
|
||||
@@ -29,57 +24,16 @@ python3_check(){
|
||||
fi
|
||||
}
|
||||
|
||||
system_check_klipperscreen(){
|
||||
source_kiauh_ini
|
||||
if [ ! -e $klipper_cfg_loc/KlipperScreen.log ]; then
|
||||
KLIPPERSCREEN_SL_FOUND="false"
|
||||
else
|
||||
KLIPPERSCREEN_SL_FOUND="true"
|
||||
fi
|
||||
}
|
||||
|
||||
get_user_selections_klipperscreen(){
|
||||
#user selection for KlipperScreen.log symlink
|
||||
if [ "$KLIPPERSCREEN_SL_FOUND" = "false" ]; then
|
||||
while true; do
|
||||
echo
|
||||
read -p "${cyan}###### Create KlipperScreen.log symlink? (y/N):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes)
|
||||
echo -e "###### > Yes"
|
||||
SEL_KSLOG_SL="true"
|
||||
break;;
|
||||
N|n|No|no|"")
|
||||
echo -e "###### > No"
|
||||
SEL_KSLOG_SL="false"
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
klipperscreen_setup(){
|
||||
dep=(wget curl unzip dfu-util)
|
||||
dependency_check
|
||||
status_msg "Downloading KlipperScreen ..."
|
||||
#force remove existing KlipperScreen dir
|
||||
# force remove existing KlipperScreen dir
|
||||
[ -d $KLIPPERSCREEN_DIR ] && rm -rf $KLIPPERSCREEN_DIR
|
||||
#clone into fresh KlipperScreen dir
|
||||
# clone into fresh KlipperScreen dir
|
||||
cd ${HOME} && git clone $KLIPPERSCREEN_REPO
|
||||
ok_msg "Download complete!"
|
||||
status_msg "Installing KlipperScreen ..."
|
||||
$KLIPPERSCREEN_DIR/scripts/KlipperScreen-install.sh
|
||||
echo; ok_msg "KlipperScreen successfully installed!"
|
||||
}
|
||||
|
||||
symlinks_klipperscreen(){
|
||||
#create a KlipperScreen.log symlink in klipper_config-dir just for convenience
|
||||
if [ "$SEL_KSLOG_SL" = "true" ] && [ ! -e $klipper_cfg_loc/KlipperScreen.log ]; then
|
||||
status_msg "Creating KlipperScreen.log symlink ..."
|
||||
ln -s /tmp/KlipperScreen.log $klipper_cfg_loc
|
||||
ok_msg "Symlink created!"
|
||||
fi
|
||||
ok_msg "KlipperScreen successfully installed!"
|
||||
}
|
||||
|
||||
132
scripts/install_mjpg-streamer.sh
Executable file
132
scripts/install_mjpg-streamer.sh
Executable file
@@ -0,0 +1,132 @@
|
||||
### base variables
|
||||
SYSTEMDDIR="/etc/systemd/system"
|
||||
WEBCAMD_SRC="https://raw.githubusercontent.com/mainsail-crew/MainsailOS/master/src/modules/mjpgstreamer/filesystem/root/usr/local/bin/webcamd"
|
||||
WEBCAM_TXT_SRC="https://raw.githubusercontent.com/mainsail-crew/MainsailOS/master/src/modules/mjpgstreamer/filesystem/home/pi/klipper_config/webcam.txt"
|
||||
|
||||
install_mjpg-streamer(){
|
||||
check_klipper_cfg_path
|
||||
source_kiauh_ini
|
||||
|
||||
### set default values
|
||||
MJPG_SERV_SRC="${SRCDIR}/kiauh/resources/webcamd.service"
|
||||
MJPG_SERV_TARGET="$SYSTEMDDIR/webcamd.service"
|
||||
WEBCAM_TXT="$klipper_cfg_loc/webcam.txt"
|
||||
|
||||
### if there is a webcamd.service -> exit
|
||||
if [ -f $MJPG_SERV_TARGET ]; then
|
||||
ERROR_MSG="Looks like MJPG-streamer is already installed!\n Please remove it first before you try to re-install it!"
|
||||
print_msg && clear_msg && return
|
||||
fi
|
||||
|
||||
### check and install dependencies if missing
|
||||
dep=(git cmake build-essential imagemagick libv4l-dev ffmpeg)
|
||||
if apt-cache search libjpeg62-turbo-dev | grep -Eq "^libjpeg62-turbo-dev "; then
|
||||
dep+=(libjpeg62-turbo-dev)
|
||||
elif apt-cache search libjpeg8-dev | grep -Eq "^libjpeg8-dev "; then
|
||||
dep+=(libjpeg8-dev)
|
||||
fi
|
||||
dependency_check
|
||||
|
||||
### step 1: clone moonraker
|
||||
status_msg "Downloading MJPG-Streamer ..."
|
||||
cd "${HOME}" && git clone https://github.com/jacksonliam/mjpg-streamer.git
|
||||
ok_msg "Download complete!"
|
||||
|
||||
### step 2: compiling mjpg-streamer
|
||||
status_msg "Compiling MJPG-Streamer ..."
|
||||
cd "${HOME}"/mjpg-streamer/mjpg-streamer-experimental && make
|
||||
ok_msg "Compiling complete!"
|
||||
|
||||
#step 3: install mjpg-streamer
|
||||
status_msg "Installing MJPG-Streamer ..."
|
||||
cd "${HOME}"/mjpg-streamer && mv mjpg-streamer-experimental/* .
|
||||
mkdir www-mjpgstreamer
|
||||
cat <<EOT >> ./www-mjpgstreamer/index.html
|
||||
<html>
|
||||
<head><title>mjpg_streamer test page</title></head>
|
||||
<body>
|
||||
<h1>Snapshot</h1>
|
||||
<p>Refresh the page to refresh the snapshot</p>
|
||||
<img src="./?action=snapshot" alt="Snapshot">
|
||||
<h1>Stream</h1>
|
||||
<img src="./?action=stream" alt="Stream">
|
||||
</body>
|
||||
</html>
|
||||
EOT
|
||||
sudo wget $WEBCAMD_SRC -O "/usr/local/bin/webcamd"
|
||||
sudo sed -i "/^config_dir=/ s|=.*|=$klipper_cfg_loc|" /usr/local/bin/webcamd
|
||||
sudo sed -i "/MJPGSTREAMER_HOME/ s/pi/${USER}/" /usr/local/bin/webcamd
|
||||
sudo chmod +x /usr/local/bin/webcamd
|
||||
|
||||
### step 4: create webcam.txt config file
|
||||
[ ! -d "$klipper_cfg_loc" ] && mkdir -p "$klipper_cfg_loc"
|
||||
if [ ! -f "$WEBCAM_TXT" ]; then
|
||||
status_msg "Creating webcam.txt config file ..."
|
||||
wget $WEBCAM_TXT_SRC -O "$WEBCAM_TXT"
|
||||
ok_msg "Done!"
|
||||
fi
|
||||
|
||||
### step 5: create systemd service
|
||||
status_msg "Creating MJPG-Streamer service ..."
|
||||
sudo cp "$MJPG_SERV_SRC" $MJPG_SERV_TARGET
|
||||
sudo sed -i "s|%USER%|${USER}|" $MJPG_SERV_TARGET
|
||||
ok_msg "MJPG-Streamer service created!"
|
||||
|
||||
### step 6: enabling and starting mjpg-streamer service
|
||||
status_msg "Starting MJPG-Streamer service ..."
|
||||
sudo systemctl enable webcamd.service
|
||||
sudo systemctl start webcamd.service
|
||||
ok_msg "MJPG-Streamer service started!"
|
||||
|
||||
### step 6.1: create webcamd.log symlink
|
||||
[ ! -d "${HOME}/klipper_logs" ] && mkdir -p "${HOME}/klipper_logs"
|
||||
if [ -f "/var/log/webcamd.log" ] && [ ! -L "${HOME}/klipper_logs/webcamd.log" ]; then
|
||||
ln -s "/var/log/webcamd.log" "${HOME}/klipper_logs/webcamd.log"
|
||||
fi
|
||||
|
||||
### step 6.2: add webcamd.log logrotate
|
||||
if [ ! -f "/etc/logrotate.d/webcamd" ]; then
|
||||
status_msg "Create logrotate rule ..."
|
||||
sudo /bin/sh -c "cat > /etc/logrotate.d/webcamd" << EOF
|
||||
/var/log/webcamd.log
|
||||
{
|
||||
rotate 2
|
||||
weekly
|
||||
maxsize 32M
|
||||
missingok
|
||||
notifempty
|
||||
compress
|
||||
delaycompress
|
||||
sharedscripts
|
||||
}
|
||||
EOF
|
||||
ok_msg "Done!"
|
||||
fi
|
||||
|
||||
### step 7: check if user is in group "video"
|
||||
usergroup_changed=false
|
||||
USER_IN_VIDEO_GROUP=$(groups "${USER}" | grep "video")
|
||||
if [ -z "$USER_IN_VIDEO_GROUP" ]; then
|
||||
status_msg "Adding user ${USER} to group 'video' ..."
|
||||
sudo usermod -a -G video "${USER}" && ok_msg "Done!"
|
||||
usergroup_changed=true
|
||||
else
|
||||
ok_msg "User ${USER} already in group 'video'!"
|
||||
fi
|
||||
|
||||
### confirm message
|
||||
CONFIRM_MSG="MJPG-Streamer has been set up!"
|
||||
if [ "$usergroup_changed" == true ]; then
|
||||
CONFIRM_MSG="${CONFIRM_MSG}\n ${yellow}INFO: Your User was added to a new group!${green}"
|
||||
CONFIRM_MSG="${CONFIRM_MSG}\n ${yellow}You need to relog/restart for the group to be applied!${green}"
|
||||
fi
|
||||
print_msg && clear_msg
|
||||
|
||||
### print webcam ip adress/url
|
||||
IP=$(hostname -I | cut -d" " -f1)
|
||||
WEBCAM_IP="http://$IP:8080/?action=stream"
|
||||
WEBCAM_URL="http://$IP/webcam/?action=stream"
|
||||
echo -e " ${cyan}● Webcam URL:${default} $WEBCAM_IP"
|
||||
echo -e " ${cyan}● Webcam URL:${default} $WEBCAM_URL"
|
||||
echo
|
||||
}
|
||||
23
scripts/install_moonraker-telegram-bot.sh
Normal file
23
scripts/install_moonraker-telegram-bot.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
install_MoonrakerTelegramBot(){
|
||||
source_kiauh_ini
|
||||
#MoonrakerTelegramBot main installation
|
||||
MoonrakerTelegramBot_setup
|
||||
#after install actions
|
||||
restart_MoonrakerTelegramBot
|
||||
}
|
||||
|
||||
MoonrakerTelegramBot_setup(){
|
||||
source_kiauh_ini
|
||||
export klipper_cfg_loc
|
||||
dep=(virtualenv)
|
||||
dependency_check
|
||||
status_msg "Downloading MoonrakerTelegramBot ..."
|
||||
#force remove existing MoonrakerTelegramBot dir
|
||||
[ -d $MOONRAKER_TELEGRAM_BOT_DIR ] && rm -rf $MOONRAKER_TELEGRAM_BOT_DIR
|
||||
#clone into fresh MoonrakerTelegramBot dir
|
||||
cd ${HOME} && git clone $NLEF_REPO
|
||||
ok_msg "Download complete!"
|
||||
status_msg "Installing MoonrakerTelegramBot ..."
|
||||
$MOONRAKER_TELEGRAM_BOT_DIR/scripts/install.sh
|
||||
echo; ok_msg "MoonrakerTelegramBot successfully installed!"
|
||||
}
|
||||
@@ -2,111 +2,93 @@
|
||||
SYSTEMDDIR="/etc/systemd/system"
|
||||
MOONRAKER_ENV="${HOME}/moonraker-env"
|
||||
MOONRAKER_DIR="${HOME}/moonraker"
|
||||
MOONRAKER_REPO="https://github.com/Arksine/moonraker.git"
|
||||
|
||||
system_check_moonraker(){
|
||||
### python 3 check
|
||||
status_msg "Your Python 3 version is: $(python3 --version)"
|
||||
major=$(python3 --version | cut -d" " -f2 | cut -d"." -f1)
|
||||
minor=$(python3 --version | cut -d"." -f2)
|
||||
if [ $major -ge 3 ] && [ $minor -ge 7 ]; then
|
||||
ok_msg "Python version ok!"
|
||||
if [ "$major" -ge 3 ] && [ "$minor" -ge 7 ]; then
|
||||
py_chk_ok="true"
|
||||
else
|
||||
warn_msg "Python version not ok!"
|
||||
py_chk_ok="false"
|
||||
fi
|
||||
|
||||
### check system for an installed and enabled octoprint service
|
||||
if systemctl list-unit-files | grep -E "octoprint.*" | grep "enabled" &>/dev/null; then
|
||||
OCTOPRINT_ENABLED="true"
|
||||
fi
|
||||
|
||||
### check system for an installed haproxy service
|
||||
if [[ $(dpkg-query -f'${Status}' --show haproxy 2>/dev/null) = *\ installed ]]; then
|
||||
HAPROXY_FOUND="true"
|
||||
fi
|
||||
|
||||
### check system for an installed lighttpd service
|
||||
if [[ $(dpkg-query -f'${Status}' --show lighttpd 2>/dev/null) = *\ installed ]]; then
|
||||
LIGHTTPD_FOUND="true"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
moonraker_setup_dialog(){
|
||||
status_msg "Initializing Moonraker installation ..."
|
||||
|
||||
### check system for several requirements before initializing the moonraker installation
|
||||
system_check_moonraker
|
||||
|
||||
### exit moonraker setup if python version is not ok
|
||||
if [ $py_chk_ok = "false" ]; then
|
||||
ERROR_MSG="Python 3.7 or above required!\n Please upgrade your Python version first."
|
||||
print_msg && clear_msg && return 0
|
||||
fi
|
||||
|
||||
### check for existing moonraker service installations
|
||||
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "moonraker.service")" ] || [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "moonraker-[[:digit:]].service")" ]; then
|
||||
ERROR_MSG="At least one Moonraker service is already installed!" && return 0
|
||||
SERVICE_FILES=$(find "$SYSTEMDDIR" -regextype posix-extended -regex "$SYSTEMDDIR/moonraker(-[^0])?[0-9]*.service")
|
||||
if [ -n "$SERVICE_FILES" ]; then
|
||||
ERROR_MSG="At least one Moonraker service is already installed:"
|
||||
for service in $SERVICE_FILES; do
|
||||
ERROR_MSG="${ERROR_MSG}\n ➔ $service"
|
||||
done && return
|
||||
fi
|
||||
|
||||
### check for existing klipper service installations
|
||||
if [ ! "$(systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ] && [ ! "$(systemctl list-units --full -all -t service --no-legend | grep -E "klipper-[[:digit:]].service")" ]; then
|
||||
ERROR_MSG="Klipper service not found, please install Klipper first!" && return 0
|
||||
status_msg "Initializing Moonraker installation ..."
|
||||
### checking system for python3.7+
|
||||
system_check_moonraker
|
||||
### exit moonraker setup if python versioncheck fails
|
||||
if [ $py_chk_ok = "false" ]; then
|
||||
ERROR_MSG="Versioncheck failed! Python 3.7 or newer required!\n"
|
||||
ERROR_MSG="${ERROR_MSG} Please upgrade Python."
|
||||
print_msg && clear_msg && return
|
||||
fi
|
||||
|
||||
### count amount of klipper services
|
||||
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ]; then
|
||||
INSTANCE_COUNT=1
|
||||
else
|
||||
INSTANCE_COUNT=$(systemctl list-units --full -all -t service --no-legend | grep -E "klipper-[[:digit:]].service" | wc -l)
|
||||
SERVICE_FILES=$(find "$SYSTEMDDIR" -regextype posix-extended -regex "$SYSTEMDDIR/klipper(-[^0])+[0-9]*.service")
|
||||
if [ -f /etc/init.d/klipper ] || [ -f /etc/systemd/system/klipper.service ]; then
|
||||
KLIPPER_COUNT=1
|
||||
elif [ -n "$SERVICE_FILES" ]; then
|
||||
KLIPPER_COUNT=$(echo "$SERVICE_FILES" | wc -l)
|
||||
fi
|
||||
|
||||
### initial moonraker.conf path check
|
||||
check_klipper_cfg_path
|
||||
|
||||
### ask user how to handle OctoPrint, Haproxy and Lighttpd
|
||||
process_octoprint_dialog
|
||||
process_haproxy_lighttpd_dialog
|
||||
|
||||
### instance confirmation dialog
|
||||
while true; do
|
||||
top_border
|
||||
if [[ $KLIPPER_COUNT -eq 1 ]]; then
|
||||
printf "|${green}%-55s${default}|\n" " 1 Klipper instance was found!"
|
||||
elif [[ $KLIPPER_COUNT -gt 1 ]]; then
|
||||
printf "|${green}%-55s${default}|\n" " $KLIPPER_COUNT Klipper instances were found!"
|
||||
else
|
||||
echo -e "| ${yellow}INFO: No existing Klipper installation found!${default} |"
|
||||
fi
|
||||
echo -e "| Usually you need one Moonraker instance per Klipper |"
|
||||
echo -e "| instance. Though you can install as many as you wish. |"
|
||||
bottom_border
|
||||
echo
|
||||
count=""
|
||||
while [[ ! ($count =~ ^[1-9]+((0)+)?$) ]]; do
|
||||
read -p "${cyan}###### Number of Moonraker instances to set up:${default} " count
|
||||
if [[ ! ($count =~ ^[1-9]+((0)+)?$) ]]; then
|
||||
warn_msg "Invalid Input!\n"
|
||||
else
|
||||
echo
|
||||
top_border
|
||||
if [ $INSTANCE_COUNT -gt 1 ]; then
|
||||
printf "|%-55s|\n" " $INSTANCE_COUNT Klipper instances were found!"
|
||||
else
|
||||
echo -e "| 1 Klipper instance was found! | "
|
||||
fi
|
||||
echo -e "| You need one Moonraker instance per Klipper instance. | "
|
||||
bottom_border
|
||||
echo
|
||||
read -p "${cyan}###### Create $INSTANCE_COUNT Moonraker instances? (Y/n):${default} " yn
|
||||
read -p "${cyan}###### Install $count instance(s)? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
echo -e "###### > Yes"
|
||||
status_msg "Creating $INSTANCE_COUNT Moonraker instances ..."
|
||||
moonraker_setup
|
||||
status_msg "Installing Moonraker ...\n"
|
||||
moonraker_setup "$count"
|
||||
break;;
|
||||
N|n|No|no)
|
||||
echo -e "###### > No"
|
||||
warn_msg "Exiting Moonraker setup ..."
|
||||
echo
|
||||
warn_msg "Exiting Moonraker setup ...\n"
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
esac
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
moonraker_setup(){
|
||||
### get printer config directory
|
||||
source_kiauh_ini
|
||||
MOONRAKER_CONF_LOC="$klipper_cfg_loc"
|
||||
|
||||
INSTANCE_COUNT=$1
|
||||
### checking dependencies
|
||||
dep=(wget curl unzip dfu-util)
|
||||
dep=(wget curl unzip dfu-util virtualenv)
|
||||
### additional deps for kiauh compatibility for armbian
|
||||
dep+=(libjpeg-dev zlib1g-dev)
|
||||
dependency_check
|
||||
@@ -114,8 +96,8 @@ moonraker_setup(){
|
||||
### step 1: clone moonraker
|
||||
status_msg "Downloading Moonraker ..."
|
||||
### force remove existing moonraker dir and clone into fresh moonraker dir
|
||||
[ -d $MOONRAKER_DIR ] && rm -rf $MOONRAKER_DIR
|
||||
cd ${HOME} && git clone $MOONRAKER_REPO
|
||||
[ -d "$MOONRAKER_DIR" ] && rm -rf "$MOONRAKER_DIR"
|
||||
cd "${HOME}" && git clone $MOONRAKER_REPO
|
||||
ok_msg "Download complete!"
|
||||
|
||||
### step 2: install moonraker dependencies and create python virtualenv
|
||||
@@ -124,475 +106,216 @@ moonraker_setup(){
|
||||
create_moonraker_virtualenv
|
||||
|
||||
### step 3: create moonraker.conf folder and moonraker.confs
|
||||
[ ! -d $MOONRAKER_CONF_LOC ] && mkdir -p $MOONRAKER_CONF_LOC
|
||||
moonraker_conf_creation
|
||||
create_moonraker_conf
|
||||
|
||||
### step 4: set up moonrakers nginx configs
|
||||
setup_moonraker_nginx_cfg
|
||||
### step 4: create final moonraker instances
|
||||
create_moonraker_service
|
||||
|
||||
### step 5: process possible disruptive services
|
||||
process_haproxy_lighttpd_services
|
||||
### step 5: create polkit rules for moonraker
|
||||
moonraker_polkit
|
||||
|
||||
### step 6: create final moonraker instances
|
||||
INSTANCE=1
|
||||
if [ $INSTANCE_COUNT -eq $INSTANCE ]; then
|
||||
create_single_moonraker_instance
|
||||
else
|
||||
create_multi_moonraker_instance
|
||||
### step 6.5: enable mainsails remoteMode if its already installed
|
||||
if [ -d $MAINSAIL_DIR ]; then
|
||||
enable_mainsail_remotemode
|
||||
fi
|
||||
fi
|
||||
### confirm message
|
||||
if [[ $INSTANCE_COUNT -eq 1 ]]; then
|
||||
CONFIRM_MSG="Moonraker has been set up!"
|
||||
elif [[ $INSTANCE_COUNT -gt 1 ]]; then
|
||||
CONFIRM_MSG="$INSTANCE_COUNT Moonraker instances have been set up!"
|
||||
fi && print_msg && clear_msg
|
||||
|
||||
### display moonraker ips to the user
|
||||
print_mr_ip_list; echo
|
||||
}
|
||||
|
||||
##############################################################################################
|
||||
#********************************************************************************************#
|
||||
##############################################################################################
|
||||
|
||||
install_moonraker_packages(){
|
||||
PKGLIST="python3-virtualenv python3-dev nginx libopenjp2-7 python3-libgpiod"
|
||||
### read PKGLIST from official install script
|
||||
status_msg "Reading dependencies..."
|
||||
install_script="${HOME}/moonraker/scripts/install-moonraker.sh"
|
||||
PKGLIST=$(grep "PKGLIST=" "$install_script" | sed 's/PKGLIST//g; s/[$"{}=]//g; s/\s\s*/ /g' | tr -d '\n')
|
||||
for pkg in $PKGLIST; do
|
||||
echo "${cyan}$pkg${default}"
|
||||
done
|
||||
read -r -a PKGLIST <<< "$PKGLIST"
|
||||
|
||||
### Update system package info
|
||||
status_msg "Running apt-get update..."
|
||||
sudo apt-get update
|
||||
sudo apt-get update --allow-releaseinfo-change
|
||||
|
||||
### Install desired packages
|
||||
status_msg "Installing packages..."
|
||||
sudo apt-get install --yes ${PKGLIST}
|
||||
sudo apt-get install --yes "${PKGLIST[@]}"
|
||||
}
|
||||
|
||||
create_moonraker_virtualenv(){
|
||||
status_msg "Installing python virtual environment..."
|
||||
|
||||
### If venv exists and user prompts a rebuild, then do so
|
||||
if [ -d ${MOONRAKER_ENV} ] && [ $REBUILD_ENV = "y" ]; then
|
||||
if [ -d "$MOONRAKER_ENV" ] && [ "$REBUILD_ENV" = "y" ]; then
|
||||
status_msg "Removing old virtualenv"
|
||||
rm -rf ${MOONRAKER_ENV}
|
||||
rm -rf "$MOONRAKER_ENV"
|
||||
fi
|
||||
|
||||
[ ! -d ${MOONRAKER_ENV} ] && virtualenv -p /usr/bin/python3 --system-site-packages ${MOONRAKER_ENV}
|
||||
if [ ! -d "$MOONRAKER_ENV" ]; then
|
||||
virtualenv -p /usr/bin/python3 "$MOONRAKER_ENV"
|
||||
fi
|
||||
|
||||
### Install/update dependencies
|
||||
${MOONRAKER_ENV}/bin/pip install -r ${MOONRAKER_DIR}/scripts/moonraker-requirements.txt
|
||||
"$MOONRAKER_ENV"/bin/pip install -r "$MOONRAKER_DIR"/scripts/moonraker-requirements.txt
|
||||
}
|
||||
|
||||
create_single_moonraker_startscript(){
|
||||
### create systemd service file
|
||||
sudo /bin/sh -c "cat > ${SYSTEMDDIR}/moonraker.service" << EOF
|
||||
#Systemd service file for moonraker
|
||||
[Unit]
|
||||
Description=Starts Moonraker on startup
|
||||
After=network.target
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
[Service]
|
||||
Type=simple
|
||||
User=${USER}
|
||||
RemainAfterExit=yes
|
||||
ExecStart=${MOONRAKER_ENV}/bin/python ${MOONRAKER_DIR}/moonraker/moonraker.py -l ${MOONRAKER_LOG} -c ${MOONRAKER_CONF}
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
EOF
|
||||
create_moonraker_service(){
|
||||
### get config directory
|
||||
source_kiauh_ini
|
||||
|
||||
### set up default values
|
||||
SINGLE_INST=1
|
||||
CFG_PATH="$klipper_cfg_loc"
|
||||
MR_ENV=$MOONRAKER_ENV
|
||||
MR_DIR=$MOONRAKER_DIR
|
||||
MR_LOG="${HOME}/klipper_logs/moonraker.log"
|
||||
MR_CONF="$CFG_PATH/moonraker.conf"
|
||||
MR_SERV_SRC="${SRCDIR}/kiauh/resources/moonraker.service"
|
||||
MR_SERV_TARGET="$SYSTEMDDIR/moonraker.service"
|
||||
|
||||
write_mr_service(){
|
||||
if [ ! -f $MR_SERV_TARGET ]; then
|
||||
status_msg "Creating Moonraker Service $i ..."
|
||||
sudo cp "$MR_SERV_SRC" $MR_SERV_TARGET
|
||||
sudo sed -i "s|%INST%|$i|" $MR_SERV_TARGET
|
||||
sudo sed -i "s|%USER%|${USER}|" $MR_SERV_TARGET
|
||||
sudo sed -i "s|%MR_ENV%|$MR_ENV|" $MR_SERV_TARGET
|
||||
sudo sed -i "s|%MR_DIR%|$MR_DIR|" $MR_SERV_TARGET
|
||||
sudo sed -i "s|%MR_LOG%|$MR_LOG|" $MR_SERV_TARGET
|
||||
sudo sed -i "s|%MR_CONF%|$MR_CONF|" $MR_SERV_TARGET
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ $SINGLE_INST -eq $INSTANCE_COUNT ]]; then
|
||||
### write single instance service
|
||||
write_mr_service
|
||||
### enable instance
|
||||
do_action_service "enable" "moonraker"
|
||||
ok_msg "Single Moonraker instance created!"
|
||||
### launching instance
|
||||
do_action_service "start" "moonraker"
|
||||
else
|
||||
i=1
|
||||
while [[ $i -le $INSTANCE_COUNT ]]; do
|
||||
### rewrite default variables for multi instance cases
|
||||
CFG_PATH="$klipper_cfg_loc/printer_$i"
|
||||
MR_SERV_TARGET="$SYSTEMDDIR/moonraker-$i.service"
|
||||
MR_CONF="$CFG_PATH/moonraker.conf"
|
||||
MR_LOG="${HOME}/klipper_logs/moonraker-$i.log"
|
||||
### write multi instance service
|
||||
write_mr_service
|
||||
### enable instance
|
||||
do_action_service "enable" "moonraker-$i"
|
||||
ok_msg "Moonraker instance #$i created!"
|
||||
### launching instance
|
||||
do_action_service "start" "moonraker-$i"
|
||||
### raise values by 1
|
||||
i=$((i+1))
|
||||
done
|
||||
unset i
|
||||
|
||||
### enable mainsails remoteMode if mainsail is found
|
||||
if [ -d "$MAINSAIL_DIR" ]; then
|
||||
status_msg "Mainsail installation found!"
|
||||
status_msg "Enabling Mainsail remoteMode ..."
|
||||
enable_mainsail_remotemode
|
||||
ok_msg "Mainsails remoteMode enabled!"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
create_multi_moonraker_startscript(){
|
||||
### create multi instance systemd service file
|
||||
sudo /bin/sh -c "cat > ${SYSTEMDDIR}/moonraker-$INSTANCE.service" << EOF
|
||||
#Systemd service file for moonraker
|
||||
[Unit]
|
||||
Description=Starts Moonraker instance $INSTANCE on startup
|
||||
After=network.target
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
[Service]
|
||||
Type=simple
|
||||
User=${USER}
|
||||
RemainAfterExit=yes
|
||||
ExecStart=${MOONRAKER_ENV}/bin/python ${MOONRAKER_DIR}/moonraker/moonraker.py -l ${MOONRAKER_LOG} -c ${MOONRAKER_CONF}
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
EOF
|
||||
create_moonraker_conf(){
|
||||
### get config directory
|
||||
source_kiauh_ini
|
||||
|
||||
### set up default values
|
||||
SINGLE_INST=1
|
||||
PORT=7125
|
||||
CFG_PATH="$klipper_cfg_loc"
|
||||
LOG_PATH="${HOME}/klipper_logs"
|
||||
MR_CONF="$CFG_PATH/moonraker.conf"
|
||||
MR_DB="${HOME}/.moonraker_database"
|
||||
KLIPPY_UDS="/tmp/klippy_uds"
|
||||
MR_CONF_SRC="${SRCDIR}/kiauh/resources/moonraker.conf"
|
||||
mr_ip_list=()
|
||||
IP=$(hostname -I | cut -d" " -f1)
|
||||
LAN="$(hostname -I | cut -d" " -f1 | cut -d"." -f1-2).0.0/16"
|
||||
|
||||
write_mr_conf(){
|
||||
[ ! -d "$CFG_PATH" ] && mkdir -p "$CFG_PATH"
|
||||
if [ ! -f "$MR_CONF" ]; then
|
||||
status_msg "Creating moonraker.conf in $CFG_PATH ..."
|
||||
cp "$MR_CONF_SRC" "$MR_CONF"
|
||||
sed -i "s|%PORT%|$PORT|" "$MR_CONF"
|
||||
sed -i "s|%CFG%|$CFG_PATH|" "$MR_CONF"
|
||||
sed -i "s|%LOG%|$LOG_PATH|" "$MR_CONF"
|
||||
sed -i "s|%MR_DB%|$MR_DB|" "$MR_CONF"
|
||||
sed -i "s|%UDS%|$KLIPPY_UDS|" "$MR_CONF"
|
||||
# if host ip is not in the default ip ranges, replace placeholder
|
||||
# otherwise remove placeholder from config
|
||||
if ! grep -q "$LAN" "$MR_CONF"; then
|
||||
sed -i "s|%LAN%|$LAN|" "$MR_CONF"
|
||||
else
|
||||
sed -i "/%LAN%/d" "$MR_CONF"
|
||||
fi
|
||||
sed -i "s|%USER%|${USER}|g" "$MR_CONF"
|
||||
ok_msg "moonraker.conf created!"
|
||||
else
|
||||
warn_msg "There is already a file called 'moonraker.conf'!"
|
||||
warn_msg "Skipping..."
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ $SINGLE_INST -eq $INSTANCE_COUNT ]]; then
|
||||
### write single instance config
|
||||
write_mr_conf
|
||||
mr_ip_list+=("$IP:$PORT")
|
||||
else
|
||||
i=1
|
||||
while [[ $i -le $INSTANCE_COUNT ]]; do
|
||||
### rewrite default variables for multi instance cases
|
||||
CFG_PATH="$klipper_cfg_loc/printer_$i"
|
||||
MR_CONF="$CFG_PATH/moonraker.conf"
|
||||
MR_DB="${HOME}/.moonraker_database_$i"
|
||||
KLIPPY_UDS="/tmp/klippy_uds-$i"
|
||||
|
||||
### write multi instance config
|
||||
write_mr_conf
|
||||
mr_ip_list+=("$IP:$PORT")
|
||||
|
||||
### raise values by 1
|
||||
PORT=$((PORT+1))
|
||||
i=$((i+1))
|
||||
done
|
||||
unset PORT && unset i
|
||||
fi
|
||||
}
|
||||
|
||||
create_single_moonraker_conf(){
|
||||
HOSTNAME=$(hostname -I | cut -d" " -f1)
|
||||
LOCAL_NETWORK="$(hostname -I | cut -d" " -f1 | cut -d"." -f1-2).0.0/16"
|
||||
|
||||
/bin/sh -c "cat > $MOONRAKER_CONF_LOC/moonraker.conf" << MOONRAKERCONF
|
||||
[server]
|
||||
host: 0.0.0.0
|
||||
port: $PORT
|
||||
enable_debug_logging: True
|
||||
config_path: $PRINTER_CFG_LOC
|
||||
klippy_uds_address: /tmp/klippy_uds
|
||||
|
||||
[authorization]
|
||||
enabled: True
|
||||
api_key_file: ~/.moonraker_api_key
|
||||
trusted_clients:
|
||||
127.0.0.1
|
||||
$LOCAL_NETWORK
|
||||
::1/128
|
||||
FE80::/10
|
||||
cors_domains:
|
||||
http://*.local
|
||||
http://my.mainsail.xyz
|
||||
https://my.mainsail.xyz
|
||||
http://app.fluidd.xyz
|
||||
https://app.fluidd.xyz
|
||||
http://$HOSTNAME
|
||||
http://$HOSTNAME:*
|
||||
|
||||
[update_manager]
|
||||
|
||||
[update_manager client mainsail]
|
||||
type: web
|
||||
repo: meteyou/mainsail
|
||||
path: ~/mainsail
|
||||
|
||||
[update_manager client fluidd]
|
||||
type: web
|
||||
repo: cadriel/fluidd
|
||||
path: ~/fluidd
|
||||
|
||||
#[update_manager client KlipperScreen]
|
||||
#type: git_repo
|
||||
#path: /home/${HOME}/KlipperScreen
|
||||
#origin: https://github.com/jordanruthe/KlipperScreen.git
|
||||
#env: /home/${HOME}/.KlipperScreen-env/bin/python
|
||||
#requirements: scripts/KlipperScreen-requirements.txt
|
||||
#install_script: scripts/KlipperScreen-install.sh
|
||||
MOONRAKERCONF
|
||||
}
|
||||
|
||||
create_multi_moonraker_conf(){
|
||||
HOSTNAME=$(hostname -I | cut -d" " -f1)
|
||||
LOCAL_NETWORK="$(hostname -I | cut -d" " -f1 | cut -d"." -f1-2).0.0/16"
|
||||
|
||||
/bin/sh -c "cat > $MOONRAKER_CONF_LOC/printer_$INSTANCE/moonraker.conf" << MOONRAKERCONF
|
||||
[server]
|
||||
host: 0.0.0.0
|
||||
port: $PORT
|
||||
enable_debug_logging: True
|
||||
config_path: $PRINTER_CFG_LOC/printer_$INSTANCE
|
||||
klippy_uds_address: /tmp/klippy_uds-$INSTANCE
|
||||
|
||||
[authorization]
|
||||
enabled: True
|
||||
api_key_file: ~/.moonraker_api_key
|
||||
trusted_clients:
|
||||
127.0.0.1
|
||||
$LOCAL_NETWORK
|
||||
::1/128
|
||||
FE80::/10
|
||||
cors_domains:
|
||||
http://*.local
|
||||
https://*.local
|
||||
http://my.mainsail.xyz
|
||||
https://my.mainsail.xyz
|
||||
http://app.fluidd.xyz
|
||||
https://app.fluidd.xyz
|
||||
http://$HOSTNAME
|
||||
http://$HOSTNAME:*
|
||||
|
||||
[update_manager]
|
||||
|
||||
[update_manager client mainsail]
|
||||
type: web
|
||||
repo: meteyou/mainsail
|
||||
path: ~/mainsail
|
||||
|
||||
[update_manager client fluidd]
|
||||
type: web
|
||||
repo: cadriel/fluidd
|
||||
path: ~/fluidd
|
||||
|
||||
#[update_manager client KlipperScreen]
|
||||
#type: git_repo
|
||||
#path: /home/${USER}/KlipperScreen
|
||||
#origin: https://github.com/jordanruthe/KlipperScreen.git
|
||||
#env: /home/${USER}/.KlipperScreen-env/bin/python
|
||||
#requirements: scripts/KlipperScreen-requirements.txt
|
||||
#install_script: scripts/KlipperScreen-install.sh
|
||||
MOONRAKERCONF
|
||||
}
|
||||
|
||||
##############################################################################################
|
||||
#********************************************************************************************#
|
||||
##############################################################################################
|
||||
|
||||
print_mr_ip_list(){
|
||||
i=1
|
||||
for ip in ${mr_ip_list[@]}; do
|
||||
for ip in "${mr_ip_list[@]}"; do
|
||||
echo -e " ${cyan}● Instance $i:${default} $ip"
|
||||
i=$((i + 1))
|
||||
done
|
||||
}
|
||||
|
||||
create_single_moonraker_instance(){
|
||||
status_msg "Setting up 1 Moonraker instance ..."
|
||||
|
||||
### single instance variables
|
||||
MOONRAKER_LOG=/tmp/moonraker.log
|
||||
MOONRAKER_CONF="$MOONRAKER_CONF_LOC/moonraker.conf"
|
||||
|
||||
### create instance
|
||||
status_msg "Creating single Moonraker instance ..."
|
||||
create_single_moonraker_startscript
|
||||
|
||||
### enable instance
|
||||
sudo systemctl enable moonraker.service
|
||||
ok_msg "Single Moonraker instance created!"
|
||||
|
||||
### launching instance
|
||||
status_msg "Launching Moonraker instance ..."
|
||||
sudo systemctl start moonraker
|
||||
|
||||
### confirm message
|
||||
CONFIRM_MSG="Single Moonraker instance has been set up!"
|
||||
print_msg && clear_msg
|
||||
|
||||
### display moonraker ip to the user
|
||||
print_mr_ip_list; echo
|
||||
}
|
||||
|
||||
create_multi_moonraker_instance(){
|
||||
status_msg "Setting up $INSTANCE_COUNT instances of Moonraker ..."
|
||||
while [ $INSTANCE -le $INSTANCE_COUNT ]; do
|
||||
### multi instance variables
|
||||
MOONRAKER_LOG=/tmp/moonraker-$INSTANCE.log
|
||||
MOONRAKER_CONF="$MOONRAKER_CONF_LOC/printer_$INSTANCE/moonraker.conf"
|
||||
|
||||
### create instance
|
||||
status_msg "Creating instance #$INSTANCE ..."
|
||||
create_multi_moonraker_startscript
|
||||
|
||||
### enable instance
|
||||
sudo systemctl enable moonraker-$INSTANCE.service
|
||||
ok_msg "Moonraker instance $INSTANCE created!"
|
||||
|
||||
### launching instance
|
||||
status_msg "Launching Moonraker instance $INSTANCE ..."
|
||||
sudo systemctl start moonraker-$INSTANCE
|
||||
|
||||
### instance counter +1
|
||||
INSTANCE=$(expr $INSTANCE + 1)
|
||||
### introduced due to
|
||||
### https://github.com/Arksine/moonraker/issues/349
|
||||
### https://github.com/Arksine/moonraker/pull/346
|
||||
moonraker_polkit(){
|
||||
SYSTEMDDIR="/etc/systemd/system"
|
||||
MOONRAKER_SERVICES=$(find "$SYSTEMDDIR" -regextype posix-extended -regex "$SYSTEMDDIR/moonraker(-[^0])?[0-9]*.service")
|
||||
for service in $MOONRAKER_SERVICES; do
|
||||
HAS_SUPP="$( grep -cm1 "SupplementaryGroups=moonraker-admin" "$service" || true )"
|
||||
if [ "$HAS_SUPP" -eq 0 ]; then
|
||||
status_msg "Adding moonraker-admin supplementary group to $service ..."
|
||||
sudo sed -i "/^Type=simple$/a SupplementaryGroups=moonraker-admin" "$service" \
|
||||
&& ok_msg "Adding moonraker-admin supplementary group successfull!"
|
||||
fi
|
||||
done
|
||||
|
||||
### confirm message
|
||||
CONFIRM_MSG="$INSTANCE_COUNT Moonraker instances have been set up!"
|
||||
print_msg && clear_msg
|
||||
|
||||
### display all moonraker ips to the user
|
||||
print_mr_ip_list; echo
|
||||
}
|
||||
|
||||
setup_moonraker_nginx_cfg(){
|
||||
get_date
|
||||
|
||||
### backup existing nginx configs
|
||||
[ -f $NGINX_CONFD/upstreams.conf ] && sudo mv $NGINX_CONFD/upstreams.conf $NGINX_CONFD/$current_date_upstreams.conf
|
||||
[ -f $NGINX_CONFD/common_vars.conf ] && sudo mv $NGINX_CONFD/common_vars.conf $NGINX_CONFD/$current_date_common_vars.conf
|
||||
|
||||
### copy nginx configs to target destination
|
||||
if [ ! -f $NGINX_CONFD/upstreams.conf ]; then
|
||||
sudo cp ${SRCDIR}/kiauh/resources/upstreams.conf $NGINX_CONFD
|
||||
fi
|
||||
if [ ! -f $NGINX_CONFD/common_vars.conf ]; then
|
||||
sudo cp ${SRCDIR}/kiauh/resources/common_vars.conf $NGINX_CONFD
|
||||
fi
|
||||
}
|
||||
|
||||
moonraker_conf_creation(){
|
||||
### default moonraker port
|
||||
DEFAULT_PORT=7125
|
||||
|
||||
### get printer and moonraker config directory
|
||||
source_kiauh_ini
|
||||
PRINTER_CFG_LOC="$klipper_cfg_loc"
|
||||
MOONRAKER_CONF_LOC="$klipper_cfg_loc"
|
||||
|
||||
### reset instances back to 1 again
|
||||
INSTANCE=1
|
||||
|
||||
### declare empty array for ips which get displayed to the user at the end of the setup
|
||||
HOSTNAME=$(hostname -I | cut -d" " -f1)
|
||||
mr_ip_list=()
|
||||
|
||||
### create single instance moonraker.conf file
|
||||
if [ $INSTANCE_COUNT -eq $INSTANCE ]; then
|
||||
### set port
|
||||
PORT=$DEFAULT_PORT
|
||||
|
||||
### write the ip and port to the ip list for displaying it later to the user
|
||||
mr_ip_list+=("$HOSTNAME:$PORT")
|
||||
|
||||
status_msg "Creating moonraker.conf in $MOONRAKER_CONF_LOC"
|
||||
[ ! -d $MOONRAKER_CONF_LOC ] && mkdir -p $MOONRAKER_CONF_LOC
|
||||
if [ ! -f $MOONRAKER_CONF_LOC/moonraker.conf ]; then
|
||||
create_single_moonraker_conf && ok_msg "moonraker.conf created!"
|
||||
else
|
||||
warn_msg "There is already a file called 'moonraker.conf'!"
|
||||
warn_msg "Skipping..."
|
||||
fi
|
||||
|
||||
### create multi instance moonraker.conf files
|
||||
else
|
||||
while [ $INSTANCE -le $INSTANCE_COUNT ]; do
|
||||
### set each instance to its own port
|
||||
PORT=$(expr $DEFAULT_PORT + $INSTANCE - 1)
|
||||
|
||||
### write the ip and port to the ip list for displaying it later to the user
|
||||
mr_ip_list+=("$HOSTNAME:$PORT")
|
||||
|
||||
### start the creation of each instance
|
||||
status_msg "Creating moonraker.conf for instance #$INSTANCE"
|
||||
[ ! -d $MOONRAKER_CONF_LOC/printer_$INSTANCE ] && mkdir -p $MOONRAKER_CONF_LOC/printer_$INSTANCE
|
||||
if [ ! -f $MOONRAKER_CONF_LOC/printer_$INSTANCE/moonraker.conf ]; then
|
||||
create_multi_moonraker_conf && ok_msg "moonraker.conf created!"
|
||||
else
|
||||
warn_msg "There is already a file called 'moonraker-$INSTANCE.conf'!"
|
||||
warn_msg "Skipping..."
|
||||
fi
|
||||
|
||||
### raise instance counter by 1
|
||||
INSTANCE=$(expr $INSTANCE + 1)
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
##############################################################################################
|
||||
#********************************************************************************************#
|
||||
##############################################################################################
|
||||
|
||||
process_octoprint_dialog(){
|
||||
#ask user to disable octoprint when its service was found
|
||||
if [ "$OCTOPRINT_ENABLED" = "true" ]; then
|
||||
while true; do
|
||||
echo
|
||||
top_border
|
||||
echo -e "| ${red}!!! WARNING - OctoPrint service found !!!${default} |"
|
||||
hr
|
||||
echo -e "| You might consider disabling the OctoPrint service, |"
|
||||
echo -e "| since an active OctoPrint service may lead to unex- |"
|
||||
echo -e "| pected behavior of the Klipper Webinterfaces. |"
|
||||
bottom_border
|
||||
read -p "${cyan}###### Do you want to disable OctoPrint now? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
echo -e "###### > Yes"
|
||||
status_msg "Stopping OctoPrint ..."
|
||||
octoprint_service "stop" && ok_msg "OctoPrint service stopped!"
|
||||
status_msg "Disabling OctoPrint ..."
|
||||
octoprint_service "disable" && ok_msg "OctoPrint service disabled!"
|
||||
break;;
|
||||
N|n|No|no)
|
||||
echo -e "###### > No"
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
process_haproxy_lighttpd_services(){
|
||||
#handle haproxy service
|
||||
if [ "$DISABLE_HAPROXY" = "true" ] || [ "$REMOVE_HAPROXY" = "true" ]; then
|
||||
if systemctl is-active haproxy -q; then
|
||||
status_msg "Stopping haproxy service ..."
|
||||
sudo systemctl stop haproxy && ok_msg "Service stopped!"
|
||||
fi
|
||||
|
||||
### disable haproxy
|
||||
if [ "$DISABLE_HAPROXY" = "true" ]; then
|
||||
status_msg "Disabling haproxy ..."
|
||||
sudo systemctl disable haproxy && ok_msg "Haproxy service disabled!"
|
||||
|
||||
### remove haproxy
|
||||
if [ "$REMOVE_HAPROXY" = "true" ]; then
|
||||
status_msg "Removing haproxy ..."
|
||||
sudo apt-get remove haproxy -y && sudo update-rc.d -f haproxy remove && ok_msg "Haproxy removed!"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
### handle lighttpd service
|
||||
if [ "$DISABLE_LIGHTTPD" = "true" ] || [ "$REMOVE_LIGHTTPD" = "true" ]; then
|
||||
if systemctl is-active lighttpd -q; then
|
||||
status_msg "Stopping lighttpd service ..."
|
||||
sudo systemctl stop lighttpd && ok_msg "Service stopped!"
|
||||
fi
|
||||
|
||||
### disable lighttpd
|
||||
if [ "$DISABLE_LIGHTTPD" = "true" ]; then
|
||||
status_msg "Disabling lighttpd ..."
|
||||
sudo systemctl disable lighttpd && ok_msg "Lighttpd service disabled!"
|
||||
|
||||
### remove lighttpd
|
||||
if [ "$REMOVE_LIGHTTPD" = "true" ]; then
|
||||
status_msg "Removing lighttpd ..."
|
||||
sudo apt-get remove lighttpd -y && sudo update-rc.d -f lighttpd remove && ok_msg "Lighttpd removed!"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
process_haproxy_lighttpd_dialog(){
|
||||
#notify user about haproxy or lighttpd services found and possible issues
|
||||
if [ "$HAPROXY_FOUND" = "true" ] || [ "$LIGHTTPD_FOUND" = "true" ]; then
|
||||
while true; do
|
||||
echo
|
||||
top_border
|
||||
echo -e "| ${red}Possibly disruptive/incompatible services found!${default} |"
|
||||
hr
|
||||
if [ "$HAPROXY_FOUND" = "true" ]; then
|
||||
echo -e "| ● haproxy |"
|
||||
fi
|
||||
if [ "$LIGHTTPD_FOUND" = "true" ]; then
|
||||
echo -e "| ● lighttpd |"
|
||||
fi
|
||||
hr
|
||||
echo -e "| Having those packages installed can lead to unwanted |"
|
||||
echo -e "| behaviour. It is recommend to remove those packages. |"
|
||||
echo -e "| |"
|
||||
echo -e "| 1) Remove packages (recommend) |"
|
||||
echo -e "| 2) Disable only (may cause issues) |"
|
||||
echo -e "| ${red}3) Skip this step (not recommended)${default} |"
|
||||
bottom_border
|
||||
read -p "${cyan}###### Please choose:${default} " action
|
||||
case "$action" in
|
||||
1)
|
||||
echo -e "###### > Remove packages"
|
||||
if [ "$HAPROXY_FOUND" = "true" ]; then
|
||||
DISABLE_HAPROXY="true"
|
||||
REMOVE_HAPROXY="true"
|
||||
fi
|
||||
if [ "$LIGHTTPD_FOUND" = "true" ]; then
|
||||
DISABLE_LIGHTTPD="true"
|
||||
REMOVE_LIGHTTPD="true"
|
||||
fi
|
||||
break;;
|
||||
2)
|
||||
echo -e "###### > Disable only"
|
||||
if [ "$HAPROXY_FOUND" = "true" ]; then
|
||||
DISABLE_HAPROXY="true"
|
||||
REMOVE_HAPROXY="false"
|
||||
fi
|
||||
if [ "$LIGHTTPD_FOUND" = "true" ]; then
|
||||
DISABLE_LIGHTTPD="true"
|
||||
REMOVE_LIGHTTPD="false"
|
||||
fi
|
||||
break;;
|
||||
3)
|
||||
echo -e "###### > Skip"
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
### execute moonrakers policykit-rules script
|
||||
"${HOME}"/moonraker/scripts/set-policykit-rules.sh
|
||||
sudo systemctl daemon-reload
|
||||
}
|
||||
@@ -69,7 +69,7 @@ octoprint_setup(){
|
||||
[ ! -d $OCTOPRINT_ENV ] && mkdir -p $OCTOPRINT_ENV
|
||||
status_msg "Set up virtualenv ..."
|
||||
cd $OCTOPRINT_ENV
|
||||
virtualenv venv
|
||||
virtualenv --python=python3 venv
|
||||
source venv/bin/activate
|
||||
|
||||
### install octoprint with pip
|
||||
@@ -273,4 +273,4 @@ print_op_ip_list(){
|
||||
echo -e " ${cyan}● Instance $i:${default} $ip"
|
||||
i=$((i + 1))
|
||||
done
|
||||
}
|
||||
}
|
||||
|
||||
37
scripts/install_pgc_for_klipper.sh
Executable file
37
scripts/install_pgc_for_klipper.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
### base variables
|
||||
PGC_FOR_KLIPPER_REPO="https://github.com/Kragrathea/pgcode"
|
||||
PGC_DIR="${HOME}/pgcode"
|
||||
|
||||
install_pgc_for_klipper(){
|
||||
pgconfsrc="$PGC_DIR/pgcode.local.conf"
|
||||
pgconf="/etc/nginx/sites-available/pgcode.local.conf"
|
||||
pgconfsl="/etc/nginx/sites-enabled/pgcode.local.conf"
|
||||
pgc_default_port="7136"
|
||||
|
||||
status_msg "Installing PrettyGCode for Klipper ..."
|
||||
### let the user decide which port is used
|
||||
echo -e "${cyan}\n###### On which port should PrettyGCode run? (Default: $pgc_default_port)${default} "
|
||||
read -e -p "${cyan}###### Port:${default} " -i "$pgc_default_port" pgc_custom_port
|
||||
### check nginx dependency
|
||||
dep=(nginx)
|
||||
dependency_check
|
||||
### clone repo
|
||||
[ -d $PGC_DIR ] && rm -rf $PGC_DIR
|
||||
cd ${HOME} && git clone $PGC_FOR_KLIPPER_REPO
|
||||
### copy nginx config into destination directory
|
||||
sudo cp $pgconfsrc $pgconf
|
||||
### replace default pi user in case the user is called different
|
||||
sudo sed -i "s|/home/pi/pgcode;|/home/${USER}/pgcode;|" $pgconf
|
||||
### replace default port
|
||||
if [ $pgc_custom_port != $pgc_default_port ]; then
|
||||
sudo sed -i "s|listen $pgc_default_port;|listen $pgc_custom_port;|" $pgconf
|
||||
sudo sed -i "s|listen \[::\]:$pgc_default_port;|listen \[::\]:$pgc_custom_port;|" $pgconf
|
||||
fi
|
||||
### create symlink
|
||||
[ ! -L $pgconfsl ] && sudo ln -s $pgconf $pgconfsl
|
||||
sudo systemctl restart nginx
|
||||
### show URI
|
||||
pgc_uri="http://$(hostname -I | cut -d" " -f1):$pgc_custom_port"
|
||||
echo -e "${cyan}\n● Accessible via:${default} $pgc_uri"
|
||||
ok_msg "PrettyGCode for Klipper installed!\n"
|
||||
}
|
||||
114
scripts/ms_theme_installer.sh
Executable file
114
scripts/ms_theme_installer.sh
Executable file
@@ -0,0 +1,114 @@
|
||||
### base variables
|
||||
SYSTEMDDIR="/etc/systemd/system"
|
||||
|
||||
get_theme_list(){
|
||||
theme_csv_url="https://raw.githubusercontent.com/mainsail-crew/docs/master/_data/themes.csv"
|
||||
theme_csv=$(curl -s -L $theme_csv_url)
|
||||
unset t_name
|
||||
unset t_note
|
||||
unset t_auth
|
||||
unset t_url
|
||||
i=0
|
||||
while IFS="," read -r col1 col2 col3 col4; do
|
||||
t_name+=("$col1")
|
||||
t_note+=("$col2")
|
||||
t_auth+=("$col3")
|
||||
t_url+=("$col4")
|
||||
if [ ! "$col1" == "name" ]; then
|
||||
printf "| $i) %-50s|\n" "[$col1]"
|
||||
fi
|
||||
i=$((i+1))
|
||||
done <<< "$theme_csv"
|
||||
}
|
||||
|
||||
ms_theme_ui(){
|
||||
top_border
|
||||
echo -e "| ${red}~~~~~~~~ [ Mainsail Theme Installer ] ~~~~~~~${default} | "
|
||||
hr
|
||||
echo -e "| ${green}A preview of each Mainsail theme can be found here:${default} | "
|
||||
echo -e "| https://docs.mainsail.xyz/theming/themes | "
|
||||
blank_line
|
||||
echo -e "| ${yellow}Important note:${default} | "
|
||||
echo -e "| Installing a theme from this menu will overwrite an | "
|
||||
echo -e "| already installed theme or modified custom.css file! | "
|
||||
hr
|
||||
get_theme_list # dynamically generate the themelist from a csv file
|
||||
echo -e "| | "
|
||||
echo -e "| R) [Remove Theme] | "
|
||||
back_footer
|
||||
}
|
||||
|
||||
ms_theme_menu(){
|
||||
ms_theme_ui
|
||||
while true; do
|
||||
read -p "${cyan}Install theme:${default} " a; echo
|
||||
if [ "$a" = "b" ] || [ "$a" = "B" ]; then
|
||||
clear && advanced_menu && break
|
||||
elif [ "$a" = "r" ] || [ "$a" = "R" ]; then
|
||||
ms_theme_delete
|
||||
ms_theme_menu
|
||||
elif [ "$a" -le ${#t_url[@]} ]; then
|
||||
ms_theme_install "${t_auth[$a]}" "${t_url[$a]}" "${t_name[$a]}" "${t_note[$a]}"
|
||||
ms_theme_menu
|
||||
else
|
||||
clear && print_header
|
||||
ERROR_MSG="Invalid command!" && print_msg && clear_msg
|
||||
ms_theme_menu
|
||||
fi
|
||||
done
|
||||
ms_theme_menu
|
||||
}
|
||||
|
||||
check_select_printer(){
|
||||
unset printer_num
|
||||
|
||||
### get klipper cfg loc and set default .theme folder loc
|
||||
check_klipper_cfg_path
|
||||
THEME_PATH="$klipper_cfg_loc"
|
||||
|
||||
### check if there is more than one moonraker instance and if yes
|
||||
### ask the user to select the printer he wants to install/remove the theme
|
||||
MR_SERVICE_COUNT=$(find "$SYSTEMDDIR" -regextype posix-extended -regex "$SYSTEMDDIR/moonraker(-[^0])?[0-9]*.service" | wc -l)
|
||||
if [[ $MR_SERVICE_COUNT -gt 1 ]]; then
|
||||
top_border
|
||||
echo -e "| More than one printer was found on this system! | "
|
||||
echo -e "| Please select the printer to which you want to | "
|
||||
echo -e "| apply the previously selected action. | "
|
||||
bottom_border
|
||||
read -p "${cyan}Select printer:${default} " printer_num
|
||||
|
||||
### rewrite the .theme path matching the selected printer
|
||||
THEME_PATH="$klipper_cfg_loc/printer_$printer_num"
|
||||
fi
|
||||
|
||||
### create the cfg folder if there is none yet
|
||||
[ ! -d "$THEME_PATH" ] && mkdir -p "$THEME_PATH"
|
||||
}
|
||||
|
||||
ms_theme_install(){
|
||||
THEME_URL="https://github.com/$1/$2"
|
||||
|
||||
### check and select printer if there is more than 1
|
||||
check_select_printer
|
||||
|
||||
### download all files
|
||||
status_msg "Installing $3 ..."
|
||||
status_msg "Please wait ..."
|
||||
|
||||
[ -d "$THEME_PATH/.theme" ] && rm -rf "$THEME_PATH/.theme"
|
||||
cd "$THEME_PATH" && git clone "$THEME_URL" ".theme"
|
||||
|
||||
ok_msg "Theme installation complete!"
|
||||
[ -n "$4" ] && echo "${yellow}###### Theme Info: $4${default}"
|
||||
ok_msg "Please remember to delete your browser cache!\n"
|
||||
}
|
||||
|
||||
ms_theme_delete(){
|
||||
check_select_printer
|
||||
if [ -d "$THEME_PATH/.theme" ]; then
|
||||
status_msg "Removing Theme ..."
|
||||
rm -rf "$THEME_PATH/.theme" && ok_msg "Theme removed!\n"
|
||||
else
|
||||
status_msg "No Theme installed!\n"
|
||||
fi
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
### base variables
|
||||
SYSTEMDDIR="/etc/systemd/system"
|
||||
|
||||
remove_klipper(){
|
||||
shopt -s extglob # enable extended globbing
|
||||
### ask the user if he wants to uninstall moonraker too.
|
||||
###? currently usefull if the user wants to switch from single-instance to multi-instance
|
||||
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "moonraker*.")" ]; then
|
||||
FILE="$SYSTEMDDIR/moonraker?(-*([0-9])).service"
|
||||
if ls $FILE 2>/dev/null 1>&2; then
|
||||
while true; do
|
||||
unset REM_MR
|
||||
top_border
|
||||
@@ -32,38 +37,20 @@ remove_klipper(){
|
||||
fi
|
||||
|
||||
### remove "legacy" klipper init.d service
|
||||
if [[ -e /etc/init.d/klipper || -e /etc/default/klipper ]]; then
|
||||
if [ -e /etc/init.d/klipper ]; then
|
||||
status_msg "Removing Klipper Service ..."
|
||||
sudo systemctl stop klipper
|
||||
sudo systemctl disable klipper
|
||||
sudo rm -rf /etc/init.d/klipper /etc/default/klipper
|
||||
sudo update-rc.d -f klipper remove
|
||||
sudo systemctl daemon-reload
|
||||
sudo rm -f /etc/init.d/klipper
|
||||
sudo rm -f /etc/default/klipper
|
||||
ok_msg "Klipper Service removed!"
|
||||
fi
|
||||
|
||||
###remove single instance
|
||||
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ]; then
|
||||
status_msg "Removing Klipper Service ..."
|
||||
sudo systemctl stop klipper
|
||||
sudo systemctl disable klipper
|
||||
sudo rm -f $SYSTEMDDIR/klipper.service
|
||||
ok_msg "Klipper Service removed!"
|
||||
fi
|
||||
if [ -f /tmp/klippy.log ]; then
|
||||
status_msg "Removing /tmp/klippy.log ..." && rm -f /tmp/klippy.log && ok_msg "Done!"
|
||||
fi
|
||||
if [ -e /tmp/klippy_uds ]; then
|
||||
status_msg "Removing /tmp/klippy_uds ..." && rm -f /tmp/klippy_uds && ok_msg "Done!"
|
||||
fi
|
||||
if [ -h /tmp/printer ]; then
|
||||
status_msg "Removing /tmp/printer ..." && rm -f /tmp/printer && ok_msg "Done!"
|
||||
fi
|
||||
|
||||
###remove multi instance services
|
||||
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "klipper-[[:digit:]].service")" ]; then
|
||||
### remove all klipper services
|
||||
FILE="$SYSTEMDDIR/klipper?(-*([0-9])).service"
|
||||
if ls $FILE 2>/dev/null 1>&2; then
|
||||
status_msg "Removing Klipper Services ..."
|
||||
for service in $(find $SYSTEMDDIR -maxdepth 1 -name "klipper-*.service" | cut -d"/" -f5)
|
||||
for service in $(ls $FILE | cut -d"/" -f5)
|
||||
do
|
||||
status_msg "Removing $service ..."
|
||||
sudo systemctl stop $service
|
||||
@@ -71,36 +58,43 @@ remove_klipper(){
|
||||
sudo rm -f $SYSTEMDDIR/$service
|
||||
ok_msg "Done!"
|
||||
done
|
||||
### reloading units
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl reset-failed
|
||||
ok_msg "Klipper Service removed!"
|
||||
fi
|
||||
|
||||
###remove multi instance logfiles
|
||||
if [ "$(find /tmp -maxdepth 1 -name "klippy-*.log")" ]; then
|
||||
for logfile in $(find /tmp -maxdepth 1 -name "klippy-*.log")
|
||||
do
|
||||
status_msg "Removing $logfile ..." && rm -f $logfile && ok_msg "Done!"
|
||||
### remove all logfiles
|
||||
FILE="${HOME}/klipper_logs/klippy?(-*([0-9])).log"
|
||||
if ls $FILE 2>/dev/null 1>&2; then
|
||||
for log in $(ls $FILE); do
|
||||
status_msg "Removing $log ..."
|
||||
rm -f $log
|
||||
ok_msg "$log removed!"
|
||||
done
|
||||
fi
|
||||
|
||||
###remove multi instance UDS
|
||||
if [ "$(find /tmp -maxdepth 1 -name "klippy_uds-*")" ]; then
|
||||
for uds in $(find /tmp -maxdepth 1 -name "klippy_uds-*")
|
||||
do
|
||||
status_msg "Removing $uds ..." && rm -f $uds && ok_msg "Done!"
|
||||
### remove all UDS
|
||||
FILE="/tmp/klippy_uds?(-*([0-9]))"
|
||||
if ls $FILE 2>/dev/null 1>&2; then
|
||||
for uds in $(ls $FILE); do
|
||||
status_msg "Removing $uds ..."
|
||||
rm -f $uds
|
||||
ok_msg "$uds removed!"
|
||||
done
|
||||
fi
|
||||
|
||||
###remove multi instance tmp-printer
|
||||
if [ "$(find /tmp -maxdepth 1 -name "printer-*")" ]; then
|
||||
for tmp_printer in $(find /tmp -maxdepth 1 -name "printer-*")
|
||||
do
|
||||
status_msg "Removing $tmp_printer ..." && rm -f $tmp_printer && ok_msg "Done!"
|
||||
### remove all tmp-printer
|
||||
FILE="/tmp/printer?(-*([0-9]))"
|
||||
if ls $FILE 2>/dev/null 1>&2; then
|
||||
for tmp_printer in $(ls $FILE); do
|
||||
status_msg "Removing $tmp_printer ..."
|
||||
rm -f $tmp_printer
|
||||
ok_msg "$tmp_printer removed!"
|
||||
done
|
||||
fi
|
||||
|
||||
###reloading units
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
###removing klipper and klippy-env folders
|
||||
### removing klipper and klippy-env folders
|
||||
if [ -d $KLIPPER_DIR ]; then
|
||||
status_msg "Removing Klipper directory ..."
|
||||
rm -rf $KLIPPER_DIR && ok_msg "Directory removed!"
|
||||
@@ -111,43 +105,33 @@ remove_klipper(){
|
||||
fi
|
||||
|
||||
CONFIRM_MSG=" Klipper was successfully removed!" && print_msg && clear_msg
|
||||
shopt -u extglob # enable extended globbing
|
||||
|
||||
if [ "$REM_MR" == "true" ]; then
|
||||
remove_moonraker
|
||||
remove_moonraker && unset REM_MR
|
||||
fi
|
||||
}
|
||||
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
remove_dwc2(){
|
||||
### remove "legacy" init.d service
|
||||
if [[ -e /etc/init.d/dwc || -e /etc/default/dwc ]]; then
|
||||
status_msg "Removing DWC2-for-Klipper-Socket Service ..."
|
||||
sudo systemctl stop dwc
|
||||
sudo systemctl disable dwc
|
||||
sudo rm -rf /etc/init.d/dwc /etc/default/dwc
|
||||
sudo update-rc.d -f dwc remove
|
||||
sudo systemctl daemon-reload
|
||||
ok_msg "DWC2-for-Klipper-Socket Service removed!"
|
||||
remove_moonraker(){
|
||||
shopt -s extglob # enable extended globbing
|
||||
### remove "legacy" moonraker init.d service
|
||||
if [ -f /etc/init.d/moonraker ]; then
|
||||
status_msg "Removing Moonraker Service ..."
|
||||
sudo systemctl stop moonraker
|
||||
sudo update-rc.d -f moonraker remove
|
||||
sudo rm -f /etc/init.d/moonraker
|
||||
sudo rm -f /etc/default/moonraker
|
||||
ok_msg "Moonraker Service removed!"
|
||||
fi
|
||||
|
||||
### remove single instance
|
||||
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "dwc.service")" ]; then
|
||||
status_msg "Removing DWC2-for-Klipper-Socket Service ..."
|
||||
sudo systemctl stop dwc
|
||||
sudo systemctl disable dwc
|
||||
sudo rm -f $SYSTEMDDIR/dwc.service
|
||||
ok_msg "DWC2-for-Klipper-Socket Service removed!"
|
||||
fi
|
||||
if [ -f /tmp/dwc.log ]; then
|
||||
status_msg "Removing /tmp/dwc.log ..." && rm -f /tmp/dwc.log && ok_msg "Done!"
|
||||
fi
|
||||
|
||||
### remove multi instance services
|
||||
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "dwc-[[:digit:]].service")" ]; then
|
||||
status_msg "Removing DWC2-for-Klipper-Socket Services ..."
|
||||
for service in $(find $SYSTEMDDIR -maxdepth 1 -name "dwc-*.service" | cut -d"/" -f5)
|
||||
### remove all moonraker services
|
||||
FILE="$SYSTEMDDIR/moonraker?(-*([0-9])).service"
|
||||
if ls $FILE 2>/dev/null 1>&2; then
|
||||
status_msg "Removing Moonraker Services ..."
|
||||
for service in $(ls $FILE | cut -d"/" -f5)
|
||||
do
|
||||
status_msg "Removing $service ..."
|
||||
sudo systemctl stop $service
|
||||
@@ -155,18 +139,92 @@ remove_dwc2(){
|
||||
sudo rm -f $SYSTEMDDIR/$service
|
||||
ok_msg "Done!"
|
||||
done
|
||||
### reloading units
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl reset-failed
|
||||
ok_msg "Moonraker Service removed!"
|
||||
fi
|
||||
|
||||
### remove multi instance logfiles
|
||||
if [ "$(find /tmp -maxdepth 1 -name "dwc-*.log")" ]; then
|
||||
for logfile in $(find /tmp -maxdepth 1 -name "dwc-*.log")
|
||||
do
|
||||
status_msg "Removing $logfile ..." && rm -f $logfile && ok_msg "Done!"
|
||||
### remove all logfiles
|
||||
FILE="${HOME}/klipper_logs/moonraker?(-*([0-9])).log"
|
||||
if ls $FILE 2>/dev/null 1>&2; then
|
||||
for log in $(ls $FILE); do
|
||||
status_msg "Removing $log ..."
|
||||
rm -f $log
|
||||
ok_msg "$log removed!"
|
||||
done
|
||||
fi
|
||||
|
||||
### reloading units
|
||||
sudo systemctl daemon-reload
|
||||
### remove moonraker nginx config
|
||||
if [[ -e $NGINX_CONFD/upstreams.conf || -e $NGINX_CONFD/common_vars.conf ]]; then
|
||||
status_msg "Removing Moonraker NGINX configuration ..."
|
||||
sudo rm -f $NGINX_CONFD/upstreams.conf $NGINX_CONFD/common_vars.conf && ok_msg "Moonraker NGINX configuration removed!"
|
||||
fi
|
||||
|
||||
### remove legacy api key
|
||||
if [ -e ${HOME}/.klippy_api_key ]; then
|
||||
status_msg "Removing legacy API Key ..." && rm ${HOME}/.klippy_api_key && ok_msg "Done!"
|
||||
fi
|
||||
|
||||
### remove api key
|
||||
if [ -e ${HOME}/.moonraker_api_key ]; then
|
||||
status_msg "Removing API Key ..." && rm ${HOME}/.moonraker_api_key && ok_msg "Done!"
|
||||
fi
|
||||
|
||||
### removing moonraker and moonraker-env folder
|
||||
if [ -d $MOONRAKER_DIR ]; then
|
||||
status_msg "Removing Moonraker directory ..."
|
||||
rm -rf $MOONRAKER_DIR && ok_msg "Directory removed!"
|
||||
fi
|
||||
if [ -d $MOONRAKER_ENV ]; then
|
||||
status_msg "Removing moonraker-env directory ..."
|
||||
rm -rf $MOONRAKER_ENV && ok_msg "Directory removed!"
|
||||
fi
|
||||
|
||||
CONFIRM_MSG=" Moonraker was successfully removed!"
|
||||
shopt -u extglob # disable extended globbing
|
||||
}
|
||||
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
remove_dwc2(){
|
||||
### remove "legacy" init.d service
|
||||
if [ -e /etc/init.d/dwc ]; then
|
||||
status_msg "Removing DWC2-for-Klipper-Socket Service ..."
|
||||
sudo systemctl stop dwc
|
||||
sudo update-rc.d -f dwc remove
|
||||
sudo rm -f /etc/init.d/dwc
|
||||
sudo rm -f /etc/default/dwc
|
||||
ok_msg "DWC2-for-Klipper-Socket Service removed!"
|
||||
fi
|
||||
|
||||
### remove all dwc services
|
||||
if ls /etc/systemd/system/dwc*.service 2>/dev/null 1>&2; then
|
||||
status_msg "Removing DWC2-for-Klipper-Socket Services ..."
|
||||
for service in $(ls /etc/systemd/system/dwc*.service | cut -d"/" -f5)
|
||||
do
|
||||
status_msg "Removing $service ..."
|
||||
sudo systemctl stop $service
|
||||
sudo systemctl disable $service
|
||||
sudo rm -f $SYSTEMDDIR/$service
|
||||
ok_msg "Done!"
|
||||
done
|
||||
### reloading units
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl reset-failed
|
||||
ok_msg "DWC2-for-Klipper-Socket Service removed!"
|
||||
fi
|
||||
|
||||
### remove all logfiles
|
||||
if ls /tmp/dwc*.log 2>/dev/null 1>&2; then
|
||||
for logfile in $(ls /tmp/dwc*.log)
|
||||
do
|
||||
status_msg "Removing $logfile ..."
|
||||
rm -f $logfile
|
||||
ok_msg "File '$logfile' removed!"
|
||||
done
|
||||
fi
|
||||
|
||||
### removing the rest of the folders
|
||||
if [ -d $DWC2FK_DIR ]; then
|
||||
@@ -182,90 +240,15 @@ remove_dwc2(){
|
||||
rm -rf $DWC2_DIR && ok_msg "Directory removed!"
|
||||
fi
|
||||
|
||||
### remove dwc2_port from ~/.kiauh.ini
|
||||
sed -i "/^dwc2_port=/d" $INI_FILE
|
||||
|
||||
CONFIRM_MSG=" DWC2-for-Klipper-Socket was successfully removed!"
|
||||
}
|
||||
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
remove_moonraker(){
|
||||
### remove "legacy" moonraker init.d service
|
||||
if [[ -e /etc/init.d/moonraker || -e /etc/default/moonraker ]]; then
|
||||
status_msg "Removing Moonraker Service ..."
|
||||
sudo systemctl stop moonraker
|
||||
sudo systemctl disable moonraker
|
||||
sudo rm -rf /etc/init.d/moonraker /etc/default/moonraker
|
||||
sudo update-rc.d -f moonraker remove
|
||||
sudo systemctl daemon-reload
|
||||
ok_msg "Moonraker Service removed!"
|
||||
fi
|
||||
|
||||
###remove single instance
|
||||
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "moonraker.service")" ]; then
|
||||
status_msg "Removing Moonraker Service ..."
|
||||
sudo systemctl stop moonraker
|
||||
sudo systemctl disable moonraker
|
||||
sudo rm -f $SYSTEMDDIR/moonraker.service
|
||||
ok_msg "Moonraker Service removed!"
|
||||
fi
|
||||
if [ -f /tmp/moonraker.log ]; then
|
||||
status_msg "Removing /tmp/moonraker.log ..." && rm -f /tmp/moonraker.log && ok_msg "Done!"
|
||||
fi
|
||||
|
||||
###remove multi instance services
|
||||
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "moonraker-[[:digit:]].service")" ]; then
|
||||
status_msg "Removing Moonraker Services ..."
|
||||
for service in $(find $SYSTEMDDIR -maxdepth 1 -name "moonraker-*.service" | cut -d"/" -f5)
|
||||
do
|
||||
status_msg "Removing $service ..."
|
||||
sudo systemctl stop $service
|
||||
sudo systemctl disable $service
|
||||
sudo rm -f $SYSTEMDDIR/$service
|
||||
ok_msg "Done!"
|
||||
done
|
||||
fi
|
||||
###remove multi instance logfiles
|
||||
if [ "$(find /tmp -maxdepth 1 -name "moonraker-*.log")" ]; then
|
||||
for logfile in $(find /tmp -maxdepth 1 -name "moonraker-*.log")
|
||||
do
|
||||
status_msg "Removing $logfile ..." && rm -f $logfile && ok_msg "Done!"
|
||||
done
|
||||
fi
|
||||
|
||||
###reloading units
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
#remove moonraker nginx config
|
||||
if [[ -e $NGINX_CONFD/upstreams.conf || -e $NGINX_CONFD/common_vars.conf ]]; then
|
||||
status_msg "Removing Moonraker NGINX configuration ..."
|
||||
sudo rm -f $NGINX_CONFD/upstreams.conf $NGINX_CONFD/common_vars.conf && ok_msg "Moonraker NGINX configuration removed!"
|
||||
fi
|
||||
|
||||
#remove legacy api key
|
||||
if [ -e ${HOME}/.klippy_api_key ]; then
|
||||
status_msg "Removing legacy API Key ..." && rm ${HOME}/.klippy_api_key && ok_msg "Done!"
|
||||
fi
|
||||
#remove api key
|
||||
if [ -e ${HOME}/.moonraker_api_key ]; then
|
||||
status_msg "Removing API Key ..." && rm ${HOME}/.moonraker_api_key && ok_msg "Done!"
|
||||
fi
|
||||
|
||||
###removing moonraker and moonraker-env folder
|
||||
if [ -d $MOONRAKER_DIR ]; then
|
||||
status_msg "Removing Moonraker directory ..."
|
||||
rm -rf $MOONRAKER_DIR && ok_msg "Directory removed!"
|
||||
fi
|
||||
if [ -d $MOONRAKER_ENV ]; then
|
||||
status_msg "Removing moonraker-env directory ..."
|
||||
rm -rf $MOONRAKER_ENV && ok_msg "Directory removed!"
|
||||
fi
|
||||
|
||||
CONFIRM_MSG=" Moonraker was successfully removed!"
|
||||
}
|
||||
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
remove_mainsail(){
|
||||
### remove mainsail dir
|
||||
if [ -d $MAINSAIL_DIR ]; then
|
||||
@@ -285,6 +268,17 @@ remove_mainsail(){
|
||||
sudo rm /etc/nginx/sites-enabled/mainsail && ok_msg "File removed!"
|
||||
fi
|
||||
|
||||
### remove mainsail nginx logs and log symlinks
|
||||
for log in $(find /var/log/nginx -name "mainsail*"); do
|
||||
sudo rm -f $log
|
||||
done
|
||||
for log in $(find ${HOME}/klipper_logs -name "mainsail*"); do
|
||||
rm -f $log
|
||||
done
|
||||
|
||||
### remove mainsail_port from ~/.kiauh.ini
|
||||
sed -i "/^mainsail_port=/d" $INI_FILE
|
||||
|
||||
CONFIRM_MSG="Mainsail successfully removed!"
|
||||
}
|
||||
|
||||
@@ -307,6 +301,17 @@ remove_fluidd(){
|
||||
sudo rm /etc/nginx/sites-enabled/fluidd && ok_msg "File removed!"
|
||||
fi
|
||||
|
||||
### remove mainsail nginx logs and log symlinks
|
||||
for log in $(find /var/log/nginx -name "fluidd*"); do
|
||||
sudo rm -f $log
|
||||
done
|
||||
for log in $(find ${HOME}/klipper_logs -name "fluidd*"); do
|
||||
rm -f $log
|
||||
done
|
||||
|
||||
### remove fluidd_port from ~/.kiauh.ini
|
||||
sed -i "/^fluidd_port=/d" $INI_FILE
|
||||
|
||||
CONFIRM_MSG="Fluidd successfully removed!"
|
||||
}
|
||||
|
||||
@@ -314,19 +319,10 @@ remove_fluidd(){
|
||||
#############################################################
|
||||
|
||||
remove_octoprint(){
|
||||
###remove single instance
|
||||
if [ "$(systemctl list-unit-files | grep -F "octoprint.service")" ]; then
|
||||
status_msg "Removing OctoPrint Service ..."
|
||||
sudo systemctl stop octoprint
|
||||
sudo systemctl disable octoprint
|
||||
sudo rm -f $SYSTEMDDIR/octoprint.service
|
||||
ok_msg "OctoPrint Service removed!"
|
||||
fi
|
||||
|
||||
###remove multi instance services
|
||||
if [ "$(systemctl list-unit-files | grep -E "octoprint-[[:digit:]].service")" ]; then
|
||||
###remove all octoprint services
|
||||
if ls /etc/systemd/system/octoprint*.service 2>/dev/null 1>&2; then
|
||||
status_msg "Removing OctoPrint Services ..."
|
||||
for service in $(find $SYSTEMDDIR -maxdepth 1 -name "octoprint-*.service" | cut -d"/" -f5)
|
||||
for service in $(ls /etc/systemd/system/octoprint*.service | cut -d"/" -f5)
|
||||
do
|
||||
status_msg "Removing $service ..."
|
||||
sudo systemctl stop $service
|
||||
@@ -334,11 +330,11 @@ remove_octoprint(){
|
||||
sudo rm -f $SYSTEMDDIR/$service
|
||||
ok_msg "OctoPrint Service removed!"
|
||||
done
|
||||
### reloading units
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl reset-failed
|
||||
fi
|
||||
|
||||
###reloading units
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
### remove sudoers file
|
||||
if [ -f /etc/sudoers.d/octoprint-shutdown ]; then
|
||||
sudo rm -rf /etc/sudoers.d/octoprint-shutdown
|
||||
@@ -351,13 +347,16 @@ remove_octoprint(){
|
||||
fi
|
||||
|
||||
###remove .octoprint directories
|
||||
if [ "$(find ${HOME} -maxdepth 1 -name ".octoprint*")" ]; then
|
||||
for folder in $(find ${HOME} -maxdepth 1 -name ".octoprint*")
|
||||
if ls -d ${HOME}/.octoprint* 2>/dev/null 1>&2; then
|
||||
for folder in $(ls -d ${HOME}/.octoprint*)
|
||||
do
|
||||
status_msg "Removing $folder ..." && rm -rf $folder && ok_msg "Done!"
|
||||
done
|
||||
fi
|
||||
|
||||
### remove octoprint_port from ~/.kiauh.ini
|
||||
sed -i "/^octoprint_port=/d" $INI_FILE
|
||||
|
||||
CONFIRM_MSG=" OctoPrint successfully removed!"
|
||||
}
|
||||
|
||||
@@ -365,12 +364,10 @@ remove_octoprint(){
|
||||
#############################################################
|
||||
|
||||
remove_nginx(){
|
||||
if [[ $(dpkg-query -f'${Status}' --show nginx 2>/dev/null) = *\ installed ]] ; then
|
||||
if systemctl is-active nginx -q; then
|
||||
status_msg "Stopping Nginx service ..."
|
||||
sudo service nginx stop && sudo systemctl disable nginx
|
||||
ok_msg "Service stopped!"
|
||||
fi
|
||||
if ls /lib/systemd/system/nginx.service 2>/dev/null 1>&2; then
|
||||
status_msg "Stopping Nginx service ..."
|
||||
sudo systemctl stop nginx && sudo systemctl disable nginx
|
||||
ok_msg "Service stopped and disabled!"
|
||||
status_msg "Purging Nginx from system ..."
|
||||
sudo apt-get purge nginx nginx-common -y
|
||||
sudo update-rc.d -f nginx remove
|
||||
@@ -381,6 +378,8 @@ remove_nginx(){
|
||||
}
|
||||
|
||||
remove_klipperscreen(){
|
||||
source_kiauh_ini
|
||||
|
||||
### remove KlipperScreen dir
|
||||
if [ -d $KLIPPERSCREEN_DIR ]; then
|
||||
status_msg "Removing KlipperScreen directory ..."
|
||||
@@ -393,11 +392,119 @@ remove_klipperscreen(){
|
||||
rm -rf $KLIPPERSCREEN_ENV_DIR && ok_msg "Directory removed!"
|
||||
fi
|
||||
|
||||
### remove KlipperScreen systemd file
|
||||
### remove KlipperScreen service
|
||||
if [ -e /etc/systemd/system/KlipperScreen.service ]; then
|
||||
status_msg "Removing KlipperScreen Service ..."
|
||||
sudo rm /etc/systemd/system/KlipperScreen.service && ok_msg "File removed!"
|
||||
status_msg "Removing KlipperScreen service ..."
|
||||
sudo systemctl stop KlipperScreen
|
||||
sudo systemctl disable KlipperScreen
|
||||
sudo rm -f $SYSTEMDDIR/KlipperScreen.service
|
||||
###reloading units
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl reset-failed
|
||||
ok_msg "KlipperScreen Service removed!"
|
||||
fi
|
||||
|
||||
### remove KlipperScreen log
|
||||
if [ -e /tmp/KlipperScreen.log ]; then
|
||||
status_msg "Removing KlipperScreen log file ..."
|
||||
rm -f /tmp/KlipperScreen.log && ok_msg "File removed!"
|
||||
fi
|
||||
|
||||
### remove KlipperScreen log symlink in config dir
|
||||
|
||||
if [ -e $klipper_cfg_loc/KlipperScreen.log ]; then
|
||||
status_msg "Removing KlipperScreen log symlink ..."
|
||||
rm -f $klipper_cfg_loc/KlipperScreen.log && ok_msg "File removed!"
|
||||
fi
|
||||
|
||||
CONFIRM_MSG="KlipperScreen successfully removed!"
|
||||
}
|
||||
|
||||
remove_MoonrakerTelegramBot(){
|
||||
source_kiauh_ini
|
||||
|
||||
### remove MoonrakerTelegramBot dir
|
||||
if [ -d $MOONRAKER_TELEGRAM_BOT_DIR ]; then
|
||||
status_msg "Removing MoonrakerTelegramBot directory ..."
|
||||
rm -rf $MOONRAKER_TELEGRAM_BOT_DIR && ok_msg "Directory removed!"
|
||||
fi
|
||||
|
||||
### remove MoonrakerTelegramBot VENV dir
|
||||
if [ -d $MOONRAKER_TELEGRAM_BOT_ENV_DIR ]; then
|
||||
status_msg "Removing MoonrakerTelegramBot VENV directory ..."
|
||||
rm -rf $MOONRAKER_TELEGRAM_BOT_ENV_DIR && ok_msg "Directory removed!"
|
||||
fi
|
||||
|
||||
### remove MoonrakerTelegramBot service
|
||||
if [ -e /etc/systemd/system/moonraker-telegram-bot.service ]; then
|
||||
status_msg "Removing MoonrakerTelegramBot service ..."
|
||||
sudo systemctl stop moonraker-telegram-bot
|
||||
sudo systemctl disable moonraker-telegram-bot
|
||||
sudo rm -f $SYSTEMDDIR/moonraker-telegram-bot.service
|
||||
###reloading units
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl reset-failed
|
||||
ok_msg "MoonrakerTelegramBot Service removed!"
|
||||
fi
|
||||
|
||||
### remove MoonrakerTelegramBot log
|
||||
if [ -e /tmp/telegram.log ] || [ -e ${HOME}/klipper_logs/telegram.log ]; then
|
||||
status_msg "Removing MoonrakerTelegramBot log file ..."
|
||||
rm -f "/tmp/telegram.log" "${HOME}/klipper_logs/telegram.log" && ok_msg "File removed!"
|
||||
fi
|
||||
|
||||
### remove MoonrakerTelegramBot log symlink in config dir
|
||||
|
||||
if [ -e $klipper_cfg_loc/telegram.log ]; then
|
||||
status_msg "Removing MoonrakerTelegramBot log symlink ..."
|
||||
rm -f $klipper_cfg_loc/telegram.log && ok_msg "File removed!"
|
||||
fi
|
||||
|
||||
CONFIRM_MSG="MoonrakerTelegramBot successfully removed!"
|
||||
}
|
||||
|
||||
remove_mjpg-streamer(){
|
||||
### remove MJPG-Streamer service
|
||||
if [ -e $SYSTEMDDIR/webcamd.service ]; then
|
||||
status_msg "Removing MJPG-Streamer service ..."
|
||||
sudo systemctl stop webcamd && sudo systemctl disable webcamd
|
||||
sudo rm -f $SYSTEMDDIR/webcamd.service
|
||||
###reloading units
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl reset-failed
|
||||
ok_msg "MJPG-Streamer Service removed!"
|
||||
fi
|
||||
|
||||
### remove webcamd from /usr/local/bin
|
||||
if [ -e "/usr/local/bin/webcamd" ]; then
|
||||
sudo rm -f "/usr/local/bin/webcamd"
|
||||
fi
|
||||
|
||||
### remove MJPG-Streamer directory
|
||||
if [ -d ${HOME}/mjpg-streamer ]; then
|
||||
status_msg "Removing MJPG-Streamer directory ..."
|
||||
rm -rf ${HOME}/mjpg-streamer
|
||||
ok_msg "MJPG-Streamer directory removed!"
|
||||
fi
|
||||
|
||||
### remove webcamd log and symlink
|
||||
[ -f "/var/log/webcamd.log" ] && sudo rm -f "/var/log/webcamd.log"
|
||||
[ -L "${HOME}/klipper_logs/webcamd.log" ] && rm -f "${HOME}/klipper_logs/webcamd.log"
|
||||
|
||||
CONFIRM_MSG="MJPG-Streamer successfully removed!"
|
||||
}
|
||||
|
||||
remove_prettygcode(){
|
||||
pgconf="/etc/nginx/sites-available/pgcode.local.conf"
|
||||
pgconfsl="/etc/nginx/sites-enabled/pgcode.local.conf"
|
||||
if [ -d ${HOME}/pgcode ] || [ -f $pgconf ] || [ -L $pgconfsl ]; then
|
||||
status_msg "Removing PrettyGCode for Klipper ..."
|
||||
rm -rf ${HOME}/pgcode
|
||||
sudo rm -f $pgconf
|
||||
sudo rm -f $pgconfsl
|
||||
sudo systemctl restart nginx
|
||||
CONFIRM_MSG="PrettyGCode for Klipper successfully removed!"
|
||||
else
|
||||
ERROR_MSG="PrettyGCode for Klipper not found!\n Skipping..."
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -50,6 +50,25 @@ load_klipper_state(){
|
||||
rollback_klipper
|
||||
}
|
||||
|
||||
rollback_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~ [ Rollback Menu ] ~~~~~~~~~~~~~") | "
|
||||
hr
|
||||
echo -e "| If serious errors occured after updating Klipper, | "
|
||||
echo -e "| you can use this menu to return to the previously | "
|
||||
echo -e "| used commit from which you have updated. | "
|
||||
bottom_border
|
||||
top_border
|
||||
echo -e "| Active branch: ${green}$PRINT_BRANCH${default} | "
|
||||
hr
|
||||
echo -e "| Currently on commit: | "
|
||||
echo -e "| $CURR_UI | "
|
||||
hr
|
||||
echo -e "| Commit last updated from: | "
|
||||
echo -e "| $PREV_UI | "
|
||||
back_footer
|
||||
}
|
||||
|
||||
rollback_klipper(){
|
||||
if [ "$PREVIOUS_COMMIT" != "0" ] && [ "$CURRENT_COMMIT" != "$PREVIOUS_COMMIT" ]; then
|
||||
while true; do
|
||||
@@ -66,7 +85,7 @@ rollback_klipper(){
|
||||
load_klipper_state
|
||||
break;;
|
||||
N|n|No|no) clear; advanced_menu; break;;
|
||||
Q|q) clear; advanced_menu; break;;
|
||||
B|b) clear; advanced_menu; break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
@@ -78,7 +97,7 @@ rollback_klipper(){
|
||||
read -p "Perform action: " action; echo
|
||||
echo -e "${default}"
|
||||
case "$action" in
|
||||
Q|q)
|
||||
B|b)
|
||||
clear; advanced_menu; break;;
|
||||
*)
|
||||
clear
|
||||
@@ -89,4 +108,4 @@ rollback_klipper(){
|
||||
esac
|
||||
done
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,18 @@ kiauh_status(){
|
||||
fi
|
||||
}
|
||||
|
||||
check_system_updates(){
|
||||
SYS_UPDATE=$(apt list --upgradeable 2>/dev/null | sed "1d")
|
||||
if [ ! -z "$SYS_UPDATE" ]; then
|
||||
# add system updates to the update all array for the update all function in the updater
|
||||
SYS_UPDATE_AVAIL="true" && update_arr+=(update_system)
|
||||
DISPLAY_SYS_UPDATE="${yellow}System upgrade available!${default}"
|
||||
else
|
||||
SYS_UPDATE_AVAIL="false"
|
||||
DISPLAY_SYS_UPDATE="${green}System up to date! ${default}"
|
||||
fi
|
||||
}
|
||||
|
||||
klipper_status(){
|
||||
kcount=0
|
||||
klipper_data=(
|
||||
@@ -19,7 +31,12 @@ klipper_status(){
|
||||
)
|
||||
|
||||
### count amount of klipper service files in /etc/systemd/system
|
||||
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "klipper" | wc -l)
|
||||
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "^klipper(\-[[:digit:]]+)?\.service$" | wc -l)
|
||||
|
||||
### a fix to detect an existing "legacy" klipper init.d installation
|
||||
if [ -f /etc/init.d/klipper ] && [ -f /etc/init.d/klipper ]; then
|
||||
SERVICE_FILE_COUNT=1
|
||||
fi
|
||||
|
||||
### remove the "SERVICE" entry from the klipper_data array if a klipper service is installed
|
||||
[ $SERVICE_FILE_COUNT -gt 0 ] && unset klipper_data[0]
|
||||
@@ -52,7 +69,7 @@ dwc2_status(){
|
||||
)
|
||||
|
||||
### count amount of dwc service files in /etc/systemd/system
|
||||
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "dwc" | wc -l)
|
||||
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "^dwc(\-[[:digit:]]+)?\.service$" | wc -l)
|
||||
|
||||
### remove the "SERVICE" entry from the dwc_data array if a dwc service is installed
|
||||
[ $SERVICE_FILE_COUNT -gt 0 ] && unset dwc_data[0]
|
||||
@@ -83,7 +100,7 @@ moonraker_status(){
|
||||
)
|
||||
|
||||
### count amount of moonraker service files in /etc/systemd/system
|
||||
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "moonraker" | wc -l)
|
||||
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "^moonraker(\-[[:digit:]]+)?\.service$" | wc -l)
|
||||
|
||||
### remove the "SERVICE" entry from the moonraker_data array if a moonraker service is installed
|
||||
[ $SERVICE_FILE_COUNT -gt 0 ] && unset moonraker_data[0]
|
||||
@@ -159,7 +176,7 @@ octoprint_status(){
|
||||
$OCTOPRINT_DIR
|
||||
)
|
||||
### count amount of octoprint service files in /etc/systemd/system
|
||||
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "octoprint" | wc -l)
|
||||
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "^octoprint(\-[[:digit:]]+)?\.service$" | wc -l)
|
||||
|
||||
### remove the "SERVICE" entry from the octoprint_data array if a octoprint service is installed
|
||||
[ $SERVICE_FILE_COUNT -gt 0 ] && unset octoprint_data[0]
|
||||
@@ -212,6 +229,36 @@ klipperscreen_status(){
|
||||
fi
|
||||
}
|
||||
|
||||
MoonrakerTelegramBot_status(){
|
||||
mtbcount=0
|
||||
MoonrakerTelegramBot_data=(
|
||||
SERVICE
|
||||
$MOONRAKER_TELEGRAM_BOT_DIR
|
||||
$MOONRAKER_TELEGRAM_BOT_ENV_DIR
|
||||
)
|
||||
|
||||
### count amount of MoonrakerTelegramBot_data service files in /etc/systemd/system
|
||||
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "moonraker-telegram-bot" | wc -l)
|
||||
|
||||
### remove the "SERVICE" entry from the MoonrakerTelegramBot_data array if a MoonrakerTelegramBot service is installed
|
||||
[ $SERVICE_FILE_COUNT -gt 0 ] && unset MoonrakerTelegramBot_data[0]
|
||||
|
||||
#count+1 for each found data-item from array
|
||||
for mtbd in "${MoonrakerTelegramBot_data[@]}"
|
||||
do
|
||||
if [ -e $mtbd ]; then
|
||||
mtbcount=$(expr $mtbcount + 1)
|
||||
fi
|
||||
done
|
||||
if [ "$mtbcount" == "${#MoonrakerTelegramBot_data[*]}" ]; then
|
||||
MOONRAKER_TELEGRAM_BOT_STATUS="${green}Installed!${default} "
|
||||
elif [ "$mtbcount" == 0 ]; then
|
||||
MOONRAKER_TELEGRAM_BOT_STATUS="${red}Not installed!${default} "
|
||||
else
|
||||
MOONRAKER_TELEGRAM_BOT_STATUS="${yellow}Incomplete!${default} "
|
||||
fi
|
||||
}
|
||||
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
@@ -284,8 +331,8 @@ compare_klipper_versions(){
|
||||
if [ "$LOCAL_COMMIT" != "$REMOTE_COMMIT" ]; then
|
||||
LOCAL_COMMIT="${yellow}$(printf "%-12s" "$LOCAL_COMMIT")${default}"
|
||||
REMOTE_COMMIT="${green}$(printf "%-12s" "$REMOTE_COMMIT")${default}"
|
||||
KLIPPER_UPDATE_AVAIL="true"
|
||||
update_arr+=(update_klipper)
|
||||
# add klipper to the update all array for the update all function in the updater
|
||||
KLIPPER_UPDATE_AVAIL="true" && update_arr+=(update_klipper)
|
||||
else
|
||||
LOCAL_COMMIT="${green}$(printf "%-12s" "$LOCAL_COMMIT")${default}"
|
||||
REMOTE_COMMIT="${green}$(printf "%-12s" "$REMOTE_COMMIT")${default}"
|
||||
@@ -318,8 +365,8 @@ compare_dwc2fk_versions(){
|
||||
if [ "$LOCAL_DWC2FK_COMMIT" != "$REMOTE_DWC2FK_COMMIT" ]; then
|
||||
LOCAL_DWC2FK_COMMIT="${yellow}$(printf "%-12s" "$LOCAL_DWC2FK_COMMIT")${default}"
|
||||
REMOTE_DWC2FK_COMMIT="${green}$(printf "%-12s" "$REMOTE_DWC2FK_COMMIT")${default}"
|
||||
DWC2FK_UPDATE_AVAIL="true"
|
||||
update_arr+=(update_dwc2fk)
|
||||
# add dwc2fk to the update all array for the update all function in the updater
|
||||
DWC2FK_UPDATE_AVAIL="true" && update_arr+=(update_dwc2fk)
|
||||
else
|
||||
LOCAL_DWC2FK_COMMIT="${green}$(printf "%-12s" "$LOCAL_DWC2FK_COMMIT")${default}"
|
||||
REMOTE_DWC2FK_COMMIT="${green}$(printf "%-12s" "$REMOTE_DWC2FK_COMMIT")${default}"
|
||||
@@ -352,16 +399,16 @@ compare_dwc2_versions(){
|
||||
read_local_dwc2_version && read_remote_dwc2_version
|
||||
if [[ $DWC2_VER_FOUND = "true" ]] && [[ $DWC2_LOCAL_VER == $DWC2_REMOTE_VER ]]; then
|
||||
#printf fits the string for displaying it in the ui to a total char length of 12
|
||||
DWC2_LOCAL_VER="${green}$(printf "v%-11s" "$DWC2_LOCAL_VER")${default}"
|
||||
DWC2_REMOTE_VER="${green}$(printf "v%-11s" "$DWC2_REMOTE_VER")${default}"
|
||||
DWC2_LOCAL_VER="${green}$(printf "%-12s" "$DWC2_LOCAL_VER")${default}"
|
||||
DWC2_REMOTE_VER="${green}$(printf "%-12s" "$DWC2_REMOTE_VER")${default}"
|
||||
elif [[ $DWC2_VER_FOUND = "true" ]] && [[ $DWC2_LOCAL_VER != $DWC2_REMOTE_VER ]]; then
|
||||
DWC2_LOCAL_VER="${yellow}$(printf "v%-11s" "$DWC2_LOCAL_VER")${default}"
|
||||
DWC2_REMOTE_VER="${green}$(printf "v%-11s" "$DWC2_REMOTE_VER")${default}"
|
||||
# set flag for the multi update function
|
||||
DWC2_LOCAL_VER="${yellow}$(printf "%-12s" "$DWC2_LOCAL_VER")${default}"
|
||||
DWC2_REMOTE_VER="${green}$(printf "%-12s" "$DWC2_REMOTE_VER")${default}"
|
||||
# add dwc to the update all array for the update all function in the updater
|
||||
DWC2_UPDATE_AVAIL="true" && update_arr+=(update_dwc2)
|
||||
else
|
||||
DWC2_LOCAL_VER=$NONE
|
||||
DWC2_REMOTE_VER="${green}$(printf "v%-11s" "$DWC2_REMOTE_VER")${default}"
|
||||
DWC2_REMOTE_VER="${green}$(printf "%-12s" "$DWC2_REMOTE_VER")${default}"
|
||||
DWC2_UPDATE_AVAIL="false"
|
||||
fi
|
||||
}
|
||||
@@ -387,8 +434,8 @@ compare_moonraker_versions(){
|
||||
if [ "$LOCAL_MOONRAKER_COMMIT" != "$REMOTE_MOONRAKER_COMMIT" ]; then
|
||||
LOCAL_MOONRAKER_COMMIT="${yellow}$(printf "%-12s" "$LOCAL_MOONRAKER_COMMIT")${default}"
|
||||
REMOTE_MOONRAKER_COMMIT="${green}$(printf "%-12s" "$REMOTE_MOONRAKER_COMMIT")${default}"
|
||||
MOONRAKER_UPDATE_AVAIL="true"
|
||||
update_arr+=(update_moonraker)
|
||||
# add moonraker to the update all array for the update all function in the updater
|
||||
MOONRAKER_UPDATE_AVAIL="true" && update_arr+=(update_moonraker)
|
||||
else
|
||||
LOCAL_MOONRAKER_COMMIT="${green}$(printf "%-12s" "$LOCAL_MOONRAKER_COMMIT")${default}"
|
||||
REMOTE_MOONRAKER_COMMIT="${green}$(printf "%-12s" "$REMOTE_MOONRAKER_COMMIT")${default}"
|
||||
@@ -426,7 +473,7 @@ compare_mainsail_versions(){
|
||||
elif [[ $MAINSAIL_VER_FOUND = "true" ]] && [[ $MAINSAIL_LOCAL_VER != $MAINSAIL_REMOTE_VER ]]; then
|
||||
MAINSAIL_LOCAL_VER="${yellow}$(printf "%-12s" "$MAINSAIL_LOCAL_VER")${default}"
|
||||
MAINSAIL_REMOTE_VER="${green}$(printf "%-12s" "$MAINSAIL_REMOTE_VER")${default}"
|
||||
# set flag for the multi update function
|
||||
# add mainsail to the update all array for the update all function in the updater
|
||||
MAINSAIL_UPDATE_AVAIL="true" && update_arr+=(update_mainsail)
|
||||
else
|
||||
MAINSAIL_LOCAL_VER=$NONE
|
||||
@@ -465,7 +512,7 @@ compare_fluidd_versions(){
|
||||
elif [[ $FLUIDD_VER_FOUND = "true" ]] && [[ $FLUIDD_LOCAL_VER != $FLUIDD_REMOTE_VER ]]; then
|
||||
FLUIDD_LOCAL_VER="${yellow}$(printf "%-12s" "$FLUIDD_LOCAL_VER")${default}"
|
||||
FLUIDD_REMOTE_VER="${green}$(printf "%-12s" "$FLUIDD_REMOTE_VER")${default}"
|
||||
# set flag for the multi update function
|
||||
# add fluidd to the update all array for the update all function in the updater
|
||||
FLUIDD_UPDATE_AVAIL="true" && update_arr+=(update_fluidd)
|
||||
else
|
||||
FLUIDD_LOCAL_VER=$NONE
|
||||
@@ -501,6 +548,65 @@ compare_klipperscreen_versions(){
|
||||
fi
|
||||
}
|
||||
|
||||
read_MoonrakerTelegramBot_versions(){
|
||||
if [ -d $MOONRAKER_TELEGRAM_BOT_DIR ] && [ -d $MOONRAKER_TELEGRAM_BOT_DIR/.git ]; then
|
||||
cd $MOONRAKER_TELEGRAM_BOT_DIR
|
||||
git fetch origin master -q
|
||||
LOCAL_MOONRAKER_TELEGRAM_BOT_COMMIT=$(git describe HEAD --always --tags | cut -d "-" -f 1,2)
|
||||
REMOTE_MOONRAKER_TELEGRAM_BOT_COMMIT=$(git describe origin/master --always --tags | cut -d "-" -f 1,2)
|
||||
else
|
||||
LOCAL_MOONRAKER_TELEGRAM_BOT_COMMIT=$NONE
|
||||
REMOTE_MOONRAKER_TELEGRAM_BOT_COMMIT=$NONE
|
||||
fi
|
||||
}
|
||||
|
||||
compare_MoonrakerTelegramBot_versions(){
|
||||
unset MOONRAKER_TELEGRAM_BOT_UPDATE_AVAIL
|
||||
read_MoonrakerTelegramBot_versions
|
||||
if [ "$LOCAL_MOONRAKER_TELEGRAM_BOT_COMMIT" != "$REMOTE_MOONRAKER_TELEGRAM_BOT_COMMIT" ]; then
|
||||
LOCAL_MOONRAKER_TELEGRAM_BOT_COMMIT="${yellow}$(printf "%-12s" "$LOCAL_MOONRAKER_TELEGRAM_BOT_COMMIT")${default}"
|
||||
REMOTE_MOONRAKER_TELEGRAM_BOT_COMMIT="${green}$(printf "%-12s" "$REMOTE_MOONRAKER_TELEGRAM_BOT_COMMIT")${default}"
|
||||
# add moonraker telegram bot to the update all array for the update all function in the updater
|
||||
MOONRAKER_TELEGRAM_BOT_UPDATE_AVAIL="true" && update_arr+=(update_MoonrakerTelegramBot)
|
||||
else
|
||||
LOCAL_MOONRAKER_TELEGRAM_BOT_COMMIT="${green}$(printf "%-12s" "$LOCAL_MOONRAKER_TELEGRAM_BOT_COMMIT")${default}"
|
||||
REMOTE_MOONRAKER_TELEGRAM_BOT_COMMIT="${green}$(printf "%-12s" "$REMOTE_MOONRAKER_TELEGRAM_BOT_COMMIT")${default}"
|
||||
MOONRAKER_TELEGRAM_BOT_UPDATE_AVAIL="false"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
read_pgc_versions(){
|
||||
PGC_DIR="${HOME}/pgcode"
|
||||
if [ -d $PGC_DIR ] && [ -d $PGC_DIR/.git ]; then
|
||||
cd $PGC_DIR
|
||||
git fetch origin main -q
|
||||
LOCAL_PGC_COMMIT=$(git describe HEAD --always --tags | cut -d "-" -f 1,2)
|
||||
REMOTE_PGC_COMMIT=$(git describe origin/main --always --tags | cut -d "-" -f 1,2)
|
||||
else
|
||||
LOCAL_PGC_COMMIT=$NONE
|
||||
REMOTE_PGC_COMMIT=$NONE
|
||||
fi
|
||||
}
|
||||
|
||||
compare_pgc_versions(){
|
||||
unset PGC_UPDATE_AVAIL
|
||||
read_pgc_versions
|
||||
if [ "$LOCAL_PGC_COMMIT" != "$REMOTE_PGC_COMMIT" ]; then
|
||||
LOCAL_PGC_COMMIT="${yellow}$(printf "%-12s" "$LOCAL_PGC_COMMIT")${default}"
|
||||
REMOTE_PGC_COMMIT="${green}$(printf "%-12s" "$REMOTE_PGC_COMMIT")${default}"
|
||||
# add PGC to the update all array for the update all function in the updater
|
||||
PGC_UPDATE_AVAIL="true" && update_arr+=(update_pgc_for_klipper)
|
||||
else
|
||||
LOCAL_PGC_COMMIT="${green}$(printf "%-12s" "$LOCAL_PGC_COMMIT")${default}"
|
||||
REMOTE_PGC_COMMIT="${green}$(printf "%-12s" "$REMOTE_PGC_COMMIT")${default}"
|
||||
PGC_UPDATE_AVAIL="false"
|
||||
fi
|
||||
}
|
||||
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
@@ -509,6 +615,7 @@ NONE="${red}$(printf "%-12s" "--------")${default}"
|
||||
|
||||
ui_print_versions(){
|
||||
unset update_arr
|
||||
check_system_updates
|
||||
compare_klipper_versions
|
||||
compare_dwc2fk_versions
|
||||
compare_dwc2_versions
|
||||
@@ -516,4 +623,6 @@ ui_print_versions(){
|
||||
compare_mainsail_versions
|
||||
compare_fluidd_versions
|
||||
compare_klipperscreen_versions
|
||||
compare_MoonrakerTelegramBot_versions
|
||||
compare_pgc_versions
|
||||
}
|
||||
|
||||
@@ -2,19 +2,23 @@ advanced_ui(){
|
||||
top_border
|
||||
echo -e "| ${yellow}~~~~~~~~~~~~~ [ Advanced Menu ] ~~~~~~~~~~~~~${default} | "
|
||||
hr
|
||||
echo -e "| 0) $OPRINT_SERVICE_STATUS| "
|
||||
hr
|
||||
echo -e "| | | "
|
||||
echo -e "| Klipper: | System: | "
|
||||
echo -e "| 1) [Switch Version] | 6) [Change hostname] | "
|
||||
if [ ! "$OPRINT_SERVICE_STATUS" == "" ]; then
|
||||
echo -e "| 0) $OPRINT_SERVICE_STATUS| "
|
||||
hr
|
||||
echo -e "| | | "
|
||||
fi
|
||||
echo -e "| Klipper: | Mainsail: | "
|
||||
echo -e "| 1) [Switch Branch] | 7) [Theme installer] | "
|
||||
echo -e "| 2) [Rollback] | | "
|
||||
echo -e "| | Extensions: | "
|
||||
echo -e "| Firmware: | 7) [Shell Command] | "
|
||||
echo -e "| | System: | "
|
||||
echo -e "| Firmware: | 8) [Change hostname] | "
|
||||
echo -e "| 3) [Build only] | | "
|
||||
echo -e "| 4) [Build + Flash MCU] | | "
|
||||
echo -e "| 5) [Get MCU ID] | | "
|
||||
echo -e "| | | "
|
||||
quit_footer
|
||||
echo -e "| 4) [Flash only] | Extensions: | "
|
||||
echo -e "| 5) [Build + Flash] | 9) [Shell Command] | "
|
||||
echo -e "| 6) [Get MCU ID] | | "
|
||||
echo -e "| | CustomPiOS: | "
|
||||
echo -e "| | 10) [Migration Helper] | "
|
||||
back_footer
|
||||
}
|
||||
|
||||
advanced_menu(){
|
||||
@@ -31,32 +35,37 @@ advanced_menu(){
|
||||
print_msg && clear_msg
|
||||
advanced_ui;;
|
||||
1)
|
||||
do_action "switch_menu" "advanced_ui";;
|
||||
do_action "switch_menu";;
|
||||
2)
|
||||
do_action "load_klipper_state" "advanced_ui";;
|
||||
3)
|
||||
do_action "build_fw" "advanced_ui";;
|
||||
4)
|
||||
clear
|
||||
print_header
|
||||
flash_routine
|
||||
### build in a sleep to give the user a chance to have a look at the
|
||||
### MCU IDs before directly starting to build the klipper firmware
|
||||
status_msg "Please wait..." && sleep 10 && build_fw
|
||||
flash_mcu
|
||||
clear && print_header
|
||||
check_usergroup_dialout
|
||||
do_action "select_flash_method" "advanced_ui";;
|
||||
5)
|
||||
clear && print_header
|
||||
check_usergroup_dialout
|
||||
status_msg "Please wait..."
|
||||
build_fw && select_flash_method
|
||||
print_msg && clear_msg
|
||||
advanced_ui;;
|
||||
5)
|
||||
do_action "get_mcu_id" "advanced_ui";;
|
||||
6)
|
||||
do_action "select_mcu_connection" "advanced_ui";;
|
||||
7)
|
||||
do_action "ms_theme_menu";;
|
||||
8)
|
||||
clear
|
||||
print_header
|
||||
create_custom_hostname && set_hostname
|
||||
print_msg && clear_msg
|
||||
advanced_ui;;
|
||||
7)
|
||||
9)
|
||||
do_action "setup_gcode_shell_command" "advanced_ui";;
|
||||
Q|q)
|
||||
10)
|
||||
do_action "migration_menu";;
|
||||
B|b)
|
||||
clear; main_menu; break;;
|
||||
*)
|
||||
deny_action "advanced_ui";;
|
||||
@@ -83,7 +92,7 @@ switch_ui(){
|
||||
echo -e "| dmbutyugin: | "
|
||||
echo -e "| 2) [--> scurve-shaping] | "
|
||||
echo -e "| 3) [--> scurve-smoothing] | "
|
||||
quit_footer
|
||||
back_footer
|
||||
}
|
||||
|
||||
switch_menu(){
|
||||
@@ -121,7 +130,7 @@ switch_menu(){
|
||||
read_branch
|
||||
print_msg && clear_msg
|
||||
switch_ui;;
|
||||
Q|q)
|
||||
B|b)
|
||||
clear; advanced_menu; break;;
|
||||
*)
|
||||
deny_action "switch_ui";;
|
||||
@@ -135,21 +144,36 @@ switch_menu(){
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
rollback_ui(){
|
||||
migration_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~ [ Rollback Menu ] ~~~~~~~~~~~~~") | "
|
||||
echo -e "| $(title_msg "~~~~~~~~~ [ CustomPiOS Migration ] ~~~~~~~~~~") | "
|
||||
hr
|
||||
echo -e "| If serious errors occured after updating Klipper, | "
|
||||
echo -e "| you can use this menu to return to the previously | "
|
||||
echo -e "| used commit from which you have updated. | "
|
||||
bottom_border
|
||||
top_border
|
||||
echo -e "| Active branch: ${green}$PRINT_BRANCH${default} | "
|
||||
echo -e "| This function will help you to migrate a vanilla | "
|
||||
echo -e "| MainsailOS or FluiddPi image to a newer state. | "
|
||||
blank_line
|
||||
echo -e "| Only use this function if you use MainsailOS 0.4.0 | "
|
||||
echo -e "| or lower, or FluiddPi v1.13.0 or lower. | "
|
||||
blank_line
|
||||
echo -e "| Please have a look at the KIAUH changelog for more | "
|
||||
echo -e "| details on what this function will do. | "
|
||||
hr
|
||||
echo -e "| Currently on commit: | "
|
||||
echo -e "| $CURR_UI | "
|
||||
hr
|
||||
echo -e "| Commit last updated from: | "
|
||||
echo -e "| $PREV_UI | "
|
||||
quit_footer
|
||||
echo -e "| | "
|
||||
echo -e "| 1) [Migrate MainsailOS] | "
|
||||
echo -e "| 2) [Migrate FluiddPi] | "
|
||||
echo -e "| | "
|
||||
back_footer
|
||||
}
|
||||
|
||||
migration_menu(){
|
||||
print_msg && clear_msg
|
||||
migration_ui
|
||||
while true; do
|
||||
read -p "${cyan}Perform action:${default} " action; echo
|
||||
case "$action" in
|
||||
1) migrate_custompios "mainsail"; migration_menu;;
|
||||
2) migrate_custompios "fluiddpi"; migration_menu;;
|
||||
B|b) clear; advanced_menu; break;;
|
||||
*) print_unkown_cmd; migration_menu;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
@@ -5,16 +5,17 @@ backup_ui(){
|
||||
echo -e "| ${yellow}Backup location: ~/kiauh-backups${default} | "
|
||||
hr
|
||||
echo -e "| Configuration folder: | Klipper Webinterface: | "
|
||||
echo -e "| 0) [Klipper configs] | 3) [Mainsail] | "
|
||||
echo -e "| | 4) [Fluidd] | "
|
||||
echo -e "| 0) [Klipper configs] | 4) [Mainsail] | "
|
||||
echo -e "| | 5) [Fluidd] | "
|
||||
echo -e "| Firmware: | | "
|
||||
echo -e "| 1) [Klipper] | HDMI Screen: | "
|
||||
echo -e "| | 5) [KlipperScreen] | "
|
||||
echo -e "| | 6) [KlipperScreen] | "
|
||||
echo -e "| Klipper API: | | "
|
||||
echo -e "| 2) [Moonraker] | Other: | "
|
||||
echo -e "| | 6) [Duet Web Control] | "
|
||||
echo -e "| | 7) [OctoPrint] | "
|
||||
quit_footer
|
||||
echo -e "| 3) [Moonraker DB] | 7) [Duet Web Control] | "
|
||||
echo -e "| | 8) [OctoPrint] | "
|
||||
echo -e "| | 9) [MoonrakerTelegramBot] | "
|
||||
back_footer
|
||||
}
|
||||
|
||||
backup_menu(){
|
||||
@@ -29,20 +30,24 @@ backup_menu(){
|
||||
2)
|
||||
do_action "backup_moonraker" "backup_ui";;
|
||||
3)
|
||||
do_action "backup_mainsail" "backup_ui";;
|
||||
do_action "backup_moonraker_database" "backup_ui";;
|
||||
4)
|
||||
do_action "backup_fluidd" "backup_ui";;
|
||||
do_action "backup_mainsail" "backup_ui";;
|
||||
5)
|
||||
do_action "backup_klipperscreen" "backup_ui";;
|
||||
do_action "backup_fluidd" "backup_ui";;
|
||||
6)
|
||||
do_action "backup_dwc2" "backup_ui";;
|
||||
do_action "backup_klipperscreen" "backup_ui";;
|
||||
7)
|
||||
do_action "backup_dwc2" "backup_ui";;
|
||||
8)
|
||||
do_action "backup_octoprint" "backup_ui";;
|
||||
Q|q)
|
||||
9)
|
||||
do_action "backup_MoonrakerTelegramBot" "backup_ui";;
|
||||
B|b)
|
||||
clear; main_menu; break;;
|
||||
*)
|
||||
deny_action "backup_ui";;
|
||||
esac
|
||||
done
|
||||
backup_menu
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ui total width = 57 chars
|
||||
top_border(){
|
||||
echo -e "/=======================================================\ "
|
||||
echo -e "/=======================================================\\"
|
||||
}
|
||||
|
||||
bottom_border(){
|
||||
@@ -8,7 +8,7 @@ bottom_border(){
|
||||
}
|
||||
|
||||
blank_line(){
|
||||
echo -e "| | "
|
||||
echo -e "| |"
|
||||
}
|
||||
|
||||
hr(){
|
||||
@@ -17,7 +17,19 @@ hr(){
|
||||
|
||||
quit_footer(){
|
||||
hr
|
||||
echo -e "| ${red}Q) Quit${default} | "
|
||||
echo -e "| ${red}Q) Quit${default} |"
|
||||
bottom_border
|
||||
}
|
||||
|
||||
back_footer(){
|
||||
hr
|
||||
echo -e "| ${green}B) « Back${default} |"
|
||||
bottom_border
|
||||
}
|
||||
|
||||
back_help_footer(){
|
||||
hr
|
||||
echo -e "| ${green}B) « Back${default} | ${yellow}H) Help [?]${default} |"
|
||||
bottom_border
|
||||
}
|
||||
|
||||
@@ -31,17 +43,19 @@ print_header(){
|
||||
|
||||
kiauh_update_msg(){
|
||||
top_border
|
||||
echo -e "| ${yellow}There is a newer version of this script available!${default} | "
|
||||
echo -e "| ${yellow}Type 'update' if you want to update KIAUH now.${default} | "
|
||||
echo -e "|${green} New KIAUH update available! ${default}| "
|
||||
hr
|
||||
echo -e "|${green} View Changelog: https://git.io/JnmlX ${default}| "
|
||||
blank_line
|
||||
echo -e "| ${yellow}Check out the KIAUH changelog for important changes${default} | "
|
||||
echo -e "| ${yellow}either to the script or the installable components!${default} | "
|
||||
echo -e "|${yellow} It is recommended to keep KIAUH up to date. Updates ${default}| "
|
||||
echo -e "|${yellow} usually contain bugfixes, important changes or new ${default}| "
|
||||
echo -e "|${yellow} features. Please consider updating! ${default}| "
|
||||
bottom_border
|
||||
}
|
||||
|
||||
##############################################################################################
|
||||
#********************************************************************************************#
|
||||
##############################################################################################
|
||||
################################################################################
|
||||
#******************************************************************************#
|
||||
################################################################################
|
||||
### TODO: rework other menus to make use of the following functions too and make them more readable
|
||||
|
||||
do_action(){
|
||||
@@ -58,4 +72,4 @@ deny_action(){
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg
|
||||
$1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,17 +6,18 @@ install_ui(){
|
||||
echo -e "| all necessary dependencies for the various | "
|
||||
echo -e "| functions on a completely fresh system. | "
|
||||
hr
|
||||
echo -e "| Firmware: | Klipper Webinterface: | "
|
||||
echo -e "| 1) [Klipper] | 3) [Mainsail] | "
|
||||
echo -e "| | 4) [Fluidd] | "
|
||||
echo -e "| Klipper API: | | "
|
||||
echo -e "| 2) [Moonraker] | HDMI Screen: | "
|
||||
echo -e "| | 5) [KlipperScreen] | "
|
||||
echo -e "| | | "
|
||||
echo -e "| | Other: | "
|
||||
echo -e "| | 6) [Duet Web Control] | "
|
||||
echo -e "| | 7) [OctoPrint] | "
|
||||
quit_footer
|
||||
echo -e "| Firmware: | Touchscreen GUI: | "
|
||||
echo -e "| 1) [Klipper] | 5) [KlipperScreen] | "
|
||||
echo -e "| | | "
|
||||
echo -e "| Klipper API: | Other: | "
|
||||
echo -e "| 2) [Moonraker] | 6) [Duet Web Control] | "
|
||||
echo -e "| | 7) [OctoPrint] | "
|
||||
echo -e "| Klipper Webinterface: | 8) [PrettyGCode] | "
|
||||
echo -e "| 3) [Mainsail] | 9) [Telegram Bot] | "
|
||||
echo -e "| 4) [Fluidd] | | "
|
||||
echo -e "| | Webcam: | "
|
||||
echo -e "| | 10) [MJPG-Streamer] | "
|
||||
back_footer
|
||||
}
|
||||
|
||||
install_menu(){
|
||||
@@ -38,7 +39,13 @@ install_menu(){
|
||||
do_action "dwc_setup_dialog" "install_ui";;
|
||||
7)
|
||||
do_action "octoprint_setup_dialog" "install_ui";;
|
||||
Q|q)
|
||||
8)
|
||||
do_action "install_pgc_for_klipper" "install_ui";;
|
||||
9)
|
||||
do_action "install_MoonrakerTelegramBot" "install_ui";;
|
||||
10)
|
||||
do_action "install_mjpg-streamer" "install_ui";;
|
||||
B|b)
|
||||
clear; main_menu; break;;
|
||||
*)
|
||||
deny_action "install_ui";;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
main_ui(){
|
||||
#[ $KIAUH_UPDATE_REMIND="true" ] && kiauh_update_reminder
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~~ [ Main Menu ] ~~~~~~~~~~~~~~~") |"
|
||||
hr
|
||||
@@ -10,7 +11,8 @@ main_ui(){
|
||||
echo -e "| 4) [Advanced] | Mainsail: $MAINSAIL_STATUS|"
|
||||
echo -e "| 5) [Backup] | Fluidd: $FLUIDD_STATUS|"
|
||||
echo -e "| | KlipperScreen: $KLIPPERSCREEN_STATUS|"
|
||||
echo -e "| 6) [Settings] | |"
|
||||
echo -e "| 6) [Settings] | Telegram Bot: $MOONRAKER_TELEGRAM_BOT_STATUS|"
|
||||
echo -e "| | |"
|
||||
echo -e "| | DWC2: $DWC2_STATUS|"
|
||||
echo -e "| ${cyan}$KIAUH_VER${default}| Octoprint: $OCTOPRINT_STATUS|"
|
||||
quit_footer
|
||||
@@ -22,11 +24,26 @@ print_kiauh_version(){
|
||||
KIAUH_VER="$(printf "%-20s" "$KIAUH_VER")"
|
||||
}
|
||||
|
||||
kiauh_update_dialog(){
|
||||
kiauh_update_msg
|
||||
read -p "${cyan}Do you want to update now? (Y/n):${default} " yn
|
||||
while true; do
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
do_action "update_kiauh"
|
||||
break;;
|
||||
N|n|No|no) break;;
|
||||
*)
|
||||
deny_action "kiauh_update_dialog";;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
main_menu(){
|
||||
print_header
|
||||
#print KIAUH update msg if update available
|
||||
if [ "$KIAUH_UPDATE_AVAIL" = "true" ]; then
|
||||
kiauh_update_msg
|
||||
kiauh_update_dialog
|
||||
fi
|
||||
#check install status
|
||||
print_kiauh_version
|
||||
@@ -37,52 +54,33 @@ main_menu(){
|
||||
mainsail_status
|
||||
octoprint_status
|
||||
klipperscreen_status
|
||||
MoonrakerTelegramBot_status
|
||||
print_branch
|
||||
print_msg && clear_msg
|
||||
main_ui
|
||||
while true; do
|
||||
read -p "${cyan}Perform action:${default} " action; echo
|
||||
case "$action" in
|
||||
"start klipper")
|
||||
do_action "klipper_service start" "main_ui";;
|
||||
"stop klipper")
|
||||
do_action "klipper_service stop" "main_ui";;
|
||||
"restart klipper")
|
||||
do_action "klipper_service restart" "main_ui";;
|
||||
"start moonraker")
|
||||
do_action "moonraker_service start" "main_ui";;
|
||||
"stop moonraker")
|
||||
do_action "moonraker_service stop" "main_ui";;
|
||||
"restart moonraker")
|
||||
do_action "moonraker_service restart" "main_ui";;
|
||||
"start dwc")
|
||||
do_action "dwc_service start" "main_ui";;
|
||||
"stop dwc")
|
||||
do_action "dwc_service stop" "main_ui";;
|
||||
"restart dwc")
|
||||
do_action "dwc_service restart" "main_ui";;
|
||||
"start octoprint")
|
||||
do_action "octoprint_service start" "main_ui";;
|
||||
"stop octoprint")
|
||||
do_action "octoprint_service stop" "main_ui";;
|
||||
"restart octoprint")
|
||||
do_action "octoprint_service restart" "main_ui";;
|
||||
update)
|
||||
do_action "update_kiauh" "main_ui";;
|
||||
0)
|
||||
do_action "upload_selection" "main_ui";;
|
||||
1)
|
||||
clear && install_menu && break;;
|
||||
2)
|
||||
clear && update_menu && break;;
|
||||
3)
|
||||
clear && remove_menu && break;;
|
||||
4)
|
||||
clear && advanced_menu && break;;
|
||||
5)
|
||||
clear && backup_menu && break;;
|
||||
6)
|
||||
clear && settings_menu && break;;
|
||||
"start klipper") do_action_service "start" "klipper"; main_ui;;
|
||||
"stop klipper") do_action_service "stop" "klipper"; main_ui;;
|
||||
"restart klipper") do_action_service "restart" "klipper"; main_ui;;
|
||||
"start moonraker") do_action_service "start" "moonraker"; main_ui;;
|
||||
"stop moonraker") do_action_service "stop" "moonraker"; main_ui;;
|
||||
"restart moonraker")do_action_service "restart" "moonraker"; main_ui;;
|
||||
"start dwc") do_action_service "start" "dwc"; main_ui;;
|
||||
"stop dwc") do_action_service "stop" "dwc"; main_ui;;
|
||||
"restart dwc") do_action_service "restart" "dwc"; main_ui;;
|
||||
"start octoprint") do_action_service "start" "octoprint"; main_ui;;
|
||||
"stop octoprint") do_action_service "stop" "octoprint"; main_ui;;
|
||||
"restart octoprint") do_action_service "restart" "octoprint"; main_ui;;
|
||||
update) do_action "update_kiauh" "main_ui";;
|
||||
0) do_action "upload_selection" "main_ui";;
|
||||
1) clear && install_menu && break;;
|
||||
2) clear && update_menu && break;;
|
||||
3) clear && remove_menu && break;;
|
||||
4) clear && advanced_menu && break;;
|
||||
5) clear && backup_menu && break;;
|
||||
6) clear && settings_menu && break;;
|
||||
Q|q)
|
||||
echo -e "${green}###### Happy printing! ######${default}"; echo
|
||||
exit -1;;
|
||||
|
||||
@@ -7,18 +7,18 @@ remove_ui(){
|
||||
echo -e "| --> ~/kiauh-backups | "
|
||||
echo -e "| You need remove them manually if you wish so. | "
|
||||
hr
|
||||
echo -e "| Firmware: | Klipper Webinterface: | "
|
||||
echo -e "| 1) [Klipper] | 3) [Mainsail] | "
|
||||
echo -e "| | 4) [Fluidd] | "
|
||||
echo -e "| Klipper API: | | "
|
||||
echo -e "| 2) [Moonraker] | HDMI Screen: | "
|
||||
echo -e "| | 5) [KlipperScreen] | "
|
||||
echo -e "| | | "
|
||||
echo -e "| | Other: | "
|
||||
echo -e "| | 6) [Duet Web Control] | "
|
||||
echo -e "| | 7) [OctoPrint] | "
|
||||
echo -e "| | 8) [NGINX] | "
|
||||
quit_footer
|
||||
echo -e "| Firmware: | Touchscreen GUI: | "
|
||||
echo -e "| 1) [Klipper] | 5) [KlipperScreen] | "
|
||||
echo -e "| | | "
|
||||
echo -e "| Klipper API: | Other: | "
|
||||
echo -e "| 2) [Moonraker] | 6) [Duet Web Control] | "
|
||||
echo -e "| | 7) [OctoPrint] | "
|
||||
echo -e "| Klipper Webinterface: | 8) [PrettyGCode] | "
|
||||
echo -e "| 3) [Mainsail] | 9) [Telegram Bot] | "
|
||||
echo -e "| 4) [Fluidd] | | "
|
||||
echo -e "| | 10) [MJPG-Streamer] | "
|
||||
echo -e "| | 11) [NGINX] | "
|
||||
back_footer
|
||||
}
|
||||
|
||||
remove_menu(){
|
||||
@@ -41,8 +41,14 @@ remove_menu(){
|
||||
7)
|
||||
do_action "remove_octoprint" "remove_ui";;
|
||||
8)
|
||||
do_action "remove_prettygcode" "remove_ui";;
|
||||
9)
|
||||
do_action "remove_MoonrakerTelegramBot" "remove_ui";;
|
||||
10)
|
||||
do_action "remove_mjpg-streamer" "remove_ui";;
|
||||
11)
|
||||
do_action "remove_nginx" "remove_ui";;
|
||||
Q|q)
|
||||
B|b)
|
||||
clear; main_menu; break;;
|
||||
*)
|
||||
deny_action "remove_ui";;
|
||||
|
||||
@@ -20,7 +20,7 @@ settings_ui(){
|
||||
else
|
||||
echo -e "| 1) Change config folder | "
|
||||
fi
|
||||
quit_footer
|
||||
back_footer
|
||||
}
|
||||
|
||||
settings_menu(){
|
||||
@@ -34,7 +34,7 @@ settings_menu(){
|
||||
else
|
||||
deny_action "settings_ui"
|
||||
fi;;
|
||||
Q|q)
|
||||
B|b)
|
||||
clear; main_menu; break;;
|
||||
*)
|
||||
deny_action "settings_ui";;
|
||||
|
||||
@@ -1,106 +1,67 @@
|
||||
update_ui(){
|
||||
ui_print_versions
|
||||
top_border
|
||||
echo -e "| ${green}~~~~~~~~~~~~~~ [ Update Menu ] ~~~~~~~~~~~~~~${default} | "
|
||||
hr
|
||||
echo -e "| Check the following website for important software | "
|
||||
echo -e "| changes to the config file before updating Klipper: | "
|
||||
echo -e "| | "
|
||||
echo -e "| ${yellow}https://www.klipper3d.org/Config_Changes.html${default} | "
|
||||
bottom_border
|
||||
top_border
|
||||
echo -e "| 0) $BB4U_STATUS| "
|
||||
hr
|
||||
echo -e "| a) [Update all] | Local Vers: | Remote Vers: | "
|
||||
echo -e "| | | | "
|
||||
echo -e "| Firmware: | | | "
|
||||
echo -e "| a) [Update all] | | | "
|
||||
echo -e "| | Local Vers: | Remote Vers: | "
|
||||
echo -e "| Klipper/Klipper API: |---------------|--------------| "
|
||||
echo -e "| 1) [Klipper] | $LOCAL_COMMIT | $REMOTE_COMMIT | "
|
||||
echo -e "| 2) [Moonraker] | $LOCAL_MOONRAKER_COMMIT | $REMOTE_MOONRAKER_COMMIT | "
|
||||
echo -e "| | | | "
|
||||
echo -e "| Webinterface: |---------------|--------------| "
|
||||
echo -e "| 2) [DWC2-for-Klipper] | $LOCAL_DWC2FK_COMMIT | $REMOTE_DWC2FK_COMMIT | "
|
||||
echo -e "| 3) [DWC2 Web UI] | $DWC2_LOCAL_VER | $DWC2_REMOTE_VER | "
|
||||
echo -e "| |---------------|--------------| "
|
||||
echo -e "| 4) [Moonraker] | $LOCAL_MOONRAKER_COMMIT | $REMOTE_MOONRAKER_COMMIT | "
|
||||
echo -e "| 5) [Mainsail] | $MAINSAIL_LOCAL_VER | $MAINSAIL_REMOTE_VER | "
|
||||
echo -e "| 6) [Fluidd] | $FLUIDD_LOCAL_VER | $FLUIDD_REMOTE_VER | "
|
||||
echo -e "| Klipper Webinterface: |---------------|--------------| "
|
||||
echo -e "| 3) [Mainsail] | $MAINSAIL_LOCAL_VER | $MAINSAIL_REMOTE_VER | "
|
||||
echo -e "| 4) [Fluidd] | $FLUIDD_LOCAL_VER | $FLUIDD_REMOTE_VER | "
|
||||
echo -e "| | | | "
|
||||
echo -e "| HDMI Screen: |---------------|--------------| "
|
||||
echo -e "| 7) [KlipperScreen] | $LOCAL_KLIPPERSCREEN_COMMIT | $REMOTE_KLIPPERSCREEN_COMMIT | "
|
||||
quit_footer
|
||||
echo -e "| Touchscreen GUI: |---------------|--------------| "
|
||||
echo -e "| 5) [KlipperScreen] | $LOCAL_KLIPPERSCREEN_COMMIT | $REMOTE_KLIPPERSCREEN_COMMIT | "
|
||||
echo -e "| | | | "
|
||||
echo -e "| Other: |---------------|--------------| "
|
||||
echo -e "| 6) [DWC2-for-Klipper] | $LOCAL_DWC2FK_COMMIT | $REMOTE_DWC2FK_COMMIT | "
|
||||
echo -e "| 7) [DWC2 Web UI] | $DWC2_LOCAL_VER | $DWC2_REMOTE_VER | "
|
||||
echo -e "| 8) [PrettyGCode] | $LOCAL_PGC_COMMIT | $REMOTE_PGC_COMMIT | "
|
||||
echo -e "| 9) [Telegram Bot] | $LOCAL_MOONRAKER_TELEGRAM_BOT_COMMIT | $REMOTE_MOONRAKER_TELEGRAM_BOT_COMMIT | "
|
||||
echo -e "| |------------------------------| "
|
||||
echo -e "| 10) [System] | $DISPLAY_SYS_UPDATE | "
|
||||
back_footer
|
||||
}
|
||||
|
||||
update_menu(){
|
||||
print_header
|
||||
#compare versions
|
||||
ui_print_versions
|
||||
print_msg && clear_msg
|
||||
read_bb4u_stat
|
||||
update_ui
|
||||
do_action "" "update_ui"
|
||||
while true; do
|
||||
read -p "${cyan}Perform action:${default} " action; echo
|
||||
case "$action" in
|
||||
0)
|
||||
clear
|
||||
print_header
|
||||
toggle_backups
|
||||
print_msg && clear_msg
|
||||
update_ui;;
|
||||
do_action "toggle_backups" "update_ui";;
|
||||
1)
|
||||
clear
|
||||
print_header
|
||||
update_klipper && ui_print_versions
|
||||
print_msg && clear_msg
|
||||
update_ui;;
|
||||
do_action "update_klipper" "update_ui";;
|
||||
2)
|
||||
clear
|
||||
print_header
|
||||
update_dwc2fk && ui_print_versions
|
||||
print_msg && clear_msg
|
||||
update_ui;;
|
||||
do_action "update_moonraker" "update_ui";;
|
||||
3)
|
||||
clear
|
||||
print_header
|
||||
update_dwc2 && ui_print_versions
|
||||
print_msg && clear_msg
|
||||
update_ui;;
|
||||
do_action "update_mainsail" "update_ui";;
|
||||
4)
|
||||
clear
|
||||
print_header
|
||||
update_moonraker && ui_print_versions
|
||||
print_msg && clear_msg
|
||||
update_ui;;
|
||||
do_action "update_fluidd" "update_ui";;
|
||||
5)
|
||||
clear
|
||||
print_header
|
||||
update_mainsail && ui_print_versions
|
||||
print_msg && clear_msg
|
||||
update_ui;;
|
||||
do_action "update_klipperscreen" "update_ui";;
|
||||
6)
|
||||
clear
|
||||
print_header
|
||||
update_fluidd && ui_print_versions
|
||||
print_msg && clear_msg
|
||||
update_ui;;
|
||||
do_action "update_dwc2fk" "update_ui";;
|
||||
7)
|
||||
clear
|
||||
print_header
|
||||
update_klipperscreen && ui_print_versions
|
||||
print_msg && clear_msg
|
||||
update_ui;;
|
||||
do_action "update_dwc2" "update_ui";;
|
||||
8)
|
||||
do_action "update_pgc_for_klipper" "update_ui";;
|
||||
9)
|
||||
do_action "update_MoonrakerTelegramBot" "update_ui";;
|
||||
10)
|
||||
do_action "update_system" "update_ui";;
|
||||
a)
|
||||
clear
|
||||
print_header
|
||||
update_all && ui_print_versions
|
||||
print_msg && clear_msg
|
||||
update_ui;;
|
||||
Q|q)
|
||||
do_action "update_all" "update_ui";;
|
||||
B|b)
|
||||
clear; main_menu; break;;
|
||||
*)
|
||||
clear
|
||||
print_header
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg
|
||||
ui_print_versions
|
||||
update_ui;;
|
||||
deny_action "update_ui";;
|
||||
esac
|
||||
done
|
||||
update_menu
|
||||
|
||||
@@ -39,6 +39,15 @@ update_all(){
|
||||
if [ "$KLIPPERSCREEN_UPDATE_AVAIL" = "true" ]; then
|
||||
echo -e "| ${cyan}● KlipperScreen${default} |"
|
||||
fi
|
||||
if [ "$PGC_UPDATE_AVAIL" = "true" ]; then
|
||||
echo -e "| ${cyan}● PrettyGCode for Klipper${default} |"
|
||||
fi
|
||||
if [ "$MOONRAKER_TELEGRAM_BOT_UPDATE_AVAIL" = "true" ]; then
|
||||
echo -e "| ${cyan}● MoonrakerTelegramBot${default} |"
|
||||
fi
|
||||
if [ "$SYS_UPDATE_AVAIL" = "true" ]; then
|
||||
echo -e "| ${cyan}● System${default} |"
|
||||
fi
|
||||
bottom_border
|
||||
if [ "${#update_arr[@]}" != "0" ]; then
|
||||
read -p "${cyan}###### Do you want to proceed? (Y/n):${default} " yn
|
||||
@@ -59,8 +68,159 @@ update_all(){
|
||||
done
|
||||
}
|
||||
|
||||
update_log_paths(){
|
||||
### update services to make use of moonrakers new log_path option
|
||||
### https://github.com/Arksine/moonraker/commit/829b3a4ee80579af35dd64a37ccc092a1f67682a
|
||||
shopt -s extglob # enable extended globbing
|
||||
source_kiauh_ini
|
||||
LPATH="${HOME}/klipper_logs"
|
||||
[ ! -d "$LPATH" ] && mkdir -p "$LPATH"
|
||||
FILE="$SYSTEMDDIR/$1?(-*([0-9])).service"
|
||||
for file in $(ls $FILE); do
|
||||
[ "$1" == "klipper" ] && LOG="klippy"
|
||||
[ "$1" == "moonraker" ] && LOG="moonraker"
|
||||
if [ ! "$(grep "\-l" $file)" ]; then
|
||||
status_msg "Updating $file ..."
|
||||
sudo sed -i -r "/ExecStart=/ s|$| -l $LPATH/$LOG.log|" $file
|
||||
ok_msg "$file updated!"
|
||||
elif [ "$(grep "\-l \/tmp\/$LOG" $file)" ]; then
|
||||
status_msg "Updating $file ..."
|
||||
sudo sed -i -r "/ExecStart=/ s|-l \/tmp\/$LOG|-l $LPATH/$LOG|" $file
|
||||
ok_msg "$file updated!"
|
||||
fi
|
||||
done
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
# patch log_path entry if not found
|
||||
dir1="$klipper_cfg_loc"
|
||||
dir2="$klipper_cfg_loc/printer_*"
|
||||
for conf in $(find $dir1 $dir2 -name "moonraker.conf" 2> /dev/null); do
|
||||
if ! grep -q "log_path" $conf; then
|
||||
status_msg "Patching $conf"
|
||||
sed -i "/^config_path/a log_path: $LPATH" $conf
|
||||
ok_msg "OK!"
|
||||
fi
|
||||
done
|
||||
|
||||
# create symlink for mainsail and fluidd nginx logs
|
||||
symlink_webui_nginx_log "mainsail"
|
||||
symlink_webui_nginx_log "fluidd"
|
||||
|
||||
# create symlink for webcamd log
|
||||
if [ -f "/var/log/webcamd.log" ] && [ ! -L "$LPATH/webcamd.log" ]; then
|
||||
status_msg "Creating symlink for '/var/log/webcamd.log' ..."
|
||||
ln -s "/var/log/webcamd.log" "$LPATH"
|
||||
ok_msg "OK!"
|
||||
fi
|
||||
|
||||
shopt -u extglob # disable extended globbing
|
||||
}
|
||||
|
||||
migrate_custompios(){
|
||||
### migrate vanilla mainsailOS 0.4.0 / fluiddPI v1.13.0
|
||||
### and older to be in sync with newer releases
|
||||
WEBCAMD_SRC="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mjpgstreamer/filesystem/root/usr/local/bin/webcamd"
|
||||
MJPG_SERV_SRC="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mjpgstreamer/filesystem/root/etc/systemd/system/webcamd.service"
|
||||
KL_SERV_SRC="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/klipper/filesystem/root/etc/systemd/system/klipper.service"
|
||||
NGINX_CFG1="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mainsail/filesystem/root/etc/nginx/conf.d/upstreams.conf"
|
||||
NGINX_CFG2="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mainsail/filesystem/root/etc/nginx/sites-available/mainsail"
|
||||
LOG_ROTATE_KLIPPER="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/klipper/filesystem/root/etc/logrotate.d/klipper"
|
||||
LOG_ROTATE_MOONRAKER="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/moonraker/filesystem/root/etc/logrotate.d/moonraker"
|
||||
LOG_ROTATE_WEBCAMD="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mjpgstreamer/filesystem/root/etc/logrotate.d/webcamd"
|
||||
|
||||
if [ "$1" == "mainsail" ]; then
|
||||
OS_VER="MainsailOS"
|
||||
MACRO_CFG="mainsail.cfg"
|
||||
fi
|
||||
if [ "$1" == "fluiddpi" ]; then
|
||||
OS_VER="FluiddPi"
|
||||
MACRO_CFG="client_macros.cfg"
|
||||
fi
|
||||
if [ ! -f "/boot/$1.txt" ] || [ ! -f "/etc/init.d/klipper" ]; then
|
||||
# abort function if there is no sign of an old CustomPiOS anymore
|
||||
ERROR_MSG="No vanilla $OS_VER found. Aborting..." && return 0
|
||||
fi
|
||||
status_msg "Starting migration of $OS_VER... Please wait..."
|
||||
if [ -d "${HOME}/klipper_logs" ]; then
|
||||
# delete an existing klipper_logs directory
|
||||
# shouldn't be there in the first place if its a true vanilla CustomPiOS
|
||||
status_msg "Recreate '~/klipper_logs' directory..."
|
||||
rm -rf "${HOME}/klipper_logs" && mkdir "${HOME}/klipper_logs"
|
||||
ok_msg "OK!"
|
||||
fi
|
||||
if [ -f "/boot/$1.txt" ]; then
|
||||
# replace old webcamd.service and webcamd
|
||||
status_msg "Migrating MJPG-Streamer..."
|
||||
sudo systemctl stop webcamd
|
||||
sudo rm -f "/etc/systemd/system/webcamd.service"
|
||||
sudo rm -f "/root/bin/webcamd"
|
||||
sudo wget $WEBCAMD_SRC -O "/usr/local/bin/webcamd"
|
||||
sudo wget $MJPG_SERV_SRC -O "/etc/systemd/system/webcamd.service"
|
||||
sudo sed -i "s/MainsailOS/$OS_VER/" "/etc/systemd/system/webcamd.service"
|
||||
sudo chmod +x "/usr/local/bin/webcamd"
|
||||
# move mainsail.txt/fluiddpi.txt from boot to klipper_config and rename it
|
||||
sudo mv "/boot/$1.txt" "${HOME}/klipper_config/webcam.txt"
|
||||
sudo chown pi:pi "${HOME}/klipper_config/webcam.txt"
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl restart webcamd
|
||||
ok_msg "OK!"
|
||||
fi
|
||||
if [ -f "/etc/init.d/klipper" ] && [ ! -f "/etc/systemd/system/klipper.service" ]; then
|
||||
# replace klipper SysVinit service with systemd service
|
||||
status_msg "Migrating Klipper Service..."
|
||||
sudo systemctl stop klipper
|
||||
sudo update-rc.d -f klipper remove
|
||||
sudo rm -f "/etc/init.d/klipper"
|
||||
sudo rm -f "/etc/default/klipper"
|
||||
sudo wget $KL_SERV_SRC -O "/etc/systemd/system/klipper.service"
|
||||
sudo systemctl enable klipper.service
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl restart klipper
|
||||
ok_msg "OK!"
|
||||
fi
|
||||
if [ -f "/etc/systemd/system/moonraker.service" ]; then
|
||||
# update new log path in existing moonraker service
|
||||
status_msg "Updating Moonraker Service..."
|
||||
sudo systemctl stop moonraker
|
||||
update_log_paths "moonraker"
|
||||
sudo systemctl restart moonraker
|
||||
ok_msg "OK!"
|
||||
fi
|
||||
if [ -f "/etc/nginx/conf.d/upstreams.conf" ]; then
|
||||
[ "$1" == "mainsail" ] && cfg="mainsail"
|
||||
[ "$1" == "fluiddpi" ] && cfg="fluidd"
|
||||
# update nginx upstreams.conf and mainsail/fluidd config file
|
||||
status_msg "Updating NGINX configurations..."
|
||||
sudo systemctl stop nginx
|
||||
sudo rm -f "/etc/nginx/conf.d/upstreams.conf"
|
||||
sudo rm -f "/etc/nginx/sites-available/$cfg"
|
||||
sudo wget $NGINX_CFG1 -O "/etc/nginx/conf.d/upstreams.conf"
|
||||
sudo wget $NGINX_CFG2 -O "/etc/nginx/sites-available/$cfg"
|
||||
sudo sed -i "s/mainsail/$cfg/g" "/etc/nginx/sites-available/$cfg"
|
||||
sudo systemctl restart nginx
|
||||
ok_msg "OK!"
|
||||
fi
|
||||
if [ -f "${HOME}/klipper_config/$MACRO_CFG" ]; then
|
||||
# update macro files
|
||||
status_msg "Updating $MACRO_CFG ..."
|
||||
MACRO_CFG_PATH="${HOME}/klipper_config/$MACRO_CFG"
|
||||
sed -i "/SAVE_GCODE_STATE NAME=PAUSE_state/d" $MACRO_CFG_PATH
|
||||
sed -i "/RESTORE_GCODE_STATE NAME=PAUSE_state/d" $MACRO_CFG_PATH
|
||||
ok_msg "OK!"
|
||||
fi
|
||||
if [ -d "/etc/logrotate.d" ]; then
|
||||
# download logrotate configs
|
||||
status_msg "Setting up logrotations..."
|
||||
sudo wget $LOG_ROTATE_KLIPPER -O "/etc/logrotate.d/klipper"
|
||||
sudo wget $LOG_ROTATE_MOONRAKER -O "/etc/logrotate.d/moonraker"
|
||||
sudo wget $LOG_ROTATE_WEBCAMD -O "/etc/logrotate.d/webcamd"
|
||||
ok_msg "OK!"
|
||||
fi
|
||||
ok_msg "Migration done!"
|
||||
}
|
||||
|
||||
update_klipper(){
|
||||
klipper_service "stop"
|
||||
do_action_service "stop" "klipper"
|
||||
if [ ! -d $KLIPPER_DIR ]; then
|
||||
cd ${HOME} && git clone $KLIPPER_REPO
|
||||
else
|
||||
@@ -69,85 +229,73 @@ update_klipper(){
|
||||
save_klipper_state
|
||||
status_msg "Updating $GET_BRANCH"
|
||||
cd $KLIPPER_DIR
|
||||
KLIPPER_OLDREQ_MD5SUM="$(md5sum $KLIPPER_DIR/scripts/klippy-requirements.txt | cut -d " " -f1)"
|
||||
|
||||
if [ "$DETACHED_HEAD" == "true" ]; then
|
||||
git checkout $GET_BRANCH
|
||||
unset DETACHED_HEAD
|
||||
fi
|
||||
|
||||
### pull latest files from github
|
||||
git pull && ok_msg "Update successfull!"
|
||||
|
||||
### check for possible new dependencies and install them
|
||||
if [[ $(md5sum $KLIPPER_DIR/scripts/klippy-requirements.txt | cut -d " " -f1) != $KLIPPER_OLDREQ_MD5SUM ]]; then
|
||||
PYTHONDIR="${HOME}/klippy-env"
|
||||
status_msg "New dependecies detected..."
|
||||
|
||||
### always rebuild the pythondir from scratch if new dependencies were detected
|
||||
rm -rf ${PYTHONDIR}
|
||||
virtualenv -p python2 ${PYTHONDIR}
|
||||
$PYTHONDIR/bin/pip install -r $KLIPPER_DIR/scripts/klippy-requirements.txt
|
||||
ok_msg "Dependencies have been installed!"
|
||||
fi
|
||||
|
||||
ok_msg "Update complete!"
|
||||
git pull
|
||||
### read PKGLIST and install possible new dependencies
|
||||
install_klipper_packages
|
||||
### install possible new python dependencies
|
||||
KLIPPER_REQ_TXT="$KLIPPER_DIR/scripts/klippy-requirements.txt"
|
||||
$KLIPPY_ENV/bin/pip install -r $KLIPPER_REQ_TXT
|
||||
fi
|
||||
klipper_service "restart"
|
||||
update_log_paths "klipper"
|
||||
ok_msg "Update complete!"
|
||||
do_action_service "restart" "klipper"
|
||||
}
|
||||
|
||||
update_dwc2fk(){
|
||||
dwc_service "stop"
|
||||
do_action_service "stop" "dwc"
|
||||
bb4u "dwc2"
|
||||
if [ ! -d $DWC2FK_DIR ]; then
|
||||
cd ${HOME} && git clone $DWC2FK_REPO
|
||||
else
|
||||
cd $DWC2FK_DIR && git pull
|
||||
fi
|
||||
dwc_service "start"
|
||||
do_action_service "start" "dwc"
|
||||
}
|
||||
|
||||
update_dwc2(){
|
||||
bb4u "dwc2"
|
||||
download_dwc2_webui
|
||||
download_dwc_webui
|
||||
}
|
||||
|
||||
update_mainsail(){
|
||||
bb4u "mainsail"
|
||||
status_msg "Updating Mainsail ..."
|
||||
mainsail_setup
|
||||
match_nginx_configs
|
||||
symlink_webui_nginx_log "mainsail"
|
||||
}
|
||||
|
||||
update_fluidd(){
|
||||
bb4u "fluidd"
|
||||
status_msg "Updating Fluidd ..."
|
||||
fluidd_setup
|
||||
match_nginx_configs
|
||||
symlink_webui_nginx_log "fluidd"
|
||||
}
|
||||
|
||||
update_moonraker(){
|
||||
moonraker_service "stop"
|
||||
do_action_service "stop" "moonraker"
|
||||
bb4u "moonraker"
|
||||
status_msg "Updating Moonraker ..."
|
||||
cd $MOONRAKER_DIR
|
||||
MOONRAKER_OLDREQ_MD5SUM=$(md5sum $MOONRAKER_DIR/scripts/moonraker-requirements.txt | cut -d " " -f1)
|
||||
|
||||
### pull latest files from github
|
||||
git pull && ok_msg "Update successfull!"
|
||||
cd "$MOONRAKER_DIR" && git pull
|
||||
### read PKGLIST and install possible new dependencies
|
||||
install_moonraker_packages
|
||||
### install possible new python dependencies
|
||||
MR_REQ_TXT="$MOONRAKER_DIR/scripts/moonraker-requirements.txt"
|
||||
"$MOONRAKER_ENV"/bin/pip install -r "$MR_REQ_TXT"
|
||||
update_log_paths "moonraker"
|
||||
|
||||
### check for possible new dependencies and install them
|
||||
if [[ $(md5sum $MOONRAKER_DIR/scripts/moonraker-requirements.txt | cut -d " " -f1) != $MOONRAKER_OLDREQ_MD5SUM ]]; then
|
||||
PYTHONDIR="${HOME}/moonraker-env"
|
||||
status_msg "New dependecies detected..."
|
||||
### always rebuild the pythondir from scratch if new dependencies were detected
|
||||
rm -rf ${PYTHONDIR}
|
||||
virtualenv -p /usr/bin/python3 ${PYTHONDIR}
|
||||
ln -s /usr/lib/python3/dist-packages/gpiod* ${PYTHONDIR}/lib/python*/site-packages
|
||||
${PYTHONDIR}/bin/pip install -r $MOONRAKER_DIR/scripts/moonraker-requirements.txt
|
||||
ok_msg "Dependencies have been installed!"
|
||||
fi
|
||||
### required due to https://github.com/Arksine/moonraker/issues/349
|
||||
moonraker_polkit
|
||||
|
||||
ok_msg "Update complete!"
|
||||
moonraker_service "restart"
|
||||
do_action_service "restart" "moonraker"
|
||||
}
|
||||
|
||||
update_klipperscreen(){
|
||||
@@ -155,7 +303,7 @@ update_klipperscreen(){
|
||||
cd $KLIPPERSCREEN_DIR
|
||||
KLIPPERSCREEN_OLDREQ_MD5SUM=$(md5sum $KLIPPERSCREEN_DIR/scripts/KlipperScreen-requirements.txt | cut -d " " -f1)
|
||||
git pull origin master -q && ok_msg "Fetch successfull!"
|
||||
git checkout -f origin/master && ok_msg "Checkout successfull"
|
||||
git checkout -f master && ok_msg "Checkout successfull"
|
||||
#KLIPPERSCREEN_NEWREQ_MD5SUM=$(md5sum $KLIPPERSCREEN_DIR/scripts/KlipperScreen-requirements.txt)
|
||||
if [[ $(md5sum $KLIPPERSCREEN_DIR/scripts/KlipperScreen-requirements.txt | cut -d " " -f1) != $KLIPPERSCREEN_OLDREQ_MD5SUM ]]; then
|
||||
status_msg "New dependecies detected..."
|
||||
@@ -166,3 +314,28 @@ update_klipperscreen(){
|
||||
ok_msg "Update complete!"
|
||||
start_klipperscreen
|
||||
}
|
||||
|
||||
update_pgc_for_klipper(){
|
||||
PGC_DIR="${HOME}/pgcode"
|
||||
status_msg "Updating PrettyGCode for Klipper ..."
|
||||
cd $PGC_DIR && git pull
|
||||
ok_msg "Update complete!"
|
||||
}
|
||||
|
||||
update_MoonrakerTelegramBot(){
|
||||
source_kiauh_ini
|
||||
export klipper_cfg_loc
|
||||
stop_MoonrakerTelegramBot
|
||||
cd $MOONRAKER_TELEGRAM_BOT_DIR
|
||||
git pull
|
||||
./scripts/install.sh
|
||||
ok_msg "Update complete!"
|
||||
start_MoonrakerTelegramBot
|
||||
}
|
||||
|
||||
update_system(){
|
||||
status_msg "Updating System ..."
|
||||
sudo apt-get update --allow-releaseinfo-change && sudo apt-get upgrade -y
|
||||
CONFIRM_MSG="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_msg && clear_msg
|
||||
}
|
||||
@@ -42,13 +42,16 @@ upload_selection(){
|
||||
|
||||
### find all suitable logfiles for klipper
|
||||
logfiles=()
|
||||
if ls /tmp/klippy*.log 2>/dev/null 1>&2; then
|
||||
for kl_log in $(find /tmp/klippy*.log); do
|
||||
klipper_logs="${HOME}/klipper_logs/klippy*.log"
|
||||
moonraker_logs="${HOME}/klipper_logs/moonraker*.log"
|
||||
|
||||
if ls $klipper_logs 2>/dev/null 1>&2; then
|
||||
for kl_log in $(find $klipper_logs); do
|
||||
logfiles+=($kl_log)
|
||||
done
|
||||
fi
|
||||
if ls /tmp/moonraker*.log 2>/dev/null 1>&2; then
|
||||
for mr_log in $(find /tmp/moonraker*.log); do
|
||||
if ls $moonraker_logs 2>/dev/null 1>&2; then
|
||||
for mr_log in $(find $moonraker_logs); do
|
||||
logfiles+=($mr_log)
|
||||
done
|
||||
fi
|
||||
@@ -68,10 +71,10 @@ upload_selection(){
|
||||
printf "| $i) %-50s|\n" "${logfiles[$i]}"
|
||||
i=$((i + 1))
|
||||
done
|
||||
quit_footer
|
||||
back_footer
|
||||
while true; do
|
||||
read -p "${cyan}Please select:${default} " choice
|
||||
if [ $choice = "q" ] || [ $choice = "Q" ]; then
|
||||
if [ $choice = "b" ] || [ $choice = "B" ]; then
|
||||
clear && main_menu && break
|
||||
elif [ $choice -le ${#logfiles[@]} ]; then
|
||||
upload_log "${logfiles[$choice]}"
|
||||
@@ -98,4 +101,4 @@ upload_log(){
|
||||
ERROR_MSG="File not found!" && print_msg && clear_msg
|
||||
upload_selection
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user