mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-12 18:14:28 +05:00
feature: initial commit to add installer for Fluidd + rewrite nginx related stuff
This commit is contained in:
19
kiauh.sh
19
kiauh.sh
@@ -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
|
||||||
|
|||||||
6
resources/common_vars_nginx.cfg
Normal file
6
resources/common_vars_nginx.cfg
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# /etc/nginx/conf.d/common_vars.conf
|
||||||
|
|
||||||
|
map $http_upgrade $connection_upgrade {
|
||||||
|
default upgrade;
|
||||||
|
'' close;
|
||||||
|
}
|
||||||
77
resources/fluidd_nginx.cfg
Normal file
77
resources/fluidd_nginx.cfg
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
# /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;
|
||||||
|
|
||||||
|
#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/;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
13
resources/moonraker_nginx.cfg
Normal file
13
resources/moonraker_nginx.cfg
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# /etc/nginx/conf.d/upstreams.conf
|
||||||
|
|
||||||
|
upstream apiserver {
|
||||||
|
#edit your api port here
|
||||||
|
ip_hash;
|
||||||
|
server 127.0.0.1:7125;
|
||||||
|
}
|
||||||
|
|
||||||
|
upstream mjpgstreamer {
|
||||||
|
#edit your webcam port here
|
||||||
|
ip_hash;
|
||||||
|
server 127.0.0.1:8081;
|
||||||
|
}
|
||||||
@@ -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
|
||||||
@@ -191,7 +191,7 @@ download_dwc2_webui(){
|
|||||||
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 -O $GET_DWC2_URL
|
||||||
ok_msg "Download complete!"
|
ok_msg "Download complete!"
|
||||||
status_msg "Unzipping archive ..."
|
status_msg "Unzipping archive ..."
|
||||||
unzip -q -o *.zip
|
unzip -q -o *.zip
|
||||||
@@ -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,14 +305,53 @@ 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
|
||||||
print_msg && clear_msg;;
|
print_msg && clear_msg;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
dwc2_port_check(){
|
||||||
|
if [ "$DWC2_ENABLED" = "false" ]; then
|
||||||
|
if [ "$SITE_ENABLED" = "true" ]; then
|
||||||
|
echo "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"
|
||||||
|
fi
|
||||||
|
if [ "$PORT_80_BLOCKED" = "true" ]; then
|
||||||
|
[ "$OCTOPRINT_PORT" = "80" ] && echo "${cyan}OctoPrint${default} already listens on Port 80!"
|
||||||
|
[ "$MAINSAIL_PORT" = "80" ] && echo "${cyan}Mainsail${default} already listens on Port 80!"
|
||||||
|
[ "$FLUIDD_PORT" = "80" ] && echo "${cyan}Fluidd${default} already listens on Port 80!"
|
||||||
|
echo "You need to choose a different Port for DWC2 than the above!"
|
||||||
|
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(){
|
||||||
|
while true; do
|
||||||
|
read -p "${cyan}Please enter a new Port:${default} " NEW_PORT
|
||||||
|
if [ "$NEW_PORT" != "$MAINSAIL_PORT" ] && [ "$NEW_PORT" != "$OCTOPRINT_PORT" ] && [ "$NEW_PORT" != "$FLUIDD_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
|
||||||
}
|
}
|
||||||
75
scripts/install_fluidd.sh
Executable file
75
scripts/install_fluidd.sh
Executable file
@@ -0,0 +1,75 @@
|
|||||||
|
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
|
||||||
|
echo "Detected other enabled Interfaces:"
|
||||||
|
[ "$MAINSAIL_ENABLED" = "true" ] && echo "${cyan}● Mainsail - Port:$MAINSAIL_PORT${default}"
|
||||||
|
[ "$DWC2_ENABLED" = "true" ] && echo "${cyan}● DWC2 - Port:$DWC2_PORT${default}"
|
||||||
|
[ "$OCTOPRINT_ENABLED" = "true" ] && echo "${cyan}● OctoPrint - Port:$OCTOPRINT_PORT${default}"
|
||||||
|
if [ "$MAINSAIL_PORT" = "80" ] || [ "$DWC2_PORT" = "80" ] || [ "$OCTOPRINT_PORT" = "80" ]; then
|
||||||
|
PORT_80_BLOCKED="true"
|
||||||
|
fi
|
||||||
|
if [ "$PORT_80_BLOCKED" = "true" ]; then
|
||||||
|
[ "$MAINSAIL_PORT" = "80" ] && echo "${cyan}Mainsail${default} already listens on Port 80!"
|
||||||
|
[ "$DWC2_PORT" = "80" ] && echo "${cyan}DWC2${default} already listens on Port 80!"
|
||||||
|
[ "$OCTOPRINT_PORT" = "80" ] && echo "${cyan}OctoPrint${default} already listens on Port 80!"
|
||||||
|
echo "You need to choose a different Port for Fluidd than the above!"
|
||||||
|
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(){
|
||||||
|
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 Mainsail!"
|
||||||
|
SET_LISTEN_PORT=$NEW_PORT
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "That port is already taken! Select a different one!"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
@@ -1,47 +1,73 @@
|
|||||||
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
|
echo "Detected other enabled Interfaces:"
|
||||||
status_msg "API response from http://$HOST_IP/printer/info :"
|
[ "$FLUIDD_ENABLED" = "true" ] && echo "${cyan}● Fluidd - Port:$FLUIDD_PORT${default}"
|
||||||
API_RESPONSE="$(curl -sG4m5 http://$HOST_IP/printer/info)"
|
[ "$DWC2_ENABLED" = "true" ] && echo "${cyan}● DWC2 - Port:$DWC2_PORT${default}"
|
||||||
echo -e "${cyan}$API_RESPONSE${default}"
|
[ "$OCTOPRINT_ENABLED" = "true" ] && echo "${cyan}● OctoPrint - Port:$OCTOPRINT_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"
|
||||||
|
fi
|
||||||
|
if [ "$PORT_80_BLOCKED" = "true" ]; then
|
||||||
|
[ "$FLUIDD_PORT" = "80" ] && echo "${cyan}Fluidd${default} already listens on Port 80!"
|
||||||
|
[ "$DWC2_PORT" = "80" ] && echo "${cyan}DWC2${default} already listens on Port 80!"
|
||||||
|
[ "$OCTOPRINT_PORT" = "80" ] && echo "${cyan}OctoPrint${default} already listens on Port 80!"
|
||||||
|
echo "You need to choose a different Port for Mainsail than the above!"
|
||||||
|
select_mainsail_port
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
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
|
else
|
||||||
echo; warn_msg "Nginx is not working correctly!"; echo
|
SET_NGINX_CFG="false"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
select_mainsail_port(){
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
get_mainsail_ver(){
|
get_mainsail_ver(){
|
||||||
MAINSAIL_VERSION=$(curl -s https://api.github.com/repositories/240875926/tags | grep name | cut -d'"' -f4 | cut -d"v" -f2 | head -1)
|
MAINSAIL_VERSION=$(curl -s https://api.github.com/repositories/240875926/tags | grep name | cut -d'"' -f4 | cut -d"v" -f2 | head -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
|
||||||
#############################################################
|
#############################################################
|
||||||
#############################################################
|
#############################################################
|
||||||
|
|
||||||
@@ -661,3 +681,17 @@ test_api(){
|
|||||||
echo; warn_msg "Klipper API not working correctly!"; echo
|
echo; warn_msg "Klipper API not working correctly!"; echo
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#test_nginx(){
|
||||||
|
# HOST_IP=$(hostname -I | cut -d" " -f1)
|
||||||
|
# status_msg "Testing Nginx ..."
|
||||||
|
# sleep 5
|
||||||
|
# status_msg "API response from http://$HOST_IP/printer/info :"
|
||||||
|
# API_RESPONSE="$(curl -sG4m5 http://$HOST_IP/printer/info)"
|
||||||
|
# echo -e "${cyan}$API_RESPONSE${default}"
|
||||||
|
# if [ $(curl -sG4 "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
|
||||||
|
#}
|
||||||
@@ -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,46 @@ octoprint_reverse_proxy_dialog(){
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
octoprint_port_check(){
|
||||||
|
if [ "$OCTOPRINT_ENABLED" = "false" ]; then
|
||||||
|
if [ "$SITE_ENABLED" = "true" ]; then
|
||||||
|
echo "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"
|
||||||
|
fi
|
||||||
|
if [ "$PORT_80_BLOCKED" = "true" ]; then
|
||||||
|
[ "$MAINSAIL_PORT" = "80" ] && echo "${cyan}Mainsail${default} already listens on Port 80!"
|
||||||
|
[ "$FLUIDD_PORT" = "80" ] && echo "${cyan}Fluidd${default} already listens on Port 80!"
|
||||||
|
[ "$DWC2_PORT" = "80" ] && echo "${cyan}DWC2${default} already listens on Port 80!"
|
||||||
|
echo "You need to choose a different Port for OctoPrint than the above!"
|
||||||
|
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(){
|
||||||
|
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" != "$FLUIDD_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
|
||||||
|
}
|
||||||
|
|
||||||
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 ..."
|
||||||
|
|||||||
@@ -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 ..."
|
||||||
fi
|
#set listen port ipv4
|
||||||
|
sed -i "s/listen\s[0-9]*;/listen $SET_LISTEN_PORT;/" ${SRCDIR}/kiauh/resources/$1
|
||||||
|
#set listen port ipv6
|
||||||
|
sed -i "s/listen\s\[\:*\]\:[0-9]*;/listen \[::\]\:$SET_LISTEN_PORT;/" ${SRCDIR}/kiauh/resources/$1
|
||||||
|
fi
|
||||||
|
#set correct user
|
||||||
|
if [ "$1" = "mainsail" ] || [ "$1" = "fluidd" ]; then
|
||||||
|
sudo sed -i "/root/s/pi/${USER}/" ${SRCDIR}/kiauh/resources/$1
|
||||||
|
fi
|
||||||
|
#moving the config file into correct directory
|
||||||
|
sudo mv ${SRCDIR}/kiauh/resources/$1 /etc/nginx/sites-available/$1
|
||||||
ok_msg "Nginx configuration for $1 was set!"
|
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
|
||||||
@@ -86,6 +86,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 +141,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 +190,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
|
||||||
|
}
|
||||||
|
|
||||||
#############################################################
|
#############################################################
|
||||||
#############################################################
|
#############################################################
|
||||||
|
|
||||||
|
|||||||
@@ -258,6 +258,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 +326,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 +375,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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ bottom_border(){
|
|||||||
echo -e "\=======================================================/"
|
echo -e "\=======================================================/"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blank_line(){
|
||||||
|
echo -e "| | "
|
||||||
|
}
|
||||||
|
|
||||||
hr(){
|
hr(){
|
||||||
echo -e "|-------------------------------------------------------|"
|
echo -e "|-------------------------------------------------------|"
|
||||||
}
|
}
|
||||||
@@ -29,7 +33,7 @@ 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} | "
|
||||||
echo -e "| | "
|
blank_line
|
||||||
echo -e "| ${yellow}Check out the KIAUH changelog for important changes${default} | "
|
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}either to the script or the installable components!${default} | "
|
||||||
bottom_border
|
bottom_border
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -32,6 +32,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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user