Compare commits

...

67 Commits

Author SHA1 Message Date
th33xitus
e9706b52d8 Update changelog.md 2021-06-15 17:22:39 +02:00
th33xitus
412e084d6d script: add short changelog url to kiauh update message 2021-06-15 16:40:10 +02:00
th33xitus
3ebee823ad script: remove KlipperScreen.log symlink dialog. 2021-06-15 16:12:58 +02:00
th33xitus
72312422e3 fix: performance improvement for loading the advanced menu ui 2021-06-15 15:56:13 +02:00
th33xitus
54089582e4 script: rewrite the auto mainsailOS/fluiddPi migration function
No auto update anymore when updating Klipper. The user now must start this function. It's available in the Advanced Menu.
2021-06-15 15:56:13 +02:00
th33xitus
9fd3f930df script: advanced_menu.sh, switch version becomes switch branch 2021-06-15 15:56:13 +02:00
th33xitus
98f0aa4b8f script: update log-upload function 2021-06-15 15:56:13 +02:00
th33xitus
19b37e4dc4 script: update klipper.service raw file link 2021-06-15 15:56:13 +02:00
th33xitus
d344b1c5f6 feat: auto mainsailOS / fluiddPi migration
script: make use of moonrakers new log_path configuration option

script: create webui nginx log symlinks upon installation/update
2021-06-15 15:56:13 +02:00
jordanruthe
f804fcb65d update: Fix detached head on KlipperScreen update (#93) 2021-06-13 17:39:12 +02:00
th33xitus
0edfc746d4 script: improve dependency checks on klipper/moonraker update 2021-06-08 17:55:40 +02:00
th33xitus
02ef0578e3 script: reading klipper/moonraker dependencies from their respective install scripts 2021-06-08 17:54:23 +02:00
th33xitus
5d11cd212a script: update install_moonraker.sh (#89) 2021-06-04 14:01:54 +02:00
cron410
bf33c77db7 script: install_klipper.sh prompt phrasing (#90) 2021-06-04 13:55:05 +02:00
th33xitus
0815d7778c feat: add cyberpunk theme to mainsail theme installer 2021-05-25 18:53:07 +02:00
th33xitus
9a3814f480 fix: typo in SYSTEMDDIR variable 2021-05-25 18:49:45 +02:00
th33xitus
a83585fb06 fix: improve pattern matching 2021-05-25 18:39:37 +02:00
th33xitus
dc27fe47e1 Merge branch 'b3tuning-install-mjpg-steamer-fix' 2021-05-25 12:16:27 +02:00
th33xitus
11b3d7a961 fix: replace config dir in webcamd file 2021-05-25 12:15:01 +02:00
th33xitus
9e0cdb0715 fix: remove webcamd file when removing mjpgstreamer 2021-05-25 12:13:36 +02:00
th33xitus
8abda56749 fix: typo in WEBCAM_TXT_SRC 2021-05-25 12:04:13 +02:00
James Hildebrand
cf20fc3c48 Issue 85 fix 2021-05-24 16:57:21 -07:00
th33xitus
6c8845d7b4 script: show found services in error message 2021-05-23 11:38:32 +02:00
th33xitus
fb0a30814d fix: validate user input for amount of Klipper instances to install 2021-05-23 10:44:51 +02:00
th33xitus
87f229c62d Update README.md 2021-05-23 10:08:16 +02:00
th33xitus
5b1da45688 fix: typo in dialog of get_mcu_id 2021-05-23 09:58:34 +02:00
th33xitus
545b978e80 update kiauh_macros.cfg
Update macros to reflect recent changes to Klipper

f10247a498
2021-05-21 08:55:11 +02:00
th33xitus
44f5609de6 script: remove deprecated moonraker.conf entries 2021-04-20 21:53:13 +02:00
th33xitus
f2a26d9b3d fix: false positive error message during klipper setup
add fix some status.sh functions too
2021-04-15 13:03:36 +02:00
Evgenii Shavrin
bb2cdab02b script: better moonraker service detection (#79)
More accurate service search
2021-04-13 12:21:16 +02:00
th33xitus
d6596d0a3d script: change kiauh update notification to a dialog 2021-04-08 18:07:30 +02:00
th33xitus
865fbc07dc script: updating webui nginx config and moonraker.conf template 2021-04-05 08:59:19 +02:00
th33xitus
40ba33eb19 fix: fix a bug that potentially caused writing a wrong config directory path to the moonraker.service file under special conditions 2021-04-03 19:29:59 +02:00
th33xitus
49b77162b0 fix: typo 2021-03-31 10:06:11 +02:00
th33xitus
adf087e3e5 script: activate [history] in moonraker.conf template 2021-03-31 09:16:31 +02:00
th33xitus
8220647564 script: rework mjpg-streamer service setup 2021-03-28 17:00:25 +02:00
th33xitus
57075ff525 script: rework klipper service setup 2021-03-28 16:45:16 +02:00
th33xitus
2f9de620bc script: rework moonraker service setup 2021-03-28 15:51:50 +02:00
th33xitus
d658c3a4cd fix: update nginx config 2021-03-28 15:46:48 +02:00
th33xitus
67f6a2c599 fix: broken update menu 2021-03-27 00:04:25 +01:00
th33xitus
f369c132d2 fix #74 - remove leftovers 2021-03-26 21:48:12 +01:00
th33xitus
cce6ac3c88 feat: add system upgrade 2021-03-26 18:36:05 +01:00
th33xitus
b9fe29068d script: apt-get update before apt-get install in dependency_check() 2021-03-25 21:40:16 +01:00
th33xitus
104089ea3d feat: add mjpg-streamer installer 2021-03-25 21:35:24 +01:00
th33xitus
48d97dab01 feat: backup moonraker database 2021-03-24 11:19:50 +01:00
th33xitus
e4a56564a1 fix: command for removing .octoprint dirs while uninstalling OctoPrint 2021-03-24 11:04:43 +01:00
th33xitus
6de8ce3278 script: add database_path to moonraker.conf template 2021-03-22 22:04:27 +01:00
th33xitus
b46457328f feat: followup to 7c7dd4e 2021-03-22 13:34:52 +01:00
th33xitus
7c7dd4ec3c feat: add mainsail theme installer 2021-03-22 10:55:24 +01:00
th33xitus
749293dde0 fix: visual bug 2021-03-17 16:13:53 +01:00
th33xitus
85f8ab4f24 fix: typo 2021-03-17 16:11:56 +01:00
th33xitus
e894496a6e script: add [history] to moonraker.conf template 2021-03-14 21:30:03 +01:00
th33xitus
19b220b772 fix: #71 2021-03-14 21:15:02 +01:00
th33xitus
a4eaa8952a script: remove unnecessary cors domains from moonraker.conf template 2021-03-12 11:20:38 +01:00
th33xitus
74a9bf783b script: deactivate moonrakers debug logging in moonraker.conf template 2021-03-11 22:08:05 +01:00
th33xitus
7597e999a1 fix: add 'octoprint_compat' entry to moonraker.conf template to enable slicer uploads 2021-03-05 09:12:00 +01:00
th33xitus
64d73ca86a refactor: determine installed services, combine single and multi remove into one step 2021-02-19 11:09:46 +01:00
th33xitus
d3283f7ab7 fix: try to fix a bug where the script errors out, telling that there is already a moonraker service installed but actually there isn't 2021-02-19 11:05:43 +01:00
th33xitus
cb443f6fee fix: rework remove processes 2021-02-17 20:50:36 +01:00
th33xitus
7162256e3f fix: remove klipperscreen log from tmp and user defined config folder 2021-02-17 20:31:26 +01:00
th33xitus
938b9d24f5 feature: add sdcard updates 2021-02-06 14:56:57 +01:00
th33xitus
38a3517c89 fix: autocommit.sh example uses .version files for getting mainsail and fluidd version 2021-02-06 12:16:04 +01:00
th33xitus
0b15cd0d9b fix: delete doubled status_msg in gcode_shell_command extension setup 2021-02-06 12:16:04 +01:00
th33xitus
9d7752a6c5 fix: typo in example pause macro 2021-02-04 19:36:57 +01:00
th33xitus
d1dff4d3b5 fix: logic error in build+flash function 2021-02-01 20:48:05 +01:00
th33xitus
49b7fe395b fix: detect an existing "legacy" klipper init.d installation 2021-01-31 18:34:05 +01:00
th33xitus
51469d8992 Update screenshot for KIAUH v3.0 2021-01-31 16:28:43 +01:00
34 changed files with 1458 additions and 955 deletions

View File

@@ -1,6 +1,6 @@
# **KIAUH - Klipper Installation And Update Helper**
![main_menu](resources/screenshots/main.png)
![main_menu](resources/screenshots/main_v3.png)
---
@@ -31,18 +31,11 @@ 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!
- **New in v3.0.0:** You can now install multiple instances (Klipper/Moonraker/DWC/Octoprint) on the same Pi!
---
### **Core Functions:**
@@ -67,18 +60,15 @@ Feel free to check out his work.
## **📝 Notes:**
- Tested **only** on Raspberry Pi OS Lite (Debian Buster)
- ( Although similar Debian based distributions might also work... )
- Tested **only** on Raspberry Pi OS Lite (Debian 10 Buster)
- Other Debian based distributions can work
- Reported to work on Armbian too
- During the use of this script you might be asked for your sudo password. There are several functions involved which need sudo privileges.
---
## **🛈 Sources & Further Information**
If you need some more detailed instructions on how to install Klipper and Mainsail with KIAUH, check out this website:\
[Installing Klipper and Mainsail](https://3dp.tumbleweedlabs.com/firmware/klipper-firmware/installing-klipper-and-mainsail-on-your-raspberry-pi)\
Credits for these instructions go to [@tumbleweedlabs](https://github.com/tumbleweedlabs).
For more information or instructions to the various components KIAUH can install, please check out the corresponding repositories listed below:
---

View File

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

View File

@@ -47,7 +47,6 @@ 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

View File

@@ -40,13 +40,11 @@ grab_version(){
cd ..
fi
if [ ! -z "$mainsail_folder" ]; then
mainsail_file=$(find $mainsail_folder/js -name "app.*.js" 2>/dev/null)
mainsail_ver=$(grep -o -E 'state:{packageVersion:.+' $mainsail_file | cut -d'"' -f2)
mainsail_ver=$(head -n 1 $mainsail_folder/.version)
m3="Mainsail version: $mainsail_ver"
fi
if [ ! -z "$fluidd_folder" ]; then
fluidd_file=$(find $fluidd_folder/js -name "app.*.js" 2>/dev/null)
fluidd_ver=$(grep -o -E '"setVersion",".+"' $fluidd_file | cut -d'"' -f4)
fluidd_ver=$(head -n 1 $fluidd_folder/.version)
m4="Fluidd version: $fluidd_ver"
fi
}

View File

@@ -1,9 +1,9 @@
#########################################################################################
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ AUTOCREATED WITH KIAUH ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
#########################################################################################
# Those are the recommended macros and config entries if you use Mainsail or Fluidd! #
# Feel free to edit or delete those macros if you already have them defined elsewhere! #
#########################################################################################
################################################################################
# ~~~~~~~~~~~~~~~~~~~~~~~~ AUTOCREATED WITH KIAUH ~~~~~~~~~~~~~~~~~~~~~~~~~~ #
################################################################################
# Recommended macros and config entries if you use Mainsail or Fluidd! #
# You can edit or delete those macros if you already defined them elsewhere! #
################################################################################
[pause_resume]
@@ -19,20 +19,18 @@ gcode:
[gcode_macro PAUSE]
rename_existing: BASE_PAUSE
# change this if you need more or less extrusion
variable_extrude: 1.0
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
##### set park positon for x and y #####
# default is your max posion from your printer.cfg
{% set x_park = printer.toolhead.axis_maximum.x|float - 5.0 %}
{% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %}
##### set defaults #####
{% set x = params.X|default(230) %} #edit to your park position
{% set y = params.Y|default(230) %} #edit to your park position
{% set z = params.Z|default(10)|float %} #edit to your park position
{% set e = params.E|default(1) %} #edit to your retract length
##### calculate save lift position #####
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.x|float %}
{% if act_z < (max_z - 2.0) %}
{% set z_safe = 2.0 %}
{% set act_z = printer.toolhead.position.z|float %}
{% set lift_z = z|abs %}
{% if act_z < (max_z - lift_z) %}
{% set z_safe = lift_z %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
@@ -40,21 +38,22 @@ gcode:
SAVE_GCODE_STATE NAME=PAUSE_state
BASE_PAUSE
G91
G1 E-{E} F2100
G1 Z{z_safe} F900
G1 E-{e} F2100
G1 Z{z_safe}
G90
G1 X{x_park} Y{y_park} F6000
G1 X{x} Y{y} F6000
[gcode_macro RESUME]
rename_existing: BASE_RESUME
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
##### end of definitions #####
##### set defaults #####
{% set e = params.E|default(1) %} #edit to your retract length
G91
G1 E{E} F2100
RESTORE_GCODE_STATE NAME=PAUSE_state
G1 E{e} F2100
G90
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
BASE_RESUME
#########################################################################################
#########################################################################################
################################################################################
################################################################################

15
resources/klipper.service Normal file
View File

@@ -0,0 +1,15 @@
#Systemd service file for klipper
[Unit]
Description=Starts klipper instance %INST% on startup
After=network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
User=%USER%
RemainAfterExit=yes
ExecStart=%KL_ENV%/bin/python %KL_DIR%/klippy/klippy.py %P_CFG% -I %P_TMP% -l %KL_LOG% -a %KL_UDS%
Restart=always
RestartSec=10

View File

@@ -2,12 +2,11 @@
server {
listen 80;
listen [::]:80;
access_log /var/log/nginx/<<UI>>-access.log;
error_log /var/log/nginx/<<UI>>-error.log;
#disable this section on smaller hardware like a pi zero
# disable this section on smaller hardware like a pi zero
gzip on;
gzip_vary on;
gzip_proxied any;
@@ -17,15 +16,18 @@ server {
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
# web_path from <<UI>> static files
root /home/pi/<<UI>>;
index index.html;
server_name _;
#max upload size for gcodes (0 = no limit)
# disable max upload size checks
client_max_body_size 0;
# disable proxy request buffering
proxy_request_buffering off;
location / {
try_files $uri $uri/ /index.html;
}

44
resources/moonraker.conf Normal file
View File

@@ -0,0 +1,44 @@
[server]
host: 0.0.0.0
port: %PORT%
enable_debug_logging: False
config_path: %CFG%
log_path: %LOG%
database_path: %MR_DB%
klippy_uds_address: %UDS%
[authorization]
trusted_clients:
127.0.0.1
%LAN%
::1/128
FE80::/10
cors_domains:
*.lan
*.local
*://my.mainsail.xyz
*://app.fluidd.xyz
[octoprint_compat]
[history]
[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

View File

@@ -0,0 +1,15 @@
#Systemd service file for moonraker
[Unit]
Description=Starts Moonraker %INST% on startup
After=network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
User=%USER%
RemainAfterExit=yes
ExecStart=%MR_ENV%/bin/python %MR_DIR%/moonraker/moonraker.py -l %MR_LOG% -c %MR_CONF%
Restart=always
RestartSec=10

14
resources/printer.cfg Normal file
View File

@@ -0,0 +1,14 @@
[mcu]
serial: /dev/serial/by-id/<your-mcu-id>
[pause_resume]
[display_status]
[virtual_sdcard]
path: ~/gcode_files
[printer]
kinematics: none
max_velocity: 1000
max_accel: 1000

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

16
resources/webcamd.service Normal file
View File

@@ -0,0 +1,16 @@
[Unit]
Description=Starts mjpg-streamer on startup
After=network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=forking
User=%USER%
WorkingDirectory=/usr/local/bin
StandardOutput=append:/var/log/webcamd.log
StandardError=append:/var/log/webcamd.log
ExecStart=/usr/local/bin/webcamd
Restart=always
RestartSec=10

View File

@@ -35,9 +35,9 @@ read_bb4u_stat(){
fi
}
##############################################################################################
#********************************************************************************************#
##############################################################################################
################################################################################
#******************************************************************************#
################################################################################
backup_printer_cfg(){
check_for_backup_dir
@@ -68,17 +68,21 @@ backup_klipper_config_dir(){
fi
}
###TODO re-evaluate if this function is still needed (just backup the full klipper_config dir instead?)
backup_moonraker_conf(){
backup_moonraker_database(){
check_for_backup_dir
if [ -f ${HOME}/moonraker.conf ]; then
if ls -d ${HOME}/.moonraker_database* 2>/dev/null 1>&2; then
get_date
status_msg "Timestamp: $current_date"
status_msg "Create backup of moonraker.conf ..."
cp ${HOME}/moonraker.conf $BACKUP_DIR/moonraker.conf."$current_date".backup && ok_msg "Backup complete!"
mkdir -p "$BACKUP_DIR/mr_db_backup/$current_date"
for database in $(ls -d ${HOME}/.moonraker_database*)
do
status_msg "Create backup of $database ..."
cp -r $database "$BACKUP_DIR/mr_db_backup/$current_date"
ok_msg "Done!"
done
ok_msg "Backup complete!\n"
else
ok_msg "No moonraker.conf found! Skipping backup ..."
ok_msg "No Moonraker database found! Skipping backup ..."
fi
}

View File

@@ -1,3 +1,6 @@
### base variables
SYSTEMDDIR="/etc/systemd/system"
# setting up some frequently used functions
check_euid(){
if [ "$EUID" -eq 0 ]
@@ -77,54 +80,55 @@ change_klipper_cfg_path(){
done
}
###? if path was changed in 'change_klipper_cfg_path', we need to edit the service files
###? and set the new path. after that, rename the old folder and reload service units.
###! users shouldn't try and move the files into subfolders with this function! as the mv command will fail
###! but the new path still gets written to the service files. if they really need to, they need to move all
###! config files or printer folder into that subfolder (still not recommended!)
set_klipper_cfg_path(){
### stop services
klipper_service "stop" && moonraker_service "stop"
### rename the klipper config folder
### copy config files to new klipper config folder
if [ ! -z "$old_klipper_cfg_loc" ] && [ -d "$old_klipper_cfg_loc" ]; then
status_msg "Renaming '$old_klipper_cfg_loc' to '$new_klipper_cfg_loc'!"; echo
mv -v "$old_klipper_cfg_loc" "$new_klipper_cfg_loc" && ok_msg "Done!"
if [ ! -d "$new_klipper_cfg_loc" ]; then
status_msg "Copy config files to '$new_klipper_cfg_loc' ..."
mkdir -p $new_klipper_cfg_loc
cd $old_klipper_cfg_loc
cp -r -v ./* $new_klipper_cfg_loc
ok_msg "Done!"
fi
fi
### handle single klipper instance service file
if [ -f /etc/systemd/system/klipper.service ]; then
if [ -f $SYSTEMDDIR/klipper.service ]; then
status_msg "Configuring Klipper for new path ..."
sudo sed -i "/ExecStart=/ s|$old_klipper_cfg_loc/printer.cfg|$new_klipper_cfg_loc/printer.cfg|" /etc/systemd/system/klipper.service
sudo sed -i -r "/ExecStart=/ s| (.+)\/printer.cfg| $new_klipper_cfg_loc/printer.cfg|" $SYSTEMDDIR/klipper.service
ok_msg "OK!"
fi
### handle multi klipper instance service file
if ls /etc/systemd/system/klipper-*.service 2>/dev/null 1>&2; then
if ls $SYSTEMDDIR/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
for service in $(find $SYSTEMDDIR/klipper-*.service); do
sudo sed -i -r "/ExecStart=/ s| (.+)\/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
if [ -f $SYSTEMDDIR/moonraker.service ]; then
status_msg "Configuring Moonraker for new path ..."
sudo sed -i "/ExecStart=/ s|$old_klipper_cfg_loc/moonraker.conf|$new_klipper_cfg_loc/moonraker.conf|" /etc/systemd/system/moonraker.service
sudo sed -i -r "/ExecStart=/ s|-c (.+)\/moonraker\.conf|-c $new_klipper_cfg_loc/moonraker.conf|" $SYSTEMDDIR/moonraker.service
### replace old file path with new one in moonraker.conf
sed -i "/config_path:/ s|config_path:.*|config_path: $new_klipper_cfg_loc|" $new_klipper_cfg_loc/moonraker.conf
sed -i -r "/config_path:/ s|config_path:.*|config_path: $new_klipper_cfg_loc|" $new_klipper_cfg_loc/moonraker.conf
ok_msg "OK!"
fi
### handle multi moonraker instance service file
if ls /etc/systemd/system/moonraker-*.service 2>/dev/null 1>&2; then
if ls $SYSTEMDDIR/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
for service in $(find $SYSTEMDDIR/moonraker-*.service); do
sudo sed -i -r "/ExecStart=/ s|-c (.+)\/printer_|-c $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
sed -i -r "/config_path:/ s|config_path:.*|config_path: $loc|" $moonraker_conf
done
ok_msg "OK!"
fi
@@ -244,6 +248,9 @@ toggle_octoprint_service(){
read_octoprint_service_status(){
unset OPRINT_SERVICE_STATUS
if [ ! -f "/etc/systemd/system/octoprint.service" ]; then
return 0
fi
if systemctl list-unit-files | grep -E "octoprint*" | grep "enabled" &>/dev/null; then
OPRINT_SERVICE_STATUS="${red}[Disable]${default} OctoPrint Service "
else
@@ -291,7 +298,7 @@ dependency_check(){
echo -e "${cyan}$element ${default}"
done
echo
sudo apt-get install ${inst[@]} -y
sudo apt-get update && sudo apt-get install ${inst[@]} -y
ok_msg "Dependencies installed!"
#clearing the array
unset inst
@@ -333,10 +340,8 @@ setup_gcode_shell_command(){
Y|y|Yes|yes|"")
if [ -d $KLIPPER_DIR/klippy/extras ]; then
status_msg "Installing gcode shell command extension ..."
status_msg "Copy gcode_shell_command.py to '$KLIPPER_DIR/klippy/extras' ..."
if [ -f $KLIPPER_DIR/klippy/extras/gcode_shell_command.py ]; then
warn_msg "There is already a file named 'gcode_shell_command.py'"
warn_msg "in the destination location!"
warn_msg "There is already a file named 'gcode_shell_command.py'\nin the destination location!"
while true; do
read -p "${cyan}###### Do you want to overwrite it? (Y/n):${default} " yn
case "$yn" in
@@ -366,10 +371,10 @@ setup_gcode_shell_command(){
install_gcode_shell_command(){
klipper_service "stop"
status_msg "Copy 'gcode_shell_command.py' to $KLIPPER_DIR/klippy/extras"
status_msg "Copy 'gcode_shell_command.py' to '$KLIPPER_DIR/klippy/extras' ..."
cp ${SRCDIR}/kiauh/resources/gcode_shell_command.py $KLIPPER_DIR/klippy/extras
echo
while true; do
echo
read -p "${cyan}###### Do you want to create the example shell command? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")

View File

@@ -6,8 +6,12 @@ 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
### check for existing klipper service files
INITD=$(ls /etc/init.d | grep -E "^klipper(\-[[:digit:]]+)?$")
SYSTEMD=$(ls /etc/systemd/system | grep -E "^klipper(\-[[:digit:]]+)?\.service$")
if [ ! -z "$INITD" ] || [ ! -z "$SYSTEMD" ]; then
echo "${red}$INITD${default}" && echo "${red}$SYSTEMD${default}"
ERROR_MSG="At least one Klipper service is already installed!\n Please remove Klipper first, before installing it again." && return 0
fi
@@ -15,19 +19,19 @@ klipper_setup_dialog(){
check_klipper_cfg_path
### ask for amount of instances to create
while true; do
INSTANCE_COUNT=""
while [[ ! ($INSTANCE_COUNT =~ ^[1-9]+$) ]]; do
echo
read -p "${cyan}###### Number of Klipper instances to set up:${default} " INSTANCE_COUNT
if [[ ! ($INSTANCE_COUNT =~ ^[1-9]+$) ]]; then
warn_msg "Invalid Input!" && echo
else
echo
read -p "${cyan}###### How many Klipper instances do you want to set up?:${default} " INSTANCE_COUNT
echo
if [ $INSTANCE_COUNT == 1 ]; then
read -p "${cyan}###### Create $INSTANCE_COUNT single instance? (Y/n):${default} " yn
else
read -p "${cyan}###### Create $INSTANCE_COUNT instances? (Y/n):${default} " yn
fi
read -p "${cyan}###### Install $INSTANCE_COUNT instance(s)? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
echo -e "###### > Yes"
status_msg "Creating $INSTANCE_COUNT Klipper instances ..."
status_msg "Installing $INSTANCE_COUNT Klipper instance(s) ..."
klipper_setup
break;;
N|n|No|no)
@@ -38,24 +42,22 @@ klipper_setup_dialog(){
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
esac
fi
done
}
install_klipper_packages(){
### Packages for python cffi
PKGLIST="python-virtualenv virtualenv python-dev libffi-dev build-essential"
### kconfig requirements
PKGLIST="${PKGLIST} libncurses-dev"
### hub-ctrl
PKGLIST="${PKGLIST} libusb-dev"
### AVR chip installation and building
PKGLIST="${PKGLIST} avrdude gcc-avr binutils-avr avr-libc"
### ARM chip installation and building
PKGLIST="${PKGLIST} stm32flash libnewlib-arm-none-eabi"
PKGLIST="${PKGLIST} gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0"
### dbus requirement for DietPi
PKGLIST="${PKGLIST} dbus"
### read PKGLIST from official install script
status_msg "Reading dependencies..."
install_script="${HOME}/klipper/scripts/install-octopi.sh"
PKGLIST=$(grep "PKGLIST=" $install_script | sed 's/PKGLIST//g; s/[$={}\n"]//g')
### rewrite packages into new array
unset PKGARR
for PKG in $PKGLIST; do PKGARR+=($PKG); done
### add dbus requirement for DietPi distro
PKGARR+=("dbus")
echo "${cyan}${PKGARR[@]}${default}"
### Update system package info
status_msg "Running apt-get update..."
@@ -63,7 +65,7 @@ install_klipper_packages(){
### Install desired packages
status_msg "Installing packages..."
sudo apt-get install --yes ${PKGLIST}
sudo apt-get install --yes ${PKGARR[@]}
}
create_klipper_virtualenv(){
@@ -74,178 +76,112 @@ create_klipper_virtualenv(){
${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}
### step 1: clone klipper
status_msg "Downloading Klipper ..."
### force remove existing klipper dir and clone into fresh klipper dir
[ -d $KLIPPER_DIR ] && rm -rf $KLIPPER_DIR
git clone $KLIPPER_REPO
cd ${HOME} && git clone $KLIPPER_REPO
status_msg "Download complete!"
### install klipper dependencies and create python virtualenv
### step 2: install klipper dependencies and create python virtualenv
status_msg "Installing dependencies ..."
install_klipper_packages
create_klipper_virtualenv
### create shared gcode_files folder
### step 3: create shared gcode_files and logs folder
[ ! -d ${HOME}/gcode_files ] && mkdir -p ${HOME}/gcode_files
### create shared config folder
[ ! -d $PRINTER_CFG_LOC ] && mkdir -p $PRINTER_CFG_LOC
[ ! -d ${HOME}/klipper_logs ] && mkdir -p ${HOME}/klipper_logs
### create klipper instances
INSTANCE=1
if [ $INSTANCE_COUNT -eq $INSTANCE ]; then
create_single_klipper_instance
else
create_multi_klipper_instance
fi
}
create_single_klipper_instance(){
status_msg "Setting up 1 Klipper instance ..."
### single instance variables
KLIPPER_LOG=/tmp/klippy.log
KLIPPY_UDS=/tmp/klippy_uds
PRINTER_CFG="$PRINTER_CFG_LOC/printer.cfg"
### create instance
status_msg "Creating single Klipper instance ..."
status_msg "Installing system start script ..."
create_single_klipper_startscript
### create printer config directory if missing
[ ! -d $PRINTER_CFG_LOC ] && mkdir -p $PRINTER_CFG_LOC
### create basic configs if missing
[ ! -f $PRINTER_CFG ] && create_minimal_printer_cfg "$PRINTER_CFG"
### enable instance
sudo systemctl enable klipper.service
ok_msg "Single Klipper instance created!"
### launching instance
status_msg "Launching Klipper instance ..."
sudo systemctl start klipper
### 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
### step 4: create klipper instances
create_klipper_service
### confirm message
CONFIRM_MSG="$INSTANCE_COUNT Klipper instances have been set up!"
[ $INSTANCE_COUNT -eq 1 ] && CONFIRM_MSG="Klipper has been set up!"
print_msg && clear_msg
}
create_klipper_service(){
### get config directory
source_kiauh_ini
##############################################################################################
#********************************************************************************************#
##############################################################################################
### set up default values
SINGLE_INST=1
CFG_PATH="$klipper_cfg_loc"
KL_ENV=$KLIPPY_ENV
KL_DIR=$KLIPPER_DIR
KL_LOG="${HOME}/klipper_logs/klippy.log"
KL_UDS="/tmp/klippy_uds"
P_TMP="/tmp/printer"
P_CFG="$CFG_PATH/printer.cfg"
P_CFG_SRC="${SRCDIR}/kiauh/resources/printer.cfg"
KL_SERV_SRC="${SRCDIR}/kiauh/resources/klipper.service"
KL_SERV_TARGET="$SYSTEMDDIR/klipper.service"
write_kl_service(){
[ ! -d $CFG_PATH ] && mkdir -p $CFG_PATH
### create a minimal config if there is no printer.cfg
[ ! -f $P_CFG ] && cp $P_CFG_SRC $P_CFG
### replace placeholder
if [ ! -f $KL_SERV_TARGET ]; then
status_msg "Creating Klipper Service $i ..."
sudo cp $KL_SERV_SRC $KL_SERV_TARGET
sudo sed -i "s|%INST%|$i|" $KL_SERV_TARGET
sudo sed -i "s|%USER%|${USER}|" $KL_SERV_TARGET
sudo sed -i "s|%KL_ENV%|$KL_ENV|" $KL_SERV_TARGET
sudo sed -i "s|%KL_DIR%|$KL_DIR|" $KL_SERV_TARGET
sudo sed -i "s|%KL_LOG%|$KL_LOG|" $KL_SERV_TARGET
sudo sed -i "s|%P_CFG%|$P_CFG|" $KL_SERV_TARGET
sudo sed -i "s|%P_TMP%|$P_TMP|" $KL_SERV_TARGET
sudo sed -i "s|%KL_UDS%|$KL_UDS|" $KL_SERV_TARGET
fi
}
if [ $SINGLE_INST -eq $INSTANCE_COUNT ]; then
### write single instance service
write_kl_service
### enable instance
sudo systemctl enable klipper.service
ok_msg "Single Klipper instance created!"
### launching instance
status_msg "Launching Klipper instance ..."
sudo systemctl start klipper
else
i=1
while [ $i -le $INSTANCE_COUNT ]; do
### rewrite default variables for multi instance cases
CFG_PATH="$klipper_cfg_loc/printer_$i"
KL_SERV_TARGET="$SYSTEMDDIR/klipper-$i.service"
P_TMP="/tmp/printer-$i"
P_CFG="$CFG_PATH/printer.cfg"
KL_LOG="${HOME}/klipper_logs/klippy-$i.log"
KL_UDS="/tmp/klippy_uds-$i"
### write multi instance service
write_kl_service
### enable instance
sudo systemctl enable klipper-$i.service
ok_msg "Klipper instance #$i created!"
### launching instance
status_msg "Launching Klipper instance #$i ..."
sudo systemctl start klipper-$i
### raise values by 1
i=$((i+1))
done
unset i
fi
}
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'. |"
echo -e "| Flashing a Smoothie based board with this method will |"
echo -e "| certainly fail. This applies to boards like the SKR |"
echo -e "| V1.3 / V1.4. You have to copy the firmware file to |"
echo -e "| the SD card manually and rename it to 'firmware.bin'. |"
hr
echo -e "| You can find the file in: ~/klipper/out/klipper.bin |"
bottom_border
@@ -254,10 +190,12 @@ flash_routine(){
case "$yn" in
Y|y|Yes|yes|"")
echo -e "###### > Yes"
FLASH_FIRMWARE="true"
get_mcu_id
break;;
N|n|No|no)
echo -e "###### > No"
FLASH_FIRMWARE="false"
break;;
*)
print_unkown_cmd
@@ -266,7 +204,36 @@ flash_routine(){
done
}
flash_mcu(){
flash_routine_sd(){
echo
top_border
echo -e "| ${red}~~~~~~~~~~~ [ ATTENTION! ] ~~~~~~~~~~~~${default} |"
hr
echo -e "| If you have a Smoothie based board with an already |"
echo -e "| flashed Klipper Firmware, you can now choose to flash |"
echo -e "| directly from the internal SD if your control board |"
echo -e "| is supported by that function. |"
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"
FLASH_FW_SD="true"
get_mcu_id
break;;
N|n|No|no)
echo -e "###### > No"
FLASH_FW_SD="false"
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
}
select_mcu_id(){
if [ ${#mcu_list[@]} -ge 1 ]; then
top_border
echo -e "| ${red}!!! IMPORTANT WARNING !!!${default} |"
@@ -288,23 +255,22 @@ flash_mcu(){
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"
read -p "${cyan}###### Please select the ID for flashing:${default} " selected_index
mcu_index=$(echo $((selected_index - 1)))
selected_mcu_id="${mcu_list[$mcu_index]}"
echo -e "\nYou have selected to flash:\n● MCU #$selected_index: $selected_mcu_id\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"
status_msg "Flashing $selected_mcu_id ..."
if [ "$FLASH_FIRMWARE" = "true" ]; then
flash_mcu
fi
if [ "$FLASH_FW_SD" = "true" ]; then
flash_mcu_sd
fi
break;;
N|n|No|no)
echo -e "###### > No"
@@ -319,13 +285,94 @@ flash_mcu(){
fi
}
flash_mcu(){
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"
}
flash_mcu_sd(){
klipper_service "stop"
### write each supported board to the array to make it selectable
board_list=()
for board in $(~/klipper/scripts/flash-sdcard.sh -l | tail -n +2); do
board_list+=($board)
done
i=0
top_border
echo -e "| Please select the type of board that corresponds to |"
echo -e "| the currently selected MCU ID you chose before. |"
blank_line
echo -e "| The following boards are currently supported: |"
hr
### display all supported boards to the user
for board in ${board_list[@]}; do
if [ $i -lt 10 ]; then
printf "| $i) %-50s|\n" "${board_list[$i]}"
else
printf "| $i) %-49s|\n" "${board_list[$i]}"
fi
i=$((i + 1))
done
quit_footer
### make the user select one of the boards
while true; do
read -p "${cyan}###### Please select board type:${default} " choice
if [ $choice = "q" ] || [ $choice = "Q" ]; then
clear && advanced_menu && break
elif [ $choice -le ${#board_list[@]} ]; then
selected_board="${board_list[$choice]}"
break
else
clear && print_header
ERROR_MSG="Invalid choice!" && print_msg && clear_msg
flash_mcu_sd
fi
done
while true; do
top_border
echo -e "| If your board is flashed with firmware that connects |"
echo -e "| at a custom baud rate, please change it now. |"
blank_line
echo -e "| If you are unsure, stick to the default 250000! |"
bottom_border
echo -e "${cyan}###### Please set the baud rate:${default} "
unset baud_rate
while [[ ! $baud_rate =~ ^[0-9]+$ ]]; do
read -e -i "250000" -e baud_rate
selected_baud_rate=$baud_rate
break
done
break
done
if ! ${HOME}/klipper/scripts/flash-sdcard.sh -b "$selected_baud_rate" "$selected_mcu_id" "$selected_board" ; then
warn_msg "Flashing failed!"
warn_msg "Please read the console output above!"
else
ok_msg "Flashing successfull!"
fi
klipper_service "start"
}
build_fw(){
if [ -d $KLIPPER_DIR ]; then
cd $KLIPPER_DIR
status_msg "Initializing firmware Setup ..."
status_msg "Initializing firmware build ..."
make clean
make menuconfig
status_msg "Building firmware ..."
make clean && make && ok_msg "Firmware built!"
make && ok_msg "Firmware built!"
else
warn_msg "Can not build firmware without a Klipper directory!"
fi
@@ -340,7 +387,7 @@ get_mcu_id(){
bottom_border
while true; do
echo -e "${cyan}"
read -p "###### Press any key to continue ... " yn
read -p "###### Press ENTER to continue ... " yn
echo -e "${default}"
case "$yn" in
*)

View File

@@ -7,6 +7,30 @@ check_moonraker(){
fi
}
get_user_selection_mjpg-streamer(){
while true; do
unset INSTALL_MJPG
echo
top_border
echo -e "| Install MJGP-Streamer for webcam support? |"
bottom_border
read -p "${cyan}###### Install MJPG-Streamer? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
echo -e "###### > Yes"
INSTALL_MJPG="true"
break;;
N|n|No|no)
echo -e "###### > No"
INSTALL_MJPG="false"
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
}
get_user_selection_kiauh_macros(){
#ask user for webui default macros
while true; do
@@ -67,17 +91,47 @@ install_webui(){
### check if another site already listens to port 80
$1_port_check
### ask user to install mjpg-streamer
get_user_selection_mjpg-streamer
### 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"
### symlink nginx log
symlink_webui_nginx_log "$1"
### copy the kiauh_macros.cfg to the config location
install_kiauh_macros
### install mainsail/fluidd
$1_setup
### install mjpg-streamer
[ "$INSTALL_MJPG" = "true" ] && install_mjpg-streamer
### confirm message
CONFIRM_MSG="$IF_NAME1 has been set up!"
print_msg && clear_msg
}
symlink_webui_nginx_log(){
LPATH="${HOME}/klipper_logs"
UI_ACCESS_LOG="/var/log/nginx/$1-access.log"
UI_ERROR_LOG="/var/log/nginx/$1-error.log"
[ ! -d "$LPATH" ] && mkdir -p "$LPATH"
if [ -f "$UI_ACCESS_LOG" ] && [ ! -L "$LPATH/$1-access.log" ]; then
status_msg "Creating symlink for $UI_ACCESS_LOG ..."
ln -s $UI_ACCESS_LOG "$LPATH"
ok_msg "OK!"
fi
if [ -f "$UI_ERROR_LOG" ] && [ ! -L "$LPATH/$1-error.log" ]; then
status_msg "Creating symlink for $UI_ERROR_LOG ..."
ln -s $UI_ERROR_LOG "$LPATH"
ok_msg "OK!"
fi
}
install_kiauh_macros(){
@@ -87,24 +141,26 @@ install_kiauh_macros(){
### create a backup of the config folder
backup_klipper_config_dir
### handle multi printer.cfg
if ls $klipper_cfg_loc/printer_* 2>/dev/null 1>&2; then
if ls $klipper_cfg_loc/printer_* 2>/dev/null 1>&2; then
for config in $(find $klipper_cfg_loc/printer_*/printer.cfg); do
path=$(echo $config | rev | cut -d"/" -f2- | rev)
if [ ! -f $path/kiauh_macros.cfg ]; then
### copy kiauh_macros.cfg to config location
status_msg "Creating macro config file ..."
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
ok_msg "$path/kiauh_macros.cfg created!"
fi
done
### handle single printer.cfg
elif [ -f $klipper_cfg_loc/printer.cfg ] && [ ! -f $klipper_cfg_loc/kiauh_macros.cfg ]; then
### copy kiauh_macros.cfg to config location
status_msg "Creating macro config file ..."
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
ok_msg "$klipper_cfg_loc/kiauh_macros.cfg created!"
fi
### restart klipper service to parse the modified printer.cfg
klipper_service "restart"
@@ -247,8 +303,6 @@ mainsail_setup(){
if [ $(ls /etc/systemd/system/moonraker* | wc -l) -gt 1 ]; then
enable_mainsail_remotemode
fi
ok_msg "Mainsail installation complete!\n"
}
enable_mainsail_remotemode(){
@@ -272,6 +326,5 @@ fluidd_setup(){
### delete downloaded zip
status_msg "Remove downloaded archive ..."
rm -rf *.zip && ok_msg "Done!" && ok_msg "Fluidd installation complete!"
echo
rm -rf *.zip && ok_msg "Done!"
}

View File

@@ -2,13 +2,8 @@ install_klipperscreen(){
python3_check
if [ $py_chk_ok = "true" ]; then
source_kiauh_ini
system_check_klipperscreen
#ask user for customization
get_user_selections_klipperscreen
#KlipperScreen main installation
klipperscreen_setup
#execute customizations
symlinks_klipperscreen
#after install actions
restart_klipperscreen
else
@@ -29,57 +24,16 @@ python3_check(){
fi
}
system_check_klipperscreen(){
source_kiauh_ini
if [ ! -e $klipper_cfg_loc/KlipperScreen.log ]; then
KLIPPERSCREEN_SL_FOUND="false"
else
KLIPPERSCREEN_SL_FOUND="true"
fi
}
get_user_selections_klipperscreen(){
#user selection for KlipperScreen.log symlink
if [ "$KLIPPERSCREEN_SL_FOUND" = "false" ]; then
while true; do
echo
read -p "${cyan}###### Create KlipperScreen.log symlink? (y/N):${default} " yn
case "$yn" in
Y|y|Yes|yes)
echo -e "###### > Yes"
SEL_KSLOG_SL="true"
break;;
N|n|No|no|"")
echo -e "###### > No"
SEL_KSLOG_SL="false"
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
fi
}
klipperscreen_setup(){
dep=(wget curl unzip dfu-util)
dependency_check
status_msg "Downloading KlipperScreen ..."
#force remove existing KlipperScreen dir
# force remove existing KlipperScreen dir
[ -d $KLIPPERSCREEN_DIR ] && rm -rf $KLIPPERSCREEN_DIR
#clone into fresh KlipperScreen dir
# clone into fresh KlipperScreen dir
cd ${HOME} && git clone $KLIPPERSCREEN_REPO
ok_msg "Download complete!"
status_msg "Installing KlipperScreen ..."
$KLIPPERSCREEN_DIR/scripts/KlipperScreen-install.sh
echo; ok_msg "KlipperScreen successfully installed!"
}
symlinks_klipperscreen(){
#create a KlipperScreen.log symlink in klipper_config-dir just for convenience
if [ "$SEL_KSLOG_SL" = "true" ] && [ ! -e $klipper_cfg_loc/KlipperScreen.log ]; then
status_msg "Creating KlipperScreen.log symlink ..."
ln -s /tmp/KlipperScreen.log $klipper_cfg_loc
ok_msg "Symlink created!"
fi
ok_msg "KlipperScreen successfully installed!"
}

View File

@@ -0,0 +1,93 @@
### base variables
SYSTEMDDIR="/etc/systemd/system"
WEBCAMD_SRC="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mjpgstreamer/filesystem/root/usr/local/bin/webcamd"
WEBCAM_TXT_SRC="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mjpgstreamer/filesystem/home/pi/klipper_config/webcam.txt"
install_mjpg-streamer(){
### checking dependencies
check_klipper_cfg_path
### set default values
MJPG_SERV_SRC="${SRCDIR}/kiauh/resources/webcamd.service"
MJPG_SERV_TARGET="$SYSTEMDDIR/webcamd.service"
WEBCAM_TXT="$klipper_cfg_loc/webcam.txt"
### if there is a webcamd.service -> exit
if [ -f $MJPG_SERV_TARGET ]; then
ERROR_MSG="Looks like MJPG-streamer is already installed!\n Please remove it first before you try to re-install it!"
print_msg && clear_msg && return 0
fi
### check and install dependencies if missing
dep=(build-essential git imagemagick libv4l-dev libjpeg-dev libjpeg62-turbo-dev cmake)
dependency_check
### step 1: clone moonraker
status_msg "Downloading MJPG-Streamer ..."
cd ${HOME} && git clone https://github.com/jacksonliam/mjpg-streamer.git
ok_msg "Download complete!"
### step 2: compiling mjpg-streamer
status_msg "Compiling MJPG-Streamer ..."
cd ${HOME}/mjpg-streamer/mjpg-streamer-experimental && make
ok_msg "Compiling complete!"
#step 3: install mjpg-streamer
status_msg "Installing MJPG-Streamer ..."
cd ${HOME}/mjpg-streamer && mv mjpg-streamer-experimental/* .
mkdir www-mjpgstreamer
cat <<EOT >> ./www-mjpgstreamer/index.html
<html>
<head><title>mjpg_streamer test page</title></head>
<body>
<h1>Snapshot</h1>
<p>Refresh the page to refresh the snapshot</p>
<img src="./?action=snapshot" alt="Snapshot">
<h1>Stream</h1>
<img src="./?action=stream" alt="Stream">
</body>
</html>
EOT
sudo wget $WEBCAMD_SRC -O "/usr/local/bin/webcamd"
sudo sed -i "/^config_dir=/ s|=.*|=$klipper_cfg_loc|" /usr/local/bin/webcamd
sudo sed -i "/MJPGSTREAMER_HOME/ s/pi/${USER}/" /usr/local/bin/webcamd
sudo chmod +x /usr/local/bin/webcamd
### step 4: create webcam.txt config file
[ ! -d $klipper_cfg_loc ] && mkdir -p $klipper_cfg_loc
if [ ! -f $WEBCAM_TXT ]; then
status_msg "Creating webcam.txt config file ..."
wget $WEBCAM_TXT_SRC -O $WEBCAM_TXT
ok_msg "Done!"
fi
### step 5: create systemd service
status_msg "Creating MJPG-Streamer service ..."
sudo cp $MJPG_SERV_SRC $MJPG_SERV_TARGET
sudo sed -i "s|%USER%|${USER}|" $MJPG_SERV_TARGET
ok_msg "MJPG-Streamer service created!"
### step 6: enabling and starting mjpg-streamer service
status_msg "Starting MJPG-Streamer service ..."
sudo systemctl enable webcamd.service
sudo systemctl start webcamd.service
ok_msg "MJPG-Streamer service started!"
### step 6.1: create webcamd.log symlink
[ ! -d ${HOME}/klipper_logs ] && mkdir -p "${HOME}/klipper_logs"
if [ -f "/var/log/webcamd.log" ] && [ ! -L "${HOME}/klipper_logs/webcamd.log" ]; then
ln -s "/var/log/webcamd.log" "${HOME}/klipper_logs/webcamd.log"
fi
### confirm message
CONFIRM_MSG="MJPG-Streamer has been set up!"
print_msg && clear_msg
### print webcam ip adress/url
IP=$(hostname -I | cut -d" " -f1)
WEBCAM_IP="http://$IP:8080/?action=stream"
WEBCAM_URL="http://$IP/webcam/?action=stream"
echo -e " ${cyan}● Webcam URL:${default} $WEBCAM_IP"
echo -e " ${cyan}● Webcam URL:${default} $WEBCAM_URL"
echo
}

View File

@@ -2,6 +2,7 @@
SYSTEMDDIR="/etc/systemd/system"
MOONRAKER_ENV="${HOME}/moonraker-env"
MOONRAKER_DIR="${HOME}/moonraker"
MOONRAKER_REPO="https://github.com/Arksine/moonraker.git"
system_check_moonraker(){
### python 3 check
@@ -45,15 +46,19 @@ moonraker_setup_dialog(){
print_msg && clear_msg && return 0
fi
shopt -s extglob # enable extended globbing
### 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
FILE="$SYSTEMDDIR/moonraker?(-*([0-9])).service"
if ls $FILE 2>/dev/null 1>&2; 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
FILE="$SYSTEMDDIR/klipper?(-*([0-9])).service"
if ! ls $FILE 2>/dev/null 1>&2; then
ERROR_MSG="Klipper service not found, please install Klipper first!" && return 0
fi
shopt -u extglob # disable extended globbing
### count amount of klipper services
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ]; then
@@ -101,10 +106,6 @@ moonraker_setup_dialog(){
}
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
@@ -124,8 +125,7 @@ moonraker_setup(){
create_moonraker_virtualenv
### step 3: create moonraker.conf folder and moonraker.confs
[ ! -d $MOONRAKER_CONF_LOC ] && mkdir -p $MOONRAKER_CONF_LOC
moonraker_conf_creation
create_moonraker_conf
### step 4: set up moonrakers nginx configs
setup_moonraker_nginx_cfg
@@ -133,25 +133,27 @@ moonraker_setup(){
### 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
# ### step 6: create final moonraker instances
create_moonraker_service
### confirm message
CONFIRM_MSG="$INSTANCE_COUNT Moonraker instances have been set up!"
[ $INSTANCE_COUNT -eq 1 ] && CONFIRM_MSG="Moonraker has been set up!"
print_msg && clear_msg
### display moonraker ips to the user
print_mr_ip_list; echo
}
##############################################################################################
#********************************************************************************************#
##############################################################################################
install_moonraker_packages(){
PKGLIST="python3-virtualenv python3-dev nginx libopenjp2-7 python3-libgpiod"
### read PKGLIST from official install script
status_msg "Reading dependencies..."
install_script="${HOME}/moonraker/scripts/install-moonraker.sh"
PKGLIST=$(grep "PKGLIST=" $install_script | sed 's/PKGLIST//g; s/[$={}\n"]//g')
### rewrite packages into new array
unset PKGARR
for PKG in $PKGLIST; do PKGARR+=($PKG); done
echo "${cyan}${PKGARR[@]}${default}"
### Update system package info
status_msg "Running apt-get update..."
@@ -159,7 +161,7 @@ install_moonraker_packages(){
### Install desired packages
status_msg "Installing packages..."
sudo apt-get install --yes ${PKGLIST}
sudo apt-get install --yes ${PKGARR[@]}
}
create_moonraker_virtualenv(){
@@ -171,157 +173,144 @@ create_moonraker_virtualenv(){
rm -rf ${MOONRAKER_ENV}
fi
[ ! -d ${MOONRAKER_ENV} ] && virtualenv -p /usr/bin/python3 --system-site-packages ${MOONRAKER_ENV}
if [ ! -d ${MOONRAKER_ENV} ]; then
virtualenv -p /usr/bin/python3 ${MOONRAKER_ENV}
ln -s /usr/lib/python3/dist-packages/gpiod* ${MOONRAKER_ENV}/lib/python*/site-packages
fi
### 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_moonraker_service(){
### get config directory
source_kiauh_ini
### set up default values
SINGLE_INST=1
CFG_PATH="$klipper_cfg_loc"
MR_ENV=$MOONRAKER_ENV
MR_DIR=$MOONRAKER_DIR
MR_LOG="${HOME}/klipper_logs/moonraker.log"
MR_CONF="$CFG_PATH/moonraker.conf"
MR_SERV_SRC="${SRCDIR}/kiauh/resources/moonraker.service"
MR_SERV_TARGET="$SYSTEMDDIR/moonraker.service"
write_mr_service(){
if [ ! -f $MR_SERV_TARGET ]; then
status_msg "Creating Moonraker Service $i ..."
sudo cp $MR_SERV_SRC $MR_SERV_TARGET
sudo sed -i "s|%INST%|$i|" $MR_SERV_TARGET
sudo sed -i "s|%USER%|${USER}|" $MR_SERV_TARGET
sudo sed -i "s|%MR_ENV%|$MR_ENV|" $MR_SERV_TARGET
sudo sed -i "s|%MR_DIR%|$MR_DIR|" $MR_SERV_TARGET
sudo sed -i "s|%MR_LOG%|$MR_LOG|" $MR_SERV_TARGET
sudo sed -i "s|%MR_CONF%|$MR_CONF|" $MR_SERV_TARGET
fi
}
if [ $SINGLE_INST -eq $INSTANCE_COUNT ]; then
### write single instance service
write_mr_service
### enable instance
sudo systemctl enable moonraker.service
ok_msg "Single Moonraker instance created!"
### launching instance
status_msg "Launching Moonraker instance ..."
sudo systemctl start moonraker
else
i=1
while [ $i -le $INSTANCE_COUNT ]; do
### rewrite default variables for multi instance cases
CFG_PATH="$klipper_cfg_loc/printer_$i"
MR_SERV_TARGET="$SYSTEMDDIR/moonraker-$i.service"
MR_CONF="$CFG_PATH/moonraker.conf"
MR_LOG="${HOME}/klipper_logs/moonraker-$i.log"
### write multi instance service
write_mr_service
### enable instance
sudo systemctl enable moonraker-$i.service
ok_msg "Moonraker instance #$i created!"
### launching instance
status_msg "Launching Moonraker instance #$i ..."
sudo systemctl start moonraker-$i
### raise values by 1
i=$((i+1))
done
unset i
### enable mainsails remoteMode if mainsail is found
if [ -d $MAINSAIL_DIR ]; then
status_msg "Mainsail installation found!"
status_msg "Enabling Mainsail remoteMode ..."
enable_mainsail_remotemode
ok_msg "Mainsails remoteMode enabled!"
fi
fi
}
create_multi_moonraker_startscript(){
### create multi instance systemd service file
sudo /bin/sh -c "cat > ${SYSTEMDDIR}/moonraker-$INSTANCE.service" << EOF
#Systemd service file for moonraker
[Unit]
Description=Starts Moonraker instance $INSTANCE on startup
After=network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
User=${USER}
RemainAfterExit=yes
ExecStart=${MOONRAKER_ENV}/bin/python ${MOONRAKER_DIR}/moonraker/moonraker.py -l ${MOONRAKER_LOG} -c ${MOONRAKER_CONF}
Restart=always
RestartSec=10
EOF
create_moonraker_conf(){
### get config directory
source_kiauh_ini
### set up default values
SINGLE_INST=1
PORT=7125
CFG_PATH="$klipper_cfg_loc"
LOG_PATH="${HOME}/klipper_logs"
MR_CONF="$CFG_PATH/moonraker.conf"
MR_DB="~/.moonraker_database"
KLIPPY_UDS="/tmp/klippy_uds"
MR_CONF_SRC="${SRCDIR}/kiauh/resources/moonraker.conf"
mr_ip_list=()
IP=$(hostname -I | cut -d" " -f1)
LAN="$(hostname -I | cut -d" " -f1 | cut -d"." -f1-2).0.0/16"
write_mr_conf(){
[ ! -d $CFG_PATH ] && mkdir -p $CFG_PATH
if [ ! -f $MR_CONF ]; then
status_msg "Creating moonraker.conf in $CFG_PATH ..."
cp $MR_CONF_SRC $MR_CONF
sed -i "s|%PORT%|$PORT|" $MR_CONF
sed -i "s|%CFG%|$CFG_PATH|" $MR_CONF
sed -i "s|%LOG%|$LOG_PATH|" $MR_CONF
sed -i "s|%MR_DB%|$MR_DB|" $MR_CONF
sed -i "s|%UDS%|$KLIPPY_UDS|" $MR_CONF
sed -i "s|%LAN%|$LAN|" $MR_CONF
sed -i "s|%USER%|${USER}|g" $MR_CONF
ok_msg "moonraker.conf created!"
else
warn_msg "There is already a file called 'moonraker.conf'!"
warn_msg "Skipping..."
fi
}
if [ $SINGLE_INST -eq $INSTANCE_COUNT ]; then
### write single instance config
write_mr_conf
mr_ip_list+=("$IP:$PORT")
else
i=1
while [ $i -le $INSTANCE_COUNT ]; do
### rewrite default variables for multi instance cases
CFG_PATH="$klipper_cfg_loc/printer_$i"
MR_CONF="$CFG_PATH/moonraker.conf"
MR_DB="~/.moonraker_database_$i"
KLIPPY_UDS="/tmp/klippy_uds-$i"
### write multi instance config
write_mr_conf
mr_ip_list+=("$IP:$PORT")
### raise values by 1
PORT=$((PORT+1))
i=$((i+1))
done
unset PORT && unset i
fi
}
create_single_moonraker_conf(){
HOSTNAME=$(hostname -I | cut -d" " -f1)
LOCAL_NETWORK="$(hostname -I | cut -d" " -f1 | cut -d"." -f1-2).0.0/16"
/bin/sh -c "cat > $MOONRAKER_CONF_LOC/moonraker.conf" << MOONRAKERCONF
[server]
host: 0.0.0.0
port: $PORT
enable_debug_logging: True
config_path: $PRINTER_CFG_LOC
klippy_uds_address: /tmp/klippy_uds
[authorization]
enabled: True
api_key_file: ~/.moonraker_api_key
trusted_clients:
127.0.0.1
$LOCAL_NETWORK
::1/128
FE80::/10
cors_domains:
http://*.local
http://my.mainsail.xyz
https://my.mainsail.xyz
http://app.fluidd.xyz
https://app.fluidd.xyz
http://$HOSTNAME
http://$HOSTNAME:*
[update_manager]
[update_manager client mainsail]
type: web
repo: meteyou/mainsail
path: ~/mainsail
[update_manager client fluidd]
type: web
repo: cadriel/fluidd
path: ~/fluidd
#[update_manager client KlipperScreen]
#type: git_repo
#path: /home/${HOME}/KlipperScreen
#origin: https://github.com/jordanruthe/KlipperScreen.git
#env: /home/${HOME}/.KlipperScreen-env/bin/python
#requirements: scripts/KlipperScreen-requirements.txt
#install_script: scripts/KlipperScreen-install.sh
MOONRAKERCONF
}
create_multi_moonraker_conf(){
HOSTNAME=$(hostname -I | cut -d" " -f1)
LOCAL_NETWORK="$(hostname -I | cut -d" " -f1 | cut -d"." -f1-2).0.0/16"
/bin/sh -c "cat > $MOONRAKER_CONF_LOC/printer_$INSTANCE/moonraker.conf" << MOONRAKERCONF
[server]
host: 0.0.0.0
port: $PORT
enable_debug_logging: True
config_path: $PRINTER_CFG_LOC/printer_$INSTANCE
klippy_uds_address: /tmp/klippy_uds-$INSTANCE
[authorization]
enabled: True
api_key_file: ~/.moonraker_api_key
trusted_clients:
127.0.0.1
$LOCAL_NETWORK
::1/128
FE80::/10
cors_domains:
http://*.local
https://*.local
http://my.mainsail.xyz
https://my.mainsail.xyz
http://app.fluidd.xyz
https://app.fluidd.xyz
http://$HOSTNAME
http://$HOSTNAME:*
[update_manager]
[update_manager client mainsail]
type: web
repo: meteyou/mainsail
path: ~/mainsail
[update_manager client fluidd]
type: web
repo: cadriel/fluidd
path: ~/fluidd
#[update_manager client KlipperScreen]
#type: git_repo
#path: /home/${USER}/KlipperScreen
#origin: https://github.com/jordanruthe/KlipperScreen.git
#env: /home/${USER}/.KlipperScreen-env/bin/python
#requirements: scripts/KlipperScreen-requirements.txt
#install_script: scripts/KlipperScreen-install.sh
MOONRAKERCONF
}
##############################################################################################
#********************************************************************************************#
##############################################################################################
print_mr_ip_list(){
i=1
for ip in ${mr_ip_list[@]}; do
@@ -330,64 +319,6 @@ print_mr_ip_list(){
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
@@ -404,68 +335,6 @@ setup_moonraker_nginx_cfg(){
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

View File

@@ -69,7 +69,7 @@ octoprint_setup(){
[ ! -d $OCTOPRINT_ENV ] && mkdir -p $OCTOPRINT_ENV
status_msg "Set up virtualenv ..."
cd $OCTOPRINT_ENV
virtualenv venv
virtualenv --python=python3 venv
source venv/bin/activate
### install octoprint with pip

75
scripts/ms_theme_installer.sh Executable file
View File

@@ -0,0 +1,75 @@
### base variables
SYSTEMDDIR="/etc/systemd/system"
check_select_printer(){
unset printer_num
### get klipper cfg loc and set default .theme folder loc
check_klipper_cfg_path
THEME_PATH="$klipper_cfg_loc"
### check if there is more than one moonraker instance and if yes
### ask the user to select the printer he wants to install/remove the theme
printer_count=$(ls /etc/systemd/system/moonraker*.service | wc -l)
if [ $printer_count -gt 1 ]; then
top_border
echo -e "| More than one printer was found on this system! | "
echo -e "| Please select the printer to which you want to | "
echo -e "| apply the previously selected action. | "
bottom_border
read -p "${cyan}Select printer:${default} " printer_num
### rewrite the .theme path matching the selected printer
THEME_PATH="$klipper_cfg_loc/printer_$printer_num"
fi
### create the cfg folder if there is none yet
[ ! -d $THEME_PATH ] && mkdir -p $THEME_PATH
}
ms_theme_delete(){
### check and select printer if there is more than 1
check_select_printer
### remove .theme folder
if [ -d "$THEME_PATH/.theme" ]; then
status_msg "Removing Theme ..."
rm -rf "$THEME_PATH/.theme" && ok_msg "Theme removed!\n"
else
status_msg "No Theme installed!\n"
fi
}
ms_theme_dracula(){
THEME_URL="https://github.com/steadyjaw/dracula-mainsail-theme"
### check and select printer if there is more than 1
check_select_printer
### download all files
status_msg "Installing Dracula theme ..."
status_msg "Please wait ..."
[ -d "$THEME_PATH/.theme" ] && rm -rf "$THEME_PATH/.theme"
cd $THEME_PATH && git clone "$THEME_URL" ".theme"
ok_msg "Theme installation complete!"
ok_msg "Please remember to delete your browser cache!\n"
}
ms_theme_cyberpunk(){
THEME_URL="https://github.com/Dario-Ciceri/cp2077-mainsail-theme"
### check and select printer if there is more than 1
check_select_printer
### download all files
status_msg "Installing Cyberpunk theme ..."
status_msg "Please wait ..."
[ -d "$THEME_PATH/.theme" ] && rm -rf "$THEME_PATH/.theme"
cd $THEME_PATH && git clone "$THEME_URL" ".theme"
ok_msg "Theme installation complete!"
ok_msg "Please remember to delete your browser cache!\n"
}

View File

@@ -1,7 +1,12 @@
### base variables
SYSTEMDDIR="/etc/systemd/system"
remove_klipper(){
shopt -s extglob # enable extended globbing
### ask the user if he wants to uninstall moonraker too.
###? currently usefull if the user wants to switch from single-instance to multi-instance
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "moonraker*.")" ]; then
FILE="$SYSTEMDDIR/moonraker?(-*([0-9])).service"
if ls $FILE 2>/dev/null 1>&2; then
while true; do
unset REM_MR
top_border
@@ -32,38 +37,20 @@ remove_klipper(){
fi
### remove "legacy" klipper init.d service
if [[ -e /etc/init.d/klipper || -e /etc/default/klipper ]]; then
if [ -e /etc/init.d/klipper ]; then
status_msg "Removing Klipper Service ..."
sudo systemctl stop klipper
sudo systemctl disable klipper
sudo rm -rf /etc/init.d/klipper /etc/default/klipper
sudo update-rc.d -f klipper remove
sudo systemctl daemon-reload
sudo rm -f /etc/init.d/klipper
sudo rm -f /etc/default/klipper
ok_msg "Klipper Service removed!"
fi
###remove single instance
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ]; then
status_msg "Removing Klipper Service ..."
sudo systemctl stop klipper
sudo systemctl disable klipper
sudo rm -f $SYSTEMDDIR/klipper.service
ok_msg "Klipper Service removed!"
fi
if [ -f /tmp/klippy.log ]; then
status_msg "Removing /tmp/klippy.log ..." && rm -f /tmp/klippy.log && ok_msg "Done!"
fi
if [ -e /tmp/klippy_uds ]; then
status_msg "Removing /tmp/klippy_uds ..." && rm -f /tmp/klippy_uds && ok_msg "Done!"
fi
if [ -h /tmp/printer ]; then
status_msg "Removing /tmp/printer ..." && rm -f /tmp/printer && ok_msg "Done!"
fi
###remove multi instance services
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "klipper-[[:digit:]].service")" ]; then
### remove all klipper services
FILE="$SYSTEMDDIR/klipper?(-*([0-9])).service"
if ls $FILE 2>/dev/null 1>&2; then
status_msg "Removing Klipper Services ..."
for service in $(find $SYSTEMDDIR -maxdepth 1 -name "klipper-*.service" | cut -d"/" -f5)
for service in $(ls $FILE | cut -d"/" -f5)
do
status_msg "Removing $service ..."
sudo systemctl stop $service
@@ -71,36 +58,43 @@ remove_klipper(){
sudo rm -f $SYSTEMDDIR/$service
ok_msg "Done!"
done
### reloading units
sudo systemctl daemon-reload
sudo systemctl reset-failed
ok_msg "Klipper Service removed!"
fi
###remove multi instance logfiles
if [ "$(find /tmp -maxdepth 1 -name "klippy-*.log")" ]; then
for logfile in $(find /tmp -maxdepth 1 -name "klippy-*.log")
do
status_msg "Removing $logfile ..." && rm -f $logfile && ok_msg "Done!"
### remove all logfiles
FILE="${HOME}/klipper_logs/klippy?(-*([0-9])).log"
if ls $FILE 2>/dev/null 1>&2; then
for log in $(ls $FILE); do
status_msg "Removing $log ..."
rm -f $log
ok_msg "$log removed!"
done
fi
###remove multi instance UDS
if [ "$(find /tmp -maxdepth 1 -name "klippy_uds-*")" ]; then
for uds in $(find /tmp -maxdepth 1 -name "klippy_uds-*")
do
status_msg "Removing $uds ..." && rm -f $uds && ok_msg "Done!"
### remove all UDS
FILE="/tmp/klippy_uds?(-*([0-9]))"
if ls $FILE 2>/dev/null 1>&2; then
for uds in $(ls $FILE); do
status_msg "Removing $uds ..."
rm -f $uds
ok_msg "$uds removed!"
done
fi
###remove multi instance tmp-printer
if [ "$(find /tmp -maxdepth 1 -name "printer-*")" ]; then
for tmp_printer in $(find /tmp -maxdepth 1 -name "printer-*")
do
status_msg "Removing $tmp_printer ..." && rm -f $tmp_printer && ok_msg "Done!"
### remove all tmp-printer
FILE="/tmp/printer?(-*([0-9]))"
if ls $FILE 2>/dev/null 1>&2; then
for tmp_printer in $(ls $FILE); do
status_msg "Removing $tmp_printer ..."
rm -f $tmp_printer
ok_msg "$tmp_printer removed!"
done
fi
###reloading units
sudo systemctl daemon-reload
###removing klipper and klippy-env folders
### removing klipper and klippy-env folders
if [ -d $KLIPPER_DIR ]; then
status_msg "Removing Klipper directory ..."
rm -rf $KLIPPER_DIR && ok_msg "Directory removed!"
@@ -111,43 +105,33 @@ remove_klipper(){
fi
CONFIRM_MSG=" Klipper was successfully removed!" && print_msg && clear_msg
shopt -u extglob # enable extended globbing
if [ "$REM_MR" == "true" ]; then
remove_moonraker
remove_moonraker && unset REM_MR
fi
}
#############################################################
#############################################################
remove_dwc2(){
### remove "legacy" init.d service
if [[ -e /etc/init.d/dwc || -e /etc/default/dwc ]]; then
status_msg "Removing DWC2-for-Klipper-Socket Service ..."
sudo systemctl stop dwc
sudo systemctl disable dwc
sudo rm -rf /etc/init.d/dwc /etc/default/dwc
sudo update-rc.d -f dwc remove
sudo systemctl daemon-reload
ok_msg "DWC2-for-Klipper-Socket Service removed!"
remove_moonraker(){
shopt -s extglob # enable extended globbing
### remove "legacy" moonraker init.d service
if [ -f /etc/init.d/moonraker ]; then
status_msg "Removing Moonraker Service ..."
sudo systemctl stop moonraker
sudo update-rc.d -f moonraker remove
sudo rm -f /etc/init.d/moonraker
sudo rm -f /etc/default/moonraker
ok_msg "Moonraker Service removed!"
fi
### remove single instance
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "dwc.service")" ]; then
status_msg "Removing DWC2-for-Klipper-Socket Service ..."
sudo systemctl stop dwc
sudo systemctl disable dwc
sudo rm -f $SYSTEMDDIR/dwc.service
ok_msg "DWC2-for-Klipper-Socket Service removed!"
fi
if [ -f /tmp/dwc.log ]; then
status_msg "Removing /tmp/dwc.log ..." && rm -f /tmp/dwc.log && ok_msg "Done!"
fi
### remove multi instance services
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "dwc-[[:digit:]].service")" ]; then
status_msg "Removing DWC2-for-Klipper-Socket Services ..."
for service in $(find $SYSTEMDDIR -maxdepth 1 -name "dwc-*.service" | cut -d"/" -f5)
### remove all moonraker services
FILE="$SYSTEMDDIR/moonraker?(-*([0-9])).service"
if ls $FILE 2>/dev/null 1>&2; then
status_msg "Removing Moonraker Services ..."
for service in $(ls $FILE | cut -d"/" -f5)
do
status_msg "Removing $service ..."
sudo systemctl stop $service
@@ -155,18 +139,92 @@ remove_dwc2(){
sudo rm -f $SYSTEMDDIR/$service
ok_msg "Done!"
done
### reloading units
sudo systemctl daemon-reload
sudo systemctl reset-failed
ok_msg "Moonraker Service removed!"
fi
### remove multi instance logfiles
if [ "$(find /tmp -maxdepth 1 -name "dwc-*.log")" ]; then
for logfile in $(find /tmp -maxdepth 1 -name "dwc-*.log")
do
status_msg "Removing $logfile ..." && rm -f $logfile && ok_msg "Done!"
### remove all logfiles
FILE="${HOME}/klipper_logs/moonraker?(-*([0-9])).log"
if ls $FILE 2>/dev/null 1>&2; then
for log in $(ls $FILE); do
status_msg "Removing $log ..."
rm -f $log
ok_msg "$log removed!"
done
fi
### reloading units
sudo systemctl daemon-reload
### remove moonraker nginx config
if [[ -e $NGINX_CONFD/upstreams.conf || -e $NGINX_CONFD/common_vars.conf ]]; then
status_msg "Removing Moonraker NGINX configuration ..."
sudo rm -f $NGINX_CONFD/upstreams.conf $NGINX_CONFD/common_vars.conf && ok_msg "Moonraker NGINX configuration removed!"
fi
### remove legacy api key
if [ -e ${HOME}/.klippy_api_key ]; then
status_msg "Removing legacy API Key ..." && rm ${HOME}/.klippy_api_key && ok_msg "Done!"
fi
### remove api key
if [ -e ${HOME}/.moonraker_api_key ]; then
status_msg "Removing API Key ..." && rm ${HOME}/.moonraker_api_key && ok_msg "Done!"
fi
### removing moonraker and moonraker-env folder
if [ -d $MOONRAKER_DIR ]; then
status_msg "Removing Moonraker directory ..."
rm -rf $MOONRAKER_DIR && ok_msg "Directory removed!"
fi
if [ -d $MOONRAKER_ENV ]; then
status_msg "Removing moonraker-env directory ..."
rm -rf $MOONRAKER_ENV && ok_msg "Directory removed!"
fi
CONFIRM_MSG=" Moonraker was successfully removed!"
shopt -u extglob # disable extended globbing
}
#############################################################
#############################################################
remove_dwc2(){
### remove "legacy" init.d service
if [ -e /etc/init.d/dwc ]; then
status_msg "Removing DWC2-for-Klipper-Socket Service ..."
sudo systemctl stop dwc
sudo update-rc.d -f dwc remove
sudo rm -f /etc/init.d/dwc
sudo rm -f /etc/default/dwc
ok_msg "DWC2-for-Klipper-Socket Service removed!"
fi
### remove all dwc services
if ls /etc/systemd/system/dwc*.service 2>/dev/null 1>&2; then
status_msg "Removing DWC2-for-Klipper-Socket Services ..."
for service in $(ls /etc/systemd/system/dwc*.service | cut -d"/" -f5)
do
status_msg "Removing $service ..."
sudo systemctl stop $service
sudo systemctl disable $service
sudo rm -f $SYSTEMDDIR/$service
ok_msg "Done!"
done
### reloading units
sudo systemctl daemon-reload
sudo systemctl reset-failed
ok_msg "DWC2-for-Klipper-Socket Service removed!"
fi
### remove all logfiles
if ls /tmp/dwc*.log 2>/dev/null 1>&2; then
for logfile in $(ls /tmp/dwc*.log)
do
status_msg "Removing $logfile ..."
rm -f $logfile
ok_msg "File '$logfile' removed!"
done
fi
### removing the rest of the folders
if [ -d $DWC2FK_DIR ]; then
@@ -188,84 +246,6 @@ remove_dwc2(){
#############################################################
#############################################################
remove_moonraker(){
### remove "legacy" moonraker init.d service
if [[ -e /etc/init.d/moonraker || -e /etc/default/moonraker ]]; then
status_msg "Removing Moonraker Service ..."
sudo systemctl stop moonraker
sudo systemctl disable moonraker
sudo rm -rf /etc/init.d/moonraker /etc/default/moonraker
sudo update-rc.d -f moonraker remove
sudo systemctl daemon-reload
ok_msg "Moonraker Service removed!"
fi
###remove single instance
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "moonraker.service")" ]; then
status_msg "Removing Moonraker Service ..."
sudo systemctl stop moonraker
sudo systemctl disable moonraker
sudo rm -f $SYSTEMDDIR/moonraker.service
ok_msg "Moonraker Service removed!"
fi
if [ -f /tmp/moonraker.log ]; then
status_msg "Removing /tmp/moonraker.log ..." && rm -f /tmp/moonraker.log && ok_msg "Done!"
fi
###remove multi instance services
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "moonraker-[[:digit:]].service")" ]; then
status_msg "Removing Moonraker Services ..."
for service in $(find $SYSTEMDDIR -maxdepth 1 -name "moonraker-*.service" | cut -d"/" -f5)
do
status_msg "Removing $service ..."
sudo systemctl stop $service
sudo systemctl disable $service
sudo rm -f $SYSTEMDDIR/$service
ok_msg "Done!"
done
fi
###remove multi instance logfiles
if [ "$(find /tmp -maxdepth 1 -name "moonraker-*.log")" ]; then
for logfile in $(find /tmp -maxdepth 1 -name "moonraker-*.log")
do
status_msg "Removing $logfile ..." && rm -f $logfile && ok_msg "Done!"
done
fi
###reloading units
sudo systemctl daemon-reload
#remove moonraker nginx config
if [[ -e $NGINX_CONFD/upstreams.conf || -e $NGINX_CONFD/common_vars.conf ]]; then
status_msg "Removing Moonraker NGINX configuration ..."
sudo rm -f $NGINX_CONFD/upstreams.conf $NGINX_CONFD/common_vars.conf && ok_msg "Moonraker NGINX configuration removed!"
fi
#remove legacy api key
if [ -e ${HOME}/.klippy_api_key ]; then
status_msg "Removing legacy API Key ..." && rm ${HOME}/.klippy_api_key && ok_msg "Done!"
fi
#remove api key
if [ -e ${HOME}/.moonraker_api_key ]; then
status_msg "Removing API Key ..." && rm ${HOME}/.moonraker_api_key && ok_msg "Done!"
fi
###removing moonraker and moonraker-env folder
if [ -d $MOONRAKER_DIR ]; then
status_msg "Removing Moonraker directory ..."
rm -rf $MOONRAKER_DIR && ok_msg "Directory removed!"
fi
if [ -d $MOONRAKER_ENV ]; then
status_msg "Removing moonraker-env directory ..."
rm -rf $MOONRAKER_ENV && ok_msg "Directory removed!"
fi
CONFIRM_MSG=" Moonraker was successfully removed!"
}
#############################################################
#############################################################
remove_mainsail(){
### remove mainsail dir
if [ -d $MAINSAIL_DIR ]; then
@@ -285,6 +265,14 @@ remove_mainsail(){
sudo rm /etc/nginx/sites-enabled/mainsail && ok_msg "File removed!"
fi
### remove mainsail nginx logs and log symlinks
for log in $(find /var/log/nginx -name "mainsail*"); do
sudo rm -f $log
done
for log in $(find ${HOME}/klipper_logs -name "mainsail*"); do
rm -f $log
done
CONFIRM_MSG="Mainsail successfully removed!"
}
@@ -307,6 +295,14 @@ remove_fluidd(){
sudo rm /etc/nginx/sites-enabled/fluidd && ok_msg "File removed!"
fi
### remove mainsail nginx logs and log symlinks
for log in $(find /var/log/nginx -name "fluidd*"); do
sudo rm -f $log
done
for log in $(find ${HOME}/klipper_logs -name "fluidd*"); do
rm -f $log
done
CONFIRM_MSG="Fluidd successfully removed!"
}
@@ -314,19 +310,10 @@ remove_fluidd(){
#############################################################
remove_octoprint(){
###remove single instance
if [ "$(systemctl list-unit-files | grep -F "octoprint.service")" ]; then
status_msg "Removing OctoPrint Service ..."
sudo systemctl stop octoprint
sudo systemctl disable octoprint
sudo rm -f $SYSTEMDDIR/octoprint.service
ok_msg "OctoPrint Service removed!"
fi
###remove multi instance services
if [ "$(systemctl list-unit-files | grep -E "octoprint-[[:digit:]].service")" ]; then
###remove all octoprint services
if ls /etc/systemd/system/octoprint*.service 2>/dev/null 1>&2; then
status_msg "Removing OctoPrint Services ..."
for service in $(find $SYSTEMDDIR -maxdepth 1 -name "octoprint-*.service" | cut -d"/" -f5)
for service in $(ls /etc/systemd/system/octoprint*.service | cut -d"/" -f5)
do
status_msg "Removing $service ..."
sudo systemctl stop $service
@@ -334,11 +321,11 @@ remove_octoprint(){
sudo rm -f $SYSTEMDDIR/$service
ok_msg "OctoPrint Service removed!"
done
### reloading units
sudo systemctl daemon-reload
sudo systemctl reset-failed
fi
###reloading units
sudo systemctl daemon-reload
### remove sudoers file
if [ -f /etc/sudoers.d/octoprint-shutdown ]; then
sudo rm -rf /etc/sudoers.d/octoprint-shutdown
@@ -351,8 +338,8 @@ remove_octoprint(){
fi
###remove .octoprint directories
if [ "$(find ${HOME} -maxdepth 1 -name ".octoprint*")" ]; then
for folder in $(find ${HOME} -maxdepth 1 -name ".octoprint*")
if ls -d ${HOME}/.octoprint* 2>/dev/null 1>&2; then
for folder in $(ls -d ${HOME}/.octoprint*)
do
status_msg "Removing $folder ..." && rm -rf $folder && ok_msg "Done!"
done
@@ -381,6 +368,8 @@ remove_nginx(){
}
remove_klipperscreen(){
source_kiauh_ini
### remove KlipperScreen dir
if [ -d $KLIPPERSCREEN_DIR ]; then
status_msg "Removing KlipperScreen directory ..."
@@ -393,11 +382,61 @@ remove_klipperscreen(){
rm -rf $KLIPPERSCREEN_ENV_DIR && ok_msg "Directory removed!"
fi
### remove KlipperScreen systemd file
### remove KlipperScreen service
if [ -e /etc/systemd/system/KlipperScreen.service ]; then
status_msg "Removing KlipperScreen Service ..."
sudo rm /etc/systemd/system/KlipperScreen.service && ok_msg "File removed!"
status_msg "Removing KlipperScreen service ..."
sudo systemctl stop KlipperScreen
sudo systemctl disable moonraker
sudo rm -f $SYSTEMDDIR/KlipperScreen.service
###reloading units
sudo systemctl daemon-reload
sudo systemctl reset-failed
ok_msg "KlipperScreen Service removed!"
fi
### remove KlipperScreen log
if [ -e /tmp/KlipperScreen.log ]; then
status_msg "Removing KlipperScreen log file ..."
rm -f /tmp/KlipperScreen.log && ok_msg "File removed!"
fi
### remove KlipperScreen log symlink in config dir
if [ -e $klipper_cfg_loc/KlipperScreen.log ]; then
status_msg "Removing KlipperScreen log symlink ..."
rm -f $klipper_cfg_loc/KlipperScreen.log && ok_msg "File removed!"
fi
CONFIRM_MSG="KlipperScreen successfully removed!"
}
remove_mjpg-streamer(){
### remove MJPG-Streamer service
if [ -e $SYSTEMDDIR/webcamd.service ]; then
status_msg "Removing MJPG-Streamer service ..."
sudo systemctl stop webcamd && sudo systemctl disable webcamd
sudo rm -f $SYSTEMDDIR/webcamd.service
###reloading units
sudo systemctl daemon-reload
sudo systemctl reset-failed
ok_msg "MJPG-Streamer Service removed!"
fi
### remove webcamd from /usr/local/bin
if [ -e "/usr/local/bin/webcamd" ]; then
sudo rm -f "/usr/local/bin/webcamd"
fi
### remove MJPG-Streamer directory
if [ -d ${HOME}/mjpg-streamer ]; then
status_msg "Removing MJPG-Streamer directory ..."
rm -rf ${HOME}/mjpg-streamer
ok_msg "MJPG-Streamer directory removed!"
fi
### remove webcamd log and symlink
[ -f "/var/log/webcamd.log" ] && sudo rm -f "/var/log/webcamd.log"
[ -L "${HOME}/klipper_logs/webcamd.log" ] && rm -f "${HOME}/klipper_logs/webcamd.log"
CONFIRM_MSG="MJPG-Streamer successfully removed!"
}

View File

@@ -10,6 +10,17 @@ kiauh_status(){
fi
}
check_system_updates(){
SYS_UPDATE=$(apt list --upgradeable 2>/dev/null | sed "1d")
if [ ! -z "$SYS_UPDATE" ]; then
SYS_UPDATE_AVAIL="true"
DISPLAY_SYS_UPDATE="${yellow}System upgrade available!${default}"
else
SYS_UPDATE_AVAIL="false"
DISPLAY_SYS_UPDATE="${green}System up to date! ${default}"
fi
}
klipper_status(){
kcount=0
klipper_data=(
@@ -19,7 +30,12 @@ klipper_status(){
)
### count amount of klipper service files in /etc/systemd/system
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "klipper" | wc -l)
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "^klipper(\-[[:digit:]]+)?\.service$" | wc -l)
### a fix to detect an existing "legacy" klipper init.d installation
if [ -f /etc/init.d/klipper ] && [ -f /etc/init.d/klipper ]; then
SERVICE_FILE_COUNT=1
fi
### remove the "SERVICE" entry from the klipper_data array if a klipper service is installed
[ $SERVICE_FILE_COUNT -gt 0 ] && unset klipper_data[0]
@@ -52,7 +68,7 @@ dwc2_status(){
)
### count amount of dwc service files in /etc/systemd/system
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "dwc" | wc -l)
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "^dwc(\-[[:digit:]]+)?\.service$" | wc -l)
### remove the "SERVICE" entry from the dwc_data array if a dwc service is installed
[ $SERVICE_FILE_COUNT -gt 0 ] && unset dwc_data[0]
@@ -83,7 +99,7 @@ moonraker_status(){
)
### count amount of moonraker service files in /etc/systemd/system
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "moonraker" | wc -l)
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "^moonraker(\-[[:digit:]]+)?\.service$" | wc -l)
### remove the "SERVICE" entry from the moonraker_data array if a moonraker service is installed
[ $SERVICE_FILE_COUNT -gt 0 ] && unset moonraker_data[0]
@@ -159,7 +175,7 @@ octoprint_status(){
$OCTOPRINT_DIR
)
### count amount of octoprint service files in /etc/systemd/system
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "octoprint" | wc -l)
SERVICE_FILE_COUNT=$(ls /etc/systemd/system | grep -E "^octoprint(\-[[:digit:]]+)?\.service$" | wc -l)
### remove the "SERVICE" entry from the octoprint_data array if a octoprint service is installed
[ $SERVICE_FILE_COUNT -gt 0 ] && unset octoprint_data[0]
@@ -352,16 +368,16 @@ compare_dwc2_versions(){
read_local_dwc2_version && read_remote_dwc2_version
if [[ $DWC2_VER_FOUND = "true" ]] && [[ $DWC2_LOCAL_VER == $DWC2_REMOTE_VER ]]; then
#printf fits the string for displaying it in the ui to a total char length of 12
DWC2_LOCAL_VER="${green}$(printf "v%-11s" "$DWC2_LOCAL_VER")${default}"
DWC2_REMOTE_VER="${green}$(printf "v%-11s" "$DWC2_REMOTE_VER")${default}"
DWC2_LOCAL_VER="${green}$(printf "%-12s" "$DWC2_LOCAL_VER")${default}"
DWC2_REMOTE_VER="${green}$(printf "%-12s" "$DWC2_REMOTE_VER")${default}"
elif [[ $DWC2_VER_FOUND = "true" ]] && [[ $DWC2_LOCAL_VER != $DWC2_REMOTE_VER ]]; then
DWC2_LOCAL_VER="${yellow}$(printf "v%-11s" "$DWC2_LOCAL_VER")${default}"
DWC2_REMOTE_VER="${green}$(printf "v%-11s" "$DWC2_REMOTE_VER")${default}"
DWC2_LOCAL_VER="${yellow}$(printf "%-12s" "$DWC2_LOCAL_VER")${default}"
DWC2_REMOTE_VER="${green}$(printf "%-12s" "$DWC2_REMOTE_VER")${default}"
# set flag for the multi update function
DWC2_UPDATE_AVAIL="true" && update_arr+=(update_dwc2)
else
DWC2_LOCAL_VER=$NONE
DWC2_REMOTE_VER="${green}$(printf "v%-11s" "$DWC2_REMOTE_VER")${default}"
DWC2_REMOTE_VER="${green}$(printf "%-12s" "$DWC2_REMOTE_VER")${default}"
DWC2_UPDATE_AVAIL="false"
fi
}
@@ -509,6 +525,7 @@ NONE="${red}$(printf "%-12s" "--------")${default}"
ui_print_versions(){
unset update_arr
check_system_updates
compare_klipper_versions
compare_dwc2fk_versions
compare_dwc2_versions

View File

@@ -2,18 +2,22 @@ advanced_ui(){
top_border
echo -e "| ${yellow}~~~~~~~~~~~~~ [ Advanced Menu ] ~~~~~~~~~~~~~${default} | "
hr
echo -e "| 0) $OPRINT_SERVICE_STATUS| "
hr
echo -e "| | | "
echo -e "| Klipper: | System: | "
echo -e "| 1) [Switch Version] | 6) [Change hostname] | "
if [ ! "$OPRINT_SERVICE_STATUS" == "" ]; then
echo -e "| 0) $OPRINT_SERVICE_STATUS| "
hr
echo -e "| | | "
fi
echo -e "| Klipper: | Mainsail: | "
echo -e "| 1) [Switch Branch] | 7) [Theme installer] | "
echo -e "| 2) [Rollback] | | "
echo -e "| | Extensions: | "
echo -e "| Firmware: | 7) [Shell Command] | "
echo -e "| | System: | "
echo -e "| Firmware: | 8) [Change hostname] | "
echo -e "| 3) [Build only] | | "
echo -e "| 4) [Build + Flash MCU] | | "
echo -e "| 5) [Get MCU ID] | | "
echo -e "| | | "
echo -e "| 4) [Build + Flash] | Extensions: | "
echo -e "| 5) [Build + SD Flash] | 9) [Shell Command] | "
echo -e "| 6) [Get MCU ID] | | "
echo -e "| | CustomPiOS: | "
echo -e "| | 10) [Migration Helper] | "
quit_footer
}
@@ -31,31 +35,43 @@ advanced_menu(){
print_msg && clear_msg
advanced_ui;;
1)
do_action "switch_menu" "advanced_ui";;
do_action "switch_menu";;
2)
do_action "load_klipper_state" "advanced_ui";;
3)
do_action "build_fw" "advanced_ui";;
4)
clear
print_header
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
if [ $FLASH_FIRMWARE = "true" ]; then
status_msg "Please wait..." && sleep 5 && build_fw
select_mcu_id
fi
print_msg && clear_msg
advanced_ui;;
5)
do_action "get_mcu_id" "advanced_ui";;
clear && print_header
flash_routine_sd
if [ $FLASH_FW_SD = "true" ]; then
status_msg "Please wait..." && sleep 5 && build_fw
select_mcu_id
fi
print_msg && clear_msg
advanced_ui;;
6)
do_action "get_mcu_id" "advanced_ui";;
7)
do_action "ms_theme_menu";;
8)
clear
print_header
create_custom_hostname && set_hostname
print_msg && clear_msg
advanced_ui;;
7)
9)
do_action "setup_gcode_shell_command" "advanced_ui";;
10)
do_action "migration_menu";;
Q|q)
clear; main_menu; break;;
*)
@@ -153,3 +169,40 @@ rollback_ui(){
echo -e "| $PREV_UI | "
quit_footer
}
#############################################################
#############################################################
migration_ui(){
top_border
echo -e "| $(title_msg "~~~~~~~~~ [ CustomPiOS Migration ] ~~~~~~~~~~") | "
hr
echo -e "| This function will help you to migrate a vanilla | "
echo -e "| MainsailOS or FluiddPi image to a newer state. | "
blank_line
echo -e "| Only use this function if you use MainsailOS 0.4.0 | "
echo -e "| or lower, or FluiddPi v1.13.0 or lower. | "
blank_line
echo -e "| Please have a look at the KIAUH changelog for more | "
echo -e "| details on what this function will do. | "
hr
echo -e "| | "
echo -e "| 1) [Migrate MainsailOS] | "
echo -e "| 2) [Migrate FluiddPi] | "
echo -e "| | "
quit_footer
}
migration_menu(){
print_msg && clear_msg
migration_ui
while true; do
read -p "${cyan}Perform action:${default} " action; echo
case "$action" in
1) migrate_custompios "mainsail"; migration_menu;;
2) migrate_custompios "fluiddpi"; migration_menu;;
Q|q) clear; advanced_menu; break;;
*) print_unkown_cmd; migration_menu;;
esac
done
}

View File

@@ -5,15 +5,15 @@ backup_ui(){
echo -e "| ${yellow}Backup location: ~/kiauh-backups${default} | "
hr
echo -e "| Configuration folder: | Klipper Webinterface: | "
echo -e "| 0) [Klipper configs] | 3) [Mainsail] | "
echo -e "| | 4) [Fluidd] | "
echo -e "| 0) [Klipper configs] | 4) [Mainsail] | "
echo -e "| | 5) [Fluidd] | "
echo -e "| Firmware: | | "
echo -e "| 1) [Klipper] | HDMI Screen: | "
echo -e "| | 5) [KlipperScreen] | "
echo -e "| | 6) [KlipperScreen] | "
echo -e "| Klipper API: | | "
echo -e "| 2) [Moonraker] | Other: | "
echo -e "| | 6) [Duet Web Control] | "
echo -e "| | 7) [OctoPrint] | "
echo -e "| 3) [Moonraker DB] | 7) [Duet Web Control] | "
echo -e "| | 8) [OctoPrint] | "
quit_footer
}
@@ -29,14 +29,16 @@ backup_menu(){
2)
do_action "backup_moonraker" "backup_ui";;
3)
do_action "backup_mainsail" "backup_ui";;
do_action "backup_moonraker_database" "backup_ui";;
4)
do_action "backup_fluidd" "backup_ui";;
do_action "backup_mainsail" "backup_ui";;
5)
do_action "backup_klipperscreen" "backup_ui";;
do_action "backup_fluidd" "backup_ui";;
6)
do_action "backup_dwc2" "backup_ui";;
do_action "backup_klipperscreen" "backup_ui";;
7)
do_action "backup_dwc2" "backup_ui";;
8)
do_action "backup_octoprint" "backup_ui";;
Q|q)
clear; main_menu; break;;

