From 9b7bde7da000823ff065e1e68f71e5a6cb46d93a Mon Sep 17 00:00:00 2001 From: th33xitus <> Date: Fri, 11 Sep 2020 12:20:31 +0200 Subject: [PATCH] fix: bug introduced in previous commit --- scripts/install_moonraker.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/install_moonraker.sh b/scripts/install_moonraker.sh index 3a9e8d4..a2e9662 100755 --- a/scripts/install_moonraker.sh +++ b/scripts/install_moonraker.sh @@ -432,7 +432,7 @@ setup_moonraker_conf(){ cp ${HOME}/kiauh/resources/moonraker.conf ${HOME} ok_msg "moonraker.conf created!" status_msg "Writing trusted clients to config ..." - write_default_trusted_client + write_default_trusted_clients ok_msg "Trusted clients written!" fi #check for at least one trusted client in an already existing moonraker.conf @@ -446,7 +446,7 @@ setup_moonraker_conf(){ #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_client + write_default_trusted_clients ok_msg "Trusted clients written!" fi fi @@ -476,13 +476,17 @@ path: ~/sdcard DEFAULT_CFG } -write_default_trusted_client(){ - DEFAULT_IP=$(hostname -I | cut -d" " -f1) +write_default_trusted_clients(){ + DEFAULT_IP=$(hostname -I) status_msg "Your devices current IP adress is:\n${cyan}● $DEFAULT_IP ${default}" - #make IP of the device KIAUH is exectuted on as default trusted client - status_msg "Writing the following IP to moonraker.conf:\n${cyan}● $DEFAULT_IP ${default}" - sed -i "/trusted_clients\:/a \ \ \ \ $DEFAULT_IP" ${HOME}/moonraker.conf - ok_msg "IP ● $DEFAULT_IP written to moonraker.conf!" + #make IP of the device KIAUH is exectuted on as + #default trusted client and expand the IP range from 0 - 255 + DEFAULT_IP_RANGE="$(echo "$DEFAULT_IP" | cut -d"." -f1-3).0/24" + status_msg "Writing the following IP range to moonraker.conf:\n${cyan}● $DEFAULT_IP_RANGE ${default}" + #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!" } #############################################################