mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-14 19:14:27 +05:00
Compare commits
395 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16e6dde998 | ||
|
|
431f58af4b | ||
|
|
c3af82745b | ||
|
|
26eecbc94b | ||
|
|
fa8a9ff7ba | ||
|
|
dc08d8e7e3 | ||
|
|
d0b895a469 | ||
|
|
5aaebc2bec | ||
|
|
538c179671 | ||
|
|
dc6fea8c3b | ||
|
|
82227f8d0b | ||
|
|
31c3f344e5 | ||
|
|
a7b7b362f3 | ||
|
|
5f142da1b6 | ||
|
|
99209f97de | ||
|
|
8a64fe495e | ||
|
|
c3468c04e4 | ||
|
|
2ef3273b74 | ||
|
|
47cf96ef74 | ||
|
|
17524bf49b | ||
|
|
0d29bf9f31 | ||
|
|
6105122467 | ||
|
|
55dad5ffb6 | ||
|
|
53aa86d138 | ||
|
|
a0e53655bd | ||
|
|
69d134d9d1 | ||
|
|
7224040f8a | ||
|
|
1570fd588e | ||
|
|
0eb2d066be | ||
|
|
61d1c46694 | ||
|
|
18e85235c1 | ||
|
|
04f204e4c7 | ||
|
|
f8aa88f480 | ||
|
|
0c4f1a5378 | ||
|
|
4652e5c177 | ||
|
|
a6156ebdf3 | ||
|
|
1c92987b42 | ||
|
|
d01140638a | ||
|
|
254e1b8244 | ||
|
|
19aed15db0 | ||
|
|
b2b19f446b | ||
|
|
8ad7f5d47c | ||
|
|
69eb96d006 | ||
|
|
e233d8435a | ||
|
|
fb52c7e4ab | ||
|
|
bc53de626f | ||
|
|
f10a604f97 | ||
|
|
1527d7a25d | ||
|
|
65062bdfda | ||
|
|
e3d242017d | ||
|
|
c14289a8a6 | ||
|
|
d12554d2b7 | ||
|
|
036fb08132 | ||
|
|
d9e697216f | ||
|
|
d958c1ba2a | ||
|
|
fb1d3a8cd9 | ||
|
|
7eb0fe24f8 | ||
|
|
738269adae | ||
|
|
d098eef08e | ||
|
|
598c106c3a | ||
|
|
8bf20aa059 | ||
|
|
748a700c36 | ||
|
|
51207e2eb9 | ||
|
|
ee252d185a | ||
|
|
cf1e37fb2a | ||
|
|
3d9722f877 | ||
|
|
1ef67fa05c | ||
|
|
db856de8e5 | ||
|
|
4748c15424 | ||
|
|
ab9d73b5b5 | ||
|
|
6c33282d43 | ||
|
|
e71f1b9dfd | ||
|
|
e24afa42ac | ||
|
|
2fa975e3c2 | ||
|
|
feb912da8a | ||
|
|
e5ce642018 | ||
|
|
7a4ccfe4df | ||
|
|
6b2175e439 | ||
|
|
dd2a26e2d0 | ||
|
|
cd1489f0e5 | ||
|
|
d705a043c9 | ||
|
|
c1a21c52b6 | ||
|
|
94762727ae | ||
|
|
9cde005e08 | ||
|
|
86e7f37f7b | ||
|
|
4d2eb49e85 | ||
|
|
715ab5f4e2 | ||
|
|
146586f894 | ||
|
|
bd78fa8ef7 | ||
|
|
b12d344b40 | ||
|
|
9ea29bf995 | ||
|
|
d066999d0b | ||
|
|
1ab681e71a | ||
|
|
f782a32e9c | ||
|
|
7dc1bc6cc8 | ||
|
|
2a29716bb9 | ||
|
|
33a9fef676 | ||
|
|
88afa55268 | ||
|
|
65ec2e5e1a | ||
|
|
08c1807cc7 | ||
|
|
218700b63d | ||
|
|
bb1c5c4900 | ||
|
|
43a724b80e | ||
|
|
08ae57d349 | ||
|
|
61dfab5683 | ||
|
|
8ee277fe2c | ||
|
|
a44ae4c2b9 | ||
|
|
240746e1b6 | ||
|
|
1fd839bc7a | ||
|
|
a6bfb30235 | ||
|
|
7854fe3d95 | ||
|
|
1eda775571 | ||
|
|
06eb86efd7 | ||
|
|
0339f3f4f5 | ||
|
|
3032356f89 | ||
|
|
f1289504bf | ||
|
|
d3b7c923bd | ||
|
|
194b8a54cc | ||
|
|
1b7b8a1cf9 | ||
|
|
e6dde2cf23 | ||
|
|
94926d5985 | ||
|
|
acf8a817d8 | ||
|
|
10558103a5 | ||
|
|
c61e101627 | ||
|
|
ddcaee0838 | ||
|
|
622e8251a3 | ||
|
|
b2556641ac | ||
|
|
93f8e5e265 | ||
|
|
dde5812c6b | ||
|
|
42a5a0b6d8 | ||
|
|
d95b8ac763 | ||
|
|
865177d0fd | ||
|
|
8923620414 | ||
|
|
ecc349e550 | ||
|
|
bc35a82cc8 | ||
|
|
4fe964e886 | ||
|
|
8371a014a0 | ||
|
|
90af76402b | ||
|
|
25b911e867 | ||
|
|
4e9776cac3 | ||
|
|
2e3975374a | ||
|
|
ed9b8d844b | ||
|
|
d3a12f7db7 | ||
|
|
3b74bb0b77 | ||
|
|
4f7ac68af6 | ||
|
|
e22c6be490 | ||
|
|
3fd9f95da3 | ||
|
|
065786fea7 | ||
|
|
e370c54739 | ||
|
|
88fd83638c | ||
|
|
3d065c0f1b | ||
|
|
d98151cfef | ||
|
|
41d2dd80a7 | ||
|
|
7ff1d972b4 | ||
|
|
efe482ea58 | ||
|
|
8ba6aee952 | ||
|
|
9ecf7068f1 | ||
|
|
74a6b04762 | ||
|
|
55382b1ecb | ||
|
|
b48319e24d | ||
|
|
8b03b27902 | ||
|
|
be2734e640 | ||
|
|
7431124d87 | ||
|
|
4ae696857f | ||
|
|
9fc7f4120a | ||
|
|
dc32470a7c | ||
|
|
d91d01ae2c | ||
|
|
62b0f2afd6 | ||
|
|
6ce475e27a | ||
|
|
e6d5a73a79 | ||
|
|
5fd19aef0b | ||
|
|
911d0d37e5 | ||
|
|
cbffa1b31a | ||
|
|
32c176bf2f | ||
|
|
b4fc691da1 | ||
|
|
6129f15386 | ||
|
|
759cc8e196 | ||
|
|
dec1c0e83c | ||
|
|
b20cda1d15 | ||
|
|
2c522e717f | ||
|
|
c06aa0457f | ||
|
|
253f4e1bf9 | ||
|
|
29e3d8b3d2 | ||
|
|
e0b7a75116 | ||
|
|
083ca8b7fd | ||
|
|
4e2c6aa2cc | ||
|
|
a4a85b1045 | ||
|
|
ccf5b003fe | ||
|
|
0027886f4f | ||
|
|
26599d734d | ||
|
|
d58841a269 | ||
|
|
ab6fa29bd2 | ||
|
|
6142c0c18f | ||
|
|
fb14d9c717 | ||
|
|
bc658f38bc | ||
|
|
976d9cb5a9 | ||
|
|
029127bf00 | ||
|
|
9b424c8343 | ||
|
|
3658137a1c | ||
|
|
4e38e85962 | ||
|
|
fe941f4227 | ||
|
|
9a4ca4114c | ||
|
|
1c41abe40f | ||
|
|
3257c845ee | ||
|
|
3d6b4bec95 | ||
|
|
c55a010bcd | ||
|
|
78dcc0a1ad | ||
|
|
2a2bc6b377 | ||
|
|
1159d74748 | ||
|
|
40f34f26ea | ||
|
|
668331e7ea | ||
|
|
d2bdf6b089 | ||
|
|
10f75268ab | ||
|
|
46e6b7d40a | ||
|
|
bd876c744d | ||
|
|
db0a4b4e03 | ||
|
|
efa67b5843 | ||
|
|
d393b0a9e9 | ||
|
|
85f0c26215 | ||
|
|
35dcf10c9a | ||
|
|
64b6d6b26a | ||
|
|
a2201ab3f7 | ||
|
|
63a2f95cc0 | ||
|
|
043f09aeeb | ||
|
|
1fa1636f75 | ||
|
|
3770f0fd7a | ||
|
|
ecd9e7f489 | ||
|
|
125eea921f | ||
|
|
2e9be1adc5 | ||
|
|
3e35be5681 | ||
|
|
d9d3006be4 | ||
|
|
6abab9fb06 | ||
|
|
ef4b6b092f | ||
|
|
b2a8c52995 | ||
|
|
9bfce238d7 | ||
|
|
d0ac497a60 | ||
|
|
4c44b8714a | ||
|
|
da1820a7da | ||
|
|
b576491320 | ||
|
|
0c9e967ebe | ||
|
|
4d53a92c83 | ||
|
|
0b474514b1 | ||
|
|
9b7bde7da0 | ||
|
|
fc61f17297 | ||
|
|
3a4fbdbd61 | ||
|
|
1ec269969b | ||
|
|
fa669a8690 | ||
|
|
599b85c47d | ||
|
|
83e9618a75 | ||
|
|
c98584dde8 | ||
|
|
53f4b9a9f5 | ||
|
|
a23fb6b79e | ||
|
|
262e489d1a | ||
|
|
9e13c2d0ea | ||
|
|
34162c4b65 | ||
|
|
7384ed8a0e | ||
|
|
8899275022 | ||
|
|
03c3c3d50f | ||
|
|
45c8b5a33f | ||
|
|
4a60b9c8ec | ||
|
|
d964523558 | ||
|
|
49a28cff22 | ||
|
|
8a5e358a73 | ||
|
|
9ec63be673 | ||
|
|
bae0c1f0fd | ||
|
|
fc777ccb96 | ||
|
|
96be30343d | ||
|
|
24a59cffb7 | ||
|
|
dba14aadb6 | ||
|
|
d51062c5ae | ||
|
|
1b4baad654 | ||
|
|
5a25bd3686 | ||
|
|
f08d6ecdc2 | ||
|
|
be56439587 | ||
|
|
dd16a2503b | ||
|
|
613e0d779f | ||
|
|
612a4225be | ||
|
|
35ecf3ae65 | ||
|
|
e32cc9d3cb | ||
|
|
9a3e41716e | ||
|
|
09e4c7bea5 | ||
|
|
5392e2a9ab | ||
|
|
41789fd158 | ||
|
|
2532fc7e4c | ||
|
|
63f65a02b4 | ||
|
|
f3a139f317 | ||
|
|
68cb5427b6 | ||
|
|
2be2ce12c6 | ||
|
|
eb6b2465c7 | ||
|
|
cc1c804730 | ||
|
|
7dda59649b | ||
|
|
60dc9d623e | ||
|
|
92b4bc41ac | ||
|
|
db5b906e5b | ||
|
|
d78670e0ab | ||
|
|
716b21a629 | ||
|
|
1a037c687b | ||
|
|
0dc5edfd7b | ||
|
|
c82e21419c | ||
|
|
7b220c6546 | ||
|
|
15c6296e2c | ||
|
|
e00d2951a9 | ||
|
|
68f7c98985 | ||
|
|
82408fee2e | ||
|
|
3076d400a0 | ||
|
|
c91718cfc3 | ||
|
|
9c20ad7d99 | ||
|
|
7614d596ab | ||
|
|
5bcd9a73b5 | ||
|
|
a06b06eb46 | ||
|
|
66e9069687 | ||
|
|
a782fecd25 | ||
|
|
5dda935f58 | ||
|
|
8cfe4a81ef | ||
|
|
2e4da7f220 | ||
|
|
be6a63f95b | ||
|
|
9fcbcfcba8 | ||
|
|
3ec26ba319 | ||
|
|
188239d7ea | ||
|
|
b850aa4d96 | ||
|
|
2e5e06c1ff | ||
|
|
96c094d36b | ||
|
|
3be01528d9 | ||
|
|
6b77070baa | ||
|
|
4e2743d587 | ||
|
|
1d9cbecbb5 | ||
|
|
bd90677cfa | ||
|
|
e75df6d46c | ||
|
|
b6c07fc357 | ||
|
|
fce1eb5a8c | ||
|
|
82d76b18f0 | ||
|
|
dc4cc59038 | ||
|
|
6f30208863 | ||
|
|
303c96cbb1 | ||
|
|
da57fe7ccc | ||
|
|
e5e135c68b | ||
|
|
22888f5756 | ||
|
|
d84a740f0d | ||
|
|
64a7dec09d | ||
|
|
a76cab0fe6 | ||
|
|
e0b9a1ef3b | ||
|
|
6c4e6b057e | ||
|
|
37b23129c0 | ||
|
|
5651ce2d63 | ||
|
|
0a0a9f2f93 | ||
|
|
876b316af4 | ||
|
|
f51ba88f64 | ||
|
|
02c6a46a78 | ||
|
|
84fc849caf | ||
|
|
87ed15a117 | ||
|
|
2bbf006475 | ||
|
|
2596e8d08a | ||
|
|
80344ec41c | ||
|
|
a2042ec378 | ||
|
|
734aed1f7b | ||
|
|
108b5c7b0c | ||
|
|
3091ce55ad | ||
|
|
e6b6dbfa74 | ||
|
|
e22105a728 | ||
|
|
092f2793b3 | ||
|
|
3ab4244709 | ||
|
|
7b48061281 | ||
|
|
2b6dbaab76 | ||
|
|
4cb2ba51bd | ||
|
|
8ffdf12a4a | ||
|
|
28d7a4aeda | ||
|
|
fed882298e | ||
|
|
e4cfad4162 | ||
|
|
b4496603ed | ||
|
|
1cc94d4874 | ||
|
|
d19c4d33cb | ||
|
|
fd71b0ee62 | ||
|
|
49d0a65bcd | ||
|
|
ba53517f09 | ||
|
|
1be6cd0a3d | ||
|
|
8c0e231ade | ||
|
|
1551920fe3 | ||
|
|
a5155c50cc | ||
|
|
57d86b9ef4 | ||
|
|
182164af9c | ||
|
|
45fe688f87 | ||
|
|
fe27d054f8 | ||
|
|
21aa2f45e5 | ||
|
|
eea1f5540e | ||
|
|
2771184e48 | ||
|
|
2b6abac0c9 | ||
|
|
85a9186c78 | ||
|
|
7106994bf6 | ||
|
|
c57acefc16 | ||
|
|
e2bb6cd849 | ||
|
|
f1d9b9c21b | ||
|
|
6cf253eb8c | ||
|
|
3f7b454710 | ||
|
|
50eb2621d7 | ||
|
|
bf70157a64 |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
kiauh.ini
|
||||
150
README.md
150
README.md
@@ -1,12 +1,146 @@
|
||||
# KIAUH
|
||||
# **KIAUH - Klipper Installation And Update Helper**
|
||||
|
||||
## Klipper Installation And Update Helper
|
||||

