diff --git a/scripts/backup.sh b/scripts/backup.sh index 2906e1c..8922194 100755 --- a/scripts/backup.sh +++ b/scripts/backup.sh @@ -16,6 +16,17 @@ backup_printer_cfg(){ 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(){ source_ini if [ ! "$backup_before_update" = "true" ]; then diff --git a/scripts/install_mainsail.sh b/scripts/install_mainsail.sh index d2b4e03..537995f 100755 --- a/scripts/install_mainsail.sh +++ b/scripts/install_mainsail.sh @@ -9,12 +9,13 @@ install_mainsail(){ } test_nginx(){ + HOST_IP=$(hostname -I | cut -d" " -f1) status_msg "Testing Nginx ..." sleep 5 - status_msg "API response from http://localhost/printer/info :" - API_RESPONSE="$(curl -sG4m5 http://localhost/printer/info)" + 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://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 else echo; warn_msg "Nginx is not working correctly!"; echo diff --git a/scripts/install_moonraker.sh b/scripts/install_moonraker.sh index 49c5ad4..a2e9662 100755 --- a/scripts/install_moonraker.sh +++ b/scripts/install_moonraker.sh @@ -438,11 +438,13 @@ setup_moonraker_conf(){ #check for at least one trusted client in an already existing moonraker.conf #in no entry is found, write default trusted client if [ "$MOONRAKER_CONF_FOUND" = "true" ]; then + backup_moonraker_conf if grep "trusted_clients:" ${HOME}/moonraker.conf -q; then TC_LINE=$(grep -n "trusted_clients:" ${HOME}/moonraker.conf | cut -d ":" -f1) FIRST_IP_LINE=$(expr $TC_LINE + 1) - FIRST_IP=$(sed -n 2p ${HOME}/moonraker.conf | cut -d" " -f5) - if [[ ! $FIRST_IP =~ ([0-9].[0-9].[0-9].[0-9]) ]]; then + 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" = "" ]; then status_msg "Writing trusted clients to config ..." write_default_trusted_clients ok_msg "Trusted clients written!" @@ -587,6 +589,7 @@ handle_haproxy_lighttpd(){ status_msg "Stopping haproxy service ..." sudo /etc/init.d/haproxy stop && ok_msg "Service stopped!" fi + status_msg "Removing haproxy ..." sudo apt-get remove haproxy -y sudo update-rc.d -f haproxy remove ok_msg "Haproxy removed!" @@ -606,6 +609,7 @@ handle_haproxy_lighttpd(){ status_msg "Stopping lighttpd service ..." sudo /etc/init.d/lighttpd stop && ok_msg "Service stopped!" fi + status_msg "Removing lighttpd ..." sudo apt-get remove lighttpd -y sudo update-rc.d -f lighttpd remove ok_msg "Lighttpd removed!" @@ -617,12 +621,13 @@ handle_haproxy_lighttpd(){ ############################################################# test_api(){ + HOST_IP=$(hostname -I | cut -d" " -f1) status_msg "Testing API ..." sleep 5 - status_msg "API response from http://localhost:7125/printer/info :" - API_RESPONSE=$(curl -sG4m5 http://localhost:7125/printer/info) + status_msg "API response from http://$HOST_IP:7125/printer/info :" + API_RESPONSE=$(curl -sG4m5 http://$HOST_IP:7125/printer/info) 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 else echo; warn_msg "Klipper API not working correctly!"; echo