Merge pull request #22 from th33xitus/work-fluidd

Installer for Fluidd and several other fixes
This commit is contained in:
th33xitus
2020-10-06 22:31:41 +02:00
committed by GitHub
23 changed files with 807 additions and 203 deletions

119
README.md
View File

@@ -1,27 +1,24 @@
# KIAUH - Klipper Installation And Update Helper # KIAUH - Klipper Installation And Update Helper
### ( This script is always work in progress! )
![main_menu](https://github.com/th33xitus/kiauh/blob/master/resources/screenshots/main.png) ![main_menu](https://github.com/th33xitus/kiauh/blob/master/resources/screenshots/main.png)
--- ---
## Disclaimer: Usage of this script happens at your own risk! ## 📢 Disclaimer: Usage of this script happens at your own risk!
This script is "only" a helping hand for you to get set up in a fast and most comfortable way.
**This does not mean, it will relieve you of using brain.exe!**
This script is "only" a helping hand for you to get set up in a fast and most comfortable way.\
**This does not mean, it will relieve you of using brain.exe! 🧠**\
Feel free to give it a try if you want. If you have suggestions or encounter any problems, please report them. Feel free to give it a try if you want. If you have suggestions or encounter any problems, please report them.
--- ---
## Instructions: ## 🛠️ Instructions:
For downloading this script it is best to have git already installed. For downloading this script it is best to have git already installed.\
If you haven't, please run `sudo apt-get install git -y` to install git first. You will need it anyways! If you haven't, please run `sudo apt-get install git -y` to install git first.\
You will need it anyways!
After git is installed, use the following commands in the given order to download and execute the script. After git is installed, use the following commands in the given order to download and execute the script:
```shell ```shell
cd ~ cd ~
@@ -31,23 +28,21 @@ chmod +x kiauh.sh scripts/*
./kiauh.sh ./kiauh.sh
``` ```
## Additional Instructions: ### Additional Instructions:
If you need some more detailed instructions on how to install Klipper and Mainsail with KIAUH, check out this website: 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)\
[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).\
Credits for these instructions go to [@tumbleweedlabs](https://github.com/tumbleweedlabs).
Feel free to check out his work. Feel free to check out his work.
--- ---
## Functions and Features: ## 🧰 Functions and Features:
### Core Functions: ### Core Functions:
- **Installing** of the Klipper Firmware to your Raspberry Pi or other Linux Distribution which makes use of init.d. - **Installing** of the Klipper Firmware to your Raspberry Pi or other Linux Distribution which makes use of init.d.
- **Installing** of several different web interfaces such as Duet Web Control, Mainsail or OctoPrint including their dependencies. - **Installing** of several different web interfaces such as Duet Web Control, Mainsail, Fluidd or OctoPrint including their dependencies.
- **Installing** of the Moonraker API - **Installing** of the Moonraker API
- **Updating** of all the listed installations above excluding OctoPrint. For updating OctoPrint, please use the OctoPrint interface! - **Updating** of all the listed installations above excluding OctoPrint. For updating OctoPrint, please use the OctoPrint interface!
- **Removing** of all the listed installations above. - **Removing** of all the listed installations above.
@@ -65,7 +60,7 @@ For a list of additional features and their descriptions please see:
--- ---
## Notes: ## 📝 Notes:
- Important changes to the script will be listed in the [Changelog](https://github.com/th33xitus/kiauh/blob/master/docs/changelog.md) - Important changes to the script will be listed in the [Changelog](https://github.com/th33xitus/kiauh/blob/master/docs/changelog.md)
- Tested only on Raspbian Buster Lite - Tested only on Raspbian Buster Lite
@@ -75,41 +70,63 @@ For a list of additional features and their descriptions please see:
--- ---
### For more information or instructions, please check out the appropriate repositories listed below: ## 🛈 Sources & Further Information
Klipper by [KevinOConnor](https://github.com/KevinOConnor) : For more information or instructions, please check out the appropriate repositories listed below:
- https://github.com/KevinOConnor/klipper
Klipper S-Curve fork by [dmbutyugin](https://github.com/dmbutyugin) :
- https://github.com/dmbutyugin/klipper/tree/scurve-smoothing
- https://github.com/dmbutyugin/klipper/tree/scurve-shaping
Moonraker by [Arksine](https://github.com/Arksine) :
- https://github.com/Arksine/moonraker
Mainsail Webinterface by [meteyou](https://github.com/meteyou) :
- https://github.com/meteyou/mainsail
Duet Web Control by [Duet3D](https://github.com/Duet3D) :
- https://github.com/Duet3D/DuetWebControl
DWC2-for-Klipper-Socket by [Stephan3](https://github.com/Stephan3) :
- https://github.com/Stephan3/dwc2-for-klipper-socket
OctoPrint Webinterface by [OctoPrint](https://github.com/OctoPrint) :
- https://octoprint.org
- https://github.com/OctoPrint/OctoPrint
--- ---
## Q&A **⛵Klipper** by [KevinOConnor](https://github.com/KevinOConnor) :
https://github.com/KevinOConnor/klipper
---
**⛵Klipper S-Curve fork** by [dmbutyugin](https://github.com/dmbutyugin) :
https://github.com/dmbutyugin/klipper/tree/scurve-smoothing\
https://github.com/dmbutyugin/klipper/tree/scurve-shaping
---
**🌙Moonraker** by [Arksine](https://github.com/Arksine) :
https://github.com/Arksine/moonraker
---
**💨Mainsail Webinterface** by [meteyou](https://github.com/meteyou) :
https://github.com/meteyou/mainsail
---
**🌊Fluidd Webinterface** by [cadriel](https://github.com/cadriel) :
https://github.com/cadriel/fluidd
---
**🕸Duet Web Control** by [Duet3D](https://github.com/Duet3D) :
https://github.com/Duet3D/DuetWebControl
---
**🕸DWC2-for-Klipper-Socket** by [Stephan3](https://github.com/Stephan3) :
https://github.com/Stephan3/dwc2-for-klipper-socket
---
**🐙OctoPrint Webinterface** by [OctoPrint](https://github.com/OctoPrint) :
https://octoprint.org\
https://github.com/OctoPrint/OctoPrint
---
## ❓ FAQ
**_Q: Can i use this script to install multiple instancec of Klipper on the same Pi? (Multisession?)_** **_Q: Can i use this script to install multiple instancec of Klipper on the same Pi? (Multisession?)_**

View File

@@ -4,11 +4,11 @@ set -e
### set some variables ### set some variables
ERROR_MSG="" ERROR_MSG=""
green=$(echo -en "\001\033[01;32m\002") green=$(echo -en "\e[92m")
yellow=$(echo -en "\001\033[01;33m\002") yellow=$(echo -en "\e[93m")
red=$(echo -en "\001\033[01;31m\002") red=$(echo -en "\e[91m")
cyan=$(echo -en "\001\033[01;36m\002") cyan=$(echo -en "\e[96m")
default=$(echo -en "\001\033[0m\002") default=$(echo -en "\e[97m")
### set important directories ### set important directories
#klipper #klipper
@@ -16,16 +16,23 @@ KLIPPER_DIR=${HOME}/klipper
KLIPPY_ENV_DIR=${HOME}/klippy-env KLIPPY_ENV_DIR=${HOME}/klippy-env
KLIPPER_SERVICE1=/etc/init.d/klipper KLIPPER_SERVICE1=/etc/init.d/klipper
KLIPPER_SERVICE2=/etc/default/klipper KLIPPER_SERVICE2=/etc/default/klipper
#dwc2 #nginx
DWC2FK_DIR=${HOME}/dwc2-for-klipper-socket NGINX_SA=/etc/nginx/sites-available
DWC_ENV_DIR=${HOME}/dwc-env NGINX_SE=/etc/nginx/sites-enabled
DWC2_DIR=${HOME}/sdcard/web NGINX_CONFD=/etc/nginx/conf.d
#mainsail/moonraker #moonraker
MAINSAIL_DIR=${HOME}/mainsail
MOONRAKER_DIR=${HOME}/moonraker MOONRAKER_DIR=${HOME}/moonraker
MOONRAKER_ENV_DIR=${HOME}/moonraker-env MOONRAKER_ENV_DIR=${HOME}/moonraker-env
MOONRAKER_SERVICE1=/etc/init.d/moonraker MOONRAKER_SERVICE1=/etc/init.d/moonraker
MOONRAKER_SERVICE2=/etc/default/moonraker MOONRAKER_SERVICE2=/etc/default/moonraker
#mainsail
MAINSAIL_DIR=${HOME}/mainsail
#fluidd
FLUIDD_DIR=${HOME}/fluidd
#dwc2
DWC2FK_DIR=${HOME}/dwc2-for-klipper-socket
DWC_ENV_DIR=${HOME}/dwc-env
DWC2_DIR=${HOME}/sdcard/web
#octoprint #octoprint
OCTOPRINT_DIR=${HOME}/OctoPrint OCTOPRINT_DIR=${HOME}/OctoPrint
OCTOPRINT_CFG_DIR=${HOME}/.octoprint OCTOPRINT_CFG_DIR=${HOME}/.octoprint

View File

@@ -0,0 +1,6 @@
# /etc/nginx/conf.d/common_vars.conf
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

View File

@@ -0,0 +1,87 @@
# /etc/nginx/sites-available/fluidd
server {
listen 80;
listen [::]:80;
access_log /var/log/nginx/fluidd-access.log;
error_log /var/log/nginx/fluidd-error.log;
#disable this section on smaller hardware like a pi zero
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_proxied expired no-cache no-store private auth;
gzip_comp_level 4;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/json application/xml;
#web_path from fluidd static files
root /home/pi/fluidd;
index index.html;
server_name _;
#max upload size for gcodes
client_max_body_size 200M;
location / {
try_files $uri $uri/ /index.html;
}
location /printer {
proxy_pass http://apiserver/printer;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
}
location /api {
proxy_pass http://apiserver/api;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
}
location /access {
proxy_pass http://apiserver/access;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
}
location /websocket {
proxy_pass http://apiserver/websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 86400;
}
location /machine {
proxy_pass http://apiserver/machine;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
}
location /server {
proxy_pass http://apiserver/server;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
}
location /webcam/ {
proxy_pass http://mjpgstreamer/;
}
}

View File

@@ -1,19 +1,4 @@
map $http_upgrade $connection_upgrade { # /etc/nginx/sites-available/mainsail
default upgrade;
'' close;
}
upstream apiserver {
#edit your api port here
ip_hash;
server 127.0.0.1:7125;
}
upstream mjpgstreamer {
#edit your webcam port here
ip_hash;
server 127.0.0.1:8081;
}
server { server {
listen 80; listen 80;
@@ -22,6 +7,16 @@ server {
access_log /var/log/nginx/mainsail-access.log; access_log /var/log/nginx/mainsail-access.log;
error_log /var/log/nginx/mainsail-error.log; error_log /var/log/nginx/mainsail-error.log;
#disable this section on smaller hardware like a pi zero
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_proxied expired no-cache no-store private auth;
gzip_comp_level 4;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/json application/xml;
#web_path from mainsail static files #web_path from mainsail static files
root /home/pi/mainsail; root /home/pi/mainsail;

View File

@@ -0,0 +1,13 @@
# /etc/nginx/conf.d/upstreams.conf
upstream apiserver {
#edit your api port here
ip_hash;
server 127.0.0.1:7125;
}
upstream mjpgstreamer {
#edit your webcam port here
ip_hash;
server 127.0.0.1:8081;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -1,6 +1,9 @@
install_dwc2(){ install_dwc2(){
if [ -d $KLIPPER_DIR ]; then if [ -d $KLIPPER_DIR ]; then
system_check_dwc2 system_check_dwc2
#check for other enabled web interfaces
unset SET_LISTEN_PORT
detect_enabled_sites
#ask user for customization #ask user for customization
get_user_selections_dwc2 get_user_selections_dwc2
#dwc2 main installation #dwc2 main installation
@@ -10,7 +13,7 @@ install_dwc2(){
write_printer_cfg_dwc2 write_printer_cfg_dwc2
#execute customizations #execute customizations
disable_octoprint disable_octoprint
create_reverse_proxy "dwc2" set_nginx_cfg "dwc2"
set_hostname set_hostname
#after install actions #after install actions
restart_klipper restart_klipper
@@ -31,7 +34,6 @@ system_check_dwc2(){
fi fi
#check if octoprint is installed #check if octoprint is installed
if systemctl is-enabled octoprint.service -q 2>/dev/null; then if systemctl is-enabled octoprint.service -q 2>/dev/null; then
unset OCTOPRINT_ENABLED
OCTOPRINT_ENABLED="true" OCTOPRINT_ENABLED="true"
fi fi
} }
@@ -104,9 +106,7 @@ get_user_selections_dwc2(){
#ask user to install reverse proxy #ask user to install reverse proxy
dwc2_reverse_proxy_dialog dwc2_reverse_proxy_dialog
#ask to change hostname #ask to change hostname
if [ "$SET_REVERSE_PROXY" = "true" ]; then [ "$SET_NGINX_CFG" = "true" ] && create_custom_hostname
create_custom_hostname
fi
#ask user to disable octoprint when such installed service was found #ask user to disable octoprint when such installed service was found
if [ "$OCTOPRINT_ENABLED" = "true" ]; then if [ "$OCTOPRINT_ENABLED" = "true" ]; then
unset DISABLE_OPRINT unset DISABLE_OPRINT
@@ -188,7 +188,7 @@ patch_klipper_sysfile_dwc2(){
download_dwc2_webui(){ download_dwc2_webui(){
#get Duet Web Control #get Duet Web Control
GET_DWC2_URL=`curl -s https://api.github.com/repositories/28820678/releases/latest | grep browser_download_url | cut -d'"' -f4` GET_DWC2_URL=$(curl -s https://api.github.com/repositories/28820678/releases/latest | grep browser_download_url | cut -d'"' -f4)
cd $DWC2_DIR cd $DWC2_DIR
status_msg "Downloading DWC2 Web UI ..." status_msg "Downloading DWC2 Web UI ..."
wget $GET_DWC2_URL wget $GET_DWC2_URL
@@ -295,7 +295,6 @@ DEFAULT_DWC2_CFG
############################################################# #############################################################
dwc2_reverse_proxy_dialog(){ dwc2_reverse_proxy_dialog(){
unset SET_REVERSE_PROXY
echo echo
top_border top_border
echo -e "| If you want to have a nicer URL or simply need/want | " echo -e "| If you want to have a nicer URL or simply need/want | "
@@ -306,10 +305,9 @@ dwc2_reverse_proxy_dialog(){
read -p "${cyan}###### Do you want to set up a reverse proxy now? (y/N):${default} " yn read -p "${cyan}###### Do you want to set up a reverse proxy now? (y/N):${default} " yn
case "$yn" in case "$yn" in
Y|y|Yes|yes) Y|y|Yes|yes)
SET_REVERSE_PROXY="true" dwc2_port_check
break;; break;;
N|n|No|no|"") N|n|No|no|"")
SET_REVERSE_PROXY="false"
break;; break;;
*) *)
print_unkown_cmd print_unkown_cmd
@@ -317,3 +315,55 @@ dwc2_reverse_proxy_dialog(){
esac esac
done done
} }
dwc2_port_check(){
if [ "$DWC2_ENABLED" = "false" ]; then
if [ "$SITE_ENABLED" = "true" ]; then
status_msg "Detected other enabled interfaces:"
[ "$OCTOPRINT_ENABLED" = "true" ] && echo " ${cyan}● OctoPrint - Port:$OCTOPRINT_PORT${default}"
[ "$MAINSAIL_ENABLED" = "true" ] && echo " ${cyan}● Mainsail - Port:$MAINSAIL_PORT${default}"
[ "$FLUIDD_ENABLED" = "true" ] && echo " ${cyan}● Fluidd - Port:$FLUIDD_PORT${default}"
if [ "$MAINSAIL_PORT" = "80" ] || [ "$OCTOPRINT_PORT" = "80" ] || [ "$FLUIDD_PORT" = "80" ]; then
PORT_80_BLOCKED="true"
select_dwc2_port
fi
else
DEFAULT_PORT=$(grep listen ${SRCDIR}/kiauh/resources/dwc2_nginx.cfg | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
SET_LISTEN_PORT=$DEFAULT_PORT
fi
SET_NGINX_CFG="true"
else
SET_NGINX_CFG="false"
fi
}
select_dwc2_port(){
if [ "$PORT_80_BLOCKED" = "true" ]; then
echo
top_border
echo -e "| ${red}!!!WARNING!!!${default} |"
echo -e "| ${red}You need to choose a different port for DWC2!${default} |"
echo -e "| ${red}The following web interface is listening at port 80:${default} |"
blank_line
[ "$OCTOPRINT_PORT" = "80" ] && echo "| ● OctoPrint |"
[ "$MAINSAIL_PORT" = "80" ] && echo "| ● Mainsail |"
[ "$FLUIDD_PORT" = "80" ] && echo "| ● Fluidd |"
blank_line
echo -e "| Make sure you don't choose a port which was already |"
echo -e "| assigned to one of the other web interfaces! |"
blank_line
echo -e "| Be aware: there is ${red}NO${default} sanity check for the following |"
echo -e "| input. So make sure to choose a valid port! |"
bottom_border
while true; do
read -p "${cyan}Please enter a new Port:${default} " NEW_PORT
if [ "$NEW_PORT" != "$MAINSAIL_PORT" ] && [ "$NEW_PORT" != "$FLUIDD_PORT" ] && [ "$NEW_PORT" != "$OCTOPRINT_PORT" ]; then
echo "Setting port $NEW_PORT for DWC2!"
SET_LISTEN_PORT=$NEW_PORT
break
else
echo "That port is already taken! Select a different one!"
fi
done
fi
}

87
scripts/install_fluidd.sh Executable file
View File

@@ -0,0 +1,87 @@
install_fluidd(){
if [ "$INST_FLUIDD" = "true" ]; then
unset SET_LISTEN_PORT
#check for other enabled web interfaces
detect_enabled_sites
#check if another site already listens to port 80
fluidd_port_check
#creating the fluidd nginx cfg
set_nginx_cfg "fluidd"
fluidd_setup && ok_msg "Fluidd installation complete!"; echo
fi
}
fluidd_port_check(){
if [ "$FLUIDD_ENABLED" = "false" ]; then
if [ "$SITE_ENABLED" = "true" ]; then
status_msg "Detected other enabled interfaces:"
[ "$OCTOPRINT_ENABLED" = "true" ] && echo " ${cyan}● OctoPrint - Port: $OCTOPRINT_PORT${default}"
[ "$MAINSAIL_ENABLED" = "true" ] && echo " ${cyan}● Mainsail - Port: $MAINSAIL_PORT${default}"
[ "$DWC2_ENABLED" = "true" ] && echo " ${cyan}● DWC2 - Port: $DWC2_PORT${default}"
if [ "$MAINSAIL_PORT" = "80" ] || [ "$DWC2_PORT" = "80" ] || [ "$OCTOPRINT_PORT" = "80" ]; then
PORT_80_BLOCKED="true"
select_fluidd_port
fi
else
DEFAULT_PORT=$(grep listen ${SRCDIR}/kiauh/resources/fluidd_nginx.cfg | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
SET_LISTEN_PORT=$DEFAULT_PORT
fi
SET_NGINX_CFG="true"
else
SET_NGINX_CFG="false"
fi
}
select_fluidd_port(){
if [ "$PORT_80_BLOCKED" = "true" ]; then
echo
top_border
echo -e "| ${red}!!!WARNING!!!${default} |"
echo -e "| ${red}You need to choose a different port for Fluidd!${default} |"
echo -e "| ${red}The following web interface is listening at port 80:${default} |"
blank_line
[ "$OCTOPRINT_PORT" = "80" ] && echo "| ● OctoPrint |"
[ "$MAINSAIL_PORT" = "80" ] && echo "| ● Mainsail |"
[ "$DWC2_PORT" = "80" ] && echo "| ● DWC2 |"
blank_line
echo -e "| Make sure you don't choose a port which was already |"
echo -e "| assigned to one of the other web interfaces! |"
blank_line
echo -e "| Be aware: there is ${red}NO${default} sanity check for the following |"
echo -e "| input. So make sure to choose a valid port! |"
bottom_border
while true; do
read -p "${cyan}Please enter a new Port:${default} " NEW_PORT
if [ "$NEW_PORT" != "$MAINSAIL_PORT" ] && [ "$NEW_PORT" != "$DWC2_PORT" ] && [ "$NEW_PORT" != "$OCTOPRINT_PORT" ]; then
echo "Setting port $NEW_PORT for Fluidd!"
SET_LISTEN_PORT=$NEW_PORT
break
else
echo "That port is already taken! Select a different one!"
fi
done
fi
}
get_fluidd_ver(){
FLUIDD_VERSION=$(curl -s https://api.github.com/repositories/295836951/tags | grep name | cut -d'"' -f4 | cut -d"v" -f2 | head -1)
}
fluidd_dl_url(){
get_fluidd_ver
FLUIDD_URL=https://github.com/cadriel/fluidd/releases/download/v$FLUIDD_VERSION/fluidd_v$FLUIDD_VERSION.zip
}
fluidd_setup(){
fluidd_dl_url
#clean up an existing fluidd folder
[ -d $FLUIDD_DIR ] && rm -rf $FLUIDD_DIR
#create fresh fluidd folder and download fluidd
mkdir $FLUIDD_DIR
cd $FLUIDD_DIR
status_msg "Downloading Fluidd $FLUIDD_VERSION ..."
wget -O fluidd.zip $FLUIDD_URL && status_msg "Extracting archive ..." && unzip -o fluidd.zip && rm fluidd.zip
### write fluidd version to file for update check reasons
echo "$FLUIDD_VERSION" > $FLUIDD_DIR/version
echo
}

View File

@@ -1,24 +1,65 @@
install_mainsail(){ install_mainsail(){
if [ "$INST_MAINSAIL" = "true" ]; then if [ "$INST_MAINSAIL" = "true" ]; then
unset SET_REVERSE_PROXY && SET_REVERSE_PROXY="true" #quick and dirty hack to make mainsail reverse proxy install, needs polish unset SET_LISTEN_PORT
create_reverse_proxy "mainsail" #check for other enabled web interfaces
mainsail_setup detect_enabled_sites
test_nginx #check if another site already listens to port 80
ok_msg "Mainsail installation complete!"; echo mainsail_port_check
#creating the mainsail nginx cfg
set_nginx_cfg "mainsail"
mainsail_setup && ok_msg "Mainsail installation complete!"; echo
fi fi
} }
test_nginx(){ mainsail_port_check(){
HOST_IP=$(hostname -I | cut -d" " -f1) if [ "$MAINSAIL_ENABLED" = "false" ]; then
status_msg "Testing Nginx ..." if [ "$SITE_ENABLED" = "true" ]; then
sleep 5 status_msg "Detected other enabled interfaces:"
status_msg "API response from http://$HOST_IP/printer/info :" [ "$OCTOPRINT_ENABLED" = "true" ] && echo -e " ${cyan}● OctoPrint - Port: $OCTOPRINT_PORT${default}"
API_RESPONSE="$(curl -sG4m5 http://$HOST_IP/printer/info)" [ "$FLUIDD_ENABLED" = "true" ] && echo -e " ${cyan}● Fluidd - Port: $FLUIDD_PORT${default}"
echo -e "${cyan}$API_RESPONSE${default}" [ "$DWC2_ENABLED" = "true" ] && echo -e " ${cyan}● DWC2 - Port: $DWC2_PORT${default}"
if [ $(curl -sG4 "http://$HOST_IP/printer/info" | grep '^{"result"' -c) -eq 1 ]; then if [ "$FLUIDD_PORT" = "80" ] || [ "$DWC2_PORT" = "80" ] || [ "$OCTOPRINT_PORT" = "80" ]; then
echo; ok_msg "Nginx is working correctly!"; echo PORT_80_BLOCKED="true"
select_mainsail_port
fi
else else
echo; warn_msg "Nginx is not working correctly!"; echo DEFAULT_PORT=$(grep listen ${SRCDIR}/kiauh/resources/mainsail_nginx.cfg | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
SET_LISTEN_PORT=$DEFAULT_PORT
fi
SET_NGINX_CFG="true"
else
SET_NGINX_CFG="false"
fi
}
select_mainsail_port(){
if [ "$PORT_80_BLOCKED" = "true" ]; then
echo
top_border
echo -e "| ${red}!!!WARNING!!!${default} |"
echo -e "| ${red}You need to choose a different port for Mainsail!${default} |"
echo -e "| ${red}The following web interface is listening at port 80:${default} |"
blank_line
[ "$OCTOPRINT_PORT" = "80" ] && echo "| ● OctoPrint |"
[ "$FLUIDD_PORT" = "80" ] && echo "| ● Fluidd |"
[ "$DWC2_PORT" = "80" ] && echo "| ● DWC2 |"
blank_line
echo -e "| Make sure you don't choose a port which was already |"
echo -e "| assigned to one of the other web interfaces! |"
blank_line
echo -e "| Be aware: there is ${red}NO${default} sanity check for the following |"
echo -e "| input. So make sure to choose a valid port! |"
bottom_border
while true; do
read -p "${cyan}Please enter a new Port:${default} " NEW_PORT
if [ "$NEW_PORT" != "$FLUIDD_PORT" ] && [ "$NEW_PORT" != "$DWC2_PORT" ] && [ "$NEW_PORT" != "$OCTOPRINT_PORT" ]; then
echo "Setting port $NEW_PORT for Mainsail!"
SET_LISTEN_PORT=$NEW_PORT
break
else
echo "That port is already taken! Select a different one!"
fi
done
fi fi
} }
@@ -28,20 +69,17 @@ get_mainsail_ver(){
mainsail_dl_url(){ mainsail_dl_url(){
get_mainsail_ver get_mainsail_ver
MAINSAIL_URL=https://github.com/meteyou/mainsail/releases/download/v"$MAINSAIL_VERSION"/mainsail-beta-"$MAINSAIL_VERSION".zip MAINSAIL_URL=https://github.com/meteyou/mainsail/releases/download/v$MAINSAIL_VERSION/mainsail-beta-$MAINSAIL_VERSION.zip
} }
mainsail_setup(){ mainsail_setup(){
mainsail_dl_url mainsail_dl_url
#clean up an existing mainsail folder #clean up an existing mainsail folder
if [ -d $MAINSAIL_DIR ]; then [ -d $MAINSAIL_DIR ] && rm -rf $MAINSAIL_DIR
rm -rf $MAINSAIL_DIR
fi
#create fresh mainsail folder and download mainsail #create fresh mainsail folder and download mainsail
mkdir $MAINSAIL_DIR mkdir $MAINSAIL_DIR && cd $MAINSAIL_DIR
cd $MAINSAIL_DIR
status_msg "Downloading Mainsail v$MAINSAIL_VERSION ..." status_msg "Downloading Mainsail v$MAINSAIL_VERSION ..."
wget -q -O mainsail.zip $MAINSAIL_URL && status_msg "Extracting archive ..." && unzip -o mainsail.zip && rm mainsail.zip wget -O mainsail.zip $MAINSAIL_URL && status_msg "Extracting archive ..." && unzip -o mainsail.zip && rm mainsail.zip
### write mainsail version to file for update check reasons ### write mainsail version to file for update check reasons
echo "$MAINSAIL_VERSION" > $MAINSAIL_DIR/version echo "$MAINSAIL_VERSION" > $MAINSAIL_DIR/version
echo echo

View File

@@ -19,7 +19,9 @@ install_moonraker(){
restart_moonraker restart_moonraker
restart_klipper restart_klipper
test_api test_api
install_mainsail #test_nginx
#install_mainsail
#install_fluidd
} }
system_check_moonraker(){ system_check_moonraker(){
@@ -67,35 +69,42 @@ system_check_moonraker(){
get_user_selections_moonraker(){ get_user_selections_moonraker(){
#ask if moonraker only or moonraker + mainsail #ask if moonraker only or moonraker + mainsail
while true; do #while true; do
echo # echo
top_border # top_border
echo -e "| Do you want to install Moonraker and Mainsail? |" # echo -e "| Install the Moonraker API only? |"
echo -e "| You can choose to install Moonraker only by answering |" # blank_line
echo -e "| with 'No'. |" # echo -e "| You can choose to install Moonraker and one of the |"
hr # echo -e "| following web interfaces: |"
echo -e "| If you select 'Yes' please be aware that an existing |" # echo -e "| 1) Mainsail |"
echo -e "| Mainsail installation will then be overwritten! |" # echo -e "| 2) Fluidd |"
bottom_border # hr
read -p "${cyan}###### Install Moonraker + Mainsail? (Y/n):${default} " yn # echo -e "| If you want to install a web interface later, just |"
case "$yn" in # echo -e "| press 'ENTER' to continue the Moonraker installation. |"
Y|y|Yes|yes|"") # bottom_border
echo -e "###### > Yes" # read -p "${cyan}Please choose:${default} " selection
INST_MAINSAIL="true" # case "$selection" in
break;; # "")
N|n|No|no) # echo -e "###### > Moonraker only"
echo -e "###### > No" # INST_NOUI="true"
INST_MAINSAIL="false" # break;;
break;; # 1)
*) # echo -e "###### > Moonraker + Mainsail"
print_unkown_cmd # INST_MAINSAIL="true"
print_msg && clear_msg;; # break;;
esac # 2)
done # echo -e "###### > Moonraker + Fluidd"
#ask to change hostname if mainsail should be installed as well # INST_FLUIDD="true"
if [ "$INST_MAINSAIL" = "true" ]; then # break;;
create_custom_hostname # *)
fi # print_unkown_cmd
# print_msg && clear_msg;;
# esac
#done
##ask to change hostname if mainsail should be installed as well
#if [ "$INST_MAINSAIL" = "true" ]; then
# create_custom_hostname
#fi
#user selection for printer.cfg #user selection for printer.cfg
if [ "$PRINTER_CFG_FOUND" = "false" ]; then if [ "$PRINTER_CFG_FOUND" = "false" ]; then
unset SEL_DEF_CFG unset SEL_DEF_CFG
@@ -252,7 +261,7 @@ get_user_selections_moonraker(){
echo -e "| |" echo -e "| |"
echo -e "| 1) Remove packages (recommend) |" echo -e "| 1) Remove packages (recommend) |"
echo -e "| 2) Disable only (may cause issues) |" echo -e "| 2) Disable only (may cause issues) |"
echo -e "| ${red}3) Skip this step (not recommend)${default} |" echo -e "| ${red}3) Skip this step (not recommended)${default} |"
bottom_border bottom_border
read -p "${cyan}###### Please choose:${default} " action read -p "${cyan}###### Please choose:${default} " action
unset REMOVE_HAPROXY unset REMOVE_HAPROXY
@@ -312,6 +321,8 @@ moonraker_setup(){
ok_msg "Download complete!" ok_msg "Download complete!"
status_msg "Installing Moonraker ..." status_msg "Installing Moonraker ..."
$MOONRAKER_DIR/scripts/install-moonraker.sh $MOONRAKER_DIR/scripts/install-moonraker.sh
#copy moonraker configuration for nginx to /etc/nginx/conf.d
setup_moonraker_nginx_cfg
#backup a possible existing printer.cfg at the old location #backup a possible existing printer.cfg at the old location
#and before patching in the new location #and before patching in the new location
backup_printer_cfg backup_printer_cfg
@@ -480,6 +491,15 @@ setup_moonraker_conf(){
fi fi
} }
setup_moonraker_nginx_cfg(){
if [ ! -f $NGINX_CONFD/upstreams.conf ]; then
sudo cp ${SRCDIR}/kiauh/resources/moonraker_nginx.cfg $NGINX_CONFD/upstreams.conf
fi
if [ ! -f $NGINX_CONFD/common_vars.conf ]; then
sudo cp ${SRCDIR}/kiauh/resources/common_vars_nginx.cfg $NGINX_CONFD/common_vars.conf
fi
}
############################################################# #############################################################
############################################################# #############################################################
@@ -651,13 +671,22 @@ handle_haproxy_lighttpd(){
test_api(){ test_api(){
HOST_IP=$(hostname -I | cut -d" " -f1) HOST_IP=$(hostname -I | cut -d" " -f1)
status_msg "Testing API ..." status_msg "Testing API ..."
sleep 5 status_msg "Please wait ..."
status_msg "API response from http://$HOST_IP:7125/printer/info :" sleep 15
API_RESPONSE=$(curl -sG4m5 http://$HOST_IP:7125/printer/info) status_msg "API response from http://"$HOST_IP":7125/printer/info :"
echo -e "${cyan}$API_RESPONSE${default}" echo -e "${cyan}$(curl -s "http://"$HOST_IP":7125/printer/info")${default}"
if [ $(curl -sG4 "http://$HOST_IP:7125/printer/info" | grep '^{"result"' -c) -eq 1 ]; then if [ $(curl -s "http://"$HOST_IP":7125/printer/info" | grep '^{"result"' -c) -eq 1 ]; then
echo; ok_msg "Klipper API is working correctly!"; echo echo; ok_msg "Klipper API is working correctly!"; echo
else else
echo; warn_msg "Klipper API not working correctly!"; echo echo; warn_msg "Klipper API not working correctly!"; echo
fi fi
status_msg "Testing Nginx ..."
status_msg "Please wait ..."
status_msg "API response from http://"$HOST_IP"/printer/info :"
echo -e "${cyan}$(curl -s "http://"$HOST_IP"/printer/info")${default}"
if [ $(curl -s "http://"$HOST_IP"/printer/info" | grep '^{"result"' -c) -eq 1 ]; then
echo; ok_msg "Nginx is working correctly!"; echo
else
echo; warn_msg "Nginx is not working correctly!"; echo
fi
} }

View File

@@ -1,4 +1,7 @@
install_octoprint(){ install_octoprint(){
#check for other enabled web interfaces
unset SET_LISTEN_PORT
detect_enabled_sites
#ask user for customization #ask user for customization
get_user_selections_octoprint get_user_selections_octoprint
#octoprint main installation #octoprint main installation
@@ -9,7 +12,7 @@ install_octoprint(){
add_reboot_permission add_reboot_permission
create_config_yaml create_config_yaml
#execute customizations #execute customizations
create_reverse_proxy "octoprint" set_nginx_cfg "octoprint"
set_hostname set_hostname
#after install actions #after install actions
load_octoprint_server load_octoprint_server
@@ -20,9 +23,7 @@ get_user_selections_octoprint(){
#ask user to set a reverse proxy #ask user to set a reverse proxy
octoprint_reverse_proxy_dialog octoprint_reverse_proxy_dialog
#ask to change hostname #ask to change hostname
if [ "$SET_REVERSE_PROXY" = "true" ]; then [ "$SET_NGINX_CFG" = "true" ] && create_custom_hostname
create_custom_hostname
fi
status_msg "Installation will start now! Please wait ..." status_msg "Installation will start now! Please wait ..."
} }
@@ -113,7 +114,6 @@ add_reboot_permission(){
} }
octoprint_reverse_proxy_dialog(){ octoprint_reverse_proxy_dialog(){
unset SET_REVERSE_PROXY
echo echo
top_border top_border
echo -e "| If you want to have nicer URLs or simply need | " echo -e "| If you want to have nicer URLs or simply need | "
@@ -128,10 +128,9 @@ octoprint_reverse_proxy_dialog(){
echo -e "${default}" echo -e "${default}"
case "$yn" in case "$yn" in
Y|y|Yes|yes) Y|y|Yes|yes)
SET_REVERSE_PROXY="true" octoprint_port_check
break;; break;;
N|n|No|no|"") N|n|No|no|"")
SET_REVERSE_PROXY="false"
break;; break;;
*) *)
print_unkown_cmd print_unkown_cmd
@@ -140,6 +139,58 @@ octoprint_reverse_proxy_dialog(){
done done
} }
octoprint_port_check(){
if [ "$OCTOPRINT_ENABLED" = "false" ]; then
if [ "$SITE_ENABLED" = "true" ]; then
status_msg "Detected other enabled interfaces:"
[ "$MAINSAIL_ENABLED" = "true" ] && echo " ${cyan}● Mainsail - Port:$MAINSAIL_PORT${default}"
[ "$FLUIDD_ENABLED" = "true" ] && echo " ${cyan}● Fluidd - Port:$FLUIDD_PORT${default}"
[ "$DWC2_ENABLED" = "true" ] && echo " ${cyan}● DWC2 - Port:$DWC2_PORT${default}"
if [ "$MAINSAIL_PORT" = "80" ] || [ "$DWC2_PORT" = "80" ] || [ "$FLUIDD_PORT" = "80" ]; then
PORT_80_BLOCKED="true"
select_octoprint_port
fi
else
DEFAULT_PORT=$(grep listen ${SRCDIR}/kiauh/resources/octoprint_nginx.cfg | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
SET_LISTEN_PORT=$DEFAULT_PORT
fi
SET_NGINX_CFG="true"
else
SET_NGINX_CFG="false"
fi
}
select_octoprint_port(){
if [ "$PORT_80_BLOCKED" = "true" ]; then
echo
top_border
echo -e "| ${red}!!!WARNING!!!${default} |"
echo -e "| ${red}You need to choose a different port for OctoPrint!${default} |"
echo -e "| ${red}The following web interface is listening at port 80:${default} |"
blank_line
[ "$MAINSAIL_PORT" = "80" ] && echo "| ● Mainsail |"
[ "$FLUIDD_PORT" = "80" ] && echo "| ● Fluidd |"
[ "$DWC2_PORT" = "80" ] && echo "| ● DWC2 |"
blank_line
echo -e "| Make sure you don't choose a port which was already |"
echo -e "| assigned to one of the other web interfaces! |"
blank_line
echo -e "| Be aware: there is ${red}NO${default} sanity check for the following |"
echo -e "| input. So make sure to choose a valid port! |"
bottom_border
while true; do
read -p "${cyan}Please enter a new Port:${default} " NEW_PORT
if [ "$NEW_PORT" != "$MAINSAIL_PORT" ] && [ "$NEW_PORT" != "$FLUIDD_PORT" ] && [ "$NEW_PORT" != "$DWC2_PORT" ]; then
echo "Setting port $NEW_PORT for OctoPrint!"
SET_LISTEN_PORT=$NEW_PORT
break
else
echo "That port is already taken! Select a different one!"
fi
done
fi
}
create_config_yaml(){ create_config_yaml(){
if [ ! -d $OCTOPRINT_CFG_DIR ]; then if [ ! -d $OCTOPRINT_CFG_DIR ]; then
status_msg "Creating config.yaml ..." status_msg "Creating config.yaml ..."

View File

@@ -1,29 +1,81 @@
create_reverse_proxy(){ set_nginx_cfg(){
if [ "$SET_REVERSE_PROXY" = "true" ]; then if [ "$SET_NGINX_CFG" = "true" ]; then
#check for dependencies #check for dependencies
dep=(nginx) dep=(nginx)
dependency_check dependency_check
#execute operations #execute operations
status_msg "Creating Nginx configuration for $1 ..." status_msg "Creating Nginx configuration for $1 ..."
cat ${HOME}/kiauh/resources/$1_nginx.cfg > ${HOME}/kiauh/resources/$1 #copy content from resources to the respective nginx config file
sudo mv ${HOME}/kiauh/resources/$1 /etc/nginx/sites-available/$1 cat ${SRCDIR}/kiauh/resources/$1_nginx.cfg > ${SRCDIR}/kiauh/resources/$1
#ONLY FOR MAINSAIL: replace username if not "pi" ##edit the nginx config file before moving it
if [ "$1" = "mainsail" ]; then if [ "$SET_LISTEN_PORT" != "$DEFAULT_PORT" ]; then
sudo sed -i "/root/s/pi/${USER}/" /etc/nginx/sites-available/mainsail status_msg "Configuring port for $1 ..."
#set listen port ipv4
sed -i "s/listen\s[0-9]*;/listen $SET_LISTEN_PORT;/" ${SRCDIR}/kiauh/resources/$1
#set listen port ipv6
sed -i "s/listen\s\[\:*\]\:[0-9]*;/listen \[::\]\:$SET_LISTEN_PORT;/" ${SRCDIR}/kiauh/resources/$1
fi fi
#set correct user
if [ "$1" = "mainsail" ] || [ "$1" = "fluidd" ]; then
sudo sed -i "/root/s/pi/${USER}/" ${SRCDIR}/kiauh/resources/$1
fi
#moving the config file into correct directory
sudo mv ${SRCDIR}/kiauh/resources/$1 /etc/nginx/sites-available/$1
ok_msg "Nginx configuration for $1 was set!" ok_msg "Nginx configuration for $1 was set!"
#remove default config if [ "$SET_LISTEN_PORT" != "" ]; then
if [ -e /etc/nginx/sites-enabled/default ]; then ok_msg "$1 listening on port $SET_LISTEN_PORT!"
sudo rm /etc/nginx/sites-enabled/default else
fi ok_msg "$1 listening on def-port $DEFAULT_PORT!"
#create symlink for own configs
if [ ! -e /etc/nginx/sites-enabled/$1 ]; then
sudo ln -s /etc/nginx/sites-available/$1 /etc/nginx/sites-enabled/
fi fi
#remove nginx default config
[ -e /etc/nginx/sites-enabled/default ] && sudo rm /etc/nginx/sites-enabled/default
#create symlink for own sites
[ ! -e /etc/nginx/sites-enabled/$1 ] && sudo ln -s /etc/nginx/sites-available/$1 /etc/nginx/sites-enabled/
restart_nginx restart_nginx
fi fi
} }
read_listen_port(){
LISTEN_PORT=$(grep listen /etc/nginx/sites-enabled/$1 | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
}
detect_enabled_sites(){
#check if there is another UI config already installed
#and reads the port they are listening on
if [ -e /etc/nginx/sites-enabled/mainsail ]; then
SITE_ENABLED="true" && MAINSAIL_ENABLED="true"
read_listen_port "mainsail"
MAINSAIL_PORT=$LISTEN_PORT
#echo "debug: Mainsail listens on port: $MAINSAIL_PORT"
else
MAINSAIL_ENABLED="false"
fi
if [ -e /etc/nginx/sites-enabled/fluidd ]; then
SITE_ENABLED="true" && FLUIDD_ENABLED="true"
read_listen_port "fluidd"
FLUIDD_PORT=$LISTEN_PORT
#echo "debug: Fluidd listens on port: $FLUIDD_PORT"
else
FLUIDD_ENABLED="false"
fi
if [ -e /etc/nginx/sites-enabled/dwc2 ]; then
SITE_ENABLED="true" && DWC2_ENABLED="true"
read_listen_port "dwc2"
DWC2_PORT=$LISTEN_PORT
#echo "debug: DWC2 listens on port: $DWC2_PORT"
else
DWC2_ENABLED="false"
fi
if [ -e /etc/nginx/sites-enabled/octoprint ]; then
SITE_ENABLED="true" && OCTOPRINT_ENABLED="true"
read_listen_port "octoprint"
OCTOPRINT_PORT=$LISTEN_PORT
#echo "debug: OctoPrint listens on port: $OCTOPRINT_PORT"
else
OCTOPRINT_ENABLED="false"
fi
}
create_custom_hostname(){ create_custom_hostname(){
echo echo
top_border top_border

View File

@@ -38,6 +38,8 @@ remove_dwc2(){
$DWC2FK_DIR $DWC2FK_DIR
$DWC_ENV_DIR $DWC_ENV_DIR
$DWC2_DIR $DWC2_DIR
/etc/nginx/sites-available/dwc2
/etc/nginx/sites-enabled/dwc2
) )
print_error "DWC2-for-Klipper-Socket &\n DWC2 Web UI" && data_count=() print_error "DWC2-for-Klipper-Socket &\n DWC2 Web UI" && data_count=()
if [ "$ERROR_MSG" = "" ]; then if [ "$ERROR_MSG" = "" ]; then
@@ -73,6 +75,16 @@ remove_dwc2(){
status_msg "Removing DWC2 directory ..." status_msg "Removing DWC2 directory ..."
rm -rf $DWC2_DIR && ok_msg "Directory removed!" rm -rf $DWC2_DIR && ok_msg "Directory removed!"
fi fi
#remove dwc2 config for nginx
if [ -e /etc/nginx/sites-available/dwc2 ]; then
status_msg "Removing DWC2 configuration for Nginx ..."
sudo rm /etc/nginx/sites-available/dwc2 && ok_msg "File removed!"
fi
#remove dwc2 symlink for nginx
if [ -L /etc/nginx/sites-enabled/dwc2 ]; then
status_msg "Removing DWC2 Symlink for Nginx ..."
sudo rm /etc/nginx/sites-enabled/dwc2 && ok_msg "File removed!"
fi
CONFIRM_MSG=" DWC2-for-Klipper-Socket & DWC2 successfully removed!" CONFIRM_MSG=" DWC2-for-Klipper-Socket & DWC2 successfully removed!"
fi fi
} }
@@ -86,6 +98,8 @@ remove_moonraker(){
$MOONRAKER_SERVICE2 $MOONRAKER_SERVICE2
$MOONRAKER_DIR $MOONRAKER_DIR
$MOONRAKER_ENV_DIR $MOONRAKER_ENV_DIR
$NGINX_CONFD/upstreams.conf
$NGINX_CONFD/common_vars.conf
${HOME}/moonraker.conf ${HOME}/moonraker.conf
${HOME}/moonraker.log ${HOME}/moonraker.log
${HOME}/klipper_config/moonraker.log ${HOME}/klipper_config/moonraker.log
@@ -139,6 +153,11 @@ remove_moonraker(){
rm -rf ${HOME}/moonraker.log ${HOME}/klipper_config/moonraker.log ${HOME}/klipper_config/klippy.log /tmp/moonraker.log rm -rf ${HOME}/moonraker.log ${HOME}/klipper_config/moonraker.log ${HOME}/klipper_config/klippy.log /tmp/moonraker.log
ok_msg "Files removed!" ok_msg "Files removed!"
fi fi
#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 #remove legacy api key
if [ -e ${HOME}/.klippy_api_key ]; then if [ -e ${HOME}/.klippy_api_key ]; then
status_msg "Removing legacy API Key ..." status_msg "Removing legacy API Key ..."
@@ -183,6 +202,33 @@ remove_mainsail(){
fi fi
} }
remove_fluidd(){
data_arr=(
$fluidd_DIR
/etc/nginx/sites-available/fluidd
/etc/nginx/sites-enabled/fluidd
)
print_error "Fluidd" && data_count=()
if [ "$ERROR_MSG" = "" ]; then
#remove fluidd dir
if [ -d $FLUIDD_DIR ]; then
status_msg "Removing Fluidd directory ..."
rm -rf $FLUIDD_DIR && ok_msg "Directory removed!"
fi
#remove fluidd config for nginx
if [ -e /etc/nginx/sites-available/fluidd ]; then
status_msg "Removing Fluidd configuration for Nginx ..."
sudo rm /etc/nginx/sites-available/fluidd && ok_msg "File removed!"
fi
#remove fluidd symlink for nginx
if [ -L /etc/nginx/sites-enabled/fluidd ]; then
status_msg "Removing Fluidd Symlink for Nginx ..."
sudo rm /etc/nginx/sites-enabled/fluidd && ok_msg "File removed!"
fi
CONFIRM_MSG="Fluidd successfully removed!"
fi
}
############################################################# #############################################################
############################################################# #############################################################
@@ -216,6 +262,16 @@ remove_octoprint(){
status_msg "Removing octoprint.log Symlink ..." status_msg "Removing octoprint.log Symlink ..."
rm -rf ${HOME}/octoprint.log && ok_msg "Symlink removed!" rm -rf ${HOME}/octoprint.log && ok_msg "Symlink removed!"
fi fi
#remove octoprint config for nginx
if [ -e /etc/nginx/sites-available/octoprint ]; then
status_msg "Removing OctoPrint configuration for Nginx ..."
sudo rm /etc/nginx/sites-available/octoprint && ok_msg "File removed!"
fi
#remove octoprint symlink for nginx
if [ -L /etc/nginx/sites-enabled/octoprint ]; then
status_msg "Removing OctoPrint Symlink for Nginx ..."
sudo rm /etc/nginx/sites-enabled/octoprint && ok_msg "File removed!"
fi
CONFIRM_MSG=" OctoPrint successfully removed!" CONFIRM_MSG=" OctoPrint successfully removed!"
fi fi
} }

View File

@@ -57,15 +57,38 @@ dwc2_status(){
fi fi
} }
moonraker_status(){
mrcount=0
moonraker_data=(
$MOONRAKER_SERVICE1
$MOONRAKER_SERVICE2
$MOONRAKER_DIR
$MOONRAKER_ENV_DIR
$NGINX_CONFD/upstreams.conf
$NGINX_CONFD/common_vars.conf
)
#count+1 for each found data-item from array
for mrd in "${moonraker_data[@]}"
do
if [ -e $mrd ]; then
mrcount=$(expr $mrcount + 1)
fi
done
if [ "$mrcount" == "${#moonraker_data[*]}" ]; then
MOONRAKER_STATUS="${green}Installed!${default} "
elif [ "$mrcount" == 0 ]; then
MOONRAKER_STATUS="${red}Not installed!${default} "
else
MOONRAKER_STATUS="${yellow}Incomplete!${default} "
fi
}
mainsail_status(){ mainsail_status(){
mcount=0 mcount=0
mainsail_data=( mainsail_data=(
$MOONRAKER_SERVICE1
$MOONRAKER_SERVICE2
$MAINSAIL_DIR $MAINSAIL_DIR
$MOONRAKER_ENV_DIR $NGINX_SA/mainsail
/etc/nginx/sites-available/mainsail $NGINX_SE/mainsail
/etc/nginx/sites-enabled/mainsail
) )
#count+1 for each found data-item from array #count+1 for each found data-item from array
for md in "${mainsail_data[@]}" for md in "${mainsail_data[@]}"
@@ -83,6 +106,29 @@ mainsail_status(){
fi fi
} }
fluidd_status(){
fcount=0
fluidd_data=(
$FLUIDD_DIR
$NGINX_SA/fluidd
$NGINX_SE/fluidd
)
#count+1 for each found data-item from array
for fd in "${fluidd_data[@]}"
do
if [ -e $fd ]; then
fcount=$(expr $fcount + 1)
fi
done
if [ "$fcount" == "${#fluidd_data[*]}" ]; then
FLUIDD_STATUS="${green}Installed!${default} "
elif [ "$fcount" == 0 ]; then
FLUIDD_STATUS="${red}Not installed!${default} "
else
FLUIDD_STATUS="${yellow}Incomplete!${default} "
fi
}
octoprint_status(){ octoprint_status(){
ocount=0 ocount=0
octoprint_data=( octoprint_data=(
@@ -258,6 +304,35 @@ compare_dwc2_versions(){
############################################################# #############################################################
############################################################# #############################################################
read_moonraker_versions(){
if [ -d $MOONRAKER_DIR ] && [ -d $MOONRAKER_DIR/.git ]; then
cd $MOONRAKER_DIR
git fetch origin master -q
LOCAL_MOONRAKER_COMMIT=$(git rev-parse --short=8 HEAD)
REMOTE_MOONRAKER_COMMIT=$(git rev-parse --short=8 origin/master)
else
LOCAL_MOONRAKER_COMMIT="${red}--------${default}"
REMOTE_MOONRAKER_COMMIT="${red}--------${default}"
fi
}
compare_moonraker_versions(){
unset MOONRAKER_UPDATE_AVAIL
read_moonraker_versions
#echo "Local: $LOCAL_MOONRAKER_COMMIT"
#echo "Remote: $REMOTE_MOONRAKER_COMMIT"
if [ "$LOCAL_MOONRAKER_COMMIT" != "$REMOTE_MOONRAKER_COMMIT" ]; then
LOCAL_MOONRAKER_COMMIT="${yellow}$LOCAL_MOONRAKER_COMMIT${default}"
REMOTE_MOONRAKER_COMMIT="${green}$REMOTE_MOONRAKER_COMMIT${default}"
MOONRAKER_UPDATE_AVAIL="true"
update_arr+=(update_moonraker)
else
LOCAL_MOONRAKER_COMMIT="${green}$LOCAL_MOONRAKER_COMMIT${default}"
REMOTE_MOONRAKER_COMMIT="${green}$REMOTE_MOONRAKER_COMMIT${default}"
MOONRAKER_UPDATE_AVAIL="false"
fi
}
read_local_mainsail_version(){ read_local_mainsail_version(){
unset MAINSAIL_IS_INSTALLED unset MAINSAIL_IS_INSTALLED
if [ -e $MAINSAIL_DIR/version ]; then if [ -e $MAINSAIL_DIR/version ]; then
@@ -297,35 +372,48 @@ compare_mainsail_versions(){
fi fi
} }
read_moonraker_versions(){ read_local_fluidd_version(){
if [ -d $MOONRAKER_DIR ] && [ -d $MOONRAKER_DIR/.git ]; then unset FLUIDD_IS_INSTALLED
cd $MOONRAKER_DIR if [ -e $FLUIDD_DIR/version ]; then
git fetch origin master -q FLUIDD_LOCAL_VER=$(head -n 1 $FLUIDD_DIR/version)
LOCAL_MOONRAKER_COMMIT=$(git rev-parse --short=8 HEAD) FLUIDD_IS_INSTALLED="true"
REMOTE_MOONRAKER_COMMIT=$(git rev-parse --short=8 origin/master)
else else
LOCAL_MOONRAKER_COMMIT="${red}--------${default}" FLUIDD_LOCAL_VER="${red}-----${default}"
REMOTE_MOONRAKER_COMMIT="${red}--------${default}" FLUIDD_IS_INSTALLED="false"
fi fi
} }
compare_moonraker_versions(){ read_remote_fluidd_version(){
unset MOONRAKER_UPDATE_AVAIL #remote checks don't work without curl installed!
read_moonraker_versions if [[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]]; then
#echo "Local: $LOCAL_MOONRAKER_COMMIT" FLUIDD_REMOTE_VER="${red}-----${default}"
#echo "Remote: $REMOTE_MOONRAKER_COMMIT"
if [ "$LOCAL_MOONRAKER_COMMIT" != "$REMOTE_MOONRAKER_COMMIT" ]; then
LOCAL_MOONRAKER_COMMIT="${yellow}$LOCAL_MOONRAKER_COMMIT${default}"
REMOTE_MOONRAKER_COMMIT="${green}$REMOTE_MOONRAKER_COMMIT${default}"
MOONRAKER_UPDATE_AVAIL="true"
update_arr+=(update_moonraker)
else else
LOCAL_MOONRAKER_COMMIT="${green}$LOCAL_MOONRAKER_COMMIT${default}" get_fluidd_ver
REMOTE_MOONRAKER_COMMIT="${green}$REMOTE_MOONRAKER_COMMIT${default}" FLUIDD_REMOTE_VER=$FLUIDD_VERSION
MOONRAKER_UPDATE_AVAIL="false"
fi fi
} }
compare_fluidd_versions(){
unset FLUIDD_UPDATE_AVAIL
read_local_fluidd_version
read_remote_fluidd_version
#echo "Local: $FLUIDD_LOCAL_VER"
#echo "Remote: $FLUIDD_REMOTE_VER"
if [ "$FLUIDD_LOCAL_VER" != "$FLUIDD_REMOTE_VER" ] && [ "$FLUIDD_IS_INSTALLED" = "true" ]; then
FLUIDD_LOCAL_VER="${yellow}$FLUIDD_LOCAL_VER${default}"
FLUIDD_REMOTE_VER="${green}$FLUIDD_REMOTE_VER${default}"
FLUIDD_UPDATE_AVAIL="true"
update_arr+=(update_fluidd)
else
FLUIDD_LOCAL_VER="${green}$FLUIDD_LOCAL_VER${default}"
FLUIDD_REMOTE_VER="${green}$FLUIDD_REMOTE_VER${default}"
FLUIDD_UPDATE_AVAIL="false"
fi
}
#############################################################
#############################################################
ui_print_versions(){ ui_print_versions(){
unset update_arr unset update_arr
compare_klipper_versions compare_klipper_versions
@@ -333,4 +421,5 @@ ui_print_versions(){
compare_dwc2_versions compare_dwc2_versions
compare_moonraker_versions compare_moonraker_versions
compare_mainsail_versions compare_mainsail_versions
compare_fluidd_versions
} }

View File

@@ -7,6 +7,10 @@ bottom_border(){
echo -e "\=======================================================/" echo -e "\=======================================================/"
} }
blank_line(){
echo -e "| | "
}
hr(){ hr(){
echo -e "|-------------------------------------------------------|" echo -e "|-------------------------------------------------------|"
} }
@@ -29,5 +33,8 @@ kiauh_update_msg(){
top_border top_border
echo -e "| ${yellow}There is a newer version of this script available!${default} | " 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 "| ${yellow}Type 'update' if you want to update KIAUH now.${default} | "
blank_line
echo -e "| ${yellow}Check out the KIAUH changelog for important changes${default} | "
echo -e "| ${yellow}either to the script or the installable components!${default} | "
bottom_border bottom_border
} }

View File

@@ -9,8 +9,8 @@ install_ui(){
echo -e "| Firmware: | Webinterface: | " echo -e "| Firmware: | Webinterface: | "
echo -e "| 1) [Klipper] | 3) [DWC2] | " echo -e "| 1) [Klipper] | 3) [DWC2] | "
echo -e "| | 4) [Mainsail] | " echo -e "| | 4) [Mainsail] | "
echo -e "| Klipper API: | 5) [Octoprint] | " echo -e "| Klipper API: | 5) [Fluidd] | "
echo -e "| 2) [Moonraker] | | " echo -e "| 2) [Moonraker] | 6) [Octoprint] | "
quit_footer quit_footer
} }
@@ -47,6 +47,12 @@ install_menu(){
print_msg && clear_msg print_msg && clear_msg
install_ui;; install_ui;;
5) 5)
clear
print_header
INST_FLUIDD="true" && install_fluidd
print_msg && clear_msg
install_ui;;
6)
clear clear
print_header print_header
install_octoprint install_octoprint

View File

@@ -6,9 +6,12 @@ main_ui(){
echo -e "| 1) [Install] | Klipper: $KLIPPER_STATUS|" echo -e "| 1) [Install] | Klipper: $KLIPPER_STATUS|"
echo -e "| 2) [Update] | Branch: ${cyan}$PRINT_BRANCH${default}|" echo -e "| 2) [Update] | Branch: ${cyan}$PRINT_BRANCH${default}|"
echo -e "| 3) [Remove] | |" echo -e "| 3) [Remove] | |"
echo -e "| | DWC2: $DWC2_STATUS|" echo -e "| | Moonraker: $MOONRAKER_STATUS|"
echo -e "| 4) [Advanced] | Mainsail: $MAINSAIL_STATUS|" echo -e "| 4) [Advanced] | |"
echo -e "| 5) [Backup] | Octoprint: $OCTOPRINT_STATUS|" echo -e "| 5) [Backup] | DWC2: $DWC2_STATUS|"
echo -e "| | Fluidd: $FLUIDD_STATUS|"
echo -e "| | Mainsail: $MAINSAIL_STATUS|"
echo -e "| | Octoprint: $OCTOPRINT_STATUS|"
echo -e "| | |" echo -e "| | |"
quit_footer quit_footer
} }
@@ -21,7 +24,9 @@ main_menu(){
fi fi
#check install status #check install status
klipper_status klipper_status
moonraker_status
dwc2_status dwc2_status
fluidd_status
mainsail_status mainsail_status
octoprint_status octoprint_status
print_branch print_branch
@@ -32,6 +37,7 @@ main_menu(){
read -p "Perform action: " action; echo read -p "Perform action: " action; echo
echo -e "${default}" echo -e "${default}"
case "$action" in case "$action" in
8) read_listen_port;;
update) update)
clear clear
print_header print_header

View File

@@ -11,10 +11,11 @@ remove_ui(){
echo -e "| Firmware: | Webinterface: | " echo -e "| Firmware: | Webinterface: | "
echo -e "| 1) [Klipper] | 3) [DWC2] | " echo -e "| 1) [Klipper] | 3) [DWC2] | "
echo -e "| | 4) [Mainsail] | " echo -e "| | 4) [Mainsail] | "
echo -e "| Klipper API: | 5) [Octoprint] | " echo -e "| Klipper API: | 5) [Fluidd] | "
echo -e "| 2) [Moonraker] | | " echo -e "| 2) [Moonraker] | 6) [Octoprint] | "
echo -e "| | | "
echo -e "| | Webserver: | " echo -e "| | Webserver: | "
echo -e "| | 6) [Nginx] | " echo -e "| | 7) [Nginx] | "
quit_footer quit_footer
} }
@@ -53,10 +54,16 @@ remove_menu(){
5) 5)
clear clear
print_header print_header
remove_octoprint remove_fluidd
print_msg && clear_msg print_msg && clear_msg
remove_ui;; remove_ui;;
6) 6)
clear
print_header
remove_octoprint
print_msg && clear_msg
remove_ui;;
7)
clear clear
print_header print_header
remove_nginx remove_nginx

View File

@@ -21,6 +21,7 @@ update_ui(){
echo -e "| |---------------|--------------| " echo -e "| |---------------|--------------| "
echo -e "| 4) [Moonraker] | $(echo "$LOCAL_MOONRAKER_COMMIT") | $(echo "$REMOTE_MOONRAKER_COMMIT") | " echo -e "| 4) [Moonraker] | $(echo "$LOCAL_MOONRAKER_COMMIT") | $(echo "$REMOTE_MOONRAKER_COMMIT") | "
echo -e "| 5) [Mainsail] | $(echo "$MAINSAIL_LOCAL_VER") | $(echo "$MAINSAIL_REMOTE_VER") | " echo -e "| 5) [Mainsail] | $(echo "$MAINSAIL_LOCAL_VER") | $(echo "$MAINSAIL_REMOTE_VER") | "
echo -e "| 6) [Fluidd] | $(echo "$FLUIDD_LOCAL_VER") | $(echo "$FLUIDD_REMOTE_VER") | "
quit_footer quit_footer
} }