View File

@@ -31,17 +31,19 @@ print_header(){
kiauh_update_msg(){
top_border
echo -e "| ${yellow}There is a newer version of this script available!${default} | "
echo -e "| ${yellow}Type 'update' if you want to update KIAUH now.${default} | "
echo -e "|${green} New KIAUH update available! ${default}| "
hr
echo -e "|${green} View Changelog: https://git.io/JnmlX ${default}| "
blank_line
echo -e "| ${yellow}Check out the KIAUH changelog for important changes${default} | "
echo -e "| ${yellow}either to the script or the installable components!${default} | "
echo -e "|${yellow} It is recommended to keep KIAUH up to date. Updates ${default}| "
echo -e "|${yellow} usually contain bugfixes, important changes or new ${default}| "
echo -e "|${yellow} features. Please consider updating! ${default}| "
bottom_border
}
##############################################################################################
#********************************************************************************************#
##############################################################################################
################################################################################
#******************************************************************************#
################################################################################
### TODO: rework other menus to make use of the following functions too and make them more readable
do_action(){

View File

@@ -6,16 +6,16 @@ install_ui(){
echo -e "| all necessary dependencies for the various | "
echo -e "| functions on a completely fresh system. | "
hr
echo -e "| Firmware: | Klipper Webinterface: | "
echo -e "| 1) [Klipper] | 3) [Mainsail] | "
echo -e "| | 4) [Fluidd] | "
echo -e "| Klipper API: | | "
echo -e "| 2) [Moonraker] | HDMI Screen: | "
echo -e "| | 5) [KlipperScreen] | "
echo -e "| | | "
echo -e "| | Other: | "
echo -e "| | 6) [Duet Web Control] | "
echo -e "| | 7) [OctoPrint] | "
echo -e "| Firmware: | Touchscreen GUI: | "
echo -e "| 1) [Klipper] | 5) [KlipperScreen] | "
echo -e "| | | "
echo -e "| Klipper API: | Other: | "
echo -e "| 2) [Moonraker] | 6) [Duet Web Control] | "
echo -e "| | 7) [OctoPrint] | "
echo -e "| Klipper Webinterface: | | "
echo -e "| 3) [Mainsail] | Webcam: | "
echo -e "| 4) [Fluidd] | 8) [MJPG-Streamer] | "
echo -e "| | | "
quit_footer
}
@@ -38,6 +38,8 @@ install_menu(){
do_action "dwc_setup_dialog" "install_ui";;
7)
do_action "octoprint_setup_dialog" "install_ui";;
8)
do_action "install_mjpg-streamer" "install_ui";;
Q|q)
clear; main_menu; break;;
*)

