refactor: remove octoprint port check

kiauh does not support setting up nginx configs for octoprint anyways. saving and comparing a non existing port is useless code

Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
th33xitus
2022-05-22 17:42:10 +02:00
parent dc133053b3
commit 55a86c086e
5 changed files with 7 additions and 63 deletions

View File

@@ -1,40 +0,0 @@
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream octoprint {
server 127.0.0.1:5000;
}
upstream mjpg-streamer {
server 127.0.0.1:8080;
}
server {
listen 80;
#listen [::]:80;
location / {
proxy_pass http://octoprint/;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
#proxy_set_header X-Script-Name /;
proxy_http_version 1.1;
client_max_body_size 0;
}
location /webcam {
proxy_pass http://mjpg-streamer/;
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

View File

@@ -344,13 +344,10 @@ function fluidd_port_check() {
if [[ ${SITE_ENABLED} == "true" ]]; then
status_msg "Detected other enabled interfaces:"
[[ ${OCTOPRINT_ENABLED} == "true" ]] && \
echo " ${cyan}● OctoPrint - Port: ${OCTOPRINT_PORT}${white}"
[[ ${MAINSAIL_ENABLED} == "true" ]] && \
echo " ${cyan}● Mainsail - Port: ${MAINSAIL_PORT}${white}"
if [[ ${MAINSAIL_PORT} == "80" ]] || [[ ${OCTOPRINT_PORT} == "80" ]]; then
if [[ ${MAINSAIL_PORT} == "80" ]]; then
PORT_80_BLOCKED="true"
select_fluidd_port
fi
@@ -373,11 +370,10 @@ function select_fluidd_port() {
echo -e "| ${red}You need to choose a different port for Fluidd!${white} |"
echo -e "| ${red}The following web interface is listening at port 80:${white} |"
blank_line
[[ ${OCTOPRINT_PORT} == "80" ]] && echo "| ● OctoPrint |"
[[ ${MAINSAIL_PORT} == "80" ]] && echo "| ● Mainsail |"
blank_line
echo -e "| Make sure you don't choose a port which is already |"
echo -e "| assigned to one of the other webinterfaces |"
echo -e "| assigned to another webinterface! |"
blank_line
echo -e "| Be aware: there is ${red}NO${white} sanity check for the following |"
echo -e "| input. So make sure to choose a valid port! |"
@@ -386,7 +382,7 @@ function select_fluidd_port() {
local new_port re="^[0-9]+$"
while true; do
read -p "${cyan}Please enter a new Port:${white} " new_port
if [[ ${new_port} =~ ${re} && ${new_port} != "${MAINSAIL_PORT}" && ${new_port} != "${OCTOPRINT_PORT}" ]]; then
if [[ ${new_port} =~ ${re} && ${new_port} != "${MAINSAIL_PORT}" ]]; then
select_msg "Setting port ${new_port} for Fluidd!"
SET_LISTEN_PORT=${new_port}
break

View File

@@ -465,13 +465,10 @@ function mainsail_port_check() {
if [[ ${SITE_ENABLED} == "true" ]]; then
status_msg "Detected other enabled interfaces:"
[[ ${OCTOPRINT_ENABLED} == "true" ]] && \
echo -e " ${cyan}● OctoPrint - Port: ${OCTOPRINT_PORT}${white}"
[[ ${FLUIDD_ENABLED} == "true" ]] && \
echo -e " ${cyan}● Fluidd - Port: ${FLUIDD_PORT}${white}"
if [[ ${FLUIDD_PORT} == "80" ]] || [[ ${OCTOPRINT_PORT} == "80" ]]; then
if [[ ${FLUIDD_PORT} == "80" ]]; then
PORT_80_BLOCKED="true"
select_mainsail_port
fi
@@ -494,12 +491,10 @@ function select_mainsail_port() {
echo -e "| ${red}You need to choose a different port for Mainsail!${white} |"
echo -e "| ${red}The following web interface is listening at port 80:${white} |"
blank_line
[[ ${OCTOPRINT_PORT} == "80" ]] && echo "| ● OctoPrint |"
[[ ${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 webinterfaces and do ${red}NOT${white} |"
echo -e "| use ports in the range of 4750 or above! |"
echo -e "| assigned to another webinterface! |"
blank_line
echo -e "| Be aware: there is ${red}NO${white} sanity check for the following |"
echo -e "| input. So make sure to choose a valid port! |"
@@ -508,7 +503,7 @@ function select_mainsail_port() {
local new_port re="^[0-9]+$"
while true; do
read -p "${cyan}Please enter a new Port:${white} " new_port
if [[ ${new_port} =~ ${re} && ${new_port} != "${FLUIDD_PORT}" && ${new_port} != "${OCTOPRINT_PORT}" ]]; then
if [[ ${new_port} =~ ${re} && ${new_port} != "${FLUIDD_PORT}" ]]; then
select_msg "Setting port ${new_port} for Mainsail!"
SET_LISTEN_PORT=${new_port}
break

View File

@@ -291,7 +291,7 @@ function read_listen_port() {
}
function detect_enabled_sites() {
MAINSAIL_ENABLED="false" FLUIDD_ENABLED="false" OCTOPRINT_ENABLED="false"
MAINSAIL_ENABLED="false" FLUIDD_ENABLED="false"
#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"
@@ -302,8 +302,4 @@ function detect_enabled_sites() {
FLUIDD_PORT=$(read_listen_port "fluidd")
fi
if [[ -e "/etc/nginx/sites-enabled/octoprint" ]]; then
SITE_ENABLED="true" && OCTOPRINT_ENABLED="true"
OCTOPRINT_PORT=$(read_listen_port "octoprint")
fi
}

View File

@@ -374,9 +374,6 @@ function remove_octoprint() {
remove_octoprint_env
remove_octoprint_dir
### remove octoprint_port from ~/.kiauh.ini
sed -i "/^octoprint_port=/d" "${INI_FILE}"
local confirm="OctoPrint was successfully removed!"
print_confirm "${confirm}" && return