|
||||
|
||||
This script was actually created for my personal use only but i then decided to make the script accessible for everyone.
|
||||
It is meant to help guiding you through a complete fresh install of Klipper and optionally the DWC2 web UI + DWC2-for-Klipper.
|
||||
There are also functions for updating your current installations or removing them from your system.
|
||||
---
|
||||
|
||||
## First things first: When you decide to use this script, you use it at your own risk!
|
||||
## **📋 Please see the [Changelog](docs/changelog.md) for possible important information !**
|
||||
|
||||
# THIS VERSION IS WORK IN PROGRESS!!!
|
||||
# BUGS MAY BE STILL PRESENT!!!
|
||||
---
|
||||
|
||||
## **📢 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** 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.
|
||||
- **Backup** of all the listed installations above.
|
||||
|
||||
### **Also possible:**
|
||||
|
||||
- Build the Klipper Firmware
|
||||
- Flash the MCU
|
||||
- Read ID of the currently connected MCU
|
||||
- and more ...
|
||||
|
||||
### **For a list of additional features please see: [Feature List](docs/features.md)**
|
||||
|
||||
---
|
||||
|
||||
## **📝 Notes:**
|
||||
|
||||
- Tested **only** on Raspberry Pi OS Lite (Debian Buster)
|
||||
- ( Although similar Debian based distributions might also work... )
|
||||
- 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).
|
||||
|
||||
For more information or instructions to the various components KIAUH can install, please check out the corresponding repositories listed below:
|
||||
|
||||
---
|
||||
|
||||
### **⛵Klipper** by [KevinOConnor](https://github.com/KevinOConnor) :
|
||||
|
||||
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 🙂
|
||||
|
||||
97
docs/changelog.md
Normal file
97
docs/changelog.md
Normal file
@@ -0,0 +1,97 @@
|
||||
## Changelog
|
||||
|
||||
This document covers possible important changes to KIAUH.
|
||||
|
||||
### 2021-01-31
|
||||
|
||||
* **This is a big one... KIAUH v3.0 is out.**\
|
||||
With this update you can now install multiple instances of Klipper, Moonraker, Duet Web Control or Octoprint on the same Pi. This was quite a big rework of the whole script. So bugs can appear but with the help of some testers, i think there shouldn't be any critical ones anymore. In this regards thanks to @lixxbox and @zellneralex for testing.
|
||||
|
||||
* Important changes to how installations are set up now: All components get installed as systemd services. Installation via init.d was dropped completely! This shouldn't affect you at all, since the common linux distributions like RaspberryPi OS or custom distributions like MainsailOS, FluiddPi or OctoPi support both ways of installing services. I just wanted to mention it here.
|
||||
|
||||
* Now with KIAUH v3.0 and multi-instance installation capabilities, there are some things to point out. You will now need to tell KIAUH where your printers configurations are located when installing Klipper for the first time. Even though it is not recommended, you can change this location with the help of KIAUH and rewrite Klipper and Moonraker to use the new location.
|
||||
|
||||
* When setting up a multi-instance system, the folder structure will only change slightly. The goal was to keep it as compatible as possible with the custom distributions like mainsailOS and FluiddPi. This should help converting a single-instance setup of mainsailOS/FluiddPi to a multi-instance setup in no time, but keeping single-instance backwards compatibility if needed at a later point in time.
|
||||
|
||||
* The folder structure is as follows when setting up multi-instances:\
|
||||
Each printer instance will get its own folder within your configuration location. The decision to this specific structure was made to make it as painless and easy as possible to convert to a multi-instance setup.
|
||||
Here is an example:
|
||||
```shell
|
||||
/home/<username>
|
||||
└── klipper_config
|
||||
├── printer_1
|
||||
│ ├── printer.cfg
|
||||
│ └── moonraker.conf
|
||||
├── printer_2
|
||||
│ ├── printer.cfg
|
||||
│ └── moonraker.conf
|
||||
└── printer_n
|
||||
├── printer.cfg
|
||||
└── moonraker.conf
|
||||
```
|
||||
* Also when setting up multi-instances of each service, the name of each service slightly changes.
|
||||
Each service gets its corresponding instance added to the service filename.
|
||||
|
||||
**This only applies to multi-instances! Single instance installations with KIAUH will keep their original names!**
|
||||
|
||||
Corresponding to the filetree example from above that would mean:
|
||||
```
|
||||
Klipper services:
|
||||
--> klipper-1.service
|
||||
--> klipper-2.service
|
||||
--> klipper-n.service
|
||||
|
||||
Moonraker services:
|
||||
--> moonraker-1.service
|
||||
--> moonraker-2.service
|
||||
--> moonraker-n.service
|
||||
```
|
||||
* The same service file rules from above apply to DWC and OctoPrint even though only Klipper and Moonraker are shown in this example.
|
||||
|
||||
* You can start, stop and restart all Klipper, Moonraker, DWC and OctoPrint instances from the KIAUH main menu. For doing this, just type "stop klipper", "start moonraker", "restart octoprint" and so on.
|
||||
|
||||
* KIAUH v3.0 relocated its ini-file. It is now a hidden file in the users home-directory calles `.kiauh.ini`. This has the benefit of keeping all values in that file between possible re-installations of KIAUH. Otherwise that file would be lost.
|
||||
|
||||
* The option of adding more trusted clients to the moonraker.conf file was dropped. Since you can edit this file right inside of Mainsail or Fluidd, only some basic entries are made which get you running.
|
||||
|
||||
* I bet i have missed mentioning other stuff as well because it took me quite some time to re-write many functions. So i just hope you like the new version 😄
|
||||
|
||||
### 2020-11-28
|
||||
|
||||
* KIAUH now supports the installation, update and removal of [KlipperScreen](https://github.com/jordanruthe/KlipperScreen). This feature was was provided by [jordanruthe](https://github.com/jordanruthe)! Thank you!
|
||||
|
||||
### 2020-11-18
|
||||
|
||||
* Some changes to Fluidd caused a little rework on how KIAUH will install/update Fluidd from now on. Please see the [fluidd v1.0.0-rc0 release notes](https://github.com/cadriel/fluidd/releases/tag/v1.0.0-rc.0) for further information about what modifications to the moonraker.conf file exactly had to be done. In a nutshell, KIAUH will now always patch the required entries to the moonraker.conf if not already there.
|
||||
|
||||
### 2020-10-30:
|
||||
|
||||
* The user can now choose to install Klipper as a systemd service.
|
||||
|
||||
* The Shell Command extension and `shell_command.py` got renamed to G-Code Shell Command extension and `gcode_shell_command.py`. In case the [pending PR](https://github.com/KevinOConnor/klipper/pull/2173) will be merged in the future, this was an early attempt to dodge possible incompatibilities. The [G-Code Shell Command docs](gcode_shell_command.md) has been updated accordingly.
|
||||
|
||||
* The way how KIAUH interacts and writes to the users printer.cfg got changed. Usually KIAUH wrote everything directly into the printer.cfg. The way it will work from now on is, that a new file called `kiauh.cfg` will be created if there is something that needs to be written to the printer.cfg and everything gets written to `kiauh.cfg` instead. The only thing which then gets written to the users printer.cfg is `[include kiauh.cfg]`. This line will be located at the very top of the existing printer.cfg with a little comment as a note. The user can then decide to either keep the `kiauh.cfg` or take its content, places it into the printer.cfg directly and remove the `[include kiauh.cfg]`.
|
||||
|
||||
* The `mainsail_macros.cfg` got renamed to `webui_macros.cfg`. Since Mainsail and Fluidd both use the same kind of pause, cancel and resume macros, a more generic name was chosen for the file containing the example macros one can choose to install when installing those webinterfaces.
|
||||
|
||||
### 2020-10-10:
|
||||
|
||||
* Support for changing the Klipper branch to the moonraker-dev branch from @Arksine has been dropped. Support for Moonraker has been merged into Klipper mainline a long time ago.
|
||||
|
||||
* A new function is available from the main menu. You can now upload your log files to http://paste.c-net.org/ to share them for debugging purposes.
|
||||
|
||||
### 2020-10-06:
|
||||
|
||||
* Fluidd, a new Klipper interface got added to the list of available installers. At the same time some installation routines have changed or have seen some rework. Changes were made to the installation of NGINX configurations. A method was introduced to change the listen port of a webinterface configuration if there is already another webinterface listening on the default port (80).
|
||||
|
||||
* At the moment, the Moonraker installer no longer asks you whether you want to install a web interface too. For now you therefore have to install them with their respective installers. Please report any bugs or issues you encounter.
|
||||
|
||||
### 2020-09-17:
|
||||
|
||||
* The dev-2.0 branch will be abandoned as of today. If you did a checkout to that branch in the past, you have to checkout back to master to receive updates.
|
||||
|
||||
### 2020-09-12:
|
||||
|
||||
* The old [dwc2-for-klipper](https://github.com/Stephan3/dwc2-for-klipper) won't be supported anymore!\
|
||||
The is a new, fully rewritten project available: [dwc2-for-klipper-socket](https://github.com/Stephan3/dwc2-for-klipper-socket).\
|
||||
The installer of this script also got rewritten to make use of that new project. You will not be able to install or remove the old [dwc2-for-klipper](https://github.com/Stephan3/dwc2-for-klipper) with KIAUH anymore if you updated KIAUH to the newest version.
|
||||
28
docs/features.md
Normal file
28
docs/features.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Feature List:
|
||||
|
||||
- **Automatic dependency check:**\
|
||||
If packages are missing but needed for the asked task, the script will automatically install them
|
||||
- **Switch between different Klipper Forks:**\
|
||||
[origin/master](https://github.com/KevinOConnor/klipper/tree/master) or [scurve-shaping](https://github.com/dmbutyugin/klipper/tree/scurve-shaping) or [scurve-smoothing](https://github.com/dmbutyugin/klipper/tree/scurve-smoothing)\
|
||||
The update function of the script will always update the currently selected/active fork!
|
||||
- **Toggle auto-create backups before updating:**\
|
||||
When enabled, a backup of the installation you want to update is made prior updating
|
||||
- **Rollback:**\
|
||||
When updating Klipper, KIAUH saves the current commit hash to a local ini-file. In case of an unsuccesfull update you can use this function to quickly revert back to the commit with the hash you updated from.
|
||||
- **Preconfigure OctoPrint:**\
|
||||
When installing OctoPrint, a config is created which preconfigures your installation to be used with Klipper.\
|
||||
That means:
|
||||
- adding the restart/shutdown commands for OctoPrint
|
||||
- adding the serial port `/tmp/printer`
|
||||
- set the behavior to "Cancel any ongoing prints but stay connected to the printer"
|
||||
- **Enable/Disable OctoPrint Service:**\
|
||||
Usefull when using DWC2/Mainsail/Fluidd and OctoPrint at the same time to prevent them interfering with each other
|
||||
|
||||
- **Installing a G-Code Shell Command extension:**\
|
||||
For further information about that extension please see the [G-Code Shell Command Extension Doc](gcode_shell_command.md)
|
||||
|
||||
- **Uploading logfiles:**\
|
||||
You can directly upload logfiles like klippy.log, moonraker.log and dwc2.log from the KIAUH main menu for providing them for troubleshooting purposes.
|
||||
|
||||
|
||||
to be continued...
|
||||
46
docs/gcode_shell_command.md
Normal file
46
docs/gcode_shell_command.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# G-Code Shell Command Extension
|
||||
|
||||
### Creator of this extension is [Arksine](https://github.com/Arksine).
|
||||
|
||||
This is a brief explanation of how to use the shell command extension for Klipper, which you can install with KIAUH.
|
||||
|
||||
After installing the extension you can execute linux commands or even scripts from within Klipper with custom commands defined in your printer.cfg.
|
||||
|
||||
#### How to configure a shell command:
|
||||
|
||||
```shell
|
||||
# Runs a linux command or script from within klipper. Note that sudo commands
|
||||
# that require password authentication are disallowed. All executable scripts
|
||||
# should include a shebang.
|
||||
# [gcode_shell_command my_shell_cmd]
|
||||
#command:
|
||||
# The linux shell command/script to be executed. This parameter must be
|
||||
# provided
|
||||
#timeout: 2.
|
||||
# The timeout in seconds until the command is forcably terminated. Default
|
||||
# is 2 seconds.
|
||||
#verbose: True
|
||||
# If enabled, the command's output will be forwarded to the terminal. Its
|
||||
# recommended to set this to false for commands that my run in quick
|
||||
# succession. Default is True.
|
||||
```
|
||||
|
||||
Once you have set up a shell command with the given parameters from above in your printer.cfg you can run the command as follows:
|
||||
`RUN_SHELL_COMMAND CMD=name`
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
[gcode_shell_command hello_world]
|
||||
command: echo hello world
|
||||
timeout: 2.
|
||||
verbose: True
|
||||
```
|
||||
|
||||
Execute with:
|
||||
`RUN_SHELL_COMMAND CMD=hello_world`
|
||||
|
||||
## Warning
|
||||
|
||||
This extension may have a high potential for abuse if not used carefully! Also, depending on the command you execute, high system loads may occur and can cause system instabilities.
|
||||
Use this extension at your own risk and only if you know what you are doing!
|
||||
422
kiauh.sh
Normal file → Executable file
422
kiauh.sh
Normal file → Executable file
@@ -2,13 +2,56 @@
|
||||
clear
|
||||
set -e
|
||||
|
||||
### set some variables
|
||||
ERROR_MSG=""
|
||||
green="\e[92m"
|
||||
yellow="\e[93m"
|
||||
red="\e[91m"
|
||||
cyan="\e[96m"
|
||||
default="\e[39m"
|
||||
### set color variables
|
||||
green=$(echo -en "\e[92m")
|
||||
yellow=$(echo -en "\e[93m")
|
||||
red=$(echo -en "\e[91m")
|
||||
cyan=$(echo -en "\e[96m")
|
||||
default=$(echo -en "\e[39m")
|
||||
|
||||
### sourcing all additional scripts
|
||||
SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"
|
||||
for script in "${SRCDIR}/kiauh/scripts/"*.sh; do . $script; done
|
||||
for script in "${SRCDIR}/kiauh/scripts/ui/"*.sh; do . $script; done
|
||||
|
||||
### set important directories
|
||||
#klipper
|
||||
KLIPPER_DIR=${HOME}/klipper
|
||||
KLIPPY_ENV=${HOME}/klippy-env
|
||||
#nginx
|
||||
NGINX_SA=/etc/nginx/sites-available
|
||||
NGINX_SE=/etc/nginx/sites-enabled
|
||||
NGINX_CONFD=/etc/nginx/conf.d
|
||||
#moonraker
|
||||
MOONRAKER_DIR=${HOME}/moonraker
|
||||
MOONRAKER_ENV=${HOME}/moonraker-env
|
||||
#mainsail
|
||||
MAINSAIL_DIR=${HOME}/mainsail
|
||||
#fluidd
|
||||
FLUIDD_DIR=${HOME}/fluidd
|
||||
#dwc2
|
||||
DWC2FK_DIR=${HOME}/dwc2-for-klipper-socket
|
||||
DWC_ENV_DIR=${HOME}/dwc-env
|
||||
DWC2_DIR=${HOME}/duetwebcontrol
|
||||
#octoprint
|
||||
OCTOPRINT_DIR=${HOME}/OctoPrint
|
||||
#KlipperScreen
|
||||
KLIPPERSCREEN_DIR=${HOME}/KlipperScreen
|
||||
KLIPPERSCREEN_ENV_DIR=${HOME}/.KlipperScreen-env
|
||||
#misc
|
||||
INI_FILE=${HOME}/.kiauh.ini
|
||||
BACKUP_DIR=${HOME}/kiauh-backups
|
||||
|
||||
### set github repos
|
||||
KLIPPER_REPO=https://github.com/KevinOConnor/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
|
||||
#branches
|
||||
BRANCH_SCURVE_SMOOTHING=dmbutyugin/scurve-smoothing
|
||||
BRANCH_SCURVE_SHAPING=dmbutyugin/scurve-shaping
|
||||
|
||||
### set some messages
|
||||
warn_msg(){
|
||||
@@ -24,364 +67,35 @@ title_msg(){
|
||||
echo -e "${cyan}$1${default}"
|
||||
}
|
||||
get_date(){
|
||||
current_date=`date +"%Y-%m-%d_%H%M%S"`
|
||||
current_date=$(date +"%y%m%d-%H%M")
|
||||
}
|
||||
print_unkown_cmd(){
|
||||
ERROR_MSG="Invalid command!"
|
||||
}
|
||||
|
||||
### sourcing all additional scripts
|
||||
for script in ${HOME}/kiauh/scripts/*; do . $script; done
|
||||
|
||||
### set important directories
|
||||
#klipper
|
||||
KLIPPER_DIR=${HOME}/klipper
|
||||
KLIPPY_ENV_DIR=${HOME}/klippy-env
|
||||
KLIPPER_SERVICE1=/etc/init.d/klipper
|
||||
KLIPPER_SERVICE2=/etc/default/klipper
|
||||
#dwc2
|
||||
DWC2FK_DIR=${HOME}/dwc2-for-klipper
|
||||
DWC2_DIR=${HOME}/sdcard/dwc2
|
||||
WEB_DWC2=${HOME}/klipper/klippy/extras/web_dwc2.py
|
||||
TORNADO_DIR1=${HOME}/klippy-env/lib/python2.7/site-packages/tornado
|
||||
TORNADO_DIR2=${HOME}/klippy-env/lib/python2.7/site-packages/tornado-5.1.1.dist-info
|
||||
#mainsail/moonraker
|
||||
MAINSAIL_DIR=${HOME}/mainsail
|
||||
MAINSAIL_SERVICE1=/etc/init.d/moonraker
|
||||
MAINSAIL_SERVICE2=/etc/default/moonraker
|
||||
#misc
|
||||
BACKUP_DIR=${HOME}/kiauh-backups
|
||||
PRINTER_CFG=${HOME}/printer.cfg
|
||||
|
||||
### set github repos
|
||||
KLIPPER_REPO=https://github.com/KevinOConnor/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.git
|
||||
#branches
|
||||
BRANCH_MOONRAKER=Arksine/work-web_server-20200131
|
||||
BRANCH_DEV_MOONRAKER=Arksine/dev-moonraker-testing
|
||||
BRANCH_SCURVE_SMOOTHING=dmbutyugin/scurve-smoothing
|
||||
BRANCH_SCURVE_SHAPING=dmbutyugin/scurve-shaping
|
||||
|
||||
print_error_msg(){
|
||||
print_msg(){
|
||||
if [[ "$ERROR_MSG" != "" ]]; then
|
||||
echo -e "${red}"
|
||||
echo -e "#########################################################"
|
||||
echo -e "$ERROR_MSG "
|
||||
echo -e " $ERROR_MSG "
|
||||
echo -e "#########################################################"
|
||||
echo -e "${default}"
|
||||
fi
|
||||
if [ "$CONFIRM_MSG" != "" ]; then
|
||||
echo -e "${green}"
|
||||
echo -e "#########################################################"
|
||||
echo -e " $CONFIRM_MSG "
|
||||
echo -e "#########################################################"
|
||||
echo -e "${default}"
|
||||
fi
|
||||
}
|
||||
|
||||
main_menu(){
|
||||
print_header
|
||||
print_error_msg && ERROR_MSG=""
|
||||
#check install status
|
||||
klipper_status
|
||||
dwc2_status
|
||||
mainsail_status
|
||||
print_branch
|
||||
main_ui
|
||||
while true; do
|
||||
read -p "Perform action: " action; echo
|
||||
case "$action" in
|
||||
0)
|
||||
clear
|
||||
print_header
|
||||
ERROR_MSG=" Sorry this function is not implemented yet!"
|
||||
print_error_msg && ERROR_MSG=""
|
||||
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;;
|
||||
Q|q)
|
||||
exit -1;;
|
||||
*)
|
||||
clear
|
||||
print_header
|
||||
ERROR_MSG=" Unknown command '$action'"
|
||||
print_error_msg && ERROR_MSG=""
|
||||
main_ui;;
|
||||
esac
|
||||
done
|
||||
clear; main_menu
|
||||
}
|
||||
|
||||
install_menu(){
|
||||
print_header
|
||||
install_ui
|
||||
while true; do
|
||||
read -p "Perform action: " action; echo
|
||||
case "$action" in
|
||||
1)
|
||||
clear
|
||||
print_header
|
||||
install_klipper
|
||||
print_error_msg && ERROR_MSG=""
|
||||
install_ui;;
|
||||
2)
|
||||
clear
|
||||
print_header
|
||||
dwc2_install_routine
|
||||
print_error_msg && ERROR_MSG=""
|
||||
install_ui;;
|
||||
3)
|
||||
clear
|
||||
print_header
|
||||
mainsail_install_routine
|
||||
print_error_msg && ERROR_MSG=""
|
||||
install_ui;;
|
||||
Q|q)
|
||||
clear; main_menu; break;;
|
||||
*)
|
||||
clear
|
||||
print_header
|
||||
ERROR_MSG=" Unknown command '$action'"
|
||||
print_error_msg && ERROR_MSG=""
|
||||
install_ui;;
|
||||
esac
|
||||
done
|
||||
install_menu
|
||||
}
|
||||
|
||||
update_menu(){
|
||||
print_header
|
||||
read_bb4u_stat
|
||||
#compare versions
|
||||
ui_print_versions
|
||||
update_ui
|
||||
while true; do
|
||||
read -p "Perform action: " action; echo
|
||||
case "$action" in
|
||||
0)
|
||||
clear
|
||||
print_header
|
||||
toggle_backups
|
||||
print_error_msg && ERROR_MSG=""
|
||||
update_ui;;
|
||||
1)
|
||||
clear
|
||||
print_header
|
||||
update_klipper && ui_print_versions
|
||||
print_error_msg && ERROR_MSG=""
|
||||
update_ui;;
|
||||
2)
|
||||
clear
|
||||
print_header
|
||||
update_dwc2fk && ui_print_versions
|
||||
print_error_msg && ERROR_MSG=""
|
||||
update_ui;;
|
||||
3)
|
||||
clear
|
||||
print_header
|
||||
update_dwc2 && ui_print_versions
|
||||
print_error_msg && ERROR_MSG=""
|
||||
update_ui;;
|
||||
4)
|
||||
clear
|
||||
print_header
|
||||
update_mainsail && ui_print_versions
|
||||
print_error_msg && ERROR_MSG=""
|
||||
update_ui;;
|
||||
Q|q)
|
||||
clear; main_menu; break;;
|
||||
*)
|
||||
clear
|
||||
print_header
|
||||
ERROR_MSG=" Unknown command '$action'"
|
||||
print_error_msg && ERROR_MSG=""
|
||||
ui_print_versions
|
||||
update_ui;;
|
||||
esac
|
||||
done
|
||||
update_menu
|
||||
}
|
||||
|
||||
remove_menu(){
|
||||
print_header
|
||||
remove_ui
|
||||
while true; do
|
||||
read -p "Perform action: " action; echo
|
||||
case "$action" in
|
||||
1)
|
||||
clear
|
||||
print_header
|
||||
remove_klipper
|
||||
print_error_msg && ERROR_MSG=""
|
||||
remove_ui;;
|
||||
2)
|
||||
clear
|
||||
print_header
|
||||
remove_dwc2
|
||||
print_error_msg && ERROR_MSG=""
|
||||
remove_ui;;
|
||||
3)
|
||||
clear
|
||||
print_header
|
||||
remove_mainsail
|
||||
print_error_msg && ERROR_MSG=""
|
||||
remove_ui;;
|
||||
Q|q)
|
||||
clear; main_menu; break;;
|
||||
*)
|
||||
clear
|
||||
print_header
|
||||
ERROR_MSG=" Unknown command '$action'"
|
||||
print_error_msg && ERROR_MSG=""
|
||||
remove_ui;;
|
||||
esac
|
||||
done
|
||||
remove_menu
|
||||
}
|
||||
|
||||
advanced_menu(){
|
||||
print_header
|
||||
print_error_msg && ERROR_MSG=""
|
||||
advanced_ui
|
||||
while true; do
|
||||
read -p "Perform action: " action; echo
|
||||
case "$action" in
|
||||
1)
|
||||
clear
|
||||
switch_menu
|
||||
print_error_msg && ERROR_MSG=""
|
||||
advanced_ui;;
|
||||
2)
|
||||
clear
|
||||
print_header
|
||||
build_fw
|
||||
print_error_msg && ERROR_MSG=""
|
||||
advanced_ui;;
|
||||
3)
|
||||
clear
|
||||
print_header
|
||||
flash_routine
|
||||
print_error_msg && ERROR_MSG=""
|
||||
advanced_ui;;
|
||||
4)
|
||||
clear
|
||||
print_header
|
||||
get_usb_id
|
||||
print_error_msg && ERROR_MSG=""
|
||||
advanced_ui;;
|
||||
5)
|
||||
clear
|
||||
print_header
|
||||
get_usb_id && write_printer_id
|
||||
print_error_msg && ERROR_MSG=""
|
||||
advanced_ui;;
|
||||
6)
|
||||
clear
|
||||
print_header
|
||||
create_dwc2fk_cfg
|
||||
print_error_msg && ERROR_MSG=""
|
||||
advanced_ui;;
|
||||
Q|q)
|
||||
clear; main_menu; break;;
|
||||
*)
|
||||
clear
|
||||
print_header
|
||||
ERROR_MSG=" Unknown command '$action'"
|
||||
print_error_msg && ERROR_MSG=""
|
||||
advanced_ui;;
|
||||
esac
|
||||
done
|
||||
advanced_menu
|
||||
}
|
||||
|
||||
switch_menu(){
|
||||
print_header
|
||||
if [ -d $KLIPPER_DIR ]; then
|
||||
read_branch
|
||||
print_error_msg && ERROR_MSG=""
|
||||
switch_ui
|
||||
while true; do
|
||||
read -p "Perform action: " action; echo
|
||||
case "$action" in
|
||||
1)
|
||||
clear
|
||||
print_header
|
||||
switch_to_origin
|
||||
read_branch
|
||||
print_error_msg && ERROR_MSG=""
|
||||
switch_ui;;
|
||||
2)
|
||||
clear
|
||||
print_header
|
||||
switch_to_scurve_shaping
|
||||
read_branch
|
||||
print_error_msg && ERROR_MSG=""
|
||||
switch_ui;;
|
||||
3)
|
||||
clear
|
||||
print_header
|
||||
switch_to_scurve_smoothing
|
||||
read_branch
|
||||
print_error_msg && ERROR_MSG=""
|
||||
switch_ui;;
|
||||
4)
|
||||
clear
|
||||
print_header
|
||||
switch_to_moonraker
|
||||
read_branch
|
||||
print_error_msg && ERROR_MSG=""
|
||||
switch_ui;;
|
||||
5)
|
||||
clear
|
||||
print_header
|
||||
switch_to_dev_moonraker
|
||||
read_branch
|
||||
print_error_msg && ERROR_MSG=""
|
||||
switch_ui;;
|
||||
Q|q)
|
||||
clear; advanced_menu; break;;
|
||||
esac
|
||||
done
|
||||
else
|
||||
ERROR_MSG=" No klipper directory found! Download klipper first!"
|
||||
fi
|
||||
}
|
||||
|
||||
backup_menu(){
|
||||
print_header
|
||||
print_error_msg && ERROR_MSG=""
|
||||
backup_ui
|
||||
while true; do
|
||||
read -p "Perform action: " action; echo
|
||||
case "$action" in
|
||||
1)
|
||||
clear
|
||||
print_header
|
||||
#function goes here
|
||||
print_error_msg && ERROR_MSG=""
|
||||
backup_ui;;
|
||||
Q|q)
|
||||
clear; main_menu; break;;
|
||||
*)
|
||||
clear
|
||||
print_header
|
||||
ERROR_MSG=" Unknown command '$action'"
|
||||
print_error_msg && ERROR_MSG=""
|
||||
backup_ui;;
|
||||
esac
|
||||
done
|
||||
backup_menu
|
||||
clear_msg(){
|
||||
unset CONFIRM_MSG
|
||||
unset ERROR_MSG
|
||||
}
|
||||
|
||||
check_euid
|
||||
init_ini
|
||||
kiauh_status
|
||||
main_menu
|
||||
64
resources/autocommit.sh
Executable file
64
resources/autocommit.sh
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
|
||||
#####################################################################
|
||||
### Please set the paths accordingly. In case you don't have all ###
|
||||
### the listed folders, just keep that line commented out. ###
|
||||
#####################################################################
|
||||
### Path to your config folder you want to backup
|
||||
#config_folder=~/klipper_config
|
||||
|
||||
### Path to your Klipper folder, by default that is '~/klipper'
|
||||
#klipper_folder=~/klipper
|
||||
|
||||
### Path to your Moonraker folder, by default that is '~/moonraker'
|
||||
#moonraker_folder=~/moonraker
|
||||
|
||||
### Path to your Mainsail folder, by default that is '~/mainsail'
|
||||
#mainsail_folder=~/mainsail
|
||||
|
||||
### Path to your Fluidd folder, by default that is '~/fluidd'
|
||||
#fluidd_folder=~/fluidd
|
||||
|
||||
#####################################################################
|
||||
#####################################################################
|
||||
|
||||
|
||||
#####################################################################
|
||||
################ !!! DO NOT EDIT BELOW THIS LINE !!! ################
|
||||
#####################################################################
|
||||
grab_version(){
|
||||
if [ ! -z "$klipper_folder" ]; then
|
||||
cd "$klipper_folder"
|
||||
klipper_commit=$(git rev-parse --short=7 HEAD)
|
||||
m1="Klipper on commit: $klipper_commit"
|
||||
cd ..
|
||||
fi
|
||||
if [ ! -z "$moonraker_folder" ]; then
|
||||
cd "$moonraker_folder"
|
||||
moonraker_commit=$(git rev-parse --short=7 HEAD)
|
||||
m2="Moonraker on commit: $moonraker_commit"
|
||||
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)
|
||||
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)
|
||||
m4="Fluidd version: $fluidd_ver"
|
||||
fi
|
||||
}
|
||||
|
||||
push_config(){
|
||||
cd $config_folder
|
||||
git pull
|
||||
git add .
|
||||
current_date=$(date +"%Y-%m-%d %T")
|
||||
git commit -m "Autocommit from $current_date" -m "$m1" -m "$m2" -m "$m3" -m "$m4"
|
||||
git push
|
||||
}
|
||||
|
||||
grab_version
|
||||
push_config
|
||||
6
resources/common_vars.conf
Normal file
6
resources/common_vars.conf
Normal file
@@ -0,0 +1,6 @@
|
||||
# /etc/nginx/conf.d/common_vars.conf
|
||||
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
26
resources/dwc2_nginx.cfg
Normal file
26
resources/dwc2_nginx.cfg
Normal file
@@ -0,0 +1,26 @@
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
upstream dwc2 {
|
||||
server 127.0.0.1:4750;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
#listen [::]:80;
|
||||
|
||||
location / {
|
||||
proxy_pass http://dwc2/;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Scheme $scheme;
|
||||
#proxy_set_header X-Script-Name /;
|
||||
proxy_http_version 1.1;
|
||||
client_max_body_size 0;
|
||||
}
|
||||
}
|
||||
83
resources/gcode_shell_command.py
Executable file
83
resources/gcode_shell_command.py
Executable file
@@ -0,0 +1,83 @@
|
||||
# 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)
|
||||
60
resources/kiauh_macros.cfg
Normal file
60
resources/kiauh_macros.cfg
Normal file
@@ -0,0 +1,60 @@
|
||||
#########################################################################################
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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! #
|
||||
#########################################################################################
|
||||
|
||||
[pause_resume]
|
||||
|
||||
[display_status]
|
||||
|
||||
[gcode_macro CANCEL_PRINT]
|
||||
rename_existing: BASE_CANCEL_PRINT
|
||||
gcode:
|
||||
TURN_OFF_HEATERS
|
||||
CLEAR_PAUSE
|
||||
SDCARD_RESET_FILE
|
||||
BASE_CANCEL_PRINT
|
||||
|
||||
[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 %}
|
||||
##### 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 %}
|
||||
{% else %}
|
||||
{% set z_safe = max_z - act_z %}
|
||||
{% endif %}
|
||||
##### end of definitions #####
|
||||
SAVE_GCODE_STATE NAME=PAUSE_state
|
||||
BASE_PAUSE
|
||||
G91
|
||||
G1 E-{E} F2100
|
||||
G1 Z{z_safe} F900
|
||||
G90
|
||||
G1 X{x_park} Y{y_park} 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 #####
|
||||
G91
|
||||
G1 E{E} F2100
|
||||
RESTORE_GCODE_STATE NAME=PAUSE_state
|
||||
BASE_RESUME
|
||||
|
||||
#########################################################################################
|
||||
#########################################################################################
|
||||
59
resources/klipper_webui_nginx.cfg
Normal file
59
resources/klipper_webui_nginx.cfg
Normal file
@@ -0,0 +1,59 @@
|
||||
# /etc/nginx/sites-available/<<UI>>
|
||||
|
||||
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
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
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;
|
||||
|
||||
#web_path from <<UI>> static files
|
||||
root /home/pi/<<UI>>;
|
||||
|
||||
index index.html;
|
||||
server_name _;
|
||||
|
||||
#max upload size for gcodes (0 = no limit)
|
||||
client_max_body_size 0;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location = /index.html {
|
||||
add_header Cache-Control "no-store, no-cache, must-revalidate";
|
||||
}
|
||||
|
||||
location /websocket {
|
||||
proxy_pass http://apiserver/websocket;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_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;
|
||||
proxy_read_timeout 86400;
|
||||
}
|
||||
|
||||
location ~ ^/(printer|api|access|machine|server)/ {
|
||||
proxy_pass http://apiserver$request_uri;
|
||||
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;
|
||||
proxy_set_header X-Scheme $scheme;
|
||||
}
|
||||
|
||||
location /webcam/ {
|
||||
proxy_pass http://mjpgstreamer/;
|
||||
}
|
||||
}
|
||||
40
resources/octoprint_nginx.cfg
Normal file
40
resources/octoprint_nginx.cfg
Normal file
@@ -0,0 +1,40 @@
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
upstream octoprint {
|
||||
server 127.0.0.1:5000;
|
||||
}
|
||||
|
||||
upstream mjpg-streamer {
|
||||
server 127.0.0.1:8080;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
#listen [::]:80;
|
||||
|
||||
location / {
|
||||
proxy_pass http://octoprint/;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Scheme $scheme;
|
||||
#proxy_set_header X-Script-Name /;
|
||||
proxy_http_version 1.1;
|
||||
client_max_body_size 0;
|
||||
}
|
||||
|
||||
location /webcam {
|
||||
proxy_pass http://mjpg-streamer/;
|
||||
}
|
||||
|
||||
# redirect server error pages to the static page /50x.html
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root html;
|
||||
}
|
||||
}
|
||||
BIN
resources/screenshots/main.png
Normal file
BIN
resources/screenshots/main.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
7
resources/shell_command.cfg
Normal file
7
resources/shell_command.cfg
Normal file
@@ -0,0 +1,7 @@
|
||||
[gcode_shell_command hello_world]
|
||||
command: echo hello world
|
||||
timeout: 2.
|
||||
verbose: True
|
||||
[gcode_macro HELLO_WORLD]
|
||||
gcode:
|
||||
RUN_SHELL_COMMAND CMD=hello_world
|
||||
13
resources/upstreams.conf
Normal file
13
resources/upstreams.conf
Normal file
@@ -0,0 +1,13 @@
|
||||
# /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
|
||||
ip_hash;
|
||||
server 127.0.0.1:8080;
|
||||
}
|
||||
185
scripts/backup.sh
Normal file → Executable file
185
scripts/backup.sh
Normal file → Executable file
@@ -1,19 +1,33 @@
|
||||
backup_printer_cfg(){
|
||||
check_for_backup_dir(){
|
||||
if [ ! -d $BACKUP_DIR ]; then
|
||||
status_msg "Create backup directory ..."
|
||||
status_msg "Create KIAUH backup directory ..."
|
||||
mkdir -p $BACKUP_DIR && ok_msg "Directory created!"
|
||||
fi
|
||||
if [ -f $PRINTER_CFG ]; then
|
||||
get_date
|
||||
status_msg "Create backup of printer.cfg ..."
|
||||
cp $PRINTER_CFG $BACKUP_DIR/printer.cfg."$current_date".backup && ok_msg "Backup created!"
|
||||
else
|
||||
ok_msg "No printer.cfg found! Skipping backup ..."
|
||||
}
|
||||
|
||||
toggle_backups(){
|
||||
source_kiauh_ini
|
||||
if [ "$backup_before_update" = "true" ]; then
|
||||
sed -i '/backup_before_update=/s/true/false/' $INI_FILE
|
||||
BB4U_STATUS="${green}[Enable]${default} backups before updating "
|
||||
CONFIRM_MSG=" Backups before updates are now >>> DISABLED <<< !"
|
||||
fi
|
||||
if [ "$backup_before_update" = "false" ]; then
|
||||
sed -i '/backup_before_update=/s/false/true/' $INI_FILE
|
||||
BB4U_STATUS="${red}[Disable]${default} backups before updating "
|
||||
CONFIRM_MSG=" Backups before updates are now >>> ENABLED <<< !"
|
||||
fi
|
||||
}
|
||||
|
||||
bb4u(){
|
||||
source_kiauh_ini
|
||||
if [ "$backup_before_update" = "true" ]; then
|
||||
backup_$1
|
||||
fi
|
||||
}
|
||||
|
||||
read_bb4u_stat(){
|
||||
source_ini
|
||||
source_kiauh_ini
|
||||
if [ ! "$backup_before_update" = "true" ]; then
|
||||
BB4U_STATUS="${green}[Enable]${default} backups before updating "
|
||||
else
|
||||
@@ -21,54 +35,143 @@ read_bb4u_stat(){
|
||||
fi
|
||||
}
|
||||
|
||||
toggle_backups(){
|
||||
source_ini
|
||||
if [ "$backup_before_update" = "true" ]; then
|
||||
sed -i '/backup_before_update=/s/true/false/' ${HOME}/kiauh2/kiauh.ini
|
||||
BB4U_STATUS="${green}[Enable]${default} backups before updating "
|
||||
fi
|
||||
if [ "$backup_before_update" = "false" ]; then
|
||||
sed -i '/backup_before_update=/s/false/true/' ${HOME}/kiauh2/kiauh.ini
|
||||
BB4U_STATUS="${red}[Disable]${default} backups before updating "
|
||||
##############################################################################################
|
||||
#********************************************************************************************#
|
||||
##############################################################################################
|
||||
|
||||
backup_printer_cfg(){
|
||||
check_for_backup_dir
|
||||
if [ -f $PRINTER_CFG ]; then
|
||||
get_date
|
||||
status_msg "Timestamp: $current_date"
|
||||
status_msg "Create backup of printer.cfg ..."
|
||||
cp $PRINTER_CFG $BACKUP_DIR/printer.cfg."$current_date".backup && ok_msg "Backup complete!"
|
||||
else
|
||||
ok_msg "No printer.cfg found! Skipping backup ..."
|
||||
fi
|
||||
}
|
||||
|
||||
bb4u_klipper(){
|
||||
source_ini
|
||||
if [ -d $KLIPPER_DIR ] && [ "$backup_before_update" = "true" ]; then
|
||||
backup_klipper_config_dir(){
|
||||
source_kiauh_ini
|
||||
check_for_backup_dir
|
||||
if [ -d "$klipper_cfg_loc" ]; then
|
||||
get_date
|
||||
status_msg "Timestamp: $current_date"
|
||||
status_msg "Create backup of the Klipper config directory ..."
|
||||
config_folder_name="$(echo "$klipper_cfg_loc" | rev | cut -d"/" -f1 | rev)"
|
||||
mkdir -p $BACKUP_DIR/$config_folder_name/$current_date
|
||||
cp -r "$klipper_cfg_loc" "$_" && ok_msg "Backup complete!"
|
||||
echo
|
||||
else
|
||||
ok_msg "No config directory found! Skipping backup ..."
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
###TODO re-evaluate if this function is still needed (just backup the full klipper_config dir instead?)
|
||||
backup_moonraker_conf(){
|
||||
check_for_backup_dir
|
||||
if [ -f ${HOME}/moonraker.conf ]; 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!"
|
||||
else
|
||||
ok_msg "No moonraker.conf found! Skipping backup ..."
|
||||
fi
|
||||
}
|
||||
|
||||
backup_klipper(){
|
||||
if [ -d $KLIPPER_DIR ] && [ -d $KLIPPY_ENV ]; then
|
||||
status_msg "Creating Klipper backup ..."
|
||||
check_for_backup_dir
|
||||
get_date
|
||||
status_msg "Timestamp: $current_date"
|
||||
mkdir -p $BACKUP_DIR/klipper-backups/"$current_date"
|
||||
cp -r $KLIPPER_DIR $_ && cp -r $KLIPPY_ENV_DIR $_ && ok_msg "Backup complete!"
|
||||
cp -r $KLIPPER_DIR $_ && cp -r $KLIPPY_ENV $_ && ok_msg "Backup complete!"
|
||||
else
|
||||
ERROR_MSG=" Can't backup klipper and/or klipper-env directory! Not found!"
|
||||
fi
|
||||
}
|
||||
|
||||
bb4u_dwc2fk(){
|
||||
source_ini
|
||||
if [ -d $DWC2FK_DIR ] && [ "$backup_before_update" = "true" ]; then
|
||||
get_date
|
||||
status_msg "Creating DWC2-for-Klipper backup ..."
|
||||
mkdir -p $BACKUP_DIR/dwc2-for-klipper-backups/"$current_date"
|
||||
cp -r $DWC2FK_DIR $_ && ok_msg "Backup complete!"
|
||||
fi
|
||||
}
|
||||
|
||||
bb4u_dwc2(){
|
||||
source_ini
|
||||
if [ -d $DWC2_DIR ] && [ "$backup_before_update" = "true" ]; then
|
||||
get_date
|
||||
backup_dwc2(){
|
||||
if [ -d $DWC2FK_DIR ] && [ -d $DWC_ENV_DIR ] && [ -d $DWC2_DIR ]; then
|
||||
status_msg "Creating DWC2 Web UI backup ..."
|
||||
check_for_backup_dir
|
||||
get_date
|
||||
status_msg "Timestamp: $current_date"
|
||||
mkdir -p $BACKUP_DIR/dwc2-backups/"$current_date"
|
||||
cp -r $DWC2_DIR $_ && ok_msg "Backup complete!"
|
||||
cp -r $DWC2FK_DIR $_ && cp -r $DWC_ENV_DIR $_ && cp -r $DWC2_DIR $_
|
||||
ok_msg "Backup complete!"
|
||||
else
|
||||
ERROR_MSG=" Can't backup dwc2-for-klipper-socket and/or dwc2 directory!\n Not found!"
|
||||
fi
|
||||
}
|
||||
|
||||
bb4u_mainsail(){
|
||||
source_ini
|
||||
if [ -d $MAINSAIL_DIR ] && [ "$backup_before_update" = "true" ]; then
|
||||
get_date
|
||||
backup_mainsail(){
|
||||
if [ -d $MAINSAIL_DIR ]; then
|
||||
status_msg "Creating Mainsail backup ..."
|
||||
check_for_backup_dir
|
||||
get_date
|
||||
status_msg "Timestamp: $current_date"
|
||||
mkdir -p $BACKUP_DIR/mainsail-backups/"$current_date"
|
||||
cp -r $MAINSAIL_DIR $_ && ok_msg "Backup complete!"
|
||||
else
|
||||
ERROR_MSG=" Can't backup mainsail directory! Not found!"
|
||||
fi
|
||||
}
|
||||
|
||||
backup_fluidd(){
|
||||
if [ -d $FLUIDD_DIR ]; then
|
||||
status_msg "Creating Fluidd backup ..."
|
||||
check_for_backup_dir
|
||||
get_date
|
||||
status_msg "Timestamp: $current_date"
|
||||
mkdir -p $BACKUP_DIR/fluidd-backups/"$current_date"
|
||||
cp -r $FLUIDD_DIR $_ && ok_msg "Backup complete!"
|
||||
else
|
||||
ERROR_MSG=" Can't backup fluidd directory! Not found!"
|
||||
fi
|
||||
}
|
||||
|
||||
backup_moonraker(){
|
||||
if [ -d $MOONRAKER_DIR ] && [ -d $MOONRAKER_ENV ]; then
|
||||
status_msg "Creating Moonraker backup ..."
|
||||
check_for_backup_dir
|
||||
get_date
|
||||
status_msg "Timestamp: $current_date"
|
||||
mkdir -p $BACKUP_DIR/moonraker-backups/"$current_date"
|
||||
cp -r $MOONRAKER_DIR $_ && cp -r $MOONRAKER_ENV $_ && ok_msg "Backup complete!"
|
||||
else
|
||||
ERROR_MSG=" Can't backup moonraker and/or moonraker-env directory! Not found!"
|
||||
fi
|
||||
}
|
||||
|
||||
backup_octoprint(){
|
||||
if [ -d $OCTOPRINT_DIR ] && [ -d $OCTOPRINT_CFG_DIR ]; then
|
||||
status_msg "Creating OctoPrint backup ..."
|
||||
check_for_backup_dir
|
||||
get_date
|
||||
status_msg "Timestamp: $current_date"
|
||||
mkdir -p $BACKUP_DIR/octoprint-backups/"$current_date"
|
||||
cp -r $OCTOPRINT_DIR $_ && cp -r $OCTOPRINT_CFG_DIR $_
|
||||
ok_msg "Backup complete!"
|
||||
else
|
||||
ERROR_MSG=" Can't backup OctoPrint and/or .octoprint directory!\n Not found!"
|
||||
fi
|
||||
}
|
||||
|
||||
backup_klipperscreen(){
|
||||
if [ -d $KLIPPERSCREEN_DIR ] ; then
|
||||
status_msg "Creating KlipperScreen backup ..."
|
||||
check_for_backup_dir
|
||||
get_date
|
||||
status_msg "Timestamp: $current_date"
|
||||
mkdir -p $BACKUP_DIR/klipperscreen-backups/"$current_date"
|
||||
cp -r $KLIPPERSCREEN_DIR $_
|
||||
ok_msg "Backup complete!"
|
||||
else
|
||||
ERROR_MSG=" Can't backup KlipperScreen directory!\n Not found!"
|
||||
fi
|
||||
}
|
||||
54
scripts/dwc2-for-klipper-socket-installer/dwc-start.sh
Executable file
54
scripts/dwc2-for-klipper-socket-installer/dwc-start.sh
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/bin/sh
|
||||
# System startup script for dwc2-for-klipper-socket
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: dwc2-for-klipper-socket
|
||||
# Required-Start: $local_fs
|
||||
# Required-Stop:
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: dwc2-for-klipper-socket daemon
|
||||
# Description: Starts the dwc2-for-klipper-socket daemon.
|
||||
### END INIT INFO
|
||||
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
DESC="dwc2-for-klipper-socket daemon"
|
||||
NAME="dwc2-for-klipper-socket"
|
||||
DEFAULTS_FILE=/etc/default/dwc
|
||||
PIDFILE=/var/run/dwc.pid
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
# Read defaults file
|
||||
[ -r $DEFAULTS_FILE ] && . $DEFAULTS_FILE
|
||||
|
||||
case "$1" in
|
||||
start) log_daemon_msg "Starting dwc2-for-klipper-socket" $NAME
|
||||
start-stop-daemon --start --quiet --exec $DWC_EXEC \
|
||||
--background --pidfile $PIDFILE --make-pidfile \
|
||||
--chuid $DWC_USER --user $DWC_USER \
|
||||
-- $DWC_ARGS
|
||||
log_end_msg $?
|
||||
;;
|
||||
stop) log_daemon_msg "Stopping dwc2-for-klipper-socket" $NAME
|
||||
killproc -p $PIDFILE $DWC_EXEC
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && [ -e "$PIDFILE" ] && rm -f $PIDFILE
|
||||
log_end_msg $RETVAL
|
||||
;;
|
||||
restart) log_daemon_msg "Restarting dwc2-for-klipper-socket" $NAME
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
reload|force-reload)
|
||||
log_daemon_msg "Reloading configuration not supported" $NAME
|
||||
log_end_msg 1
|
||||
;;
|
||||
status)
|
||||
status_of_proc -p $PIDFILE $DWC_EXEC $NAME && exit 0 || exit $?
|
||||
;;
|
||||
*) log_action_msg "Usage: /etc/init.d/dwc {start|stop|status|restart|reload|force-reload}"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
exit 0
|
||||
106
scripts/dwc2-for-klipper-socket-installer/install-debian.sh
Executable file
106
scripts/dwc2-for-klipper-socket-installer/install-debian.sh
Executable file
@@ -0,0 +1,106 @@
|
||||
#!/bin/bash
|
||||
# This script installs dwc2-for-klipper-socket on a Raspberry Pi machine running
|
||||
# Raspbian/Raspberry Pi OS based distributions.
|
||||
|
||||
# https://github.com/Stephan3/dwc2-for-klipper-socket.git
|
||||
|
||||
PYTHONDIR="${HOME}/dwc-env"
|
||||
SYSTEMDDIR="/etc/systemd/system"
|
||||
DWC_USER=${USER}
|
||||
|
||||
# Step 1: Verify Klipper has been installed
|
||||
check_klipper()
|
||||
{
|
||||
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ]; then
|
||||
echo "Klipper service found!"
|
||||
else
|
||||
echo "Klipper service not found, please install Klipper first"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# Step 2: Install packages
|
||||
install_packages()
|
||||
{
|
||||
PKGLIST="python3-virtualenv python3-dev python3-tornado"
|
||||
|
||||
# Update system package info
|
||||
report_status "Running apt-get update..."
|
||||
sudo apt-get update
|
||||
|
||||
# Install desired packages
|
||||
report_status "Installing packages..."
|
||||
sudo apt-get install --yes ${PKGLIST}
|
||||
}
|
||||
|
||||
# Step 3: Create python virtual environment
|
||||
create_virtualenv()
|
||||
{
|
||||
report_status "Updating python virtual environment..."
|
||||
|
||||
# Create virtualenv if it doesn't already exist
|
||||
[ ! -d ${PYTHONDIR} ] && virtualenv -p /usr/bin/python3 ${PYTHONDIR}
|
||||
|
||||
# Install/update dependencies
|
||||
${PYTHONDIR}/bin/pip install tornado==6.0.4
|
||||
}
|
||||
|
||||
# Step 4: Install startup script
|
||||
install_script(){
|
||||
report_status "Installing system start script..."
|
||||
sudo /bin/sh -c "cat > $SYSTEMDDIR/dwc.service" << EOF
|
||||
#Systemd service file for DWC
|
||||
[Unit]
|
||||
Description=dwc_webif
|
||||
After=network.target
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=$DWC_USER
|
||||
RemainAfterExit=yes
|
||||
ExecStart=${PYTHONDIR}/bin/python3 ${SRCDIR}/web_dwc2.py
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
EOF
|
||||
# Use systemctl to enable the klipper systemd service script
|
||||
sudo systemctl enable dwc.service
|
||||
}
|
||||
|
||||
# Step 5: Start DWC service
|
||||
start_software()
|
||||
{
|
||||
report_status "Launching dwc2-for-klipper-socket..."
|
||||
sudo systemctl start dwc
|
||||
}
|
||||
|
||||
# Helper functions
|
||||
report_status()
|
||||
{
|
||||
echo -e "\n\n###### $1"
|
||||
}
|
||||
|
||||
verify_ready()
|
||||
{
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
echo "This script must not run as root"
|
||||
exit -1
|
||||
fi
|
||||
}
|
||||
|
||||
# Force script to exit if an error occurs
|
||||
set -e
|
||||
|
||||
# Find SRCDIR from the pathname of this script
|
||||
SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"
|
||||
|
||||
# Run installation steps defined above
|
||||
verify_ready
|
||||
check_klipper
|
||||
install_packages
|
||||
create_virtualenv
|
||||
install_script
|
||||
start_software
|
||||
106
scripts/dwc2-for-klipper-socket-installer/install-octopi.sh
Executable file
106
scripts/dwc2-for-klipper-socket-installer/install-octopi.sh
Executable file
@@ -0,0 +1,106 @@
|
||||
#!/bin/bash
|
||||
# This script installs dwc2-for-klipper-socket on a Raspberry Pi machine running
|
||||
# Raspbian/Raspberry Pi OS based distributions.
|
||||
|
||||
# https://github.com/Stephan3/dwc2-for-klipper-socket.git
|
||||
|
||||
PYTHONDIR="${HOME}/dwc-env"
|
||||
|
||||
# Step 1: Verify Klipper has been installed
|
||||
check_klipper()
|
||||
{
|
||||
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ]; then
|
||||
echo "Klipper service found!"
|
||||
else
|
||||
echo "Klipper service not found, please install Klipper first"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# Step 2: Install packages
|
||||
install_packages()
|
||||
{
|
||||
PKGLIST="python3-virtualenv python3-dev python3-tornado"
|
||||
|
||||
# Update system package info
|
||||
report_status "Running apt-get update..."
|
||||
sudo apt-get update
|
||||
|
||||
# Install desired packages
|
||||
report_status "Installing packages..."
|
||||
sudo apt-get install --yes ${PKGLIST}
|
||||
}
|
||||
|
||||
# Step 3: Create python virtual environment
|
||||
create_virtualenv()
|
||||
{
|
||||
report_status "Updating python virtual environment..."
|
||||
|
||||
# Create virtualenv if it doesn't already exist
|
||||
[ ! -d ${PYTHONDIR} ] && virtualenv -p /usr/bin/python3 ${PYTHONDIR}
|
||||
|
||||
# Install/update dependencies
|
||||
${PYTHONDIR}/bin/pip install tornado==6.0.4
|
||||
}
|
||||
|
||||
# Step 4: Install startup script
|
||||
install_script(){
|
||||
report_status "Installing system start script..."
|
||||
sudo cp "${SRCDIR}/scripts/dwc-start.sh" /etc/init.d/dwc
|
||||
sudo update-rc.d dwc defaults
|
||||
}
|
||||
|
||||
# Step 5: Install startup script config
|
||||
install_config(){
|
||||
DEFAULTS_FILE=/etc/default/dwc
|
||||
[ -f $DEFAULTS_FILE ] && return
|
||||
|
||||
report_status "Installing system start configuration..."
|
||||
sudo /bin/sh -c "cat > $DEFAULTS_FILE" <<EOF
|
||||
# Configuration for /etc/init.d/dwc
|
||||
DWC_USER=$USER
|
||||
|
||||
DWC_EXEC=${PYTHONDIR}/bin/python3
|
||||
|
||||
DWC_ARGS="${SRCDIR}/web_dwc2.py"
|
||||
EOF
|
||||
}
|
||||
|
||||
# Step 4: Start server
|
||||
start_software()
|
||||
{
|
||||
report_status "Launching dwc2-for-klipper-socket..."
|
||||
sudo /etc/init.d/klipper stop
|
||||
sudo /etc/init.d/dwc restart
|
||||
sudo /etc/init.d/klipper start
|
||||
}
|
||||
|
||||
# Helper functions
|
||||
report_status()
|
||||
{
|
||||
echo -e "\n\n###### $1"
|
||||
}
|
||||
|
||||
verify_ready()
|
||||
{
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
echo "This script must not run as root"
|
||||
exit -1
|
||||
fi
|
||||
}
|
||||
|
||||
# Force script to exit if an error occurs
|
||||
set -e
|
||||
|
||||
# Find SRCDIR from the pathname of this script
|
||||
SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"
|
||||
|
||||
# Run installation steps defined above
|
||||
verify_ready
|
||||
check_klipper
|
||||
install_packages
|
||||
create_virtualenv
|
||||
install_script
|
||||
install_config
|
||||
start_software
|
||||
41
scripts/dwc2-for-klipper-socket-installer/uninstall-debian.sh
Executable file
41
scripts/dwc2-for-klipper-socket-installer/uninstall-debian.sh
Executable file
@@ -0,0 +1,41 @@
|
||||
stop_service() {
|
||||
# Stop DWC Service
|
||||
echo "#### Stopping DWC Service.."
|
||||
sudo systemctl stop dwc
|
||||
sudo systemctl disable dwc
|
||||
}
|
||||
|
||||
remove_service() {
|
||||
# Remove DWC from Services
|
||||
echo
|
||||
echo "#### Removing DWC Service.."
|
||||
sudo rm -f /etc/systemd/system/dwc.service
|
||||
sudo systemctl daemon-reload
|
||||
}
|
||||
|
||||
remove_files() {
|
||||
# Remove virtualenv
|
||||
if [ -d ~/dwc-env ]; then
|
||||
echo "Removing virtualenv..."
|
||||
rm -rf ~/dwc-env
|
||||
else
|
||||
echo "No DWC virtualenv found"
|
||||
fi
|
||||
|
||||
# Notify user of method to remove DWC source code
|
||||
echo
|
||||
echo "The DWC system files and virtualenv have been removed."
|
||||
}
|
||||
|
||||
verify_ready()
|
||||
{
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
echo "This script must not run as root"
|
||||
exit -1
|
||||
fi
|
||||
}
|
||||
|
||||
verify_ready
|
||||
stop_service
|
||||
remove_service
|
||||
remove_files
|
||||
45
scripts/dwc2-for-klipper-socket-installer/uninstall-octopi.sh
Executable file
45
scripts/dwc2-for-klipper-socket-installer/uninstall-octopi.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
stop_service() {
|
||||
# Stop DWC Service
|
||||
echo "#### Stopping DWC Service.."
|
||||
sudo service dwc stop
|
||||
}
|
||||
|
||||
remove_service() {
|
||||
# Remove DWC from Startup
|
||||
echo
|
||||
echo "#### Removing DWC from Startup.."
|
||||
sudo update-rc.d -f dwc remove
|
||||
|
||||
# Remove DWC from Services
|
||||
echo
|
||||
echo "#### Removing DWC Service.."
|
||||
sudo rm -f /etc/init.d/dwc /etc/default/dwc
|
||||
|
||||
}
|
||||
|
||||
remove_files() {
|
||||
# Remove virtualenv
|
||||
if [ -d ~/dwc-env ]; then
|
||||
echo "Removing virtualenv..."
|
||||
rm -rf ~/dwc-env
|
||||
else
|
||||
echo "No DWC virtualenv found"
|
||||
fi
|
||||
|
||||
# Notify user of method to remove DWC source code
|
||||
echo
|
||||
echo "The DWC system files and virtualenv have been removed."
|
||||
}
|
||||
|
||||
verify_ready()
|
||||
{
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
echo "This script must not run as root"
|
||||
exit -1
|
||||
fi
|
||||
}
|
||||
|
||||
verify_ready
|
||||
stop_service
|
||||
remove_service
|
||||
remove_files
|
||||
575
scripts/functions.sh
Normal file → Executable file
575
scripts/functions.sh
Normal file → Executable file
@@ -3,64 +3,300 @@ check_euid(){
|
||||
if [ "$EUID" -eq 0 ]
|
||||
then
|
||||
echo -e "${red}"
|
||||
echo -e "/=================================================\ "
|
||||
top_border
|
||||
echo -e "| !!! THIS SCRIPT MUST NOT RAN AS ROOT !!! |"
|
||||
echo -e "\=================================================/ "
|
||||
bottom_border
|
||||
echo -e "${default}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
source_ini(){
|
||||
source ${HOME}/kiauh2/kiauh.ini
|
||||
}
|
||||
|
||||
start_klipper(){
|
||||
if [ -e /etc/init.d/klipper ]; then
|
||||
status_msg "Starting klipper service ..."
|
||||
sudo /etc/init.d/klipper start && sleep 2 && ok_msg "Klipper service started!"
|
||||
fi
|
||||
}
|
||||
stop_klipper(){
|
||||
if [ -e /etc/init.d/klipper ]; then
|
||||
status_msg "Stopping klipper service ..."
|
||||
sudo /etc/init.d/klipper stop && sleep 2 && ok_msg "Klipper service stopped!"
|
||||
check_klipper_cfg_path(){
|
||||
source_kiauh_ini
|
||||
if [ -z $klipper_cfg_loc ]; then
|
||||
echo
|
||||
top_border
|
||||
echo -e "| ${red}!!! WARNING !!!${default} |"
|
||||
echo -e "| ${red}No Klipper configuration directory set!${default} |"
|
||||
hr
|
||||
echo -e "| Before we can continue, KIAUH needs to know where |"
|
||||
echo -e "| you want your printer configuration to be. |"
|
||||
blank_line
|
||||
echo -e "| Please specify a folder where your Klipper configu- |"
|
||||
echo -e "| ration is stored or, if you don't have one yet, in |"
|
||||
echo -e "| which it should be saved after the installation. |"
|
||||
bottom_border
|
||||
change_klipper_cfg_path
|
||||
fi
|
||||
}
|
||||
|
||||
start_moonraker(){
|
||||
if [ -e /etc/init.d/moonraker ]; then
|
||||
status_msg "Starting moonraker service ..."
|
||||
sudo /etc/init.d/moonraker start && sleep 2 && ok_msg "Moonraker service started!"
|
||||
fi
|
||||
}
|
||||
|
||||
stop_moonraker(){
|
||||
if [ -e /etc/init.d/moonraker ]; then
|
||||
status_msg "Stopping moonraker service ..."
|
||||
sudo /etc/init.d/moonraker stop && sleep 2 && ok_msg "Moonraker service stopped!"
|
||||
fi
|
||||
}
|
||||
|
||||
dep_check(){
|
||||
for package in "${dep[@]}"
|
||||
do
|
||||
! command -v $package >&/dev/null 2>&1 && install+=($package)
|
||||
done
|
||||
if ! [ ${#install[@]} -eq 0 ]; then
|
||||
warn_msg "The following packages are missing but necessary:"
|
||||
echo ${install[@]}
|
||||
change_klipper_cfg_path(){
|
||||
source_kiauh_ini
|
||||
old_klipper_cfg_loc="$klipper_cfg_loc"
|
||||
EXAMPLE_FOLDER=$(printf "%s/your_config_folder" "${HOME}")
|
||||
while true; do
|
||||
read -p "Do you want to install them now? (Y/n): " yn
|
||||
top_border
|
||||
echo -e "| ${red}IMPORTANT:${default} |"
|
||||
echo -e "| Please enter the new path in the following format: |"
|
||||
printf "| ${yellow}%-51s${default} |\n" "$EXAMPLE_FOLDER"
|
||||
blank_line
|
||||
echo -e "| By default 'klipper_config' is recommended! |"
|
||||
bottom_border
|
||||
echo
|
||||
echo -e "${cyan}###### Please set the Klipper config directory:${default} "
|
||||
if [ -z "$old_klipper_cfg_loc" ]; then
|
||||
read -e -i "/home/${USER}/klipper_config" -e new_klipper_cfg_loc
|
||||
else
|
||||
read -e -i "$old_klipper_cfg_loc" -e new_klipper_cfg_loc
|
||||
fi
|
||||
echo
|
||||
read -p "${cyan}###### Set config directory to '${yellow}$new_klipper_cfg_loc${cyan}' ? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
status_msg "Installing dependencies ..."
|
||||
sudo apt-get install ${install[@]} -y && ok_msg "Dependencies installed!"
|
||||
echo -e "###### > Yes"
|
||||
|
||||
### backup the old config dir
|
||||
backup_klipper_config_dir
|
||||
|
||||
### write new location to kiauh.ini
|
||||
sed -i "s|klipper_cfg_loc=$old_klipper_cfg_loc|klipper_cfg_loc=$new_klipper_cfg_loc|" $INI_FILE
|
||||
status_msg "Directory set to '$new_klipper_cfg_loc'!"
|
||||
|
||||
### write new location to klipper and moonraker service
|
||||
set_klipper_cfg_path
|
||||
echo; ok_msg "Config directory changed!"
|
||||
break;;
|
||||
N|n|No|no) break;;
|
||||
*) echo "Unknown parameter: $yn"; echo;;
|
||||
N|n|No|no)
|
||||
echo -e "###### > No"
|
||||
change_klipper_cfg_path
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
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"
|
||||
|
||||
### rename the 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!"
|
||||
fi
|
||||
|
||||
### handle single klipper instance service file
|
||||
if [ -f /etc/systemd/system/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
|
||||
ok_msg "OK!"
|
||||
fi
|
||||
### handle multi klipper instance service file
|
||||
if ls /etc/systemd/system/klipper-*.service 2>/dev/null 1>&2; then
|
||||
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
|
||||
done
|
||||
ok_msg "OK!"
|
||||
fi
|
||||
|
||||
### handle single moonraker instance service and moonraker.conf file
|
||||
if [ -f /etc/systemd/system/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
|
||||
### 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
|
||||
ok_msg "OK!"
|
||||
fi
|
||||
### handle multi moonraker instance service file
|
||||
if ls /etc/systemd/system/moonraker-*.service 2>/dev/null 1>&2; then
|
||||
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
|
||||
done
|
||||
### replace old file path with new one in moonraker.conf
|
||||
for moonraker_conf in $(find $new_klipper_cfg_loc/printer_*/moonraker.conf); do
|
||||
loc=$(echo "$moonraker_conf" | rev | cut -d"/" -f2- | rev)
|
||||
sed -i "/config_path:/ s|config_path:.*|config_path: $loc|" $moonraker_conf
|
||||
done
|
||||
ok_msg "OK!"
|
||||
fi
|
||||
|
||||
### reloading units
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
### restart services
|
||||
klipper_service "restart" && moonraker_service "restart"
|
||||
}
|
||||
|
||||
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(){
|
||||
### 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"
|
||||
[ "$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)
|
||||
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
|
||||
}
|
||||
|
||||
toggle_octoprint_service(){
|
||||
if systemctl list-unit-files | grep -E "octoprint.*" | grep "enabled" &>/dev/null; then
|
||||
octoprint_service "stop"
|
||||
octoprint_service "disable"
|
||||
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"
|
||||
sleep 2
|
||||
CONFIRM_MSG=" OctoPrint Service is now >>> ENABLED <<< !"
|
||||
else
|
||||
ERROR_MSG=" You cannot activate a service that does not exist!"
|
||||
fi
|
||||
}
|
||||
|
||||
read_octoprint_service_status(){
|
||||
unset OPRINT_SERVICE_STATUS
|
||||
if systemctl list-unit-files | grep -E "octoprint*" | grep "enabled" &>/dev/null; then
|
||||
OPRINT_SERVICE_STATUS="${red}[Disable]${default} OctoPrint Service "
|
||||
else
|
||||
OPRINT_SERVICE_STATUS="${green}[Enable]${default} OctoPrint Service "
|
||||
fi
|
||||
}
|
||||
|
||||
start_klipperscreen(){
|
||||
status_msg "Starting KlipperScreen Service ..."
|
||||
sudo systemctl start KlipperScreen && ok_msg "KlipperScreen Service started!"
|
||||
}
|
||||
|
||||
stop_klipperscreen(){
|
||||
status_msg "Stopping KlipperScreen Service ..."
|
||||
sudo systemctl stop KlipperScreen && ok_msg "KlipperScreen Service stopped!"
|
||||
}
|
||||
|
||||
restart_klipperscreen(){
|
||||
status_msg "Restarting KlipperScreen Service ..."
|
||||
sudo systemctl restart KlipperScreen && ok_msg "KlipperScreen Service restarted!"
|
||||
}
|
||||
|
||||
restart_nginx(){
|
||||
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "nginx.service")" ]; then
|
||||
status_msg "Restarting NGINX Service ..."
|
||||
sudo systemctl restart nginx && ok_msg "NGINX Service restarted!"
|
||||
fi
|
||||
}
|
||||
|
||||
dependency_check(){
|
||||
status_msg "Checking for the following dependencies:"
|
||||
#check if package is installed, if not write name into array
|
||||
for pkg in "${dep[@]}"
|
||||
do
|
||||
echo -e "${cyan}● $pkg ${default}"
|
||||
if [[ ! $(dpkg-query -f'${Status}' --show $pkg 2>/dev/null) = *\ installed ]]; then
|
||||
inst+=($pkg)
|
||||
fi
|
||||
done
|
||||
#if array is not empty, install packages from array elements
|
||||
if [ "${#inst[@]}" != "0" ]; then
|
||||
status_msg "Installing the following dependencies:"
|
||||
for element in ${inst[@]}
|
||||
do
|
||||
echo -e "${cyan}● $element ${default}"
|
||||
done
|
||||
echo
|
||||
sudo apt-get install ${inst[@]} -y
|
||||
ok_msg "Dependencies installed!"
|
||||
#clearing the array
|
||||
unset inst
|
||||
else
|
||||
ok_msg "Dependencies already met! Continue..."
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -75,111 +311,194 @@ print_error(){
|
||||
done
|
||||
sum=$(IFS=+; echo "$((${data_count[*]}))")
|
||||
if [ $sum -eq 0 ]; then
|
||||
ERROR_MSG=" Looks like $1 was already removed!\n Skipping..."
|
||||
ERROR_MSG="Looks like $1 was already removed!\n Skipping..."
|
||||
else
|
||||
ERROR_MSG=""
|
||||
fi
|
||||
}
|
||||
|
||||
pkg_check(){
|
||||
status_msg "Checking if nginx is installed"
|
||||
if [[ $(dpkg-query -f'${Status}' --show nginx 2>/dev/null) = *\ installed ]]; then
|
||||
echo "nginx found!"
|
||||
else
|
||||
echo "nginx was not found, installing..." 2>&1
|
||||
sudo apt-get -y install nginx 2>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
build_fw(){
|
||||
if [ -d $KLIPPER_DIR ]; then
|
||||
cd $KLIPPER_DIR && 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 printers id
|
||||
get_usb_id(){
|
||||
warn_msg "Make sure your printer is the only USB device connected!"
|
||||
setup_gcode_shell_command(){
|
||||
echo
|
||||
top_border
|
||||
echo -e "| You are about to install the G-Code Shell Command |"
|
||||
echo -e "| extension. Please make sure to read the instructions |"
|
||||
echo -e "| before you continue and remember that potential risks |"
|
||||
echo -e "| can be involved after installing this extension! |"
|
||||
blank_line
|
||||
echo -e "| ${red}You accept that you are doing this on your own risk!${default} |"
|
||||
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 correct USB port ..."
|
||||
USB_ID=$(ls /dev/serial/by-id/*)
|
||||
if [ -e /dev/serial/by-id/* ]; then
|
||||
status_msg "The ID of your printer is:"
|
||||
title_msg "$USB_ID"
|
||||
else
|
||||
warn_msg "Could not retrieve ID!"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
write_printer_id(){
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Do you want to write the ID to your printer.cfg? (Y/n): " yn
|
||||
echo -e "${default}"
|
||||
read -p "${cyan}###### Do you want to continue? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
backup_printer_cfg
|
||||
cat <<PRINTERID >> $PRINTER_CFG
|
||||
|
||||
##########################
|
||||
### CREATED WITH KIAUH ###
|
||||
##########################
|
||||
[mcu]
|
||||
serial: $USB_ID
|
||||
##########################
|
||||
##########################
|
||||
PRINTERID
|
||||
ok_msg "Config written!"
|
||||
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!"
|
||||
while true; do
|
||||
read -p "${cyan}###### Do you want to overwrite it? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
rm -f $KLIPPER_DIR/klippy/extras/gcode_shell_command.py
|
||||
install_gcode_shell_command
|
||||
break;;
|
||||
N|n|No|no) break;;
|
||||
N|n|No|no)
|
||||
break;;
|
||||
esac
|
||||
done
|
||||
else
|
||||
install_gcode_shell_command
|
||||
fi
|
||||
else
|
||||
ERROR_MSG="Folder ~/klipper/klippy/extras not found!"
|
||||
fi
|
||||
break;;
|
||||
N|n|No|no)
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
flash_routine(){
|
||||
echo -e "/=================================================\ "
|
||||
echo -e "| ATTENTION! |"
|
||||
echo -e "| Flashing a Smoothie based board for the first |"
|
||||
echo -e "| time with this script will certainly fail. |"
|
||||
echo -e "| This applies to boards like the BTT SKR V1.3 or |"
|
||||
echo -e "| the newer SKR V1.4 (Turbo). You have to copy |"
|
||||
echo -e "| the firmware file to the microSD card manually |"
|
||||
echo -e "| and rename it to 'firmware.bin'. |"
|
||||
echo -e "| |"
|
||||
echo -e "| You find the file in: ~/klipper/out/klipper.bin |"
|
||||
echo -e "\=================================================/ "
|
||||
install_gcode_shell_command(){
|
||||
klipper_service "stop"
|
||||
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 -e "${cyan}"
|
||||
read -p "###### Do you want to continue? (Y/n): " yn
|
||||
echo -e "${default}"
|
||||
read -p "${cyan}###### Do you want to create the example shell command? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
get_usb_id && flash_mcu && write_printer_id; break;;
|
||||
N|n|No|no) break;;
|
||||
status_msg "Copy shell_command.cfg ..."
|
||||
### create a backup of the config folder
|
||||
backup_klipper_config_dir
|
||||
|
||||
### handle single printer.cfg
|
||||
if [ -f $klipper_cfg_loc/printer.cfg ] && [ ! -f $klipper_cfg_loc/shell_command.cfg ]; then
|
||||
### copy shell_command.cfg to config location
|
||||
cp ${SRCDIR}/kiauh/resources/shell_command.cfg $klipper_cfg_loc
|
||||
ok_msg "$klipper_cfg_loc/shell_command.cfg created!"
|
||||
|
||||
### write the include to the very first line of the printer.cfg
|
||||
sed -i "1 i [include shell_command.cfg]" $klipper_cfg_loc/printer.cfg
|
||||
fi
|
||||
|
||||
### handle multi printer.cfg
|
||||
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/shell_command.cfg ]; then
|
||||
### copy shell_command.cfg to config location
|
||||
cp ${SRCDIR}/kiauh/resources/shell_command.cfg $path
|
||||
ok_msg "$path/shell_command.cfg created!"
|
||||
|
||||
### write the include to the very first line of the printer.cfg
|
||||
sed -i "1 i [include shell_command.cfg]" $path/printer.cfg
|
||||
fi
|
||||
done
|
||||
fi
|
||||
break;;
|
||||
N|n|No|no)
|
||||
break;;
|
||||
esac
|
||||
done
|
||||
ok_msg "Shell command extension installed!"
|
||||
klipper_service "restart"
|
||||
}
|
||||
|
||||
flash_mcu(){
|
||||
stop_klipper
|
||||
if ! make flash FLASH_DEVICE="$USB_ID" ; then
|
||||
warn_msg "Flashing failed!"
|
||||
warn_msg "Please read the log above!"
|
||||
else
|
||||
ok_msg "Flashing successfull!"
|
||||
create_minimal_cfg(){
|
||||
#create a minimal default config
|
||||
if [ "$SEL_DEF_CFG" = "true" ]; then
|
||||
cat <<- EOF >> $PRINTER_CFG
|
||||
[mcu]
|
||||
serial: </dev/serial/by-id/your-mcu>
|
||||
|
||||
[printer]
|
||||
kinematics: none
|
||||
max_velocity: 1
|
||||
max_accel: 1
|
||||
|
||||
[virtual_sdcard]
|
||||
path: ~/sdcard
|
||||
|
||||
[pause_resume]
|
||||
[display_status]
|
||||
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
|
||||
cp ${SRCDIR}/kiauh/kiauh.ini $INI_FILE
|
||||
fi
|
||||
if [ ! -f $INI_FILE ]; then
|
||||
echo -e "#don't edit this file if you don't know what you are doing...\c" > $INI_FILE
|
||||
fi
|
||||
if [ ! $(grep -E "^backup_before_update=." $INI_FILE) ]; then
|
||||
echo -e "\nbackup_before_update=false\c" >> $INI_FILE
|
||||
fi
|
||||
if [ ! $(grep -E "^previous_origin_state=[[:alnum:]]" $INI_FILE) ]; then
|
||||
echo -e "\nprevious_origin_state=0\c" >> $INI_FILE
|
||||
fi
|
||||
if [ ! $(grep -E "^previous_smoothing_state=[[:alnum:]]" $INI_FILE) ]; then
|
||||
echo -e "\nprevious_smoothing_state=0\c" >> $INI_FILE
|
||||
fi
|
||||
if [ ! $(grep -E "^previous_shaping_state=[[:alnum:]]" $INI_FILE) ]; then
|
||||
echo -e "\nprevious_shaping_state=0\c" >> $INI_FILE
|
||||
fi
|
||||
if [ ! $(grep -E "^logupload_accepted=." $INI_FILE) ]; then
|
||||
echo -e "\nlogupload_accepted=false\c" >> $INI_FILE
|
||||
fi
|
||||
###add empty klipper config path if missing
|
||||
if [ ! $(grep -E "^klipper_cfg_loc=" $INI_FILE) ]; then
|
||||
echo -e "\nklipper_cfg_loc=\c" >> $INI_FILE
|
||||
fi
|
||||
start_klipper
|
||||
}
|
||||
522
scripts/install_dwc2.sh
Normal file → Executable file
522
scripts/install_dwc2.sh
Normal file → Executable file
@@ -1,166 +1,390 @@
|
||||
#TODO:
|
||||
# - check for existing/running octoprint service
|
||||
# - ask for permission to disable octoprint service
|
||||
### base variables
|
||||
SYSTEMDDIR="/etc/systemd/system"
|
||||
DWC_ENV="${HOME}/dwc-env"
|
||||
DWC2_DIR="${HOME}/duetwebcontrol"
|
||||
|
||||
dwc2_install_routine(){
|
||||
if [ -d $KLIPPER_DIR ]; then
|
||||
# check for existing installation
|
||||
if [ -d ${HOME}/klippy-env/lib/python2.7/site-packages/tornado ]; then
|
||||
ERROR_MSG=" Looks like DWC2 is already installed!\n Skipping..."
|
||||
return
|
||||
system_check_dwc(){
|
||||
### check system for an installed octoprint service
|
||||
if systemctl is-enabled octoprint.service -q 2>/dev/null; then
|
||||
OCTOPRINT_ENABLED="true"
|
||||
fi
|
||||
stop_klipper
|
||||
install_tornado
|
||||
install_dwc2fk && dwc2fk_cfg
|
||||
install_dwc2
|
||||
start_klipper
|
||||
}
|
||||
|
||||
dwc_setup_dialog(){
|
||||
status_msg "Initializing Duet Web Control installation ..."
|
||||
|
||||
### check system for several requirements before initializing the dwc2 installation
|
||||
system_check_dwc
|
||||
|
||||
### 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
|
||||
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
|
||||
ERROR_MSG=" Please install Klipper first!\n Skipping..."
|
||||
INSTANCE_COUNT=$(systemctl list-units --full -all -t service --no-legend | grep -E "klipper-[[:digit:]].service" | wc -l)
|
||||
fi
|
||||
}
|
||||
|
||||
install_tornado(){
|
||||
#check for dependencies
|
||||
dep=(virtualenv)
|
||||
dep_check
|
||||
#execute operation
|
||||
status_msg "Installing Tornado 5.1.1 ..."
|
||||
cd ${HOME}
|
||||
PYTHONDIR="${HOME}/klippy-env"
|
||||
virtualenv ${PYTHONDIR}
|
||||
${PYTHONDIR}/bin/pip install tornado==5.1.1 && ok_msg "Tornado 5.1.1 successfully installed!"
|
||||
}
|
||||
### initial config path check
|
||||
check_klipper_cfg_path
|
||||
|
||||
install_dwc2fk(){
|
||||
cd ${HOME}
|
||||
status_msg "Cloning dwc2-for-klipper repository ..."
|
||||
git clone $DWC2FK_REPO && ok_msg "dwc2-for-klipper successfully cloned!"
|
||||
#create a web_dwc2.py symlink if not already existing
|
||||
if [ -d $KLIPPER_DIR/klippy/extras ] && [ ! -e $KLIPPER_DIR/klippy/extras/web_dwc2.py ]; then
|
||||
status_msg "Creating web_dwc2.py symlink ..."
|
||||
ln -s $DWC2FK_DIR/web_dwc2.py $KLIPPER_DIR/klippy/extras/web_dwc2.py && ok_msg "Symlink created!"
|
||||
### ask user how to handle OctoPrint, Haproxy and Lighttpd
|
||||
process_octoprint_dialog_dwc2
|
||||
process_haproxy_lighttpd_dialog
|
||||
|
||||
### instance confirmation dialog
|
||||
while true; do
|
||||
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
|
||||
}
|
||||
|
||||
dwc2fk_cfg(){
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Do you want to create the config now? (Y/n): " yn
|
||||
echo -e "${default}"
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"") create_dwc2fk_cfg; break;;
|
||||
N|n|No|no) break;;
|
||||
*) echo "Unknown parameter: $yn"; dwc2fk_cfg;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
create_dwc2fk_cfg(){
|
||||
echo -e "/=================================================\ "
|
||||
echo -e "| 1) [Default configuration] | "
|
||||
echo -e "| 2) [Custom configuration] | "
|
||||
echo -e "| 3) [Skip] | "
|
||||
echo -e "\=================================================/ "
|
||||
while true; do
|
||||
read -p "Please select: " choice; echo
|
||||
case "$choice" in
|
||||
1) dwc2fk_default_cfg && ok_msg "Config written ..."; break;;
|
||||
2) create_dwc2fk_custom_cfg && ok_msg "Config written ..."; break;;
|
||||
3) echo "Skipping ..."; break;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
dwc2fk_default_cfg(){
|
||||
cat <<DWC2 >> $PRINTER_CFG
|
||||
|
||||
##########################
|
||||
### CREATED WITH KIAUH ###
|
||||
##########################
|
||||
[virtual_sdcard]
|
||||
path: ~/sdcard
|
||||
|
||||
[web_dwc2]
|
||||
printer_name: my_printer
|
||||
listen_adress: 0.0.0.0
|
||||
listen_port: 4750
|
||||
web_path: dwc2/web
|
||||
##########################
|
||||
##########################
|
||||
DWC2
|
||||
}
|
||||
|
||||
create_dwc2fk_custom_cfg(){
|
||||
echo -e "${cyan}"
|
||||
read -e -p "Printer name: " -i "my_printer" PRINTER_NAME
|
||||
read -e -p "Listen adress: " -i "0.0.0.0" LISTEN_ADRESS
|
||||
read -e -p "Listen port: " -i "4750" LISTEN_PORT
|
||||
read -e -p "Web path: " -i "dwc2/web" WEB_PATH
|
||||
echo -e "${default}"
|
||||
DWC2_CFG=$(cat <<DWC2
|
||||
|
||||
##########################
|
||||
### CREATED WITH KIAUH ###
|
||||
##########################
|
||||
[virtual_sdcard]
|
||||
path: ~/sdcard
|
||||
|
||||
[web_dwc2]
|
||||
printer_name: $PRINTER_NAME
|
||||
listen_adress: $LISTEN_ADRESS
|
||||
listen_port: $LISTEN_PORT
|
||||
web_path: $WEB_PATH
|
||||
##########################
|
||||
##########################
|
||||
DWC2
|
||||
)
|
||||
echo "The following lines will be written:"
|
||||
echo -e "$DWC2_CFG"
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Write now (Y) or start over (n)? (Y/n): " yn
|
||||
echo -e "${default}"
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"") echo -e "$DWC2_CFG" >> $PRINTER_CFG; break;;
|
||||
N|n|No|no) create_dwc2fk_custom_cfg;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
install_dwc2(){
|
||||
#needed packages for webcam
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Do you want to use a webcam? (Y/n): " yn
|
||||
echo -e "${default}"
|
||||
echo -e "| You need one DWC instance per Klipper instance. | "
|
||||
bottom_border
|
||||
echo
|
||||
read -p "${cyan}###### Create $INSTANCE_COUNT DWC instances? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
status_msg "Checking for dependencies ..."
|
||||
webcam_dep_check && ok_msg "Dependencies installed!"
|
||||
echo -e "###### > Yes"
|
||||
status_msg "Creating $INSTANCE_COUNT DWC instances ..."
|
||||
dwc_setup
|
||||
break;;
|
||||
N|n|No|no) break;;
|
||||
*) echo "Unknown parameter: $yn"; echo;;
|
||||
N|n|No|no)
|
||||
echo -e "###### > No"
|
||||
warn_msg "Exiting DWC setup ..."
|
||||
echo
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
#the update_dwc2 function does the same as installing dwc2
|
||||
update_dwc2 && ok_msg "DWC2 Web UI installed!"
|
||||
}
|
||||
|
||||
webcam_dep_check(){
|
||||
webcam_dep=(
|
||||
build-essential
|
||||
libjpeg8-dev
|
||||
imagemagick
|
||||
libv4l-dev
|
||||
cmake
|
||||
)
|
||||
for pkg in "${webcam_dep[@]}"
|
||||
do
|
||||
if ! [[ $(dpkg-query -f'${Status}' --show $pkg 2>/dev/null) = *\ installed ]]; then
|
||||
install+=($pkg)
|
||||
fi
|
||||
###TODO for future: should be some kind of shared function between moonraker and this installer, since it does the same
|
||||
process_octoprint_dialog_dwc2(){
|
||||
### 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 Duet Web Control for Klipper. |"
|
||||
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 ..."
|
||||
sudo systemctl stop octoprint && ok_msg "OctoPrint service stopped!"
|
||||
status_msg "Disabling OctoPrint ..."
|
||||
sudo systemctl 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
|
||||
status_msg "Installation will start now! Please wait ..."
|
||||
}
|
||||
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
get_dwc_ver(){
|
||||
DWC2_VERSION=$(curl -s https://api.github.com/repositories/28820678/releases/latest | grep tag_name | cut -d'"' -f4)
|
||||
}
|
||||
|
||||
dwc_setup(){
|
||||
### get printer config directory
|
||||
source_kiauh_ini
|
||||
DWC_CONF_LOC="$klipper_cfg_loc"
|
||||
|
||||
### check dependencies
|
||||
dep=(git wget gzip tar curl)
|
||||
dependency_check
|
||||
|
||||
### step 1: get dwc2-for-klipper
|
||||
status_msg "Downloading DWC2-for-Klipper-Socket ..."
|
||||
cd ${HOME} && git clone $DWC2FK_REPO
|
||||
ok_msg "Download complete!"
|
||||
|
||||
### step 2: install dwc2 dependencies and create python virtualenv
|
||||
status_msg "Installing dependencies ..."
|
||||
install_dwc_packages
|
||||
create_dwc_virtualenv
|
||||
|
||||
### step 3: create dwc2.cfg folder and dwc2.cfg
|
||||
[ ! -d $DWC_CONF_LOC ] && mkdir -p $DWC_CONF_LOC
|
||||
dwc_cfg_creation
|
||||
|
||||
### step 4: download Duet Web Control
|
||||
download_dwc_webui
|
||||
|
||||
### step 5: create dwc instances
|
||||
INSTANCE=1
|
||||
if [ $INSTANCE_COUNT -eq $INSTANCE ]; then
|
||||
create_single_dwc_instance
|
||||
else
|
||||
#create_multi_dwc_instance
|
||||
create_multi_dwc_instance
|
||||
fi
|
||||
}
|
||||
|
||||
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
|
||||
ok_msg "Download complete!"
|
||||
status_msg "Extracting archive ..."
|
||||
unzip -q -o *.zip
|
||||
for f_ in $(find . | grep '.gz')
|
||||
do
|
||||
gunzip -f ${f_}
|
||||
done
|
||||
ok_msg "Done!"
|
||||
status_msg "Writing DWC version to file ..."
|
||||
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!"
|
||||
}
|
||||
|
||||
##############################################################################################
|
||||
#********************************************************************************************#
|
||||
##############################################################################################
|
||||
|
||||
install_dwc_packages()
|
||||
{
|
||||
PKGLIST="python3-virtualenv python3-dev python3-tornado"
|
||||
|
||||
# Update system package info
|
||||
status_msg "Running apt-get update..."
|
||||
sudo apt-get update
|
||||
|
||||
# Install desired packages
|
||||
status_msg "Installing packages..."
|
||||
sudo apt-get install --yes ${PKGLIST}
|
||||
}
|
||||
|
||||
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}
|
||||
|
||||
# Install/update dependencies
|
||||
${DWC_ENV}/bin/pip install tornado==6.0.4
|
||||
}
|
||||
|
||||
create_single_dwc_startscript(){
|
||||
### create systemd service file
|
||||
sudo /bin/sh -c "cat > ${SYSTEMDDIR}/dwc.service" << DWC
|
||||
[Unit]
|
||||
Description=DuetWebControl
|
||||
After=network.target
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
[Service]
|
||||
Type=simple
|
||||
User=${USER}
|
||||
RemainAfterExit=yes
|
||||
ExecStart=${DWC_ENV}/bin/python3 ${DWC2FK_DIR}/web_dwc2.py -l ${DWC_LOG} -c ${DWC_CFG}
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
DWC
|
||||
}
|
||||
|
||||
create_multi_dwc_startscript(){
|
||||
### create systemd service file
|
||||
sudo /bin/sh -c "cat > ${SYSTEMDDIR}/dwc-$INSTANCE.service" << DWC
|
||||
[Unit]
|
||||
Description=DuetWebControl
|
||||
After=network.target
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
[Service]
|
||||
Type=simple
|
||||
User=${USER}
|
||||
RemainAfterExit=yes
|
||||
ExecStart=${DWC_ENV}/bin/python3 ${DWC2FK_DIR}/web_dwc2.py -l ${DWC_LOG} -c ${DWC_CFG}
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
DWC
|
||||
}
|
||||
|
||||
create_single_dwcfk_cfg(){
|
||||
### create single instance config file
|
||||
/bin/sh -c "cat > $DWC_CONF_LOC/dwc2.cfg" << DWCCFG
|
||||
[webserver]
|
||||
listen_adress: 0.0.0.0
|
||||
web_root: ${HOME}/duetwebcontrol
|
||||
port: ${PORT}
|
||||
|
||||
[reply_filters]
|
||||
regex:
|
||||
max_accel: \d+.\d+
|
||||
max_accel_to_decel: \d+.\d+
|
||||
square_corner_velocity: \d+.\d+
|
||||
max_velocity: \d+.\d+
|
||||
DWCCFG
|
||||
}
|
||||
|
||||
create_multi_dwcfk_cfg(){
|
||||
### create single instance config file
|
||||
/bin/sh -c "cat > $DWC_CONF_LOC/printer_$INSTANCE/dwc2.cfg" << DWCCFG
|
||||
[webserver]
|
||||
listen_adress: 0.0.0.0
|
||||
web_root: ${HOME}/duetwebcontrol
|
||||
port: ${PORT}
|
||||
|
||||
[reply_filters]
|
||||
regex:
|
||||
max_accel: \d+.\d+
|
||||
max_accel_to_decel: \d+.\d+
|
||||
square_corner_velocity: \d+.\d+
|
||||
max_velocity: \d+.\d+
|
||||
DWCCFG
|
||||
}
|
||||
|
||||
##############################################################################################
|
||||
#********************************************************************************************#
|
||||
##############################################################################################
|
||||
|
||||
print_dwc_ip_list(){
|
||||
i=1
|
||||
for ip in ${dwc_ip_list[@]}; do
|
||||
echo -e " ${cyan}● Instance $i:${default} $ip"
|
||||
i=$((i + 1))
|
||||
done
|
||||
}
|
||||
|
||||
create_single_dwc_instance(){
|
||||
status_msg "Setting up 1 Duet Web Control instance ..."
|
||||
|
||||
### single instance variables
|
||||
DWC_LOG=/tmp/dwc.log
|
||||
DWC_CFG="$DWC_CONF_LOC/dwc2.cfg"
|
||||
|
||||
### create instance
|
||||
status_msg "Creating single DWC instance ..."
|
||||
create_single_dwc_startscript
|
||||
|
||||
### enable instance
|
||||
sudo systemctl enable dwc.service
|
||||
ok_msg "Single DWC instance created!"
|
||||
|
||||
### launching instance
|
||||
status_msg "Launching DWC instance ..."
|
||||
sudo systemctl start dwc
|
||||
|
||||
### confirm message
|
||||
CONFIRM_MSG="Single DWC instance has been set up!"
|
||||
print_msg && clear_msg
|
||||
|
||||
### display moonraker ip to the user
|
||||
print_dwc_ip_list; echo
|
||||
}
|
||||
|
||||
create_multi_dwc_instance(){
|
||||
status_msg "Setting up $INSTANCE_COUNT instances of Duet Web Control ..."
|
||||
while [ $INSTANCE -le $INSTANCE_COUNT ]; do
|
||||
### multi instance variables
|
||||
DWC_LOG=/tmp/dwc-$INSTANCE.log
|
||||
DWC_CFG="$DWC_CONF_LOC/printer_$INSTANCE/dwc2.cfg"
|
||||
|
||||
### create instance
|
||||
status_msg "Creating instance #$INSTANCE ..."
|
||||
create_multi_dwc_startscript
|
||||
|
||||
### enable instance
|
||||
sudo systemctl enable dwc-$INSTANCE.service
|
||||
ok_msg "DWC instance $INSTANCE created!"
|
||||
|
||||
### launching instance
|
||||
status_msg "Launching DWC instance $INSTANCE ..."
|
||||
sudo systemctl start dwc-$INSTANCE
|
||||
|
||||
### instance counter +1
|
||||
INSTANCE=$(expr $INSTANCE + 1)
|
||||
done
|
||||
|
||||
### confirm message
|
||||
CONFIRM_MSG="$INSTANCE_COUNT DWC instances has been set up!"
|
||||
print_msg && clear_msg
|
||||
|
||||
### display moonraker ip to the user
|
||||
print_dwc_ip_list; echo
|
||||
}
|
||||
|
||||
dwc_cfg_creation(){
|
||||
### default dwc port
|
||||
DEFAULT_PORT=4750
|
||||
|
||||
### get printer config directory
|
||||
source_kiauh_ini
|
||||
DWC_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)
|
||||
dwc_ip_list=()
|
||||
|
||||
### create single instance dwc2.cfg 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
|
||||
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
|
||||
create_single_dwcfk_cfg && ok_msg "dwc2.cfg created!"
|
||||
else
|
||||
warn_msg "There is already a file called 'dwc2.cfg'!"
|
||||
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
|
||||
dwc_ip_list+=("$HOSTNAME:$PORT")
|
||||
|
||||
### 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
|
||||
create_multi_dwcfk_cfg && ok_msg "dwc2.cfg created!"
|
||||
else
|
||||
warn_msg "There is already a file called 'dwc2.cfg'!"
|
||||
warn_msg "Skipping..."
|
||||
fi
|
||||
|
||||
### raise instance counter by 1
|
||||
INSTANCE=$(expr $INSTANCE + 1)
|
||||
done
|
||||
if ! [ ${#install[@]} -eq 0 ]; then
|
||||
sudo apt-get install ${install[@]} -y
|
||||
fi
|
||||
}
|
||||
387
scripts/install_klipper.sh
Normal file → Executable file
387
scripts/install_klipper.sh
Normal file → Executable file
@@ -1,30 +1,371 @@
|
||||
install_klipper(){
|
||||
if [ -e /etc/init.d/klipper ] && [ -e /etc/default/klipper ]; then
|
||||
ERROR_MSG=" Looks like klipper is already installed!\n Skipping ..."
|
||||
else
|
||||
#check for dependencies
|
||||
dep=(git)
|
||||
dep_check
|
||||
#execute operation
|
||||
cd ${HOME}
|
||||
status_msg "Cloning klipper repository ..."
|
||||
git clone $KLIPPER_REPO && ok_msg "Klipper successfully cloned!"
|
||||
status_msg "Installing klipper service ..."
|
||||
$KLIPPER_DIR/scripts/install-octopi.sh && sleep 2 && ok_msg "Klipper installation complete!"
|
||||
#create a klippy.log symlink in home-dir just for convenience
|
||||
if [ ! -e ${HOME}/klippy.log ]; then
|
||||
status_msg "Creating klippy.log symlink ..."
|
||||
ln -s /tmp/klippy.log ${HOME}/klippy.log && ok_msg "Symlink created!"
|
||||
### base variables
|
||||
SYSTEMDDIR="/etc/systemd/system"
|
||||
KLIPPY_ENV="${HOME}/klippy-env"
|
||||
KLIPPER_DIR="${HOME}/klipper"
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
### initial printer.cfg path check
|
||||
check_klipper_cfg_path
|
||||
|
||||
### ask for amount of instances to create
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Do you want to flash your MCU now? (Y/n): " yn
|
||||
echo -e "${default}"
|
||||
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
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"") build_fw && flash_routine; break;;
|
||||
N|n|No|no) break;;
|
||||
*) warn_msg "Unknown parameter: $yn"; echo;;
|
||||
Y|y|Yes|yes|"")
|
||||
echo -e "###### > Yes"
|
||||
status_msg "Creating $INSTANCE_COUNT Klipper instances ..."
|
||||
klipper_setup
|
||||
break;;
|
||||
N|n|No|no)
|
||||
echo -e "###### > No"
|
||||
warn_msg "Exiting Klipper setup ..."
|
||||
echo
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
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"
|
||||
|
||||
### Update system package info
|
||||
status_msg "Running apt-get update..."
|
||||
sudo apt-get update
|
||||
|
||||
### Install desired packages
|
||||
status_msg "Installing packages..."
|
||||
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}
|
||||
# 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
|
||||
}
|
||||
|
||||
klipper_setup(){
|
||||
### get printer config directory
|
||||
source_kiauh_ini
|
||||
PRINTER_CFG_LOC="$klipper_cfg_loc"
|
||||
|
||||
### clone klipper
|
||||
cd ${HOME}
|
||||
status_msg "Downloading Klipper ..."
|
||||
[ -d $KLIPPER_DIR ] && rm -rf $KLIPPER_DIR
|
||||
git clone $KLIPPER_REPO
|
||||
status_msg "Download complete!"
|
||||
|
||||
### 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
|
||||
|
||||
### 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
|
||||
|
||||
### confirm message
|
||||
CONFIRM_MSG="Single Klipper instance has been set up!"
|
||||
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 instance
|
||||
status_msg "Creating instance #$INSTANCE ..."
|
||||
create_multi_klipper_startscript
|
||||
|
||||
### 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"
|
||||
|
||||
### enable instance
|
||||
sudo systemctl enable klipper-$INSTANCE.service
|
||||
ok_msg "Klipper instance $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
|
||||
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
|
||||
done
|
||||
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
|
||||
}
|
||||
277
scripts/install_klipper_webui.sh
Executable file
277
scripts/install_klipper_webui.sh
Executable file
@@ -0,0 +1,277 @@
|
||||
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
|
||||
moonraker_chk_ok="true"
|
||||
else
|
||||
moonraker_chk_ok="false"
|
||||
fi
|
||||
}
|
||||
|
||||
get_user_selection_kiauh_macros(){
|
||||
#ask user for webui default macros
|
||||
while true; do
|
||||
unset ADD_KIAUH_MACROS
|
||||
echo
|
||||
top_border
|
||||
echo -e "| It is recommended to have some important macros set |"
|
||||
echo -e "| up in your printer configuration to have $1|"
|
||||
echo -e "| fully functional and working. |"
|
||||
blank_line
|
||||
echo -e "| Those macros are: |"
|
||||
echo -e "| ${cyan}● [gcode_macro PAUSE]${default} |"
|
||||
echo -e "| ${cyan}● [gcode_macro RESUME]${default} |"
|
||||
echo -e "| ${cyan}● [gcode_macro CANCEL_PRINT]${default} |"
|
||||
blank_line
|
||||
echo -e "| If you already have these macros in your config file |"
|
||||
echo -e "| you can skip this step and choose 'no'. |"
|
||||
echo -e "| Otherwise you should consider to answer with 'yes' to |"
|
||||
echo -e "| add the recommended example macros to your config. |"
|
||||
bottom_border
|
||||
read -p "${cyan}###### Add the recommended macros? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
echo -e "###### > Yes"
|
||||
ADD_KIAUH_MACROS="true"
|
||||
break;;
|
||||
N|n|No|no)
|
||||
echo -e "###### > No"
|
||||
ADD_KIAUH_MACROS="false"
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
install_webui(){
|
||||
### check if moonraker is already installed
|
||||
check_moonraker
|
||||
|
||||
[ $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
|
||||
|
||||
### check for other enabled web interfaces
|
||||
unset SET_LISTEN_PORT
|
||||
detect_enabled_sites
|
||||
|
||||
### 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"
|
||||
|
||||
### creating the mainsail/fluidd nginx cfg
|
||||
set_nginx_cfg "$1"
|
||||
|
||||
### copy the kiauh_macros.cfg to the config location
|
||||
install_kiauh_macros
|
||||
|
||||
### install mainsail/fluidd
|
||||
$1_setup
|
||||
}
|
||||
|
||||
install_kiauh_macros(){
|
||||
source_kiauh_ini
|
||||
### copy kiauh_macros.cfg
|
||||
if [ "$ADD_KIAUH_MACROS" = "true" ]; then
|
||||
### 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
|
||||
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
|
||||
### copy kiauh_macros.cfg to config location
|
||||
cp ${SRCDIR}/kiauh/resources/kiauh_macros.cfg $path
|
||||
ok_msg "$path/kiauh_macros.cfg created!"
|
||||
### write the include to the very first line of the printer.cfg
|
||||
sed -i "1 i [include kiauh_macros.cfg]" $path/printer.cfg
|
||||
fi
|
||||
done
|
||||
### handle single printer.cfg
|
||||
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!"
|
||||
### 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
|
||||
fi
|
||||
### restart klipper service to parse the modified printer.cfg
|
||||
klipper_service "restart"
|
||||
fi
|
||||
}
|
||||
|
||||
mainsail_port_check(){
|
||||
if [ "$MAINSAIL_ENABLED" = "false" ]; then
|
||||
if [ "$SITE_ENABLED" = "true" ]; then
|
||||
status_msg "Detected other enabled interfaces:"
|
||||
[ "$OCTOPRINT_ENABLED" = "true" ] && echo -e " ${cyan}● OctoPrint - Port: $OCTOPRINT_PORT${default}"
|
||||
[ "$FLUIDD_ENABLED" = "true" ] && echo -e " ${cyan}● Fluidd - Port: $FLUIDD_PORT${default}"
|
||||
[ "$DWC2_ENABLED" = "true" ] && echo -e " ${cyan}● DWC2 - Port: $DWC2_PORT${default}"
|
||||
if [ "$FLUIDD_PORT" = "80" ] || [ "$DWC2_PORT" = "80" ] || [ "$OCTOPRINT_PORT" = "80" ]; then
|
||||
PORT_80_BLOCKED="true"
|
||||
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)
|
||||
SET_LISTEN_PORT=$DEFAULT_PORT
|
||||
fi
|
||||
SET_NGINX_CFG="true"
|
||||
else
|
||||
SET_NGINX_CFG="false"
|
||||
fi
|
||||
}
|
||||
|
||||
fluidd_port_check(){
|
||||
if [ "$FLUIDD_ENABLED" = "false" ]; then
|
||||
if [ "$SITE_ENABLED" = "true" ]; then
|
||||
status_msg "Detected other enabled interfaces:"
|
||||
[ "$OCTOPRINT_ENABLED" = "true" ] && echo " ${cyan}● OctoPrint - Port: $OCTOPRINT_PORT${default}"
|
||||
[ "$MAINSAIL_ENABLED" = "true" ] && echo " ${cyan}● Mainsail - Port: $MAINSAIL_PORT${default}"
|
||||
[ "$DWC2_ENABLED" = "true" ] && echo " ${cyan}● DWC2 - Port: $DWC2_PORT${default}"
|
||||
if [ "$MAINSAIL_PORT" = "80" ] || [ "$DWC2_PORT" = "80" ] || [ "$OCTOPRINT_PORT" = "80" ]; then
|
||||
PORT_80_BLOCKED="true"
|
||||
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)
|
||||
SET_LISTEN_PORT=$DEFAULT_PORT
|
||||
fi
|
||||
SET_NGINX_CFG="true"
|
||||
else
|
||||
SET_NGINX_CFG="false"
|
||||
fi
|
||||
}
|
||||
|
||||
select_mainsail_port(){
|
||||
if [ "$PORT_80_BLOCKED" = "true" ]; then
|
||||
echo
|
||||
top_border
|
||||
echo -e "| ${red}!!!WARNING!!!${default} |"
|
||||
echo -e "| ${red}You need to choose a different port for Mainsail!${default} |"
|
||||
echo -e "| ${red}The following web interface is listening at port 80:${default} |"
|
||||
blank_line
|
||||
[ "$OCTOPRINT_PORT" = "80" ] && echo "| ● OctoPrint |"
|
||||
[ "$FLUIDD_PORT" = "80" ] && echo "| ● Fluidd |"
|
||||
[ "$DWC2_PORT" = "80" ] && echo "| ● DWC2 |"
|
||||
blank_line
|
||||
echo -e "| Make sure you don't choose a port which was already |"
|
||||
echo -e "| assigned to one of the other webinterfaces and do ${red}NOT${default} |"
|
||||
echo -e "| use ports in the range of 4750 or above! |"
|
||||
blank_line
|
||||
echo -e "| Be aware: there is ${red}NO${default} sanity check for the following |"
|
||||
echo -e "| input. So make sure to choose a valid port! |"
|
||||
bottom_border
|
||||
while true; do
|
||||
read -p "${cyan}Please enter a new Port:${default} " NEW_PORT
|
||||
if [ "$NEW_PORT" != "$FLUIDD_PORT" ] && [ "$NEW_PORT" != "$DWC2_PORT" ] && [ "$NEW_PORT" != "$OCTOPRINT_PORT" ]; then
|
||||
echo "Setting port $NEW_PORT for Mainsail!"
|
||||
SET_LISTEN_PORT=$NEW_PORT
|
||||
break
|
||||
else
|
||||
echo "That port is already taken! Select a different one!"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
select_fluidd_port(){
|
||||
if [ "$PORT_80_BLOCKED" = "true" ]; then
|
||||
echo
|
||||
top_border
|
||||
echo -e "| ${red}!!!WARNING!!!${default} |"
|
||||
echo -e "| ${red}You need to choose a different port for Fluidd!${default} |"
|
||||
echo -e "| ${red}The following web interface is listening at port 80:${default} |"
|
||||
blank_line
|
||||
[ "$OCTOPRINT_PORT" = "80" ] && echo "| ● OctoPrint |"
|
||||
[ "$MAINSAIL_PORT" = "80" ] && echo "| ● Mainsail |"
|
||||
[ "$DWC2_PORT" = "80" ] && echo "| ● DWC2 |"
|
||||
blank_line
|
||||
echo -e "| Make sure you don't choose a port which was already |"
|
||||
echo -e "| assigned to one of the other webinterfaces and do ${red}NOT${default} |"
|
||||
echo -e "| use ports in the range of 4750 or above! |"
|
||||
blank_line
|
||||
echo -e "| Be aware: there is ${red}NO${default} sanity check for the following |"
|
||||
echo -e "| input. So make sure to choose a valid port! |"
|
||||
bottom_border
|
||||
while true; do
|
||||
read -p "${cyan}Please enter a new Port:${default} " NEW_PORT
|
||||
if [ "$NEW_PORT" != "$MAINSAIL_PORT" ] && [ "$NEW_PORT" != "$DWC2_PORT" ] && [ "$NEW_PORT" != "$OCTOPRINT_PORT" ]; then
|
||||
echo "Setting port $NEW_PORT for Fluidd!"
|
||||
SET_LISTEN_PORT=$NEW_PORT
|
||||
break
|
||||
else
|
||||
echo "That port is already taken! Select a different one!"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
get_mainsail_ver(){
|
||||
MAINSAIL_VERSION=$(curl -s https://api.github.com/repositories/240875926/releases | 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)
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
### remove existing and create fresh mainsail folder, then download mainsail
|
||||
[ -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!"
|
||||
|
||||
### extract archive
|
||||
status_msg "Extracting archive ..."
|
||||
unzip -q -o *.zip && ok_msg "Done!"
|
||||
|
||||
### delete downloaded zip
|
||||
status_msg "Remove downloaded archive ..."
|
||||
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
|
||||
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
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
### remove existing and create fresh fluidd folder, then download fluidd
|
||||
[ -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!"
|
||||
|
||||
### extract archive
|
||||
status_msg "Extracting archive ..."
|
||||
unzip -q -o *.zip && ok_msg "Done!"
|
||||
|
||||
### delete downloaded zip
|
||||
status_msg "Remove downloaded archive ..."
|
||||
rm -rf *.zip && ok_msg "Done!" && ok_msg "Fluidd installation complete!"
|
||||
echo
|
||||
}
|
||||
85
scripts/install_klipperscreen.sh
Executable file
85
scripts/install_klipperscreen.sh
Executable file
@@ -0,0 +1,85 @@
|
||||
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
|
||||
ERROR_MSG="Python 3.7 or above required!\n Please upgrade your Python version first."
|
||||
print_msg && clear_msg
|
||||
fi
|
||||
}
|
||||
|
||||
python3_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!"
|
||||
py_chk_ok="true"
|
||||
else
|
||||
py_chk_ok="false"
|
||||
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
|
||||
[ -d $KLIPPERSCREEN_DIR ] && rm -rf $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
|
||||
}
|
||||
@@ -1,349 +0,0 @@
|
||||
mainsail_install_routine(){
|
||||
if [ -d $KLIPPER_DIR ]; then
|
||||
#check for dependencies
|
||||
dep=(wget curl unzip)
|
||||
dep_check
|
||||
#execute operation
|
||||
install_moonraker
|
||||
disable_wrong_webserver
|
||||
remove_wrong_webserver
|
||||
install_nginx
|
||||
test_api
|
||||
test_nginx
|
||||
install_mainsail && ok_msg "Mainsail install complete!"; echo
|
||||
else
|
||||
ERROR_MSG=" Please install Klipper first!\n Skipping..."
|
||||
fi
|
||||
}
|
||||
|
||||
install_moonraker(){
|
||||
cd $KLIPPER_DIR
|
||||
if [[ $(git describe --all) = "remotes/Arksine/work-web_server-20200131" ]]; then
|
||||
status_msg "Installing Moonraker ..."
|
||||
$KLIPPER_DIR/scripts/install-moonraker.sh && ok_msg "Moonraker successfully installed!"
|
||||
if [ ! -d ${HOME}/sdcard ]; then
|
||||
mkdir ${HOME}/sdcard
|
||||
fi
|
||||
#create a moonraker.log symlink in home-dir just for convenience
|
||||
if [ ! -e ${HOME}/moonraker.log ]; then
|
||||
status_msg "Creating moonraker.log symlink ..."
|
||||
ln -s /tmp/moonraker.log ${HOME}/moonraker.log && ok_msg "Symlink created!"
|
||||
fi
|
||||
else
|
||||
warn_msg "You are not using Arksine/work-web_server-20200131."
|
||||
warn_msg "Please switch to the moonraker fork first!"
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Do you want to switch to it now? (Y/n): " yn
|
||||
echo -e "${default}"
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"") switch_to_moonraker && install_moonraker; break;;
|
||||
N|n|No|no) break;;
|
||||
*) echo "Unknown parameter: $yn"; echo;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
check_printer_cfg(){
|
||||
if [ ! -e $PRINTER_CFG ]; then
|
||||
warn_msg "No printer.cfg found"
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Do you want to create a default config? (Y/n): " yn
|
||||
echo -e "${default}"
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"") create_default_cfg; break;;
|
||||
N|n|No|no) break;;
|
||||
*) echo "Unknown parameter: $yn"; echo;;
|
||||
esac
|
||||
done
|
||||
else
|
||||
check_vsdcard_section
|
||||
check_api_section
|
||||
fi
|
||||
}
|
||||
|
||||
disable_wrong_webserver(){
|
||||
if systemctl is-active haproxy ; then
|
||||
status_msg "Stopping haproxy service ..."
|
||||
sudo /etc/init.d/haproxy stop && ok_msg "Service stopped!"
|
||||
fi
|
||||
if systemctl is-active lighttpd ; then
|
||||
status_msg "Stopping lighttpd service ..."
|
||||
sudo /etc/init.d/lighttpd stop && ok_msg "Service stopped!"
|
||||
fi
|
||||
}
|
||||
|
||||
remove_wrong_webserver(){
|
||||
rem=(haproxy lighttpd)
|
||||
for remove in "${rem[@]}"
|
||||
do
|
||||
if [[ $(dpkg-query -f'${Status}' --show $remove 2>/dev/null) = *\ installed ]]; then
|
||||
delete+=($remove)
|
||||
fi
|
||||
done
|
||||
if ! [ ${#delete[@]} -eq 0 ]; then
|
||||
sudo apt-get remove ${delete[@]} -y
|
||||
fi
|
||||
}
|
||||
|
||||
install_nginx(){
|
||||
if ! [[ $(dpkg-query -f'${Status}' --show nginx 2>/dev/null) = *\ installed ]]; then
|
||||
status_msg "Installing Nginx ..."
|
||||
sudo apt-get install nginx -y && ok_msg "Nginx successfully installed!"
|
||||
fi
|
||||
if [ ! -d $MAINSAIL_DIR ]; then
|
||||
mkdir $MAINSAIL_DIR
|
||||
fi
|
||||
status_msg "Configure Nginx ..."
|
||||
create_mainsail_cfgfile && sudo mv $MAINSAIL_DIR/mainsail /etc/nginx/sites-available/
|
||||
if [ -e /etc/nginx/sites-enabled/default ]; then
|
||||
sudo rm /etc/nginx/sites-enabled/default
|
||||
fi
|
||||
if [ ! -e /etc/nginx/sites-enabled/mainsail ]; then
|
||||
sudo ln -s /etc/nginx/sites-available/mainsail /etc/nginx/sites-enabled/
|
||||
fi
|
||||
ok_msg "Nginx configured!"
|
||||
}
|
||||
|
||||
test_api(){
|
||||
status_msg "Testing API ..."
|
||||
sleep 5
|
||||
status_msg "API response from http://localhost:7125/printer/info:"
|
||||
API_RESPONSE="$(curl -sG4 http://localhost:7125/printer/info)"
|
||||
echo -e "${cyan}$API_RESPONSE${default}"
|
||||
if [ $(curl -sG4 "http://localhost:7125/printer/info" | grep '^{"result"' -c) -eq 1 ]; then
|
||||
echo; ok_msg "Klipper API is working correctly!"; echo
|
||||
else
|
||||
echo; warn_msg "Klipper API not working correctly!"; echo
|
||||
fi
|
||||
}
|
||||
|
||||
test_nginx(){
|
||||
sudo /etc/init.d/nginx restart
|
||||
status_msg "Testing Nginx ..."
|
||||
sleep 5
|
||||
status_msg "API response from http://localhost/printer/info:"
|
||||
API_RESPONSE="$(curl -sG4 http://localhost/printer/info)"
|
||||
echo -e "${cyan}$API_RESPONSE${default}"
|
||||
if [ $(curl -sG4 "http://localhost/printer/info" | grep '^{"result"' -c) -eq 1 ]; then
|
||||
echo; ok_msg "Nginx is working correctly!"; echo
|
||||
else
|
||||
echo; warn_msg "Nginx is not working correctly!"; echo
|
||||
fi
|
||||
}
|
||||
|
||||
get_mainsail_ver(){
|
||||
MAINSAIL_VERSION=`curl -s https://api.github.com/repositories/240875926/tags | grep name | cut -d'"' -f4 | cut -d"v" -f2 | head -1`
|
||||
}
|
||||
|
||||
mainsail_dl_url(){
|
||||
get_mainsail_ver
|
||||
MAINSAIL_URL=https://github.com/meteyou/mainsail/releases/download/v"$MAINSAIL_VERSION"/mainsail-alpha-"$MAINSAIL_VERSION".zip
|
||||
}
|
||||
|
||||
install_mainsail(){
|
||||
mainsail_dl_url
|
||||
if [ ! -d $MAINSAIL_DIR ]; then
|
||||
mkdir $MAINSAIL_DIR
|
||||
fi
|
||||
cd $MAINSAIL_DIR
|
||||
status_msg "Downloading Mainsail v$MAINSAIL_VERSION ..."
|
||||
wget -q -O mainsail.zip $MAINSAIL_URL && status_msg "Extracting archive ..." && unzip -o mainsail.zip && rm mainsail.zip
|
||||
### write mainsail version to file for update check reasons
|
||||
echo "$MAINSAIL_VERSION" > $MAINSAIL_DIR/version
|
||||
}
|
||||
|
||||
create_mainsail_cfgfile(){
|
||||
cat <<MAINSAIL_CFG > $MAINSAIL_DIR/mainsail
|
||||
map \$http_upgrade \$connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
upstream apiserver {
|
||||
#edit your api port here
|
||||
ip_hash;
|
||||
server 127.0.0.1:7125;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
|
||||
access_log /var/log/nginx/mainsail-access.log;
|
||||
error_log /var/log/nginx/mainsail-error.log;
|
||||
|
||||
#web_path from mainsail static files
|
||||
root /home/pi/mainsail;
|
||||
|
||||
index index.html;
|
||||
server_name _;
|
||||
|
||||
#max upload size for gcodes
|
||||
client_max_body_size 200M;
|
||||
|
||||
location / {
|
||||
try_files \$uri \$uri/ /index.html;
|
||||
}
|
||||
|
||||
location /printer {
|
||||
proxy_pass http://apiserver/printer;
|
||||
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;
|
||||
proxy_set_header X-Scheme \$scheme;
|
||||
}
|
||||
|
||||
location /api {
|
||||
proxy_pass http://apiserver/api;
|
||||
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;
|
||||
proxy_set_header X-Scheme \$scheme;
|
||||
}
|
||||
|
||||
location /access {
|
||||
proxy_pass http://apiserver/access;
|
||||
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;
|
||||
proxy_set_header X-Scheme \$scheme;
|
||||
}
|
||||
|
||||
location /websocket {
|
||||
proxy_pass http://apiserver/websocket;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade \$http_upgrade;
|
||||
proxy_set_header Connection \$connection_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;
|
||||
proxy_read_timeout 86400;
|
||||
}
|
||||
|
||||
location /machine {
|
||||
proxy_pass http://apiserver/machine;
|
||||
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;
|
||||
proxy_set_header X-Scheme \$scheme;
|
||||
}
|
||||
|
||||
location /server {
|
||||
proxy_pass http://apiserver/server;
|
||||
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;
|
||||
proxy_set_header X-Scheme \$scheme;
|
||||
}
|
||||
}
|
||||
MAINSAIL_CFG
|
||||
}
|
||||
|
||||
check_vsdcard_section(){
|
||||
# check if virtual sdcard is present in printer.cfg
|
||||
if [ $(grep '^\[virtual_sdcard\]$' /home/pi/printer.cfg) ]; then
|
||||
echo "Virtual sdcard already configured"
|
||||
else
|
||||
echo "No virtual sdcard entry found..."
|
||||
echo "Configuring virtual sdcard..."
|
||||
# append the following lines to printer.cfg
|
||||
cat <<VSDCARD >> $PRINTER_CFG
|
||||
|
||||
##########################
|
||||
### CREATED WITH KIAUH ###
|
||||
##########################
|
||||
[virtual_sdcard]
|
||||
path: ~/sdcard
|
||||
##########################
|
||||
##########################
|
||||
VSDCARD
|
||||
fi
|
||||
}
|
||||
|
||||
check_api_section(){
|
||||
# check if api server is present in printer.cfg
|
||||
if [ $(grep '^\[api_server\]$' /home/pi/printer.cfg) ]; then
|
||||
echo "API server already configured"
|
||||
else
|
||||
echo "No API server entry found..."
|
||||
echo "Configuring API server..."
|
||||
# append the following lines to printer.cfg
|
||||
cat <<API >> $PRINTER_CFG
|
||||
|
||||
##########################
|
||||
### CREATED WITH KIAUH ###
|
||||
##########################
|
||||
[api_server]
|
||||
trusted_clients:
|
||||
192.168.0.0/24
|
||||
192.168.1.0/24
|
||||
127.0.0.0/24
|
||||
##########################
|
||||
##########################
|
||||
API
|
||||
fi
|
||||
}
|
||||
|
||||
create_default_cfg(){
|
||||
cat <<MAINSAIL_CFG >> $PRINTER_CFG
|
||||
|
||||
##########################
|
||||
### CREATED WITH KIAUH ###
|
||||
##########################
|
||||
[virtual_sdcard]
|
||||
path: ~/sdcard
|
||||
|
||||
[api_server]
|
||||
trusted_clients:
|
||||
192.168.0.0/24
|
||||
192.168.1.0/24
|
||||
127.0.0.0/24
|
||||
|
||||
[pause_resume]
|
||||
|
||||
[gcode_macro CANCEL]
|
||||
default_parameter_X: 230
|
||||
default_parameter_Y: 230
|
||||
default_parameter_Z: 10
|
||||
gcode:
|
||||
M104 S0
|
||||
M140 S0
|
||||
M141 S0
|
||||
M106 S0
|
||||
CLEAR_PAUSE
|
||||
RESET_SD
|
||||
|
||||
[gcode_macro CANCEL_PRINT]
|
||||
gcode:
|
||||
CANCEL
|
||||
|
||||
[gcode_macro PAUSE]
|
||||
rename_existing: BASE_PAUSE
|
||||
default_parameter_X: 230
|
||||
default_parameter_Y: 230
|
||||
default_parameter_Z: 10
|
||||
gcode:
|
||||
SAVE_GCODE_STATE NAME=PAUSE_state
|
||||
BASE_PAUSE
|
||||
G91
|
||||
G1 E-1.7 F2100
|
||||
G1 Z{Z}
|
||||
G90
|
||||
G1 X{X} Y{Y} F6000
|
||||
G91
|
||||
|
||||
[gcode_macro RESUME]
|
||||
rename_existing: BASE_RESUME
|
||||
gcode:
|
||||
G91
|
||||
G1 E1.7 F2100
|
||||
G91
|
||||
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
|
||||
BASE_RESUME
|
||||
##########################
|
||||
##########################
|
||||
MAINSAIL_CFG
|
||||
}
|
||||
598
scripts/install_moonraker.sh
Executable file
598
scripts/install_moonraker.sh
Executable file
@@ -0,0 +1,598 @@
|
||||
### base variables
|
||||
SYSTEMDDIR="/etc/systemd/system"
|
||||
MOONRAKER_ENV="${HOME}/moonraker-env"
|
||||
MOONRAKER_DIR="${HOME}/moonraker"
|
||||
|
||||
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!"
|
||||
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
|
||||
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
|
||||
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)
|
||||
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
|
||||
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
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
echo -e "###### > Yes"
|
||||
status_msg "Creating $INSTANCE_COUNT Moonraker instances ..."
|
||||
moonraker_setup
|
||||
break;;
|
||||
N|n|No|no)
|
||||
echo -e "###### > No"
|
||||
warn_msg "Exiting Moonraker setup ..."
|
||||
echo
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
moonraker_setup(){
|
||||
### get printer config directory
|
||||
source_kiauh_ini
|
||||
MOONRAKER_CONF_LOC="$klipper_cfg_loc"
|
||||
|
||||
### checking dependencies
|
||||
dep=(wget curl unzip dfu-util)
|
||||
### additional deps for kiauh compatibility for armbian
|
||||
dep+=(libjpeg-dev zlib1g-dev)
|
||||
dependency_check
|
||||
|
||||
### 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
|
||||
ok_msg "Download complete!"
|
||||
|
||||
### step 2: install moonraker dependencies and create python virtualenv
|
||||
status_msg "Installing dependencies ..."
|
||||
install_moonraker_packages
|
||||
create_moonraker_virtualenv
|
||||
|
||||
### step 3: create moonraker.conf folder and moonraker.confs
|
||||
[ ! -d $MOONRAKER_CONF_LOC ] && mkdir -p $MOONRAKER_CONF_LOC
|
||||
moonraker_conf_creation
|
||||
|
||||
### step 4: set up moonrakers nginx configs
|
||||
setup_moonraker_nginx_cfg
|
||||
|
||||
### step 5: process possible disruptive services
|
||||
process_haproxy_lighttpd_services
|
||||
|
||||
### 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
|
||||
}
|
||||
|
||||
##############################################################################################
|
||||
#********************************************************************************************#
|
||||
##############################################################################################
|
||||
|
||||
install_moonraker_packages(){
|
||||
PKGLIST="python3-virtualenv python3-dev nginx libopenjp2-7 python3-libgpiod"
|
||||
|
||||
### Update system package info
|
||||
status_msg "Running apt-get update..."
|
||||
sudo apt-get update
|
||||
|
||||
### Install desired packages
|
||||
status_msg "Installing packages..."
|
||||
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
|
||||
status_msg "Removing old virtualenv"
|
||||
rm -rf ${MOONRAKER_ENV}
|
||||
fi
|
||||
|
||||
[ ! -d ${MOONRAKER_ENV} ] && virtualenv -p /usr/bin/python3 --system-site-packages ${MOONRAKER_ENV}
|
||||
|
||||
### Install/update dependencies
|
||||
${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_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_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
|
||||
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)
|
||||
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
|
||||
}
|
||||
276
scripts/install_octoprint.sh
Executable file
276
scripts/install_octoprint.sh
Executable file
@@ -0,0 +1,276 @@
|
||||
### base variables
|
||||
SYSTEMDDIR="/etc/systemd/system"
|
||||
OCTOPRINT_ENV="${HOME}/OctoPrint"
|
||||
|
||||
octoprint_setup_dialog(){
|
||||
status_msg "Initializing OctoPrint installation ..."
|
||||
|
||||
### 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)
|
||||
fi
|
||||
|
||||
### instance confirmation dialog
|
||||
while true; do
|
||||
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 OctoPrint instance per Klipper instance. | "
|
||||
bottom_border
|
||||
echo
|
||||
read -p "${cyan}###### Create $INSTANCE_COUNT OctoPrint instances? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
echo -e "###### > Yes"
|
||||
status_msg "Creating $INSTANCE_COUNT OctoPrint instances ..."
|
||||
octoprint_setup
|
||||
break;;
|
||||
N|n|No|no)
|
||||
echo -e "###### > No"
|
||||
warn_msg "Exiting OctoPrint setup ..."
|
||||
echo
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
octoprint_dependencies(){
|
||||
dep=(
|
||||
git
|
||||
wget
|
||||
python-pip
|
||||
python-dev
|
||||
libyaml-dev
|
||||
build-essential
|
||||
python-setuptools
|
||||
python-virtualenv
|
||||
)
|
||||
dependency_check
|
||||
}
|
||||
|
||||
octoprint_setup(){
|
||||
### check and install all dependencies
|
||||
octoprint_dependencies
|
||||
|
||||
### add user to usergroups and add reboot permissions
|
||||
add_to_groups
|
||||
add_reboot_permission
|
||||
|
||||
### create and activate the virtualenv
|
||||
[ ! -d $OCTOPRINT_ENV ] && mkdir -p $OCTOPRINT_ENV
|
||||
status_msg "Set up virtualenv ..."
|
||||
cd $OCTOPRINT_ENV
|
||||
virtualenv venv
|
||||
source venv/bin/activate
|
||||
|
||||
### install octoprint with pip
|
||||
status_msg "Download and install OctoPrint ..."
|
||||
pip install pip --upgrade
|
||||
pip install --no-cache-dir octoprint
|
||||
ok_msg "Download complete!"
|
||||
|
||||
### leave virtualenv
|
||||
deactivate
|
||||
|
||||
### set up instances
|
||||
INSTANCE=1
|
||||
if [ $INSTANCE_COUNT -eq $INSTANCE ]; then
|
||||
create_single_octoprint_instance
|
||||
else
|
||||
create_multi_octoprint_instance
|
||||
fi
|
||||
}
|
||||
|
||||
add_to_groups(){
|
||||
if [ ! "$(groups | grep tty)" ]; then
|
||||
status_msg "Adding user '${USER}' to group 'tty' ..."
|
||||
sudo usermod -a -G tty ${USER} && ok_msg "Done!"
|
||||
fi
|
||||
if [ ! "$(groups | grep dialout)" ]; then
|
||||
status_msg "Adding user '${USER}' to group 'dialout' ..."
|
||||
sudo usermod -a -G dialout ${USER} && ok_msg "Done!"
|
||||
fi
|
||||
}
|
||||
|
||||
create_single_octoprint_startscript(){
|
||||
### create single instance systemd service file
|
||||
sudo /bin/sh -c "cat > ${SYSTEMDDIR}/octoprint.service" << OCTOPRINT
|
||||
[Unit]
|
||||
Description=Starts OctoPrint on startup
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Environment="LC_ALL=C.UTF-8"
|
||||
Environment="LANG=C.UTF-8"
|
||||
Type=simple
|
||||
User=$USER
|
||||
ExecStart=${OCTOPRINT_ENV}/venv/bin/octoprint --basedir ${BASEDIR} --config ${CONFIG_YAML} --port=${PORT} serve
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
OCTOPRINT
|
||||
}
|
||||
|
||||
create_multi_octoprint_startscript(){
|
||||
### create multi instance systemd service file
|
||||
sudo /bin/sh -c "cat > ${SYSTEMDDIR}/octoprint-$INSTANCE.service" << OCTOPRINT
|
||||
[Unit]
|
||||
Description=Starts OctoPrint instance $INSTANCE on startup
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Environment="LC_ALL=C.UTF-8"
|
||||
Environment="LANG=C.UTF-8"
|
||||
Type=simple
|
||||
User=$USER
|
||||
ExecStart=${OCTOPRINT_ENV}/venv/bin/octoprint --basedir ${BASEDIR} --config ${CONFIG_YAML} --port=${PORT} serve
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
OCTOPRINT
|
||||
}
|
||||
|
||||
create_config_yaml(){
|
||||
### create multi instance config.yaml file
|
||||
/bin/sh -c "cat > ${BASEDIR}/config.yaml" << CONFIGYAML
|
||||
serial:
|
||||
additionalPorts:
|
||||
- ${TMP_PRINTER}
|
||||
disconnectOnErrors: false
|
||||
port: ${TMP_PRINTER}
|
||||
server:
|
||||
commands:
|
||||
serverRestartCommand: ${RESTART_COMMAND}
|
||||
systemRestartCommand: sudo shutdown -r now
|
||||
systemShutdownCommand: sudo shutdown -h now
|
||||
CONFIGYAML
|
||||
}
|
||||
|
||||
create_single_octoprint_instance(){
|
||||
status_msg "Setting up 1 OctoPrint instance ..."
|
||||
|
||||
### single instance variables
|
||||
PORT=5000
|
||||
BASEDIR="${HOME}/.octoprint"
|
||||
TMP_PRINTER="/tmp/printer"
|
||||
CONFIG_YAML="$BASEDIR/config.yaml"
|
||||
RESTART_COMMAND="sudo service octoprint restart"
|
||||
|
||||
### declare empty array for ips which get displayed to the user at the end of the setup
|
||||
HOSTNAME=$(hostname -I | cut -d" " -f1)
|
||||
op_ip_list=()
|
||||
|
||||
### create instance
|
||||
status_msg "Creating single OctoPrint instance ..."
|
||||
create_single_octoprint_startscript
|
||||
op_ip_list+=("$HOSTNAME:$PORT")
|
||||
|
||||
### create the config.yaml
|
||||
if [ ! -f $BASEDIR/config.yaml ]; then
|
||||
status_msg "Creating config.yaml ..."
|
||||
[ ! -d $BASEDIR ] && mkdir $BASEDIR
|
||||
create_config_yaml
|
||||
ok_msg "Config created!"
|
||||
fi
|
||||
|
||||
### enable instance
|
||||
sudo systemctl enable octoprint.service
|
||||
ok_msg "Single OctoPrint instance created!"
|
||||
|
||||
### launching instance
|
||||
status_msg "Launching OctoPrint instance ..."
|
||||
sudo systemctl start octoprint
|
||||
|
||||
### confirm message
|
||||
CONFIRM_MSG="Single OctoPrint instance has been set up!"
|
||||
print_msg && clear_msg
|
||||
|
||||
### display all octoprint ips to the user
|
||||
print_op_ip_list; echo
|
||||
}
|
||||
|
||||
create_multi_octoprint_instance(){
|
||||
status_msg "Setting up $INSTANCE_COUNT instances of OctoPrint ..."
|
||||
|
||||
### declare empty array for ips which get displayed to the user at the end of the setup
|
||||
HOSTNAME=$(hostname -I | cut -d" " -f1)
|
||||
op_ip_list=()
|
||||
|
||||
### default port
|
||||
PORT=5000
|
||||
|
||||
while [ $INSTANCE -le $INSTANCE_COUNT ]; do
|
||||
### multi instance variables
|
||||
BASEDIR="${HOME}/.octoprint-$INSTANCE"
|
||||
TMP_PRINTER="/tmp/printer-$INSTANCE"
|
||||
CONFIG_YAML="$BASEDIR/config.yaml"
|
||||
RESTART_COMMAND="sudo service octoprint restart"
|
||||
|
||||
### create instance
|
||||
status_msg "Creating instance #$INSTANCE ..."
|
||||
create_multi_octoprint_startscript
|
||||
op_ip_list+=("$HOSTNAME:$PORT")
|
||||
|
||||
### create the config.yaml
|
||||
if [ ! -f $BASEDIR/config.yaml ]; then
|
||||
status_msg "Creating config.yaml for instance #$INSTANCE..."
|
||||
[ ! -d $BASEDIR ] && mkdir $BASEDIR
|
||||
create_config_yaml
|
||||
ok_msg "Config #$INSTANCE created!"
|
||||
fi
|
||||
|
||||
### enable instance
|
||||
sudo systemctl enable octoprint-$INSTANCE.service
|
||||
ok_msg "OctoPrint instance $INSTANCE created!"
|
||||
|
||||
### launching instance
|
||||
status_msg "Launching OctoPrint instance $INSTANCE ..."
|
||||
sudo systemctl start octoprint-$INSTANCE
|
||||
|
||||
### instance counter +1
|
||||
INSTANCE=$(expr $INSTANCE + 1)
|
||||
|
||||
### port +1
|
||||
PORT=$(expr $PORT + 1)
|
||||
done
|
||||
|
||||
### confirm message
|
||||
CONFIRM_MSG="$INSTANCE_COUNT OctoPrint instances have been set up!"
|
||||
print_msg && clear_msg
|
||||
|
||||
### display all moonraker ips to the user
|
||||
print_op_ip_list; echo
|
||||
}
|
||||
|
||||
add_reboot_permission(){
|
||||
USER=${USER}
|
||||
#create a backup when file already exists
|
||||
if [ -f /etc/sudoers.d/octoprint-shutdown ]; then
|
||||
sudo mv /etc/sudoers.d/octoprint-shutdown /etc/sudoers.d/octoprint-shutdown.old
|
||||
fi
|
||||
#create new permission file
|
||||
status_msg "Add reboot permission to user '$USER' ..."
|
||||
cd ${HOME} && echo "$USER ALL=NOPASSWD: /sbin/shutdown" > octoprint-shutdown
|
||||
sudo chown 0 octoprint-shutdown
|
||||
sudo mv octoprint-shutdown /etc/sudoers.d/octoprint-shutdown
|
||||
ok_msg "Permission set!"
|
||||
}
|
||||
|
||||
print_op_ip_list(){
|
||||
i=1
|
||||
for ip in ${op_ip_list[@]}; do
|
||||
echo -e " ${cyan}● Instance $i:${default} $ip"
|
||||
i=$((i + 1))
|
||||
done
|
||||
}
|
||||
172
scripts/network_functions.sh
Executable file
172
scripts/network_functions.sh
Executable file
@@ -0,0 +1,172 @@
|
||||
set_nginx_cfg(){
|
||||
if [ "$SET_NGINX_CFG" = "true" ]; then
|
||||
#check for dependencies
|
||||
dep=(nginx)
|
||||
dependency_check
|
||||
#execute operations
|
||||
status_msg "Creating Nginx configuration for $1 ..."
|
||||
#copy content from resources to the respective nginx config file
|
||||
cat ${SRCDIR}/kiauh/resources/klipper_webui_nginx.cfg > ${SRCDIR}/kiauh/resources/$1
|
||||
##edit the nginx config file before moving it
|
||||
sed -i "s/<<UI>>/$1/g" ${SRCDIR}/kiauh/resources/$1
|
||||
if [ "$SET_LISTEN_PORT" != "$DEFAULT_PORT" ]; then
|
||||
status_msg "Configuring port for $1 ..."
|
||||
#set listen port ipv4
|
||||
sed -i "s/listen\s[0-9]*;/listen $SET_LISTEN_PORT;/" ${SRCDIR}/kiauh/resources/$1
|
||||
#set listen port ipv6
|
||||
sed -i "s/listen\s\[\:*\]\:[0-9]*;/listen \[::\]\:$SET_LISTEN_PORT;/" ${SRCDIR}/kiauh/resources/$1
|
||||
fi
|
||||
#set correct user
|
||||
if [ "$1" = "mainsail" ] || [ "$1" = "fluidd" ]; then
|
||||
sudo sed -i "/root/s/pi/${USER}/" ${SRCDIR}/kiauh/resources/$1
|
||||
fi
|
||||
#moving the config file into correct directory
|
||||
sudo mv ${SRCDIR}/kiauh/resources/$1 /etc/nginx/sites-available/$1
|
||||
ok_msg "Nginx configuration for $1 was set!"
|
||||
if [ "$SET_LISTEN_PORT" != "" ]; then
|
||||
ok_msg "$1 listening on port $SET_LISTEN_PORT!"
|
||||
else
|
||||
ok_msg "$1 listening on default port $DEFAULT_PORT!"
|
||||
fi
|
||||
#remove nginx default config
|
||||
[ -e /etc/nginx/sites-enabled/default ] && sudo rm /etc/nginx/sites-enabled/default
|
||||
#create symlink for own sites
|
||||
[ ! -e /etc/nginx/sites-enabled/$1 ] && sudo ln -s /etc/nginx/sites-available/$1 /etc/nginx/sites-enabled/
|
||||
restart_nginx
|
||||
fi
|
||||
}
|
||||
|
||||
read_listen_port(){
|
||||
LISTEN_PORT=$(grep listen /etc/nginx/sites-enabled/$1 | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
|
||||
}
|
||||
|
||||
detect_enabled_sites(){
|
||||
#check if there is another UI config already installed
|
||||
#and reads the port they are listening on
|
||||
if [ -e /etc/nginx/sites-enabled/mainsail ]; then
|
||||
SITE_ENABLED="true" && MAINSAIL_ENABLED="true"
|
||||
read_listen_port "mainsail"
|
||||
MAINSAIL_PORT=$LISTEN_PORT
|
||||
#echo "debug: Mainsail listens on port: $MAINSAIL_PORT"
|
||||
else
|
||||
MAINSAIL_ENABLED="false"
|
||||
fi
|
||||
if [ -e /etc/nginx/sites-enabled/fluidd ]; then
|
||||
SITE_ENABLED="true" && FLUIDD_ENABLED="true"
|
||||
read_listen_port "fluidd"
|
||||
FLUIDD_PORT=$LISTEN_PORT
|
||||
#echo "debug: Fluidd listens on port: $FLUIDD_PORT"
|
||||
else
|
||||
FLUIDD_ENABLED="false"
|
||||
fi
|
||||
if [ -e /etc/nginx/sites-enabled/dwc2 ]; then
|
||||
SITE_ENABLED="true" && DWC2_ENABLED="true"
|
||||
read_listen_port "dwc2"
|
||||
DWC2_PORT=$LISTEN_PORT
|
||||
#echo "debug: DWC2 listens on port: $DWC2_PORT"
|
||||
else
|
||||
DWC2_ENABLED="false"
|
||||
fi
|
||||
if [ -e /etc/nginx/sites-enabled/octoprint ]; then
|
||||
SITE_ENABLED="true" && OCTOPRINT_ENABLED="true"
|
||||
read_listen_port "octoprint"
|
||||
OCTOPRINT_PORT=$LISTEN_PORT
|
||||
#echo "debug: OctoPrint listens on port: $OCTOPRINT_PORT"
|
||||
else
|
||||
OCTOPRINT_ENABLED="false"
|
||||
fi
|
||||
}
|
||||
|
||||
create_custom_hostname(){
|
||||
echo
|
||||
top_border
|
||||
echo -e "| You can change the hostname of this machine to use |"
|
||||
echo -e "| that name to open the Interface in your browser. |"
|
||||
echo -e "| |"
|
||||
echo -e "| E.g.: If you set the hostname to 'my-printer' you |"
|
||||
echo -e "| can open DWC2/Mainsail/Fluidd/Octoprint by |"
|
||||
echo -e "| browsing to: http://my-printer.local |"
|
||||
bottom_border
|
||||
while true; do
|
||||
read -p "${cyan}###### Do you want to change the hostname? (y/N):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes)
|
||||
user_input_hostname
|
||||
break;;
|
||||
N|n|No|no|"") break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
user_input_hostname(){
|
||||
unset NEW_HOSTNAME
|
||||
unset HOSTNAME_VALID
|
||||
unset HOSTENAME_CONFIRM
|
||||
echo
|
||||
top_border
|
||||
echo -e "| ${green}Allowed characters: a-z, 0-9 and single '-'${default} |"
|
||||
echo -e "| ${red}No special characters allowed!${default} |"
|
||||
echo -e "| ${red}No leading or trailing '-' allowed!${default} |"
|
||||
bottom_border
|
||||
while true; do
|
||||
read -p "${cyan}###### Please set the new hostname:${default} " NEW_HOSTNAME
|
||||
if [[ $NEW_HOSTNAME =~ ^[^\-\_]+([0-9a-z]\-{0,1})+[^\-\_]+$ ]]; then
|
||||
ok_msg "'$NEW_HOSTNAME' is a valid hostname!"
|
||||
HOSTNAME_VALID="true"
|
||||
while true; do
|
||||
echo
|
||||
read -p "${cyan}###### Do you want '$NEW_HOSTNAME' to be the new hostname? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
echo -e "###### > Yes"
|
||||
HOSTENAME_CONFIRM="true"
|
||||
break;;
|
||||
N|n|No|no)
|
||||
echo -e "###### > No"
|
||||
echo -e "${red}Skip hostname change ...${default}"
|
||||
HOSTENAME_CONFIRM="false"
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
break
|
||||
else
|
||||
warn_msg "'$NEW_HOSTNAME' is not a valid hostname!"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
set_hostname(){
|
||||
if [ "$HOSTNAME_VALID" = "true" ] && [ "$HOSTENAME_CONFIRM" = "true" ]; then
|
||||
#check for dependencies
|
||||
dep=(avahi-daemon)
|
||||
dependency_check
|
||||
#execute operations
|
||||
#get current hostname and write to variable
|
||||
HOSTNAME=$(hostname)
|
||||
#create host file if missing or create backup of existing one with current date&time
|
||||
if [ -f /etc/hosts ]; then
|
||||
status_msg "Creating backup of hosts file ..."
|
||||
get_date
|
||||
sudo cp /etc/hosts /etc/hosts."$current_date".bak
|
||||
ok_msg "Backup done!"
|
||||
ok_msg "File:'/etc/hosts."$current_date".bak'"
|
||||
else
|
||||
sudo touch /etc/hosts
|
||||
fi
|
||||
#set hostname in /etc/hostname
|
||||
status_msg "Setting hostname to '$NEW_HOSTNAME' ..."
|
||||
status_msg "Please wait ..."
|
||||
sudo hostnamectl set-hostname "$NEW_HOSTNAME"
|
||||
#write new hostname to /etc/hosts
|
||||
status_msg "Writing new hostname to /etc/hosts ..."
|
||||
echo "127.0.0.1 $NEW_HOSTNAME" | sudo tee -a /etc/hosts &>/dev/null
|
||||
ok_msg "New hostname successfully configured!"
|
||||
ok_msg "Remember to reboot for the changes to take effect!"
|
||||
fi
|
||||
}
|
||||
532
scripts/remove.sh
Normal file → Executable file
532
scripts/remove.sh
Normal file → Executable file
@@ -1,145 +1,403 @@
|
||||
remove_klipper(){
|
||||
data_arr=(
|
||||
/etc/init.d/klipper
|
||||
/etc/default/klipper
|
||||
$KLIPPER_DIR
|
||||
$KLIPPY_ENV_DIR
|
||||
${HOME}/klippy.log
|
||||
)
|
||||
print_error "Klipper" && data_count=()
|
||||
if [ "$ERROR_MSG" = "" ]; then
|
||||
stop_klipper
|
||||
if [[ -e /etc/init.d/klipper || -e /etc/default/klipper ]]; then
|
||||
status_msg "Removing klipper service ..."
|
||||
sudo update-rc.d -f klipper remove
|
||||
sudo rm -rf /etc/init.d/klipper /etc/default/klipper && ok_msg "Klipper service removed!"
|
||||
fi
|
||||
if [[ -d $KLIPPER_DIR || -d $KLIPPY_ENV_DIR ]]; then
|
||||
status_msg "Removing klipper and klippy-env diretory ..."
|
||||
rm -rf $KLIPPER_DIR $KLIPPY_ENV_DIR && ok_msg "Directories removed!"
|
||||
fi
|
||||
if [[ -L ${HOME}/klippy.log || -e /tmp/klippy.log ]]; then
|
||||
status_msg "Removing klippy.log symlink ..."
|
||||
rm -rf ${HOME}/klippy.log /tmp/klippy.log && ok_msg "Symlink removed!"
|
||||
fi
|
||||
ok_msg "Klipper successfully removed!"
|
||||
fi
|
||||
}
|
||||
|
||||
remove_dwc2(){
|
||||
data_arr=(
|
||||
$DWC2FK_DIR
|
||||
$TORNADO_DIR1
|
||||
$TORNADO_DIR2
|
||||
$WEB_DWC2
|
||||
$DWC2_DIR
|
||||
)
|
||||
print_error "DWC2-for-Klipper &\n DWC2 Web UI" && data_count=()
|
||||
if [ "$ERROR_MSG" = "" ]; then
|
||||
if [ -d $DWC2FK_DIR ]; then
|
||||
status_msg "Removing dwc2-for-klipper directory ..."
|
||||
rm -rf $DWC2FK_DIR && ok_msg "Directory removed!"
|
||||
fi
|
||||
if [ -d $TORNADO_DIR1 ]; then
|
||||
status_msg "Removing tornado from klippy-env ..."
|
||||
rm -rf $TORNADO_DIR1 $TORNADO_DIR2 && ok_msg "Tornado removed!"
|
||||
fi
|
||||
if [ -e $WEB_DWC2 ]; then
|
||||
status_msg "Removing web_dwc2.py symlink from klippy ..."
|
||||
rm -rf $WEB_DWC2 && ok_msg "File removed!"
|
||||
fi
|
||||
if [ -d $DWC2_DIR ]; then
|
||||
status_msg "Removing dwc2 directory ..."
|
||||
rm -rf $DWC2_DIR && ok_msg "Directory removed!"
|
||||
fi
|
||||
ok_msg "DWC2-for-Klipper & DWC2 Web UI successfully removed!"
|
||||
fi
|
||||
}
|
||||
|
||||
remove_mainsail(){
|
||||
data_arr=(
|
||||
$MAINSAIL_SERVICE1
|
||||
$MAINSAIL_SERVICE2
|
||||
$MAINSAIL_DIR
|
||||
${HOME}/moonraker.log
|
||||
${HOME}/.klippy_api_key
|
||||
${HOME}/.moonraker_api_key
|
||||
${HOME}/moonraker-env
|
||||
/etc/nginx/sites-available/mainsail
|
||||
/etc/nginx/sites-enabled/mainsail
|
||||
/etc/init.d/nginx
|
||||
/etc/default/nginx
|
||||
)
|
||||
print_error "Mainsail" && data_count=()
|
||||
if [ "$ERROR_MSG" = "" ]; then
|
||||
stop_moonraker
|
||||
#remove moonraker services
|
||||
if [[ -e /etc/init.d/moonraker || -e /etc/default/moonraker ]]; then
|
||||
status_msg "Removing moonraker service ..."
|
||||
sudo update-rc.d -f moonraker remove
|
||||
sudo rm -rf /etc/init.d/moonraker /etc/default/moonraker && ok_msg "Moonraker service removed!"
|
||||
fi
|
||||
#remove mainsail dir
|
||||
if [ -d $MAINSAIL_DIR ]; then
|
||||
status_msg "Removing mainsail directory ..."
|
||||
rm -rf $MAINSAIL_DIR && ok_msg "Directory removed!"
|
||||
fi
|
||||
#remove moonraker-env
|
||||
if [ -d ${HOME}/moonraker-env ]; then
|
||||
status_msg "Removing moonraker virtualenv ..."
|
||||
rm -rf ${HOME}/moonraker-env && ok_msg "Directory removed!"
|
||||
fi
|
||||
#remove moonraker.log symlink
|
||||
if [[ -L ${HOME}/moonraker.log || -e /tmp/moonraker.log ]]; then
|
||||
status_msg "Removing moonraker.log symlink ..."
|
||||
rm -rf ${HOME}/moonraker.log /tmp/moonraker.log && ok_msg "Symlink removed!"
|
||||
fi
|
||||
#remove mainsail cfg
|
||||
if [ -e /etc/nginx/sites-available/mainsail ]; then
|
||||
status_msg "Removing mainsail configuration for nginx ..."
|
||||
sudo rm /etc/nginx/sites-available/mainsail && ok_msg "File removed!"
|
||||
fi
|
||||
#remove mainsail symlink
|
||||
if [ -L /etc/nginx/sites-enabled/mainsail ]; then
|
||||
status_msg "Removing mainsail symlink for nginx ..."
|
||||
sudo rm /etc/nginx/sites-enabled/mainsail && ok_msg "File 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
|
||||
remove_nginx
|
||||
ok_msg "Mainsail successfully removed!"
|
||||
fi
|
||||
}
|
||||
|
||||
remove_nginx(){
|
||||
#ask for complete removal of nginx if installed
|
||||
if [[ $(dpkg-query -f'${Status}' --show nginx 2>/dev/null) = *\ installed ]] ; then
|
||||
### 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
|
||||
while true; do
|
||||
echo
|
||||
read -p "Do you want to completely remove (purge) nginx? (Y/n): " yn
|
||||
unset REM_MR
|
||||
top_border
|
||||
echo -e "| Do you want to remove Moonraker afterwards? |"
|
||||
echo -e "| |"
|
||||
echo -e "| This is useful in case you want to switch from a |"
|
||||
echo -e "| single-instance to a multi-instance installation, |"
|
||||
echo -e "| which makes a re-installation of Moonraker necessary. |"
|
||||
echo -e "| |"
|
||||
echo -e "| If for any other reason you only want to uninstall |"
|
||||
echo -e "| Klipper, please select 'No' and continue. |"
|
||||
bottom_border
|
||||
read -p "${cyan}###### Remove Moonraker afterwards? (y/N):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
status_msg "Stopping and removing nginx service ..."
|
||||
if [ -e /etc/init.d/nginx ]; then
|
||||
sudo /etc/init.d/nginx stop && ok_msg "Nginx service stopped!"
|
||||
sudo rm /etc/init.d/nginx && ok_msg "Nginx service removed!"
|
||||
fi
|
||||
if [ -e /etc/default/nginx ]; then
|
||||
sudo rm /etc/default/nginx
|
||||
fi
|
||||
status_msg "Purging nginx from system ..."
|
||||
sudo apt-get purge nginx nginx-common -y && ok_msg "Nginx removed!"
|
||||
Y|y|Yes|yes)
|
||||
echo -e "###### > Yes"
|
||||
REM_MR="true"
|
||||
break;;
|
||||
N|n|No|no) break;;
|
||||
N|n|No|no|"")
|
||||
echo -e "###### > No"
|
||||
REM_MR="false"
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
### remove "legacy" klipper init.d service
|
||||
if [[ -e /etc/init.d/klipper || -e /etc/default/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
|
||||
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
|
||||
status_msg "Removing Klipper Services ..."
|
||||
for service in $(find $SYSTEMDDIR -maxdepth 1 -name "klipper-*.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 "klippy-*.log")" ]; then
|
||||
for logfile in $(find /tmp -maxdepth 1 -name "klippy-*.log")
|
||||
do
|
||||
status_msg "Removing $logfile ..." && rm -f $logfile && ok_msg "Done!"
|
||||
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!"
|
||||
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!"
|
||||
done
|
||||
fi
|
||||
|
||||
###reloading units
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
###removing klipper and klippy-env folders
|
||||
if [ -d $KLIPPER_DIR ]; then
|
||||
status_msg "Removing Klipper directory ..."
|
||||
rm -rf $KLIPPER_DIR && ok_msg "Directory removed!"
|
||||
fi
|
||||
if [ -d $KLIPPY_ENV ]; then
|
||||
status_msg "Removing klippy-env directory ..."
|
||||
rm -rf $KLIPPY_ENV && ok_msg "Directory removed!"
|
||||
fi
|
||||
|
||||
CONFIRM_MSG=" Klipper was successfully removed!" && print_msg && clear_msg
|
||||
|
||||
if [ "$REM_MR" == "true" ]; then
|
||||
remove_moonraker
|
||||
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!"
|
||||
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)
|
||||
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 "dwc-*.log")" ]; then
|
||||
for logfile in $(find /tmp -maxdepth 1 -name "dwc-*.log")
|
||||
do
|
||||
status_msg "Removing $logfile ..." && rm -f $logfile && ok_msg "Done!"
|
||||
done
|
||||
fi
|
||||
|
||||
### reloading units
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
### removing the rest of the folders
|
||||
if [ -d $DWC2FK_DIR ]; then
|
||||
status_msg "Removing DWC2-for-Klipper-Socket directory ..."
|
||||
rm -rf $DWC2FK_DIR && ok_msg "Directory removed!"
|
||||
fi
|
||||
if [ -d $DWC_ENV_DIR ]; then
|
||||
status_msg "Removing DWC2-for-Klipper-Socket virtualenv ..."
|
||||
rm -rf $DWC_ENV_DIR && ok_msg "Directory removed!"
|
||||
fi
|
||||
if [ -d $DWC2_DIR ]; then
|
||||
status_msg "Removing DWC2 directory ..."
|
||||
rm -rf $DWC2_DIR && ok_msg "Directory removed!"
|
||||
fi
|
||||
|
||||
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
|
||||
status_msg "Removing Mainsail directory ..."
|
||||
rm -rf $MAINSAIL_DIR && ok_msg "Directory removed!"
|
||||
fi
|
||||
|
||||
### remove mainsail config for nginx
|
||||
if [ -e /etc/nginx/sites-available/mainsail ]; then
|
||||
status_msg "Removing Mainsail configuration for Nginx ..."
|
||||
sudo rm /etc/nginx/sites-available/mainsail && ok_msg "File removed!"
|
||||
fi
|
||||
|
||||
### remove mainsail symlink for nginx
|
||||
if [ -L /etc/nginx/sites-enabled/mainsail ]; then
|
||||
status_msg "Removing Mainsail Symlink for Nginx ..."
|
||||
sudo rm /etc/nginx/sites-enabled/mainsail && ok_msg "File removed!"
|
||||
fi
|
||||
|
||||
CONFIRM_MSG="Mainsail successfully removed!"
|
||||
}
|
||||
|
||||
remove_fluidd(){
|
||||
### remove fluidd dir
|
||||
if [ -d $FLUIDD_DIR ]; then
|
||||
status_msg "Removing Fluidd directory ..."
|
||||
rm -rf $FLUIDD_DIR && ok_msg "Directory removed!"
|
||||
fi
|
||||
|
||||
### remove fluidd config for nginx
|
||||
if [ -e /etc/nginx/sites-available/fluidd ]; then
|
||||
status_msg "Removing Fluidd configuration for Nginx ..."
|
||||
sudo rm /etc/nginx/sites-available/fluidd && ok_msg "File removed!"
|
||||
fi
|
||||
|
||||
### remove fluidd symlink for nginx
|
||||
if [ -L /etc/nginx/sites-enabled/fluidd ]; then
|
||||
status_msg "Removing Fluidd Symlink for Nginx ..."
|
||||
sudo rm /etc/nginx/sites-enabled/fluidd && ok_msg "File removed!"
|
||||
fi
|
||||
|
||||
CONFIRM_MSG="Fluidd successfully removed!"
|
||||
}
|
||||
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
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
|
||||
status_msg "Removing OctoPrint Services ..."
|
||||
for service in $(find $SYSTEMDDIR -maxdepth 1 -name "octoprint-*.service" | cut -d"/" -f5)
|
||||
do
|
||||
status_msg "Removing $service ..."
|
||||
sudo systemctl stop $service
|
||||
sudo systemctl disable $service
|
||||
sudo rm -f $SYSTEMDDIR/$service
|
||||
ok_msg "OctoPrint Service removed!"
|
||||
done
|
||||
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
|
||||
fi
|
||||
|
||||
### remove OctoPrint directory
|
||||
if [ -d ${HOME}/OctoPrint ]; then
|
||||
status_msg "Removing OctoPrint directory ..."
|
||||
rm -rf ${HOME}/OctoPrint && ok_msg "Directory removed!"
|
||||
fi
|
||||
|
||||
###remove .octoprint directories
|
||||
if [ "$(find ${HOME} -maxdepth 1 -name ".octoprint*")" ]; then
|
||||
for folder in $(find ${HOME} -maxdepth 1 -name ".octoprint*")
|
||||
do
|
||||
status_msg "Removing $folder ..." && rm -rf $folder && ok_msg "Done!"
|
||||
done
|
||||
fi
|
||||
|
||||
CONFIRM_MSG=" OctoPrint successfully removed!"
|
||||
}
|
||||
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
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
|
||||
status_msg "Purging Nginx from system ..."
|
||||
sudo apt-get purge nginx nginx-common -y
|
||||
sudo update-rc.d -f nginx remove
|
||||
CONFIRM_MSG=" Nginx successfully removed!"
|
||||
else
|
||||
ERROR_MSG=" Looks like Nginx was already removed!\n Skipping..."
|
||||
fi
|
||||
}
|
||||
|
||||
remove_klipperscreen(){
|
||||
### remove KlipperScreen dir
|
||||
if [ -d $KLIPPERSCREEN_DIR ]; then
|
||||
status_msg "Removing KlipperScreen directory ..."
|
||||
rm -rf $KLIPPERSCREEN_DIR && ok_msg "Directory removed!"
|
||||
fi
|
||||
|
||||
### remove KlipperScreen VENV dir
|
||||
if [ -d $KLIPPERSCREEN_ENV_DIR ]; then
|
||||
status_msg "Removing KlipperScreen VENV directory ..."
|
||||
rm -rf $KLIPPERSCREEN_ENV_DIR && ok_msg "Directory removed!"
|
||||
fi
|
||||
|
||||
### remove KlipperScreen systemd file
|
||||
if [ -e /etc/systemd/system/KlipperScreen.service ]; then
|
||||
status_msg "Removing KlipperScreen Service ..."
|
||||
sudo rm /etc/systemd/system/KlipperScreen.service && ok_msg "File removed!"
|
||||
fi
|
||||
|
||||
CONFIRM_MSG="KlipperScreen successfully removed!"
|
||||
}
|
||||
92
scripts/rollback.sh
Executable file
92
scripts/rollback.sh
Executable file
@@ -0,0 +1,92 @@
|
||||
save_klipper_state(){
|
||||
source_kiauh_ini
|
||||
#read current klipper state
|
||||
cd $KLIPPER_DIR
|
||||
COMMIT_STATE=$(git rev-parse --short HEAD)
|
||||
if [ "$GET_BRANCH" = "master" ]; then
|
||||
ORI_OLD=$previous_origin_state
|
||||
ORI_NEW=$COMMIT_STATE
|
||||
sed -i "/previous_origin_state=/s/$ORI_OLD/$ORI_NEW/" $INI_FILE
|
||||
elif [ "$GET_BRANCH" = "scurve-shaping" ]; then
|
||||
SHA_OLD=$previous_shaping_state
|
||||
SHA_NEW=$COMMIT_STATE
|
||||
sed -i "/previous_shaping_state=/s/$SHA_OLD/$SHA_NEW/" $INI_FILE
|
||||
elif [ "$GET_BRANCH" = "scurve-smoothing" ]; then
|
||||
SMO_OLD=$previous_smoothing_state
|
||||
SMO_NEW=$COMMIT_STATE
|
||||
sed -i "/previous_smoothing_state=/s/$SMO_OLD/$SMO_NEW/" $INI_FILE
|
||||
fi
|
||||
}
|
||||
|
||||
load_klipper_state(){
|
||||
source_kiauh_ini
|
||||
print_branch
|
||||
cd $KLIPPER_DIR
|
||||
CURRENT_COMMIT=$(git rev-parse --short=8 HEAD)
|
||||
if [ "$GET_BRANCH" = "origin/master" ] || [ "$GET_BRANCH" = "master" ]; then
|
||||
PREVIOUS_COMMIT=$previous_origin_state
|
||||
elif [ "$GET_BRANCH" = "scurve-shaping" ]; then
|
||||
PREVIOUS_COMMIT=$previous_shaping_state
|
||||
elif [ "$GET_BRANCH" = "scurve-smoothing" ]; then
|
||||
PREVIOUS_COMMIT=$previous_smoothing_state
|
||||
fi
|
||||
CURRENT_COMMIT_DATE=$(git show -s --format=%cd --date=short $CURRENT_COMMIT)
|
||||
if [ "$PREVIOUS_COMMIT" != "0" ]; then
|
||||
PREVIOUS_COMMIT_DATE=$(git show -s --format=%cd --date=short $PREVIOUS_COMMIT)
|
||||
fi
|
||||
if [ "$PREVIOUS_COMMIT" = "0" ]; then
|
||||
CURR_UI=$(echo -e "${green}$CURRENT_COMMIT from $CURRENT_COMMIT_DATE${default}")
|
||||
PREV_UI=$(echo -e "${red}None${default} ")
|
||||
else
|
||||
if [ "$CURRENT_COMMIT" = "$PREVIOUS_COMMIT" ]; then
|
||||
CURR_UI=$(echo -e "${green}$CURRENT_COMMIT from $CURRENT_COMMIT_DATE${default}")
|
||||
PREV_UI=$(echo -e "${green}$PREVIOUS_COMMIT from $PREVIOUS_COMMIT_DATE${default}")
|
||||
else
|
||||
CURR_UI=$(echo -e "${yellow}$CURRENT_COMMIT from $CURRENT_COMMIT_DATE${default}")
|
||||
PREV_UI=$(echo -e "${yellow}$PREVIOUS_COMMIT from $PREVIOUS_COMMIT_DATE${default}")
|
||||
fi
|
||||
fi
|
||||
rollback_ui
|
||||
rollback_klipper
|
||||
}
|
||||
|
||||
rollback_klipper(){
|
||||
if [ "$PREVIOUS_COMMIT" != "0" ] && [ "$CURRENT_COMMIT" != "$PREVIOUS_COMMIT" ]; then
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "###### Do you want to rollback to $PREVIOUS_COMMIT? (Y/n): " yn
|
||||
echo -e "${default}"
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
clear
|
||||
print_header
|
||||
status_msg "Rolling back to $PREVIOUS_COMMIT ..."
|
||||
git reset --hard $PREVIOUS_COMMIT -q
|
||||
ok_msg "Rollback complete!"; echo
|
||||
load_klipper_state
|
||||
break;;
|
||||
N|n|No|no) clear; advanced_menu; break;;
|
||||
Q|q) clear; advanced_menu; break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
else
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "Perform action: " action; echo
|
||||
echo -e "${default}"
|
||||
case "$action" in
|
||||
Q|q)
|
||||
clear; advanced_menu; break;;
|
||||
*)
|
||||
clear
|
||||
print_header
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg
|
||||
rollback_ui;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
}
|
||||
475
scripts/status.sh
Normal file → Executable file
475
scripts/status.sh
Normal file → Executable file
@@ -1,20 +1,40 @@
|
||||
kiauh_status(){
|
||||
if [ -d "${SRCDIR}/kiauh/.git" ]; then
|
||||
cd ${SRCDIR}/kiauh
|
||||
if git branch -a | grep "* master" -q; then
|
||||
git fetch -q
|
||||
if [[ "$(git rev-parse --short=8 origin/master)" != "$(git rev-parse --short=8 HEAD)" ]]; then
|
||||
KIAUH_UPDATE_AVAIL="true"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
klipper_status(){
|
||||
kcount=0
|
||||
klipper_data=(
|
||||
SERVICE
|
||||
$KLIPPER_DIR
|
||||
$KLIPPY_ENV_DIR
|
||||
$KLIPPER_SERVICE1
|
||||
$KLIPPER_SERVICE2
|
||||
)
|
||||
#count+1 for each found data-item from array
|
||||
|
||||
### count amount of klipper service files in /etc/systemd/system
|
||||
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "klipper" | wc -l)
|
||||
|
||||
### remove the "SERVICE" entry from the klipper_data array if a klipper service is installed
|
||||
[ $SERVICE_FILE_COUNT -gt 0 ] && unset klipper_data[0]
|
||||
|
||||
### count+1 for each found data-item from array
|
||||
for kd in "${klipper_data[@]}"
|
||||
do
|
||||
if [ -e $kd ]; then
|
||||
kcount=$(expr $kcount + 1)
|
||||
fi
|
||||
done
|
||||
|
||||
### display status
|
||||
if [ "$kcount" == "${#klipper_data[*]}" ]; then
|
||||
KLIPPER_STATUS="${green}Installed!${default} "
|
||||
KLIPPER_STATUS="$(printf "${green}Installed: %-5s${default}" $SERVICE_FILE_COUNT)"
|
||||
elif [ "$kcount" == 0 ]; then
|
||||
KLIPPER_STATUS="${red}Not installed!${default} "
|
||||
else
|
||||
@@ -24,22 +44,29 @@ klipper_status(){
|
||||
|
||||
dwc2_status(){
|
||||
dcount=0
|
||||
dwc2_data=(
|
||||
$DWC2FK_DIR
|
||||
$WEB_DWC2
|
||||
dwc_data=(
|
||||
SERVICE
|
||||
$DWC2_DIR
|
||||
$TORNADO_DIR1
|
||||
$TORNADO_DIR2
|
||||
$DWC2FK_DIR
|
||||
$DWC_ENV_DIR
|
||||
)
|
||||
|
||||
### count amount of dwc service files in /etc/systemd/system
|
||||
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "dwc" | 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]
|
||||
|
||||
#count+1 for each found data-item from array
|
||||
for dd in "${dwc2_data[@]}"
|
||||
for dd in "${dwc_data[@]}"
|
||||
do
|
||||
if [ -e $dd ]; then
|
||||
dcount=$(expr $dcount + 1)
|
||||
fi
|
||||
done
|
||||
if [ "$dcount" == "${#dwc2_data[*]}" ]; then
|
||||
DWC2_STATUS="${green}Installed!${default} "
|
||||
|
||||
if [ "$dcount" == "${#dwc_data[*]}" ]; then
|
||||
DWC2_STATUS="$(printf "${green}Installed: %-5s${default}" $SERVICE_FILE_COUNT)"
|
||||
elif [ "$dcount" == 0 ]; then
|
||||
DWC2_STATUS="${red}Not installed!${default} "
|
||||
else
|
||||
@@ -47,19 +74,44 @@ dwc2_status(){
|
||||
fi
|
||||
}
|
||||
|
||||
moonraker_status(){
|
||||
mrcount=0
|
||||
moonraker_data=(
|
||||
SERVICE
|
||||
$MOONRAKER_DIR
|
||||
$MOONRAKER_ENV_DIR
|
||||
)
|
||||
|
||||
### count amount of moonraker service files in /etc/systemd/system
|
||||
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "moonraker" | 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]
|
||||
|
||||
### count+1 for each found data-item from array
|
||||
for mrd in "${moonraker_data[@]}"
|
||||
do
|
||||
if [ -e $mrd ]; then
|
||||
mrcount=$(expr $mrcount + 1)
|
||||
fi
|
||||
done
|
||||
|
||||
### display status
|
||||
if [ "$mrcount" == "${#moonraker_data[*]}" ]; then
|
||||
MOONRAKER_STATUS="$(printf "${green}Installed: %-5s${default}" $SERVICE_FILE_COUNT)"
|
||||
elif [ "$mrcount" == 0 ]; then
|
||||
MOONRAKER_STATUS="${red}Not installed!${default} "
|
||||
else
|
||||
MOONRAKER_STATUS="${yellow}Incomplete!${default} "
|
||||
fi
|
||||
}
|
||||
|
||||
mainsail_status(){
|
||||
mcount=0
|
||||
mainsail_data=(
|
||||
$MAINSAIL_SERVICE1
|
||||
$MAINSAIL_SERVICE2
|
||||
$MAINSAIL_DIR
|
||||
#${HOME}/.klippy_api_key
|
||||
#${HOME}/.moonraker_api_key
|
||||
#${HOME}/moonraker-env
|
||||
/etc/nginx/sites-available/mainsail
|
||||
/etc/nginx/sites-enabled/mainsail
|
||||
/etc/init.d/nginx
|
||||
/etc/default/nginx
|
||||
$NGINX_SA/mainsail
|
||||
$NGINX_SE/mainsail
|
||||
)
|
||||
#count+1 for each found data-item from array
|
||||
for md in "${mainsail_data[@]}"
|
||||
@@ -77,150 +129,391 @@ mainsail_status(){
|
||||
fi
|
||||
}
|
||||
|
||||
fluidd_status(){
|
||||
fcount=0
|
||||
fluidd_data=(
|
||||
$FLUIDD_DIR
|
||||
$NGINX_SA/fluidd
|
||||
$NGINX_SE/fluidd
|
||||
)
|
||||
#count+1 for each found data-item from array
|
||||
for fd in "${fluidd_data[@]}"
|
||||
do
|
||||
if [ -e $fd ]; then
|
||||
fcount=$(expr $fcount + 1)
|
||||
fi
|
||||
done
|
||||
if [ "$fcount" == "${#fluidd_data[*]}" ]; then
|
||||
FLUIDD_STATUS="${green}Installed!${default} "
|
||||
elif [ "$fcount" == 0 ]; then
|
||||
FLUIDD_STATUS="${red}Not installed!${default} "
|
||||
else
|
||||
FLUIDD_STATUS="${yellow}Incomplete!${default} "
|
||||
fi
|
||||
}
|
||||
|
||||
octoprint_status(){
|
||||
ocount=0
|
||||
octoprint_data=(
|
||||
SERVICE
|
||||
$OCTOPRINT_DIR
|
||||
)
|
||||
### count amount of octoprint service files in /etc/systemd/system
|
||||
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "octoprint" | 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]
|
||||
|
||||
#count+1 for each found data-item from array
|
||||
for op in "${octoprint_data[@]}"
|
||||
do
|
||||
if [ -e $op ]; then
|
||||
ocount=$(expr $ocount + 1)
|
||||
fi
|
||||
done
|
||||
|
||||
### display status
|
||||
if [ "$ocount" == "${#octoprint_data[*]}" ]; then
|
||||
OCTOPRINT_STATUS="$(printf "${green}Installed: %-5s${default}" $SERVICE_FILE_COUNT)"
|
||||
elif [ "$ocount" == 0 ]; then
|
||||
OCTOPRINT_STATUS="${red}Not installed!${default} "
|
||||
else
|
||||
OCTOPRINT_STATUS="${yellow}Incomplete!${default} "
|
||||
fi
|
||||
}
|
||||
|
||||
klipperscreen_status(){
|
||||
klsccount=0
|
||||
klipperscreen_data=(
|
||||
SERVICE
|
||||
$KLIPPERSCREEN_DIR
|
||||
$KLIPPERSCREEN_ENV_DIR
|
||||
)
|
||||
|
||||
### count amount of klipperscreen_data service files in /etc/systemd/system
|
||||
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "KlipperScreen" | wc -l)
|
||||
|
||||
### remove the "SERVICE" entry from the klipperscreen_data array if a KlipperScreen service is installed
|
||||
[ $SERVICE_FILE_COUNT -gt 0 ] && unset klipperscreen_data[0]
|
||||
|
||||
#count+1 for each found data-item from array
|
||||
for klscd in "${klipperscreen_data[@]}"
|
||||
do
|
||||
if [ -e $klscd ]; then
|
||||
klsccount=$(expr $klsccount + 1)
|
||||
fi
|
||||
done
|
||||
if [ "$klsccount" == "${#klipperscreen_data[*]}" ]; then
|
||||
KLIPPERSCREEN_STATUS="${green}Installed!${default} "
|
||||
elif [ "$klsccount" == 0 ]; then
|
||||
KLIPPERSCREEN_STATUS="${red}Not installed!${default} "
|
||||
else
|
||||
KLIPPERSCREEN_STATUS="${yellow}Incomplete!${default} "
|
||||
fi
|
||||
}
|
||||
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
### reading the klipper branch the user is currently on
|
||||
read_branch(){
|
||||
if [ -d $KLIPPER_DIR ] && [ -d $KLIPPER_DIR/.git ]; then
|
||||
if [ -d $KLIPPER_DIR/.git ]; then
|
||||
cd $KLIPPER_DIR
|
||||
GET_BRANCH=$(git branch -a | head -1 | cut -d " " -f5 | cut -d ")" -f1)
|
||||
#if reading the branch gives an empty string
|
||||
#we are on non-detached HEAD state on origin/master
|
||||
#and need to set GET_BRANCH to make a non-empty string
|
||||
if [ -z $GET_BRANCH ]; then
|
||||
GET_BRANCH="origin/master"
|
||||
GET_BRANCH="$(git branch | grep "*" | cut -d"*" -f2 | cut -d" " -f2)"
|
||||
### try to fix a detached HEAD state and read the correct branch from the output you get
|
||||
if [ "$(echo $GET_BRANCH | grep "HEAD" )" ]; then
|
||||
DETACHED_HEAD="true"
|
||||
GET_BRANCH=$(git branch | grep "HEAD" | rev | cut -d" " -f1 | rev | cut -d")" -f1 | cut -d"/" -f2)
|
||||
### try to identify the branch when the HEAD was detached at a single commit
|
||||
### will only work if its either master, scurve-shaping or scurve-smoothing branch
|
||||
if [[ $GET_BRANCH =~ [[:alnum:]] ]]; then
|
||||
if [ "$(git branch -r --contains $GET_BRANCH | grep "master")" ]; then
|
||||
GET_BRANCH="master"
|
||||
elif [ "$(git branch -r --contains $GET_BRANCH | grep "scurve-shaping")" ]; then
|
||||
GET_BRANCH="scurve-shaping"
|
||||
elif [ "$(git branch -r --contains $GET_BRANCH | grep "scurve-smoothing")" ]; then
|
||||
GET_BRANCH="scurve-smoothing"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
GET_BRANCH=""
|
||||
fi
|
||||
}
|
||||
|
||||
#prints the current klipper branch in the main menu
|
||||
print_branch(){
|
||||
read_branch
|
||||
if [ "$GET_BRANCH" == "origin/master" ]; then
|
||||
PRINT_BRANCH="${cyan}$GET_BRANCH${default} "
|
||||
elif [ "$GET_BRANCH" == "dmbutyugin/scurve-shaping" ]; then
|
||||
PRINT_BRANCH="${cyan}scurve-shaping${default} "
|
||||
elif [ "$GET_BRANCH" == "dmbutyugin/scurve-smoothing" ]; then
|
||||
PRINT_BRANCH="${cyan}scurve-smoothing${default} "
|
||||
elif [ "$GET_BRANCH" == "Arksine/work-web_server-20200131" ]; then
|
||||
PRINT_BRANCH="${cyan}moonraker${default} "
|
||||
elif [ "$GET_BRANCH" == "Arksine/dev-moonraker-testing" ]; then
|
||||
PRINT_BRANCH="${cyan}dev-moonraker${default} "
|
||||
if [ ! -z "$GET_BRANCH" ]; then
|
||||
PRINT_BRANCH="$(printf "%-16s" "$GET_BRANCH")"
|
||||
else
|
||||
PRINT_BRANCH="${red}----${default} "
|
||||
PRINT_BRANCH="${red}--------------${default} "
|
||||
fi
|
||||
}
|
||||
|
||||
read_local_klipper_commit(){
|
||||
if [ -d $KLIPPER_DIR ] && [ -d $KLIPPER_DIR/.git ]; then
|
||||
cd $KLIPPER_DIR
|
||||
LOCAL_COMMIT=$(git rev-parse --short=8 HEAD)
|
||||
LOCAL_COMMIT=$(git describe HEAD --always --tags | cut -d "-" -f 1,2)
|
||||
else
|
||||
LOCAL_COMMIT=""
|
||||
LOCAL_COMMIT=$NONE
|
||||
fi
|
||||
}
|
||||
|
||||
read_remote_klipper_commit(){
|
||||
read_branch
|
||||
if [ ! -z $GET_BRANCH ];then
|
||||
REMOTE_COMMIT=$(git rev-parse --short=8 $GET_BRANCH)
|
||||
if [ ! -z "$GET_BRANCH" ];then
|
||||
if [ "$GET_BRANCH" = "origin/master" ] || [ "$GET_BRANCH" = "master" ]; then
|
||||
git fetch origin -q
|
||||
REMOTE_COMMIT=$(git describe origin/master --always --tags | cut -d "-" -f 1,2)
|
||||
elif [ "$GET_BRANCH" = "scurve-shaping" ]; then
|
||||
git fetch dmbutyugin scurve-shaping -q
|
||||
REMOTE_COMMIT=$(git describe dmbutyugin/scurve-shaping --always --tags | cut -d "-" -f 1,2)
|
||||
elif [ "$GET_BRANCH" = "scurve-smoothing" ]; then
|
||||
git fetch dmbutyugin scurve-smoothing -q
|
||||
REMOTE_COMMIT=$(git describe dmbutyugin/scurve-smoothing --always --tags | cut -d "-" -f 1,2)
|
||||
fi
|
||||
else
|
||||
REMOTE_COMMIT=""
|
||||
REMOTE_COMMIT=$NONE
|
||||
fi
|
||||
}
|
||||
|
||||
compare_klipper_versions(){
|
||||
read_local_klipper_commit
|
||||
read_remote_klipper_commit
|
||||
#echo "Local: $LOCAL_COMMIT"
|
||||
#echo "Remote: $REMOTE_COMMIT"
|
||||
unset KLIPPER_UPDATE_AVAIL
|
||||
read_local_klipper_commit && read_remote_klipper_commit
|
||||
if [ "$LOCAL_COMMIT" != "$REMOTE_COMMIT" ]; then
|
||||
LOCAL_COMMIT="${yellow}$LOCAL_COMMIT${default}"
|
||||
REMOTE_COMMIT="${green}$REMOTE_COMMIT${default}"
|
||||
LOCAL_COMMIT="${yellow}$(printf "%-12s" "$LOCAL_COMMIT")${default}"
|
||||
REMOTE_COMMIT="${green}$(printf "%-12s" "$REMOTE_COMMIT")${default}"
|
||||
KLIPPER_UPDATE_AVAIL="true"
|
||||
update_arr+=(update_klipper)
|
||||
else
|
||||
LOCAL_COMMIT="${green}$LOCAL_COMMIT${default}"
|
||||
REMOTE_COMMIT="${green}$REMOTE_COMMIT${default}"
|
||||
LOCAL_COMMIT="${green}$(printf "%-12s" "$LOCAL_COMMIT")${default}"
|
||||
REMOTE_COMMIT="${green}$(printf "%-12s" "$REMOTE_COMMIT")${default}"
|
||||
KLIPPER_UPDATE_AVAIL="false"
|
||||
fi
|
||||
#if detached head was found, force the user with warn message to update klipper
|
||||
if [ "$DETACHED_HEAD" == "true" ]; then
|
||||
LOCAL_COMMIT="${red}$(printf "%-12s" "Need update!")${default}"
|
||||
fi
|
||||
}
|
||||
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
read_dwc2fk_versions(){
|
||||
if [ -d $DWC2FK_DIR ] && [ -d $DWC2FK_DIR/.git ]; then
|
||||
cd $DWC2FK_DIR
|
||||
LOCAL_DWC2FK_COMMIT=$(git rev-parse --short=8 HEAD)
|
||||
REMOTE_DWC2FK_COMMIT=$(git rev-parse --short=8 origin/master)
|
||||
git fetch origin master -q
|
||||
LOCAL_DWC2FK_COMMIT=$(git describe HEAD --always --tags | cut -d "-" -f 1,2)
|
||||
REMOTE_DWC2FK_COMMIT=$(git describe origin/master --always --tags | cut -d "-" -f 1,2)
|
||||
else
|
||||
LOCAL_DWC2FK_COMMIT=""
|
||||
REMOTE_DWC2FK_COMMIT=""
|
||||
LOCAL_DWC2FK_COMMIT=$NONE
|
||||
REMOTE_DWC2FK_COMMIT=$NONE
|
||||
fi
|
||||
}
|
||||
|
||||
compare_dwc2fk_versions(){
|
||||
unset DWC2FK_UPDATE_AVAIL
|
||||
read_dwc2fk_versions
|
||||
#echo "Local: $LOCAL_DWC2FK_COMMIT"
|
||||
#echo "Remote: $REMOTE_DWC2FK_COMMIT"
|
||||
if [ "$LOCAL_DWC2FK_COMMIT" != "$REMOTE_DWC2FK_COMMIT" ]; then
|
||||
LOCAL_DWC2FK_COMMIT="${yellow}$LOCAL_DWC2FK_COMMIT${default}"
|
||||
REMOTE_DWC2FK_COMMIT="${green}$REMOTE_DWC2FK_COMMIT${default}"
|
||||
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)
|
||||
else
|
||||
LOCAL_DWC2FK_COMMIT="${green}$LOCAL_DWC2FK_COMMIT${default}"
|
||||
REMOTE_DWC2FK_COMMIT="${green}$REMOTE_DWC2FK_COMMIT${default}"
|
||||
LOCAL_DWC2FK_COMMIT="${green}$(printf "%-12s" "$LOCAL_DWC2FK_COMMIT")${default}"
|
||||
REMOTE_DWC2FK_COMMIT="${green}$(printf "%-12s" "$REMOTE_DWC2FK_COMMIT")${default}"
|
||||
DWC2FK_UPDATE_AVAIL="false"
|
||||
fi
|
||||
}
|
||||
|
||||
read_local_dwc2_version(){
|
||||
if [ -e $DWC2_DIR/web/version ]; then
|
||||
DWC2_LOCAL_VER=$(head -n 1 $DWC2_DIR/web/version)
|
||||
unset DWC2_VER_FOUND
|
||||
if [ -e $DWC2_DIR/.version ]; then
|
||||
DWC2_VER_FOUND="true"
|
||||
DWC2_LOCAL_VER=$(head -n 1 $DWC2_DIR/.version)
|
||||
else
|
||||
DWC2_LOCAL_VER=""
|
||||
DWC2_VER_FOUND="false" && unset DWC2_LOCAL_VER
|
||||
fi
|
||||
}
|
||||
|
||||
read_remote_dwc2_version(){
|
||||
DWC2_REMOTE_VER=$(curl -s https://api.github.com/repositories/28820678/releases/latest | grep tag_name | cut -d'"' -f4)
|
||||
#remote checks don't work without curl installed!
|
||||
if [[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]]; then
|
||||
DWC2_REMOTE_VER=$NONE
|
||||
else
|
||||
get_dwc_ver
|
||||
DWC2_REMOTE_VER=$DWC2_VERSION
|
||||
fi
|
||||
}
|
||||
|
||||
compare_dwc2_versions(){
|
||||
read_local_dwc2_version
|
||||
read_remote_dwc2_version
|
||||
#echo "Local: $DWC2_LOCAL_VER"
|
||||
#echo "Remote: $DWC2_REMOTE_VER"
|
||||
if [ "$DWC2_LOCAL_VER" != "$DWC2_REMOTE_VER" ]; then
|
||||
DWC2_LOCAL_VER="${yellow}$DWC2_LOCAL_VER${default}"
|
||||
DWC2_REMOTE_VER="${green}$DWC2_REMOTE_VER${default}"
|
||||
unset DWC2_UPDATE_AVAIL
|
||||
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}"
|
||||
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_UPDATE_AVAIL="true" && update_arr+=(update_dwc2)
|
||||
else
|
||||
DWC2_LOCAL_VER="${green}$DWC2_LOCAL_VER${default}"
|
||||
DWC2_REMOTE_VER="${green}$DWC2_REMOTE_VER${default}"
|
||||
DWC2_LOCAL_VER=$NONE
|
||||
DWC2_REMOTE_VER="${green}$(printf "v%-11s" "$DWC2_REMOTE_VER")${default}"
|
||||
DWC2_UPDATE_AVAIL="false"
|
||||
fi
|
||||
}
|
||||
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
read_moonraker_versions(){
|
||||
if [ -d $MOONRAKER_DIR ] && [ -d $MOONRAKER_DIR/.git ]; then
|
||||
cd $MOONRAKER_DIR
|
||||
git fetch origin master -q
|
||||
LOCAL_MOONRAKER_COMMIT=$(git describe HEAD --always --tags | cut -d "-" -f 1,2)
|
||||
REMOTE_MOONRAKER_COMMIT=$(git describe origin/master --always --tags | cut -d "-" -f 1,2)
|
||||
else
|
||||
LOCAL_MOONRAKER_COMMIT=$NONE
|
||||
REMOTE_MOONRAKER_COMMIT=$NONE
|
||||
fi
|
||||
}
|
||||
|
||||
compare_moonraker_versions(){
|
||||
unset MOONRAKER_UPDATE_AVAIL
|
||||
read_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)
|
||||
else
|
||||
LOCAL_MOONRAKER_COMMIT="${green}$(printf "%-12s" "$LOCAL_MOONRAKER_COMMIT")${default}"
|
||||
REMOTE_MOONRAKER_COMMIT="${green}$(printf "%-12s" "$REMOTE_MOONRAKER_COMMIT")${default}"
|
||||
MOONRAKER_UPDATE_AVAIL="false"
|
||||
fi
|
||||
}
|
||||
|
||||
read_local_mainsail_version(){
|
||||
if [ -e $MAINSAIL_DIR/version ]; then
|
||||
MAINSAIL_LOCAL_VER=$(head -n 1 $MAINSAIL_DIR/version)
|
||||
unset MAINSAIL_VER_FOUND
|
||||
if [ -e $MAINSAIL_DIR/.version ]; then
|
||||
MAINSAIL_VER_FOUND="true"
|
||||
MAINSAIL_LOCAL_VER=$(head -n 1 $MAINSAIL_DIR/.version)
|
||||
else
|
||||
MAINSAIL_LOCAL_VER=""
|
||||
MAINSAIL_VER_FOUND="false" && unset MAINSAIL_LOCAL_VER
|
||||
fi
|
||||
}
|
||||
|
||||
read_remote_mainsail_version(){
|
||||
#remote checks don't work without curl installed!
|
||||
if [[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]]; then
|
||||
MAINSAIL_REMOTE_VER=$NONE
|
||||
else
|
||||
get_mainsail_ver
|
||||
MAINSAIL_REMOTE_VER=$MAINSAIL_VERSION
|
||||
}
|
||||
|
||||
compare_mainsail_versions(){
|
||||
read_local_mainsail_version
|
||||
read_remote_mainsail_version
|
||||
#echo "Local: $MAINSAIL_LOCAL_VER"
|
||||
#echo "Remote: $MAINSAIL_REMOTE_VER"
|
||||
if [ "$MAINSAIL_LOCAL_VER" != "$MAINSAIL_REMOTE_VER" ]; then
|
||||
MAINSAIL_LOCAL_VER="${yellow}$MAINSAIL_LOCAL_VER${default}"
|
||||
MAINSAIL_REMOTE_VER="${green}$MAINSAIL_REMOTE_VER${default}"
|
||||
else
|
||||
MAINSAIL_LOCAL_VER="${green}$MAINSAIL_LOCAL_VER${default}"
|
||||
MAINSAIL_REMOTE_VER="${green}$MAINSAIL_REMOTE_VER${default}"
|
||||
fi
|
||||
}
|
||||
|
||||
compare_mainsail_versions(){
|
||||
unset MAINSAIL_UPDATE_AVAIL
|
||||
read_local_mainsail_version && read_remote_mainsail_version
|
||||
if [[ $MAINSAIL_VER_FOUND = "true" ]] && [[ $MAINSAIL_LOCAL_VER == $MAINSAIL_REMOTE_VER ]]; then
|
||||
#printf fits the string for displaying it in the ui to a total char length of 12
|
||||
MAINSAIL_LOCAL_VER="${green}$(printf "%-12s" "$MAINSAIL_LOCAL_VER")${default}"
|
||||
MAINSAIL_REMOTE_VER="${green}$(printf "%-12s" "$MAINSAIL_REMOTE_VER")${default}"
|
||||
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
|
||||
MAINSAIL_UPDATE_AVAIL="true" && update_arr+=(update_mainsail)
|
||||
else
|
||||
MAINSAIL_LOCAL_VER=$NONE
|
||||
MAINSAIL_REMOTE_VER="${green}$(printf "%-12s" "$MAINSAIL_REMOTE_VER")${default}"
|
||||
MAINSAIL_UPDATE_AVAIL="false"
|
||||
fi
|
||||
}
|
||||
|
||||
read_local_fluidd_version(){
|
||||
unset FLUIDD_VER_FOUND
|
||||
if [ -e $FLUIDD_DIR/.version ]; then
|
||||
FLUIDD_VER_FOUND="true"
|
||||
FLUIDD_LOCAL_VER=$(head -n 1 $FLUIDD_DIR/.version)
|
||||
else
|
||||
FLUIDD_VER_FOUND="false" && unset FLUIDD_LOCAL_VER
|
||||
fi
|
||||
}
|
||||
|
||||
read_remote_fluidd_version(){
|
||||
#remote checks don't work without curl installed!
|
||||
if [[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]]; then
|
||||
FLUIDD_REMOTE_VER=$NONE
|
||||
else
|
||||
get_fluidd_ver
|
||||
FLUIDD_REMOTE_VER=$FLUIDD_VERSION
|
||||
fi
|
||||
}
|
||||
|
||||
compare_fluidd_versions(){
|
||||
unset FLUIDD_UPDATE_AVAIL
|
||||
read_local_fluidd_version && read_remote_fluidd_version
|
||||
if [[ $FLUIDD_VER_FOUND = "true" ]] && [[ $FLUIDD_LOCAL_VER == $FLUIDD_REMOTE_VER ]]; then
|
||||
#printf fits the string for displaying it in the ui to a total char length of 12
|
||||
FLUIDD_LOCAL_VER="${green}$(printf "%-12s" "$FLUIDD_LOCAL_VER")${default}"
|
||||
FLUIDD_REMOTE_VER="${green}$(printf "%-12s" "$FLUIDD_REMOTE_VER")${default}"
|
||||
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
|
||||
FLUIDD_UPDATE_AVAIL="true" && update_arr+=(update_fluidd)
|
||||
else
|
||||
FLUIDD_LOCAL_VER=$NONE
|
||||
FLUIDD_REMOTE_VER="${green}$(printf "%-12s" "$FLUIDD_REMOTE_VER")${default}"
|
||||
FLUIDD_UPDATE_AVAIL="false"
|
||||
fi
|
||||
}
|
||||
|
||||
read_klipperscreen_versions(){
|
||||
if [ -d $KLIPPERSCREEN_DIR ] && [ -d $KLIPPERSCREEN_DIR/.git ]; then
|
||||
cd $KLIPPERSCREEN_DIR
|
||||
git fetch origin master -q
|
||||
LOCAL_KLIPPERSCREEN_COMMIT=$(git describe HEAD --always --tags | cut -d "-" -f 1,2)
|
||||
REMOTE_KLIPPERSCREEN_COMMIT=$(git describe origin/master --always --tags | cut -d "-" -f 1,2)
|
||||
else
|
||||
LOCAL_KLIPPERSCREEN_COMMIT=$NONE
|
||||
REMOTE_KLIPPERSCREEN_COMMIT=$NONE
|
||||
fi
|
||||
}
|
||||
|
||||
compare_klipperscreen_versions(){
|
||||
unset KLIPPERSCREEN_UPDATE_AVAIL
|
||||
read_klipperscreen_versions
|
||||
if [ "$LOCAL_KLIPPERSCREEN_COMMIT" != "$REMOTE_KLIPPERSCREEN_COMMIT" ]; then
|
||||
LOCAL_KLIPPERSCREEN_COMMIT="${yellow}$(printf "%-12s" "$LOCAL_KLIPPERSCREEN_COMMIT")${default}"
|
||||
REMOTE_KLIPPERSCREEN_COMMIT="${green}$(printf "%-12s" "$REMOTE_KLIPPERSCREEN_COMMIT")${default}"
|
||||
KLIPPERSCREEN_UPDATE_AVAIL="true"
|
||||
update_arr+=(update_klipperscreen)
|
||||
else
|
||||
LOCAL_KLIPPERSCREEN_COMMIT="${green}$(printf "%-12s" "$LOCAL_KLIPPERSCREEN_COMMIT")${default}"
|
||||
REMOTE_KLIPPERSCREEN_COMMIT="${green}$(printf "%-12s" "$REMOTE_KLIPPERSCREEN_COMMIT")${default}"
|
||||
KLIPPERSCREEN_UPDATE_AVAIL="false"
|
||||
fi
|
||||
}
|
||||
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
#display this as placeholder if no version/commit could be fetched
|
||||
NONE="${red}$(printf "%-12s" "--------")${default}"
|
||||
|
||||
ui_print_versions(){
|
||||
unset update_arr
|
||||
compare_klipper_versions
|
||||
compare_dwc2fk_versions
|
||||
compare_dwc2_versions
|
||||
compare_moonraker_versions
|
||||
compare_mainsail_versions
|
||||
compare_fluidd_versions
|
||||
compare_klipperscreen_versions
|
||||
}
|
||||
26
scripts/switch_branch.sh
Normal file → Executable file
26
scripts/switch_branch.sh
Normal file → Executable file
@@ -1,7 +1,7 @@
|
||||
switch_to_origin(){
|
||||
switch_to_master(){
|
||||
cd $KLIPPER_DIR
|
||||
status_msg "Switching...Please wait ..."; echo
|
||||
git fetch origin -q && git checkout origin/master -q
|
||||
git fetch origin -q && git checkout master; echo
|
||||
}
|
||||
|
||||
switch_to_scurve_shaping(){
|
||||
@@ -10,7 +10,7 @@ switch_to_scurve_shaping(){
|
||||
if ! git remote | grep dmbutyugin -q; then
|
||||
git remote add dmbutyugin $DMBUTYUGIN_REPO
|
||||
fi
|
||||
git fetch dmbutyugin -q && git checkout $BRANCH_SCURVE_SHAPING -q
|
||||
git fetch dmbutyugin -q && git checkout scurve-shaping; echo
|
||||
}
|
||||
|
||||
switch_to_scurve_smoothing(){
|
||||
@@ -19,23 +19,5 @@ switch_to_scurve_smoothing(){
|
||||
if ! git remote | grep dmbutyugin -q; then
|
||||
git remote add dmbutyugin $DMBUTYUGIN_REPO
|
||||
fi
|
||||
git fetch dmbutyugin -q && git checkout $BRANCH_SCURVE_SMOOTHING -q
|
||||
}
|
||||
|
||||
switch_to_moonraker(){
|
||||
cd $KLIPPER_DIR
|
||||
status_msg "Switching...Please wait ..."; echo
|
||||
if ! git remote | grep Arksine -q; then
|
||||
git remote add Arksine $ARKSINE_REPO
|
||||
fi
|
||||
git fetch Arksine -q && git checkout $BRANCH_MOONRAKER -q
|
||||
}
|
||||
|
||||
switch_to_dev_moonraker(){
|
||||
cd $KLIPPER_DIR
|
||||
status_msg "Switching...Please wait ..."; echo
|
||||
if ! git remote | grep Arksine -q; then
|
||||
git remote add Arksine $ARKSINE_REPO
|
||||
fi
|
||||
git fetch Arksine -q && git checkout $BRANCH_DEV_MOONRAKER -q
|
||||
git fetch dmbutyugin -q && git checkout scurve-smoothing; echo
|
||||
}
|
||||
154
scripts/ui.sh
154
scripts/ui.sh
@@ -1,154 +0,0 @@
|
||||
### set up some UI stuff
|
||||
|
||||
#ui total width = 57 chars
|
||||
top_border(){
|
||||
echo -e "/=======================================================\ "
|
||||
}
|
||||
|
||||
bottom_border(){
|
||||
echo -e "\=======================================================/"
|
||||
}
|
||||
|
||||
hr(){
|
||||
echo -e "|-------------------------------------------------------|"
|
||||
}
|
||||
|
||||
quit_footer(){
|
||||
hr
|
||||
echo -e "| ${red}Q) Quit${default} | "
|
||||
bottom_border
|
||||
}
|
||||
|
||||
print_header(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~~~~ [ KIAUH ] ~~~~~~~~~~~~~~~~~") |"
|
||||
echo -e "| $(title_msg " Klipper Installation And Update Helper ") |"
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") |"
|
||||
bottom_border
|
||||
}
|
||||
|
||||
main_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~~ [ Main Menu ] ~~~~~~~~~~~~~~~") |"
|
||||
hr
|
||||
echo -e "| 0) [System status] | |"
|
||||
echo -e "| | Klipper: $KLIPPER_STATUS|"
|
||||
echo -e "| 1) [Install] | Branch: $PRINT_BRANCH|"
|
||||
echo -e "| 2) [Update] | |"
|
||||
echo -e "| 3) [Remove] | DWC2: $DWC2_STATUS|"
|
||||
echo -e "| | Mainsail: $MAINSAIL_STATUS|"
|
||||
echo -e "| 4) [Advanced] | Octoprint: #### WIP #### |"
|
||||
echo -e "| 5) [Backup] | |"
|
||||
quit_footer
|
||||
}
|
||||
|
||||
install_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~ [ Installation Menu ] ~~~~~~~~~~~") | "
|
||||
hr
|
||||
echo -e "| You need this menu usually only for installing | "
|
||||
echo -e "| all necessary dependencies for the various | "
|
||||
echo -e "| functions on a completely fresh system. | "
|
||||
hr
|
||||
echo -e "| Firmware: | | "
|
||||
echo -e "| 1) [Klipper] | | "
|
||||
echo -e "| | | "
|
||||
echo -e "| Webinterface: | | "
|
||||
echo -e "| 2) [DWC2] | | "
|
||||
echo -e "| 3) [Mainsail] | | "
|
||||
echo -e "| | | "
|
||||
quit_footer
|
||||
}
|
||||
|
||||
update_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~ [ Update Menu ] ~~~~~~~~~~~~~~") | "
|
||||
hr
|
||||
echo -e "| It's a good idea to check the following website | "
|
||||
echo -e "| for important software changes to the config file | "
|
||||
echo -e "| BEFORE updating your klipper installation: | "
|
||||
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 "| | Local Vers: | Remote Vers: | "
|
||||
echo -e "| Firmware: | | | "
|
||||
echo -e "| 1) [Klipper] | $(echo "$LOCAL_COMMIT") | $(echo "$REMOTE_COMMIT") | "
|
||||
echo -e "| | | | "
|
||||
echo -e "| Webinterface: | | | "
|
||||
echo -e "| 2) [DWC2-for-Klipper] | $(echo "$LOCAL_DWC2FK_COMMIT") | $(echo "$REMOTE_DWC2FK_COMMIT") | "
|
||||
echo -e "| 3) [DWC2 Web UI] | $(echo "$DWC2_LOCAL_VER") | $(echo "$DWC2_REMOTE_VER") | "
|
||||
echo -e "| 4) [Mainsail] | $(echo "$MAINSAIL_LOCAL_VER") | $(echo "$MAINSAIL_REMOTE_VER") | "
|
||||
echo -e "| | | | "
|
||||
quit_footer
|
||||
}
|
||||
|
||||
remove_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~ [ Remove Menu ] ~~~~~~~~~~~~~~") | "
|
||||
hr
|
||||
echo -e "| Files and directories which remain untouched: | "
|
||||
echo -e "| --> ~/printer.cfg | "
|
||||
echo -e "| --> ~/backup | "
|
||||
echo -e "| You need remove them manually if you wish so. | "
|
||||
hr
|
||||
echo -e "| 1) [Klipper] | | "
|
||||
echo -e "| 2) [DWC2-for-Klipper] | | "
|
||||
echo -e "| 3) [Mainsail] | | "
|
||||
echo -e "| | | "
|
||||
quit_footer
|
||||
}
|
||||
|
||||
advanced_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~ [ Advanced Menu ] ~~~~~~~~~~~~~") | "
|
||||
hr
|
||||
echo -e "| 1) [Switch Klipper version] | "
|
||||
echo -e "| | "
|
||||
echo -e "| 2) [Build Firmware] | "
|
||||
echo -e "| 3) [Flash MCU] | "
|
||||
echo -e "| 4) [Get Printer-ID] | "
|
||||
echo -e "| 5) [Write Printer-ID to printer.cfg] | "
|
||||
echo -e "| 6) [Write DWC2-for-klipper config] | "
|
||||
echo -e "| | "
|
||||
echo -e "| x) [Enable/Disable Octoprint service] | "
|
||||
echo -e "| | "
|
||||
quit_footer
|
||||
}
|
||||
|
||||
backup_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~ [ Backup Menu ] ~~~~~~~~~~~~~~") | "
|
||||
hr
|
||||
echo -e "| | "
|
||||
hr
|
||||
echo -e "| 1) [ ] | "
|
||||
echo -e "| 2) [ ] | "
|
||||
echo -e "| 3) [ ] | "
|
||||
echo -e "| 4) [ ] | "
|
||||
echo -e "| 5) [ ] | "
|
||||
echo -e "| 6) [ ] | "
|
||||
echo -e "| 7) [ ] | "
|
||||
echo -e "| | "
|
||||
quit_footer
|
||||
}
|
||||
|
||||
switch_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~ [ Switch Klipper Branch ] ~~~~~~~~~") |"
|
||||
bottom_border
|
||||
echo
|
||||
echo -e " $(title_msg "Active branch: ")${green}$GET_BRANCH${default}"
|
||||
echo
|
||||
top_border
|
||||
echo -e "| 1) [--> origin/master] | "
|
||||
echo -e "| | "
|
||||
echo -e "| 2) [--> scurve-shaping] | "
|
||||
echo -e "| 3) [--> scurve-smoothing] | "
|
||||
echo -e "| | "
|
||||
echo -e "| 4) [--> moonraker] | "
|
||||
echo -e "| 5) [--> dev-moonraker] | "
|
||||
quit_footer
|
||||
}
|
||||
155
scripts/ui/advanced_menu.sh
Executable file
155
scripts/ui/advanced_menu.sh
Executable file
@@ -0,0 +1,155 @@
|
||||
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] | "
|
||||
echo -e "| 2) [Rollback] | | "
|
||||
echo -e "| | Extensions: | "
|
||||
echo -e "| Firmware: | 7) [Shell Command] | "
|
||||
echo -e "| 3) [Build only] | | "
|
||||
echo -e "| 4) [Build + Flash MCU] | | "
|
||||
echo -e "| 5) [Get MCU ID] | | "
|
||||
echo -e "| | | "
|
||||
quit_footer
|
||||
}
|
||||
|
||||
advanced_menu(){
|
||||
read_octoprint_service_status
|
||||
do_action "" "advanced_ui"
|
||||
while true; do
|
||||
read -p "${cyan}Perform action:${default} " action; echo
|
||||
case "$action" in
|
||||
0)
|
||||
clear
|
||||
print_header
|
||||
toggle_octoprint_service
|
||||
read_octoprint_service_status
|
||||
print_msg && clear_msg
|
||||
advanced_ui;;
|
||||
1)
|
||||
do_action "switch_menu" "advanced_ui";;
|
||||
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
|
||||
print_msg && clear_msg
|
||||
advanced_ui;;
|
||||
5)
|
||||
do_action "get_mcu_id" "advanced_ui";;
|
||||
6)
|
||||
clear
|
||||
print_header
|
||||
create_custom_hostname && set_hostname
|
||||
print_msg && clear_msg
|
||||
advanced_ui;;
|
||||
7)
|
||||
do_action "setup_gcode_shell_command" "advanced_ui";;
|
||||
Q|q)
|
||||
clear; main_menu; break;;
|
||||
*)
|
||||
deny_action "advanced_ui";;
|
||||
esac
|
||||
done
|
||||
advanced_menu
|
||||
}
|
||||
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
switch_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~ [ Switch Klipper Branch ] ~~~~~~~~~") |"
|
||||
bottom_border
|
||||
echo
|
||||
echo -e " $(title_msg "Active Branch: ")${green}$GET_BRANCH${default}"
|
||||
echo
|
||||
top_border
|
||||
echo -e "| | "
|
||||
echo -e "| KevinOConnor: | "
|
||||
echo -e "| 1) [--> master] | "
|
||||
echo -e "| | "
|
||||
echo -e "| dmbutyugin: | "
|
||||
echo -e "| 2) [--> scurve-shaping] | "
|
||||
echo -e "| 3) [--> scurve-smoothing] | "
|
||||
quit_footer
|
||||
}
|
||||
|
||||
switch_menu(){
|
||||
if [ -d $KLIPPER_DIR ]; then
|
||||
read_branch
|
||||
do_action "" "switch_ui"
|
||||
while true; do
|
||||
read -p "${cyan}Perform action:${default} " action; echo
|
||||
case "$action" in
|
||||
1)
|
||||
clear
|
||||
print_header
|
||||
switch_to_master
|
||||
read_branch
|
||||
print_msg && clear_msg
|
||||
switch_ui;;
|
||||
2)
|
||||
clear
|
||||
print_header
|
||||
switch_to_scurve_shaping
|
||||
read_branch
|
||||
print_msg && clear_msg
|
||||
switch_ui;;
|
||||
3)
|
||||
clear
|
||||
print_header
|
||||
switch_to_scurve_smoothing
|
||||
read_branch
|
||||
print_msg && clear_msg
|
||||
switch_ui;;
|
||||
4)
|
||||
clear
|
||||
print_header
|
||||
switch_to_moonraker
|
||||
read_branch
|
||||
print_msg && clear_msg
|
||||
switch_ui;;
|
||||
Q|q)
|
||||
clear; advanced_menu; break;;
|
||||
*)
|
||||
deny_action "switch_ui";;
|
||||
esac
|
||||
done
|
||||
else
|
||||
ERROR_MSG="No Klipper directory found! Download Klipper first!"
|
||||
fi
|
||||
}
|
||||
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
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 | "
|
||||
quit_footer
|
||||
}
|
||||
48
scripts/ui/backup_menu.sh
Executable file
48
scripts/ui/backup_menu.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
backup_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~ [ Backup Menu ] ~~~~~~~~~~~~~~") | "
|
||||
hr
|
||||
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 "| Firmware: | | "
|
||||
echo -e "| 1) [Klipper] | HDMI Screen: | "
|
||||
echo -e "| | 5) [KlipperScreen] | "
|
||||
echo -e "| Klipper API: | | "
|
||||
echo -e "| 2) [Moonraker] | Other: | "
|
||||
echo -e "| | 6) [Duet Web Control] | "
|
||||
echo -e "| | 7) [OctoPrint] | "
|
||||
quit_footer
|
||||
}
|
||||
|
||||
backup_menu(){
|
||||
do_action "" "backup_ui"
|
||||
while true; do
|
||||
read -p "${cyan}Perform action:${default} " action; echo
|
||||
case "$action" in
|
||||
0)
|
||||
do_action "backup_klipper_config_dir" "backup_ui";;
|
||||
1)
|
||||
do_action "backup_klipper" "backup_ui";;
|
||||
2)
|
||||
do_action "backup_moonraker" "backup_ui";;
|
||||
3)
|
||||
do_action "backup_mainsail" "backup_ui";;
|
||||
4)
|
||||
do_action "backup_fluidd" "backup_ui";;
|
||||
5)
|
||||
do_action "backup_klipperscreen" "backup_ui";;
|
||||
6)
|
||||
do_action "backup_dwc2" "backup_ui";;
|
||||
7)
|
||||
do_action "backup_octoprint" "backup_ui";;
|
||||
Q|q)
|
||||
clear; main_menu; break;;
|
||||
*)
|
||||
deny_action "backup_ui";;
|
||||
esac
|
||||
done
|
||||
backup_menu
|
||||
}
|
||||
61
scripts/ui/general_ui.sh
Executable file
61
scripts/ui/general_ui.sh
Executable file
@@ -0,0 +1,61 @@
|
||||
#ui total width = 57 chars
|
||||
top_border(){
|
||||
echo -e "/=======================================================\ "
|
||||
}
|
||||
|
||||
bottom_border(){
|
||||
echo -e "\=======================================================/"
|
||||
}
|
||||
|
||||
blank_line(){
|
||||
echo -e "| | "
|
||||
}
|
||||
|
||||
hr(){
|
||||
echo -e "|-------------------------------------------------------|"
|
||||
}
|
||||
|
||||
quit_footer(){
|
||||
hr
|
||||
echo -e "| ${red}Q) Quit${default} | "
|
||||
bottom_border
|
||||
}
|
||||
|
||||
print_header(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~~~~ [ KIAUH ] ~~~~~~~~~~~~~~~~~") |"
|
||||
echo -e "| $(title_msg " Klipper Installation And Update Helper ") |"
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") |"
|
||||
bottom_border
|
||||
}
|
||||
|
||||
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} | "
|
||||
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} | "
|
||||
bottom_border
|
||||
}
|
||||
|
||||
##############################################################################################
|
||||
#********************************************************************************************#
|
||||
##############################################################################################
|
||||
### TODO: rework other menus to make use of the following functions too and make them more readable
|
||||
|
||||
do_action(){
|
||||
clear && print_header
|
||||
### $1 is the action the user wants to fire
|
||||
$1
|
||||
print_msg && clear_msg
|
||||
### $2 is the menu the user usually gets directed back to after an action is completed
|
||||
$2
|
||||
}
|
||||
|
||||
deny_action(){
|
||||
clear && print_header
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg
|
||||
$1
|
||||
}
|
||||
48
scripts/ui/install_menu.sh
Executable file
48
scripts/ui/install_menu.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
install_ui(){
|
||||
top_border
|
||||
echo -e "| ${green}~~~~~~~~~~~ [ Installation Menu ] ~~~~~~~~~~~${default} | "
|
||||
hr
|
||||
echo -e "| You need this menu usually only for installing | "
|
||||
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
|
||||
}
|
||||
|
||||
install_menu(){
|
||||
do_action "" "install_ui"
|
||||
while true; do
|
||||
read -p "${cyan}Perform action:${default} " action; echo
|
||||
case "$action" in
|
||||
1)
|
||||
do_action "klipper_setup_dialog" "install_ui";;
|
||||
2)
|
||||
do_action "moonraker_setup_dialog" "install_ui";;
|
||||
3)
|
||||
do_action "install_webui mainsail" "install_ui";;
|
||||
4)
|
||||
do_action "install_webui fluidd" "install_ui";;
|
||||
5)
|
||||
do_action "install_klipperscreen" "install_ui";;
|
||||
6)
|
||||
do_action "dwc_setup_dialog" "install_ui";;
|
||||
7)
|
||||
do_action "octoprint_setup_dialog" "install_ui";;
|
||||
Q|q)
|
||||
clear; main_menu; break;;
|
||||
*)
|
||||
deny_action "install_ui";;
|
||||
esac
|
||||
done
|
||||
install_menu
|
||||
}
|
||||
94
scripts/ui/main_menu.sh
Executable file
94
scripts/ui/main_menu.sh
Executable file
@@ -0,0 +1,94 @@
|
||||
main_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~~ [ Main Menu ] ~~~~~~~~~~~~~~~") |"
|
||||
hr
|
||||
echo -e "| 0) [Upload Log] | Klipper: $KLIPPER_STATUS|"
|
||||
echo -e "| | Branch: ${cyan}$PRINT_BRANCH${default}|"
|
||||
echo -e "| 1) [Install] | |"
|
||||
echo -e "| 2) [Update] | Moonraker: $MOONRAKER_STATUS|"
|
||||
echo -e "| 3) [Remove] | |"
|
||||
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 "| | DWC2: $DWC2_STATUS|"
|
||||
echo -e "| ${cyan}$KIAUH_VER${default}| Octoprint: $OCTOPRINT_STATUS|"
|
||||
quit_footer
|
||||
}
|
||||
|
||||
print_kiauh_version(){
|
||||
cd ${SRCDIR}/kiauh
|
||||
KIAUH_VER=$(git describe HEAD --always --tags | cut -d "-" -f 1,2)
|
||||
KIAUH_VER="$(printf "%-20s" "$KIAUH_VER")"
|
||||
}
|
||||
|
||||
main_menu(){
|
||||
print_header
|
||||
#print KIAUH update msg if update available
|
||||
if [ "$KIAUH_UPDATE_AVAIL" = "true" ]; then
|
||||
kiauh_update_msg
|
||||
fi
|
||||
#check install status
|
||||
print_kiauh_version
|
||||
klipper_status
|
||||
moonraker_status
|
||||
dwc2_status
|
||||
fluidd_status
|
||||
mainsail_status
|
||||
octoprint_status
|
||||
klipperscreen_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;;
|
||||
Q|q)
|
||||
echo -e "${green}###### Happy printing! ######${default}"; echo
|
||||
exit -1;;
|
||||
*)
|
||||
deny_action "main_ui";;
|
||||
esac
|
||||
done
|
||||
clear; main_menu
|
||||
}
|
||||
52
scripts/ui/remove_menu.sh
Executable file
52
scripts/ui/remove_menu.sh
Executable file
@@ -0,0 +1,52 @@
|
||||
remove_ui(){
|
||||
top_border
|
||||
echo -e "| ${red}~~~~~~~~~~~~~~ [ Remove Menu ] ~~~~~~~~~~~~~~${default} | "
|
||||
hr
|
||||
echo -e "| Directories which remain untouched: | "
|
||||
echo -e "| --> Your printer configuration directory | "
|
||||
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
|
||||
}
|
||||
|
||||
remove_menu(){
|
||||
do_action "" "remove_ui"
|
||||
while true; do
|
||||
read -p "${cyan}Perform action:${default} " action; echo
|
||||
case "$action" in
|
||||
1)
|
||||
do_action "remove_klipper" "remove_ui";;
|
||||
2)
|
||||
do_action "remove_moonraker" "remove_ui";;
|
||||
3)
|
||||
do_action "remove_mainsail" "remove_ui";;
|
||||
4)
|
||||
do_action "remove_fluidd" "remove_ui";;
|
||||
5)
|
||||
do_action "remove_klipperscreen" "remove_ui";;
|
||||
6)
|
||||
do_action "remove_dwc2" "remove_ui";;
|
||||
7)
|
||||
do_action "remove_octoprint" "remove_ui";;
|
||||
8)
|
||||
do_action "remove_nginx" "remove_ui";;
|
||||
Q|q)
|
||||
clear; main_menu; break;;
|
||||
*)
|
||||
deny_action "remove_ui";;
|
||||
esac
|
||||
done
|
||||
remove_menu
|
||||
}
|
||||
44
scripts/ui/settings_menu.sh
Executable file
44
scripts/ui/settings_menu.sh
Executable file
@@ -0,0 +1,44 @@
|
||||
settings_ui(){
|
||||
source_kiauh_ini
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~ [ KIAUH Settings ] ~~~~~~~~~~~~~") | "
|
||||
hr
|
||||
echo -e "| ${red}Caution:${default} | "
|
||||
echo -e "| When you change the config folder, be aware that ALL | "
|
||||
echo -e "| Klipper and Moonraker services will be STOPPED, | "
|
||||
echo -e "| reconfigured and then restarted again. | "
|
||||
blank_line
|
||||
echo -e "| ${red}DO NOT change the folder during printing!${default} | "
|
||||
hr
|
||||
blank_line
|
||||
echo -e "| ${cyan}● Current Klipper config folder:${default} | "
|
||||
printf "|%-55s|\n" " $klipper_cfg_loc"
|
||||
blank_line
|
||||
hr
|
||||
if [ -z $klipper_cfg_loc ]; then
|
||||
echo -e "| ${red}N/A) Install Klipper with KIAUH first to unlock!${default} | "
|
||||
else
|
||||
echo -e "| 1) Change config folder | "
|
||||
fi
|
||||
quit_footer
|
||||
}
|
||||
|
||||
settings_menu(){
|
||||
do_action "" "settings_ui"
|
||||
while true; do
|
||||
read -p "${cyan}Perform action:${default} " action; echo
|
||||
case "$action" in
|
||||
1)
|
||||
if [ ! -z $klipper_cfg_loc ]; then
|
||||
do_action "change_klipper_cfg_path" "settings_ui"
|
||||
else
|
||||
deny_action "settings_ui"
|
||||
fi;;
|
||||
Q|q)
|
||||
clear; main_menu; break;;
|
||||
*)
|
||||
deny_action "settings_ui";;
|
||||
esac
|
||||
done
|
||||
settings_ui
|
||||
}
|
||||
107
scripts/ui/update_menu.sh
Executable file
107
scripts/ui/update_menu.sh
Executable file
@@ -0,0 +1,107 @@
|
||||
update_ui(){
|
||||
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 "| 1) [Klipper] | $LOCAL_COMMIT | $REMOTE_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 "| | | | "
|
||||
echo -e "| HDMI Screen: |---------------|--------------| "
|
||||
echo -e "| 7) [KlipperScreen] | $LOCAL_KLIPPERSCREEN_COMMIT | $REMOTE_KLIPPERSCREEN_COMMIT | "
|
||||
quit_footer
|
||||
}
|
||||
|
||||
update_menu(){
|
||||
print_header
|
||||
#compare versions
|
||||
ui_print_versions
|
||||
print_msg && clear_msg
|
||||
read_bb4u_stat
|
||||
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;;
|
||||
1)
|
||||
clear
|
||||
print_header
|
||||
update_klipper && ui_print_versions
|
||||
print_msg && clear_msg
|
||||
update_ui;;
|
||||
2)
|
||||
clear
|
||||
print_header
|
||||
update_dwc2fk && ui_print_versions
|
||||
print_msg && clear_msg
|
||||
update_ui;;
|
||||
3)
|
||||
clear
|
||||
print_header
|
||||
update_dwc2 && ui_print_versions
|
||||
print_msg && clear_msg
|
||||
update_ui;;
|
||||
4)
|
||||
clear
|
||||
print_header
|
||||
update_moonraker && ui_print_versions
|
||||
print_msg && clear_msg
|
||||
update_ui;;
|
||||
5)
|
||||
clear
|
||||
print_header
|
||||
update_mainsail && ui_print_versions
|
||||
print_msg && clear_msg
|
||||
update_ui;;
|
||||
6)
|
||||
clear
|
||||
print_header
|
||||
update_fluidd && ui_print_versions
|
||||
print_msg && clear_msg
|
||||
update_ui;;
|
||||
7)
|
||||
clear
|
||||
print_header
|
||||
update_klipperscreen && ui_print_versions
|
||||
print_msg && clear_msg
|
||||
update_ui;;
|
||||
a)
|
||||
clear
|
||||
print_header
|
||||
update_all && ui_print_versions
|
||||
print_msg && clear_msg
|
||||
update_ui;;
|
||||
Q|q)
|
||||
clear; main_menu; break;;
|
||||
*)
|
||||
clear
|
||||
print_header
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg
|
||||
ui_print_versions
|
||||
update_ui;;
|
||||
esac
|
||||
done
|
||||
update_menu
|
||||
}
|
||||
191
scripts/update.sh
Normal file → Executable file
191
scripts/update.sh
Normal file → Executable file
@@ -1,77 +1,168 @@
|
||||
#TODO
|
||||
# - update the correct branch
|
||||
# - version checks before updating
|
||||
update_kiauh(){
|
||||
if [ "$KIAUH_UPDATE_AVAIL" = "true" ]; then
|
||||
status_msg "Updating KIAUH ..."
|
||||
cd ${SRCDIR}/kiauh
|
||||
### force reset kiauh before updating
|
||||
git reset --hard
|
||||
git pull && ok_msg "Update complete! Please restart KIAUH."
|
||||
exit -1
|
||||
fi
|
||||
}
|
||||
|
||||
#WIP
|
||||
update_check(){
|
||||
read_local_commit
|
||||
read_remote_commit
|
||||
update_all(){
|
||||
while true; do
|
||||
if [ "${#update_arr[@]}" = "0" ]; then
|
||||
CONFIRM_MSG="Everything is already up to date!"
|
||||
echo; break
|
||||
fi
|
||||
echo
|
||||
top_border
|
||||
echo -e "| The following installations will be updated: |"
|
||||
if [ "$KLIPPER_UPDATE_AVAIL" = "true" ]; then
|
||||
echo -e "| ${cyan}● Klipper${default} |"
|
||||
fi
|
||||
if [ "$DWC2FK_UPDATE_AVAIL" = "true" ]; then
|
||||
echo -e "| ${cyan}● DWC2-for-Klipper-Socket${default} |"
|
||||
fi
|
||||
if [ "$DWC2_UPDATE_AVAIL" = "true" ]; then
|
||||
echo -e "| ${cyan}● Duet Web Control${default} |"
|
||||
fi
|
||||
if [ "$MOONRAKER_UPDATE_AVAIL" = "true" ]; then
|
||||
echo -e "| ${cyan}● Moonraker${default} |"
|
||||
fi
|
||||
if [ "$MAINSAIL_UPDATE_AVAIL" = "true" ]; then
|
||||
echo -e "| ${cyan}● Mainsail${default} |"
|
||||
fi
|
||||
if [ "$FLUIDD_UPDATE_AVAIL" = "true" ]; then
|
||||
echo -e "| ${cyan}● Fluidd${default} |"
|
||||
fi
|
||||
if [ "$KLIPPERSCREEN_UPDATE_AVAIL" = "true" ]; then
|
||||
echo -e "| ${cyan}● KlipperScreen${default} |"
|
||||
fi
|
||||
bottom_border
|
||||
if [ "${#update_arr[@]}" != "0" ]; then
|
||||
read -p "${cyan}###### Do you want to proceed? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
for update in ${update_arr[@]}
|
||||
do
|
||||
$update
|
||||
done
|
||||
break;;
|
||||
N|n|No|no)
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
update_klipper(){
|
||||
stop_klipper
|
||||
bb4u_klipper
|
||||
klipper_service "stop"
|
||||
if [ ! -d $KLIPPER_DIR ]; then
|
||||
cd ${HOME} && git clone $KLIPPER_REPO
|
||||
else
|
||||
bb4u "klipper"
|
||||
read_branch
|
||||
save_klipper_state
|
||||
status_msg "Updating $GET_BRANCH"
|
||||
#fetching origin/master -> error
|
||||
#rewriting origin/master to origin
|
||||
if [ "$GET_BRANCH" == "origin/master" ]; then
|
||||
FETCH_BRANCH="origin"
|
||||
else
|
||||
FETCH_BRANCH=$(echo "$GET_BRANCH" | cut -d "/" -f1)
|
||||
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
|
||||
status_msg "Fetching from $FETCH_BRANCH"
|
||||
git fetch $FETCH_BRANCH -q && ok_msg "Fetch successfull!"
|
||||
status_msg "Checking out $GET_BRANCH"
|
||||
git checkout $GET_BRANCH -q && ok_msg "Checkout successfull!" && echo; ok_msg "Update complete!"
|
||||
|
||||
### 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
|
||||
start_klipper; echo
|
||||
|
||||
ok_msg "Update complete!"
|
||||
fi
|
||||
klipper_service "restart"
|
||||
}
|
||||
|
||||
update_dwc2fk(){
|
||||
stop_klipper
|
||||
bb4u_dwc2fk
|
||||
dwc_service "stop"
|
||||
bb4u "dwc2"
|
||||
if [ ! -d $DWC2FK_DIR ]; then
|
||||
cd ${HOME} && git clone $DWC2FK_REPO
|
||||
else
|
||||
cd $DWC2FK_DIR && git pull
|
||||
#create a web_dwc2.py symlink if not already existing
|
||||
if [ -d $KLIPPER_DIR/klippy/extras ] && [ ! -e $WEB_DWC2 ]; then
|
||||
status_msg "Creating web_dwc2.py symlink ..."
|
||||
ln -s $DWC2FK_DIR/web_dwc2.py $WEB_DWC2 && ok_msg "Symlink created!"
|
||||
fi
|
||||
fi
|
||||
start_klipper
|
||||
dwc_service "start"
|
||||
}
|
||||
|
||||
update_dwc2(){
|
||||
bb4u_dwc2
|
||||
#check dependencies
|
||||
dep=(wget gzip tar curl)
|
||||
dep_check
|
||||
#execute operation
|
||||
GET_DWC2_URL=`curl -s https://api.github.com/repositories/28820678/releases/latest | grep browser_download_url | cut -d'"' -f4`
|
||||
if [ ! -d $DWC2_DIR/web ]; then
|
||||
mkdir -p $DWC2_DIR/web
|
||||
fi
|
||||
cd $DWC2_DIR/web
|
||||
status_msg "Downloading DWC2 Web UI ..."
|
||||
wget -q $GET_DWC2_URL && ok_msg "Download complete!"
|
||||
status_msg "Unzipping archive ..."
|
||||
unzip -q -o *.zip && for f_ in $(find . | grep '.gz');do gunzip -f ${f_};done && ok_msg "Done!"
|
||||
status_msg "Writing version to file ..."
|
||||
echo $GET_DWC2_URL | cut -d/ -f8 > $DWC2_DIR/web/version && ok_msg "Done!"
|
||||
status_msg "Do a little cleanup ..."
|
||||
rm -rf DuetWebControl-SD.zip && ok_msg "Done!"
|
||||
bb4u "dwc2"
|
||||
download_dwc2_webui
|
||||
}
|
||||
|
||||
update_mainsail(){
|
||||
stop_klipper
|
||||
bb4u_mainsail
|
||||
bb4u "mainsail"
|
||||
status_msg "Updating Mainsail ..."
|
||||
install_mainsail
|
||||
start_klipper
|
||||
mainsail_setup
|
||||
}
|
||||
|
||||
update_fluidd(){
|
||||
bb4u "fluidd"
|
||||
status_msg "Updating Fluidd ..."
|
||||
fluidd_setup
|
||||
}
|
||||
|
||||
update_moonraker(){
|
||||
moonraker_service "stop"
|
||||
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!"
|
||||
|
||||
### 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
|
||||
|
||||
ok_msg "Update complete!"
|
||||
moonraker_service "restart"
|
||||
}
|
||||
|
||||
update_klipperscreen(){
|
||||
stop_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"
|
||||
#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..."
|
||||
PYTHONDIR="${HOME}/.KlipperScreen-env"
|
||||
$PYTHONDIR/bin/pip install -r $KLIPPERSCREEN_DIR/scripts/KlipperScreen-requirements.txt
|
||||
ok_msg "Dependencies have been installed!"
|
||||
fi
|
||||
ok_msg "Update complete!"
|
||||
start_klipperscreen
|
||||
}
|
||||
101
scripts/upload_log.sh
Executable file
101
scripts/upload_log.sh
Executable file
@@ -0,0 +1,101 @@
|
||||
accept_upload_conditions(){
|
||||
while true; do
|
||||
top_border
|
||||
echo -e "| ${red}~~~~~~~~~~~ [ Upload Agreement ] ~~~~~~~~~~~~${default} |"
|
||||
hr
|
||||
echo -e "| The following function will help to quickly upload |"
|
||||
echo -e "| logs for debugging purposes. With confirming this |"
|
||||
echo -e "| dialog, you agree that during that process your logs |"
|
||||
echo -e "| will be uploaded to: ${yellow}http://paste.c-net.org/${default} |"
|
||||
hr
|
||||
echo -e "| ${red}PLEASE NOTE:${default} |"
|
||||
echo -e "| Be aware that logs can contain network information, |"
|
||||
echo -e "| private data like usernames, filenames, or other |"
|
||||
echo -e "| information you may not want to make public. |"
|
||||
blank_line
|
||||
echo -e "| Do ${red}NOT${default} use this function if you don't agree! |"
|
||||
bottom_border
|
||||
read -p "${cyan}Do you accept? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
sed -i "/logupload_accepted=/s/false/true/" $INI_FILE
|
||||
clear && print_header && upload_selection
|
||||
;;
|
||||
N|n|No|no)
|
||||
clear
|
||||
main_menu
|
||||
break
|
||||
;;
|
||||
*)
|
||||
clear
|
||||
print_header
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg
|
||||
accept_upload_conditions;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
upload_selection(){
|
||||
source_kiauh_ini
|
||||
[ "$logupload_accepted" = "false" ] && accept_upload_conditions
|
||||
|
||||
### 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
|
||||
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
|
||||
logfiles+=($mr_log)
|
||||
done
|
||||
fi
|
||||
if ls /tmp/dwc2*.log 2>/dev/null 1>&2; then
|
||||
for dwc_log in $(find /tmp/dwc2*.log); do
|
||||
logfiles+=($dwc_log)
|
||||
done
|
||||
fi
|
||||
|
||||
### draw interface
|
||||
i=0
|
||||
top_border
|
||||
echo -e "| ${yellow}~~~~~~~~~~~~~~~ [ Log Upload ] ~~~~~~~~~~~~~~${default} |"
|
||||
hr
|
||||
echo -e "| You can choose the following files for uploading: |"
|
||||
for log in ${logfiles[@]}; do
|
||||
printf "| $i) %-50s|\n" "${logfiles[$i]}"
|
||||
i=$((i + 1))
|
||||
done
|
||||
quit_footer
|
||||
while true; do
|
||||
read -p "${cyan}Please select:${default} " choice
|
||||
if [ $choice = "q" ] || [ $choice = "Q" ]; then
|
||||
clear && main_menu && break
|
||||
elif [ $choice -le ${#logfiles[@]} ]; then
|
||||
upload_log "${logfiles[$choice]}"
|
||||
upload_selection
|
||||
else
|
||||
clear && print_header
|
||||
ERROR_MSG="File not found!" && print_msg && clear_msg
|
||||
upload_selection
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
upload_log(){
|
||||
if [ -f "$1" ]; then
|
||||
clear && print_header
|
||||
status_msg "Uploading $1 ..."
|
||||
LINK=$(curl -s --upload-file $1 'http://paste.c-net.org/')
|
||||
[ ! -z "$LINK" ] && ok_msg "$1 upload successfull!"
|
||||
echo -e "\n${cyan}###### Here is your link:${default}"
|
||||
echo -e ">>>>>> $LINK\n"
|
||||
unset LINK
|
||||
else
|
||||
clear && print_header
|
||||
ERROR_MSG="File not found!" && print_msg && clear_msg
|
||||
upload_selection
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user