View File

@@ -1,4 +1,5 @@
main_ui(){
#[ $KIAUH_UPDATE_REMIND="true" ] && kiauh_update_reminder
top_border
echo -e "| $(title_msg "~~~~~~~~~~~~~~~ [ Main Menu ] ~~~~~~~~~~~~~~~") |"
hr
@@ -22,11 +23,26 @@ print_kiauh_version(){
KIAUH_VER="$(printf "%-20s" "$KIAUH_VER")"
}
kiauh_update_dialog(){
kiauh_update_msg
read -p "${cyan}Do you want to update now? (Y/n):${default} " yn
while true; do
case "$yn" in
Y|y|Yes|yes|"")
do_action "update_kiauh"
break;;
N|n|No|no) break;;
*)
deny_action "kiauh_update_dialog";;
esac
done
}
main_menu(){
print_header
#print KIAUH update msg if update available
if [ "$KIAUH_UPDATE_AVAIL" = "true" ]; then
kiauh_update_msg
kiauh_update_dialog
fi
#check install status
print_kiauh_version

31
scripts/ui/ms_theme_menu.sh Executable file
View File

@@ -0,0 +1,31 @@
ms_theme_ui(){
top_border
echo -e "| ${red}~~~~~~~~ [ Mainsail Theme Installer ] ~~~~~~~${default} | "
hr
echo -e "| Please note: | "
echo -e "| Installing a theme from this menu will overwrite an | "
echo -e "| already installed theme or modified custom.css file! | "
hr
echo -e "| Theme: | "
echo -e "| 1) [Dracula] | "
echo -e "| 2) [Cyberpunk] | "
echo -e "| | "
echo -e "| R) [Remove Theme] | "
echo -e "| | "
quit_footer
}
ms_theme_menu(){
do_action "" "ms_theme_ui"
while true; do
read -p "${cyan}Perform action:${default} " action; echo
case "$action" in
1) do_action "ms_theme_dracula" "ms_theme_ui";;
2) do_action "ms_theme_cyberpunk" "ms_theme_ui";;
R|r) do_action "ms_theme_delete" "ms_theme_ui";;
Q|q) clear; advanced_menu; break;;
*) deny_action "ms_theme_ui";;
esac
done
ms_theme_menu
}

