mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-14 11:04:29 +05:00
fix: tweak moonraker/mainsail install process
This commit is contained in:
@@ -16,6 +16,17 @@ backup_printer_cfg(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
backup_moonraker_conf(){
|
||||||
|
check_for_backup_dir
|
||||||
|
if [ -f ${HOME}/moonraker.conf ]; then
|
||||||
|
get_date
|
||||||
|
status_msg "Create backup of moonraker.conf ..."
|
||||||
|
cp ${HOME}/moonraker.conf $BACKUP_DIR/moonraker.conf."$current_date".backup && ok_msg "Backup complete!"
|
||||||
|
else
|
||||||
|
ok_msg "No moonraker.conf found! Skipping backup ..."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
read_bb4u_stat(){
|
read_bb4u_stat(){
|
||||||
source_ini
|
source_ini
|
||||||
if [ ! "$backup_before_update" = "true" ]; then
|
if [ ! "$backup_before_update" = "true" ]; then
|
||||||
|
|||||||
@@ -9,12 +9,13 @@ install_mainsail(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_nginx(){
|
test_nginx(){
|
||||||
|
HOST_IP=$(hostname -I | cut -d" " -f1)
|
||||||
status_msg "Testing Nginx ..."
|
status_msg "Testing Nginx ..."
|
||||||
sleep 5
|
sleep 5
|
||||||
status_msg "API response from http://localhost/printer/info :"
|
status_msg "API response from http://$HOST_IP/printer/info :"
|
||||||
API_RESPONSE="$(curl -sG4m5 http://localhost/printer/info)"
|
API_RESPONSE="$(curl -sG4m5 http://$HOST_IP/printer/info)"
|
||||||
echo -e "${cyan}$API_RESPONSE${default}"
|
echo -e "${cyan}$API_RESPONSE${default}"
|
||||||
if [ $(curl -sG4 "http://localhost/printer/info" | grep '^{"result"' -c) -eq 1 ]; then
|
if [ $(curl -sG4 "http://$HOST_IP/printer/info" | grep '^{"result"' -c) -eq 1 ]; then
|
||||||
echo; ok_msg "Nginx is working correctly!"; echo
|
echo; ok_msg "Nginx is working correctly!"; echo
|
||||||
else
|
else
|
||||||
echo; warn_msg "Nginx is not working correctly!"; echo
|
echo; warn_msg "Nginx is not working correctly!"; echo
|
||||||
|
|||||||
@@ -432,19 +432,21 @@ setup_moonraker_conf(){
|
|||||||
cp ${HOME}/kiauh/resources/moonraker.conf ${HOME}
|
cp ${HOME}/kiauh/resources/moonraker.conf ${HOME}
|
||||||
ok_msg "moonraker.conf created!"
|
ok_msg "moonraker.conf created!"
|
||||||
status_msg "Writing trusted clients to config ..."
|
status_msg "Writing trusted clients to config ..."
|
||||||
write_default_trusted_clients
|
write_default_trusted_client
|
||||||
ok_msg "Trusted clients written!"
|
ok_msg "Trusted clients written!"
|
||||||
fi
|
fi
|
||||||
#check for at least one trusted client in an already existing moonraker.conf
|
#check for at least one trusted client in an already existing moonraker.conf
|
||||||
#in no entry is found, write default trusted client
|
#in no entry is found, write default trusted client
|
||||||
if [ "$MOONRAKER_CONF_FOUND" = "true" ]; then
|
if [ "$MOONRAKER_CONF_FOUND" = "true" ]; then
|
||||||
|
backup_moonraker_conf
|
||||||
if grep "trusted_clients:" ${HOME}/moonraker.conf -q; then
|
if grep "trusted_clients:" ${HOME}/moonraker.conf -q; then
|
||||||
TC_LINE=$(grep -n "trusted_clients:" ${HOME}/moonraker.conf | cut -d ":" -f1)
|
TC_LINE=$(grep -n "trusted_clients:" ${HOME}/moonraker.conf | cut -d ":" -f1)
|
||||||
FIRST_IP_LINE=$(expr $TC_LINE + 1)
|
FIRST_IP_LINE=$(expr $TC_LINE + 1)
|
||||||
FIRST_IP=$(sed -n 2p ${HOME}/moonraker.conf | cut -d" " -f5)
|
FIRST_IP=$(sed -n "$FIRST_IP_LINE"p ${HOME}/moonraker.conf | cut -d" " -f5)
|
||||||
if [[ ! $FIRST_IP =~ ([0-9].[0-9].[0-9].[0-9]) ]]; then
|
#if [[ ! $FIRST_IP =~ ([0-9].[0-9].[0-9].[0-9]) ]]; then
|
||||||
|
if [ "$FIRST_IP" = "" ]; then
|
||||||
status_msg "Writing trusted clients to config ..."
|
status_msg "Writing trusted clients to config ..."
|
||||||
write_default_trusted_clients
|
write_default_trusted_client
|
||||||
ok_msg "Trusted clients written!"
|
ok_msg "Trusted clients written!"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -474,17 +476,13 @@ path: ~/sdcard
|
|||||||
DEFAULT_CFG
|
DEFAULT_CFG
|
||||||
}
|
}
|
||||||
|
|
||||||
write_default_trusted_clients(){
|
write_default_trusted_client(){
|
||||||
DEFAULT_IP=$(hostname -I)
|
DEFAULT_IP=$(hostname -I | cut -d" " -f1)
|
||||||
status_msg "Your devices current IP adress is:\n${cyan}● $DEFAULT_IP ${default}"
|
status_msg "Your devices current IP adress is:\n${cyan}● $DEFAULT_IP ${default}"
|
||||||
#make IP of the device KIAUH is exectuted on as
|
#make IP of the device KIAUH is exectuted on as default trusted client
|
||||||
#default trusted client and expand the IP range from 0 - 255
|
status_msg "Writing the following IP to moonraker.conf:\n${cyan}● $DEFAULT_IP ${default}"
|
||||||
DEFAULT_IP_RANGE="$(echo "$DEFAULT_IP" | cut -d"." -f1-3).0/24"
|
sed -i "/trusted_clients\:/a \ \ \ \ $DEFAULT_IP" ${HOME}/moonraker.conf
|
||||||
status_msg "Writing the following IP range to moonraker.conf:\n${cyan}● $DEFAULT_IP_RANGE ${default}"
|
ok_msg "IP ● $DEFAULT_IP written to moonraker.conf!"
|
||||||
#write the ip range in the first line below "trusted clients"
|
|
||||||
#example: 192.168.1.0/24
|
|
||||||
sed -i "/trusted_clients\:/a \ \ \ \ $DEFAULT_IP_RANGE" ${HOME}/moonraker.conf
|
|
||||||
ok_msg "IP range of ● $DEFAULT_IP_RANGE written to moonraker.conf!"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#############################################################
|
#############################################################
|
||||||
@@ -587,6 +585,7 @@ handle_haproxy_lighttpd(){
|
|||||||
status_msg "Stopping haproxy service ..."
|
status_msg "Stopping haproxy service ..."
|
||||||
sudo /etc/init.d/haproxy stop && ok_msg "Service stopped!"
|
sudo /etc/init.d/haproxy stop && ok_msg "Service stopped!"
|
||||||
fi
|
fi
|
||||||
|
status_msg "Removing haproxy ..."
|
||||||
sudo apt-get remove haproxy -y
|
sudo apt-get remove haproxy -y
|
||||||
sudo update-rc.d -f haproxy remove
|
sudo update-rc.d -f haproxy remove
|
||||||
ok_msg "Haproxy removed!"
|
ok_msg "Haproxy removed!"
|
||||||
@@ -606,6 +605,7 @@ handle_haproxy_lighttpd(){
|
|||||||
status_msg "Stopping lighttpd service ..."
|
status_msg "Stopping lighttpd service ..."
|
||||||
sudo /etc/init.d/lighttpd stop && ok_msg "Service stopped!"
|
sudo /etc/init.d/lighttpd stop && ok_msg "Service stopped!"
|
||||||
fi
|
fi
|
||||||
|
status_msg "Removing lighttpd ..."
|
||||||
sudo apt-get remove lighttpd -y
|
sudo apt-get remove lighttpd -y
|
||||||
sudo update-rc.d -f lighttpd remove
|
sudo update-rc.d -f lighttpd remove
|
||||||
ok_msg "Lighttpd removed!"
|
ok_msg "Lighttpd removed!"
|
||||||
@@ -617,12 +617,13 @@ handle_haproxy_lighttpd(){
|
|||||||
#############################################################
|
#############################################################
|
||||||
|
|
||||||
test_api(){
|
test_api(){
|
||||||
|
HOST_IP=$(hostname -I | cut -d" " -f1)
|
||||||
status_msg "Testing API ..."
|
status_msg "Testing API ..."
|
||||||
sleep 5
|
sleep 5
|
||||||
status_msg "API response from http://localhost:7125/printer/info :"
|
status_msg "API response from http://$HOST_IP:7125/printer/info :"
|
||||||
API_RESPONSE=$(curl -sG4m5 http://localhost:7125/printer/info)
|
API_RESPONSE=$(curl -sG4m5 http://$HOST_IP:7125/printer/info)
|
||||||
echo -e "${cyan}$API_RESPONSE${default}"
|
echo -e "${cyan}$API_RESPONSE${default}"
|
||||||
if [ $(curl -sG4 "http://localhost:7125/printer/info" | grep '^{"result"' -c) -eq 1 ]; then
|
if [ $(curl -sG4 "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
|
||||||
|
|||||||
Reference in New Issue
Block a user