View File

@@ -7,17 +7,16 @@ remove_ui(){
echo -e "| --> ~/kiauh-backups | "
echo -e "| You need remove them manually if you wish so. | "
hr
echo -e "| Firmware: | Klipper Webinterface: | "
echo -e "| 1) [Klipper] | 3) [Mainsail] | "
echo -e "| | 4) [Fluidd] | "
echo -e "| Klipper API: | | "
echo -e "| 2) [Moonraker] | HDMI Screen: | "
echo -e "| | 5) [KlipperScreen] | "
echo -e "| | | "
echo -e "| | Other: | "
echo -e "| | 6) [Duet Web Control] | "
echo -e "| | 7) [OctoPrint] | "
echo -e "| | 8) [NGINX] | "
echo -e "| Firmware: | Touchscreen GUI: | "
echo -e "| 1) [Klipper] | 5) [KlipperScreen] | "
echo -e "| | | "
echo -e "| Klipper API: | Other: | "
echo -e "| 2) [Moonraker] | 6) [Duet Web Control] | "
echo -e "| | 7) [OctoPrint] | "
echo -e "| Klipper Webinterface: | 8) [NGINX] | "
echo -e "| 3) [Mainsail] | 9) [MJPG-Streamer] | "
echo -e "| 4) [Fluidd] | | "
echo -e "| | | "
quit_footer
}
@@ -42,6 +41,8 @@ remove_menu(){
do_action "remove_octoprint" "remove_ui";;
8)
do_action "remove_nginx" "remove_ui";;
9)
do_action "remove_mjpg-streamer" "remove_ui";;
Q|q)
clear; main_menu; break;;
*)

View File

@@ -1,106 +1,61 @@
update_ui(){
ui_print_versions
top_border
echo -e "| ${green}~~~~~~~~~~~~~~ [ Update Menu ] ~~~~~~~~~~~~~~${default} | "
hr
echo -e "| Check the following website for important software | "
echo -e "| changes to the config file before updating Klipper: | "
echo -e "| | "
echo -e "| ${yellow}https://www.klipper3d.org/Config_Changes.html${default} | "
bottom_border
top_border
echo -e "| 0) $BB4U_STATUS| "
hr
echo -e "| a) [Update all] | Local Vers: | Remote Vers: | "
echo -e "| | | | "
echo -e "| Firmware: | | | "
echo -e "| a) [Update all] | | | "
echo -e "| | Local Vers: | Remote Vers: | "
echo -e "| Klipper/Klipper API: |---------------|--------------| "
echo -e "| 1) [Klipper] | $LOCAL_COMMIT | $REMOTE_COMMIT | "
echo -e "| 2) [Moonraker] | $LOCAL_MOONRAKER_COMMIT | $REMOTE_MOONRAKER_COMMIT | "
echo -e "| | | | "
echo -e "| Webinterface: |---------------|--------------| "
echo -e "| 2) [DWC2-for-Klipper] | $LOCAL_DWC2FK_COMMIT | $REMOTE_DWC2FK_COMMIT | "
echo -e "| 3) [DWC2 Web UI] | $DWC2_LOCAL_VER | $DWC2_REMOTE_VER | "
echo -e "| |---------------|--------------| "
echo -e "| 4) [Moonraker] | $LOCAL_MOONRAKER_COMMIT | $REMOTE_MOONRAKER_COMMIT | "
echo -e "| 5) [Mainsail] | $MAINSAIL_LOCAL_VER | $MAINSAIL_REMOTE_VER | "
echo -e "| 6) [Fluidd] | $FLUIDD_LOCAL_VER | $FLUIDD_REMOTE_VER | "
echo -e "| Klipper Webinterface: |---------------|--------------| "
echo -e "| 3) [Mainsail] | $MAINSAIL_LOCAL_VER | $MAINSAIL_REMOTE_VER | "
echo -e "| 4) [Fluidd] | $FLUIDD_LOCAL_VER | $FLUIDD_REMOTE_VER | "
echo -e "| | | | "
echo -e "| HDMI Screen: |---------------|--------------| "
echo -e "| 7) [KlipperScreen] | $LOCAL_KLIPPERSCREEN_COMMIT | $REMOTE_KLIPPERSCREEN_COMMIT | "
echo -e "| Touchscreen GUI: |---------------|--------------| "
echo -e "| 5) [KlipperScreen] | $LOCAL_KLIPPERSCREEN_COMMIT | $REMOTE_KLIPPERSCREEN_COMMIT | "
echo -e "| | | | "
echo -e "| Other: |---------------|--------------| "
echo -e "| 6) [DWC2-for-Klipper] | $LOCAL_DWC2FK_COMMIT | $REMOTE_DWC2FK_COMMIT | "
echo -e "| 7) [DWC2 Web UI] | $DWC2_LOCAL_VER | $DWC2_REMOTE_VER | "
echo -e "| |------------------------------| "
echo -e "| 8) [System] | $DISPLAY_SYS_UPDATE | "
quit_footer
}
update_menu(){
print_header
#compare versions
ui_print_versions
print_msg && clear_msg
read_bb4u_stat
update_ui
do_action "" "update_ui"
while true; do
read -p "${cyan}Perform action:${default} " action; echo
case "$action" in
0)
clear
print_header
toggle_backups
print_msg && clear_msg
update_ui;;
do_action "toggle_backups" "update_ui";;
1)
clear
print_header
update_klipper && ui_print_versions
print_msg && clear_msg
update_ui;;
do_action "update_klipper" "update_ui";;
2)
clear
print_header
update_dwc2fk && ui_print_versions
print_msg && clear_msg
update_ui;;
do_action "update_moonraker" "update_ui";;
3)
clear
print_header
update_dwc2 && ui_print_versions
print_msg && clear_msg
update_ui;;
do_action "update_mainsail" "update_ui";;
4)
clear
print_header
update_moonraker && ui_print_versions
print_msg && clear_msg
update_ui;;
do_action "update_fluidd" "update_ui";;
5)
clear
print_header
update_mainsail && ui_print_versions
print_msg && clear_msg
update_ui;;
do_action "update_klipperscreen" "update_ui";;
6)
clear
print_header
update_fluidd && ui_print_versions
print_msg && clear_msg
update_ui;;
do_action "update_dwc2fk" "update_ui";;
7)
clear
print_header
update_klipperscreen && ui_print_versions
print_msg && clear_msg
update_ui;;
do_action "update_dwc2" "update_ui";;
8)
do_action "update_system" "update_ui";;
a)
clear
print_header
update_all && ui_print_versions
print_msg && clear_msg
update_ui;;
do_action "update_all" "update_ui";;
Q|q)
clear; main_menu; break;;
*)
clear
print_header
print_unkown_cmd
print_msg && clear_msg
ui_print_versions
update_ui;;
deny_action "update_ui";;
esac
done
update_menu

View File

@@ -39,6 +39,9 @@ update_all(){
if [ "$KLIPPERSCREEN_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● KlipperScreen${default} |"
fi
if [ "$SYS_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● System${default} |"
fi
bottom_border
if [ "${#update_arr[@]}" != "0" ]; then
read -p "${cyan}###### Do you want to proceed? (Y/n):${default} " yn
@@ -59,6 +62,145 @@ update_all(){
done
}
update_log_paths(){
### update services to make use of moonrakers new log_path option
### https://github.com/Arksine/moonraker/commit/829b3a4ee80579af35dd64a37ccc092a1f67682a
shopt -s extglob # enable extended globbing
LPATH="${HOME}/klipper_logs"
[ ! -d "$LPATH" ] && mkdir -p "$LPATH"
FILE="$SYSTEMDDIR/$1?(-*([0-9])).service"
for file in $(ls $FILE); do
[ "$1" == "klipper" ] && LOG="klippy"
[ "$1" == "moonraker" ] && LOG="moonraker"
if [ ! "$(grep "\-l" $file)" ]; then
status_msg "Updating $file ..."
sudo sed -i -r "/ExecStart=/ s|$| -l $LPATH/$LOG.log|" $file
ok_msg "$file updated!"
elif [ "$(grep "\-l \/tmp\/$LOG" $file)" ]; then
status_msg "Updating $file ..."
sudo sed -i -r "/ExecStart=/ s|-l \/tmp\/$LOG|-l $LPATH/$LOG|" $file
ok_msg "$file updated!"
fi
done
sudo systemctl daemon-reload
# create symlink for mainsail and fluidd nginx logs
symlink_webui_nginx_log "mainsail"
symlink_webui_nginx_log "fluidd"
# create symlink for webcamd log
if [ -f "/var/log/webcamd.log" ] && [ ! -L "$LPATH/webcamd.log" ]; then
status_msg "Creating symlink for '/var/log/webcamd.log' ..."
ln -s "/var/log/webcamd.log" "$LPATH"
ok_msg "OK!"
fi
shopt -u extglob # disable extended globbing
}
migrate_custompios(){
### migrate vanilla mainsailOS 0.4.0 / fluiddPI v1.13.0
### and older to be in sync with newer releases
WEBCAMD_SRC="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mjpgstreamer/filesystem/root/usr/local/bin/webcamd"
MJPG_SERV_SRC="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mjpgstreamer/filesystem/root/etc/systemd/system/webcamd.service"
KL_SERV_SRC="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/klipper/filesystem/root/etc/systemd/system/klipper.service"
NGINX_CFG1="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mainsail/filesystem/root/etc/nginx/conf.d/upstreams.conf"
NGINX_CFG2="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mainsail/filesystem/root/etc/nginx/sites-available/mainsail"
LOG_ROTATE_KLIPPER="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/klipper/filesystem/root/etc/logrotate.d/klipper"
LOG_ROTATE_MOONRAKER="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/moonraker/filesystem/root/etc/logrotate.d/moonraker"
LOG_ROTATE_WEBCAMD="https://raw.githubusercontent.com/raymondh2/MainsailOS/master/src/modules/mjpgstreamer/filesystem/root/etc/logrotate.d/webcamd"
if [ "$1" == "mainsail" ]; then
OS_VER="MainsailOS"
MACRO_CFG="mainsail.cfg"
fi
if [ "$1" == "fluiddpi" ]; then
OS_VER="FluiddPi"
MACRO_CFG="client_macros.cfg"
fi
if [ ! -f "/boot/$1.txt" ] || [ ! -f "/etc/init.d/klipper" ]; then
# abort function if there is no sign of an old CustomPiOS anymore
ERROR_MSG="No vanilla $OS_VER found. Aborting..." && return 0
fi
status_msg "Starting migration of $OS_VER... Please wait..."
if [ -d "${HOME}/klipper_logs" ]; then
# delete an existing klipper_logs directory
# shouldn't be there in the first place if its a true vanilla CustomPiOS
status_msg "Recreate '~/klipper_logs' directory..."
rm -rf "${HOME}/klipper_logs" && mkdir "${HOME}/klipper_logs"
ok_msg "OK!"
fi
if [ -f "/boot/$1.txt" ]; then
# replace old webcamd.service and webcamd
status_msg "Migrating MJPG-Streamer..."
sudo systemctl stop webcamd
sudo rm -f "/etc/systemd/system/webcamd.service"
sudo rm -f "/root/bin/webcamd"
sudo wget $WEBCAMD_SRC -O "/usr/local/bin/webcamd"
sudo wget $MJPG_SERV_SRC -O "/etc/systemd/system/webcamd.service"
sudo sed -i "s/MainsailOS/$OS_VER/" "/etc/systemd/system/webcamd.service"
sudo chmod +x "/usr/local/bin/webcamd"
# move mainsail.txt/fluiddpi.txt from boot to klipper_config and rename it
sudo mv "/boot/$1.txt" "${HOME}/klipper_config/webcam.txt"
sudo chown pi:pi "${HOME}/klipper_config/webcam.txt"
sudo systemctl daemon-reload
sudo systemctl restart webcamd
ok_msg "OK!"
fi
if [ -f "/etc/init.d/klipper" ] && [ ! -f "/etc/systemd/system/klipper.service" ]; then
# replace klipper SysVinit service with systemd service
status_msg "Migrating Klipper Service..."
sudo systemctl stop klipper
sudo update-rc.d -f klipper remove
sudo rm -f "/etc/init.d/klipper"
sudo rm -f "/etc/default/klipper"
sudo wget $KL_SERV_SRC -O "/etc/systemd/system/klipper.service"
sudo systemctl enable klipper.service
sudo systemctl daemon-reload
sudo systemctl restart klipper
ok_msg "OK!"
fi
if [ -f "/etc/systemd/system/moonraker.service" ]; then
# update new log path in existing moonraker service
status_msg "Updating Moonraker Service..."
sudo systemctl stop moonraker
update_log_paths "moonraker"
sudo systemctl restart moonraker
ok_msg "OK!"
fi
if [ -f "/etc/nginx/conf.d/upstreams.conf" ]; then
[ "$1" == "mainsail" ] && cfg="mainsail"
[ "$1" == "fluiddpi" ] && cfg="fluidd"
# update nginx upstreams.conf and mainsail/fluidd config file
status_msg "Updating NGINX configurations..."
sudo systemctl stop nginx
sudo rm -f "/etc/nginx/conf.d/upstreams.conf"
sudo rm -f "/etc/nginx/sites-available/$cfg"
sudo wget $NGINX_CFG1 -O "/etc/nginx/conf.d/upstreams.conf"
sudo wget $NGINX_CFG2 -O "/etc/nginx/sites-available/$cfg"
sudo sed -i "s/mainsail/$cfg/g" "/etc/nginx/sites-available/$cfg"
sudo systemctl restart nginx
ok_msg "OK!"
fi
if [ -f "${HOME}/klipper_config/$MACRO_CFG" ]; then
# update macro files
status_msg "Updating $MACRO_CFG ..."
MACRO_CFG_PATH="${HOME}/klipper_config/$MACRO_CFG"
sed -i "/SAVE_GCODE_STATE NAME=PAUSE_state/d" $MACRO_CFG_PATH
sed -i "/RESTORE_GCODE_STATE NAME=PAUSE_state/d" $MACRO_CFG_PATH
ok_msg "OK!"
fi
if [ -d "/etc/logrotate.d" ]; then
# download logrotate configs
status_msg "Setting up logrotations..."
sudo wget $LOG_ROTATE_KLIPPER -O "/etc/logrotate.d/klipper"
sudo wget $LOG_ROTATE_MOONRAKER -O "/etc/logrotate.d/moonraker"
sudo wget $LOG_ROTATE_WEBCAMD -O "/etc/logrotate.d/webcamd"
ok_msg "OK!"
fi
ok_msg "Migration done!"
}
update_klipper(){
klipper_service "stop"
if [ ! -d $KLIPPER_DIR ]; then
@@ -69,18 +211,23 @@ update_klipper(){
save_klipper_state
status_msg "Updating $GET_BRANCH"
cd $KLIPPER_DIR
KLIPPER_OLDREQ_MD5SUM="$(md5sum $KLIPPER_DIR/scripts/klippy-requirements.txt | cut -d " " -f1)"
if [ "$DETACHED_HEAD" == "true" ]; then
git checkout $GET_BRANCH
unset DETACHED_HEAD
fi
### get current klippy-requirements.txt md5sum
KLIPPER_OLDREQ_MD5SUM="$(md5sum $KLIPPER_DIR/scripts/klippy-requirements.txt | cut -d " " -f1)"
### pull latest files from github
git pull && ok_msg "Update successfull!"
git pull
### read PKGLIST and install possible new dependencies
install_klipper_packages
### get possible new klippy-requirements.txt md5sum
KLIPPER_NEWREQ_MD5SUM="$(md5sum $KLIPPER_DIR/scripts/klippy-requirements.txt | cut -d " " -f1)"
### check for possible new dependencies and install them
if [[ $(md5sum $KLIPPER_DIR/scripts/klippy-requirements.txt | cut -d " " -f1) != $KLIPPER_OLDREQ_MD5SUM ]]; then
if [[ $KLIPPER_NEWREQ_MD5SUM != $KLIPPER_OLDREQ_MD5SUM ]]; then
PYTHONDIR="${HOME}/klippy-env"
status_msg "New dependecies detected..."
@@ -90,9 +237,9 @@ update_klipper(){
$PYTHONDIR/bin/pip install -r $KLIPPER_DIR/scripts/klippy-requirements.txt
ok_msg "Dependencies have been installed!"
fi
ok_msg "Update complete!"
fi
update_log_paths "klipper"
ok_msg "Update complete!"
klipper_service "restart"
}
@@ -109,19 +256,21 @@ update_dwc2fk(){
update_dwc2(){
bb4u "dwc2"
download_dwc2_webui
download_dwc_webui
}
update_mainsail(){
bb4u "mainsail"
status_msg "Updating Mainsail ..."
mainsail_setup
symlink_webui_nginx_log "mainsail"
}
update_fluidd(){
bb4u "fluidd"
status_msg "Updating Fluidd ..."
fluidd_setup
symlink_webui_nginx_log "fluidd"
}
update_moonraker(){
@@ -129,13 +278,18 @@ update_moonraker(){
bb4u "moonraker"
status_msg "Updating Moonraker ..."
cd $MOONRAKER_DIR
MOONRAKER_OLDREQ_MD5SUM=$(md5sum $MOONRAKER_DIR/scripts/moonraker-requirements.txt | cut -d " " -f1)
### get current moonraker-requirements.txt md5sum
MOONRAKER_OLDREQ_MD5SUM=$(md5sum $MOONRAKER_DIR/scripts/moonraker-requirements.txt | cut -d " " -f1)
### pull latest files from github
git pull && ok_msg "Update successfull!"
git pull
### read PKGLIST and install possible new dependencies
install_moonraker_packages
### get possible new moonraker-requirements.txt md5sum
MOONRAKER_NEWREQ_MD5SUM=$(md5sum $MOONRAKER_DIR/scripts/moonraker-requirements.txt | cut -d " " -f1)
### check for possible new dependencies and install them
if [[ $(md5sum $MOONRAKER_DIR/scripts/moonraker-requirements.txt | cut -d " " -f1) != $MOONRAKER_OLDREQ_MD5SUM ]]; then
if [[ $MOONRAKER_NEWREQ_MD5SUM != $MOONRAKER_OLDREQ_MD5SUM ]]; then
PYTHONDIR="${HOME}/moonraker-env"
status_msg "New dependecies detected..."
### always rebuild the pythondir from scratch if new dependencies were detected
@@ -145,7 +299,7 @@ update_moonraker(){
${PYTHONDIR}/bin/pip install -r $MOONRAKER_DIR/scripts/moonraker-requirements.txt
ok_msg "Dependencies have been installed!"
fi
update_log_paths "moonraker"
ok_msg "Update complete!"
moonraker_service "restart"
}
@@ -155,7 +309,7 @@ update_klipperscreen(){
cd $KLIPPERSCREEN_DIR
KLIPPERSCREEN_OLDREQ_MD5SUM=$(md5sum $KLIPPERSCREEN_DIR/scripts/KlipperScreen-requirements.txt | cut -d " " -f1)
git pull origin master -q && ok_msg "Fetch successfull!"
git checkout -f origin/master && ok_msg "Checkout successfull"
git checkout -f master && ok_msg "Checkout successfull"
#KLIPPERSCREEN_NEWREQ_MD5SUM=$(md5sum $KLIPPERSCREEN_DIR/scripts/KlipperScreen-requirements.txt)
if [[ $(md5sum $KLIPPERSCREEN_DIR/scripts/KlipperScreen-requirements.txt | cut -d " " -f1) != $KLIPPERSCREEN_OLDREQ_MD5SUM ]]; then
status_msg "New dependecies detected..."
@@ -166,3 +320,10 @@ update_klipperscreen(){
ok_msg "Update complete!"
start_klipperscreen
}
update_system(){
status_msg "Updating System ..."
sudo apt-get update && sudo apt-get upgrade -y
ok_msg "Update complete! Check the log above!"
ok_msg "KIAUH won't do any dist-upgrades!\n"
}

View File

@@ -42,13 +42,16 @@ upload_selection(){
### find all suitable logfiles for klipper
logfiles=()
if ls /tmp/klippy*.log 2>/dev/null 1>&2; then
for kl_log in $(find /tmp/klippy*.log); do
klipper_logs="${HOME}/klipper_logs/klippy*.log"
moonraker_logs="${HOME}/klipper_logs/moonraker*.log"
if ls $klipper_logs 2>/dev/null 1>&2; then
for kl_log in $(find $klipper_logs); do
logfiles+=($kl_log)
done
fi
if ls /tmp/moonraker*.log 2>/dev/null 1>&2; then
for mr_log in $(find /tmp/moonraker*.log); do
if ls $moonraker_logs 2>/dev/null 1>&2; then
for mr_log in $(find $moonraker_logs); do
logfiles+=($mr_log)
done
fi