From 024ef5867d0d2b10b7666b92ec8e4980ecf9c72a Mon Sep 17 00:00:00 2001 From: CJ Keeney Date: Fri, 19 Jul 2024 16:05:15 -0700 Subject: [PATCH 1/2] Update manager.py cmd to get ip address --- manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manager.py b/manager.py index e10e5675..5c4d8500 100644 --- a/manager.py +++ b/manager.py @@ -779,7 +779,7 @@ def get_ip(machine): :return: """ #print("get_ip") - cmd = "wsl.exe -d " + str(machine) + ' ' + "/bin/sh -c " + '"' + """(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}')""" + '"' + cmd = "wsl.exe -d " + str(machine) + ' ' + "/bin/sh -c " + '"' + """(ip route show | grep default | awk '{print $3}')""" + '"' #print(cmd) @@ -795,7 +795,7 @@ def get_ip(machine): try: ipa = ipaddress.ip_address(result) except: - cmd = "wsl.exe -d " + str(machine) + ' ' + "/bin/sh -c " + '"' + """echo $(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}')""" + '"' + cmd = "wsl.exe -d " + str(machine) + ' ' + "/bin/sh -c " + '"' + """echo $(ip route show | grep default | awk '{print $3}')""" + '"' result = os.popen(cmd).readlines()[0] #result = "localhost" From ef945e5004f4fb5eb561a8e8035512744f7ab5c0 Mon Sep 17 00:00:00 2001 From: CJ Keeney Date: Sat, 20 Jul 2024 11:42:16 -0700 Subject: [PATCH 2/2] Update IP address getter --- assets/GWSL_helper.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/assets/GWSL_helper.sh b/assets/GWSL_helper.sh index e463a463..a7bfeb80 100644 --- a/assets/GWSL_helper.sh +++ b/assets/GWSL_helper.sh @@ -41,19 +41,19 @@ then then # Configure Fish sed -i.bak '/DISPLAY /d' ~/.config/fish/config.fish - echo "set -gx DISPLAY (cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}'):0.0 #GWSL" >> ~/.config/fish/config.fish + echo "set -gx DISPLAY (ip route show | grep default | awk '{print $3}'):0.0 #GWSL" >> ~/.config/fish/config.fish elif [ $wsl_shell == "zsh" ] then # Configure Zsh sed -i.bak '/DISPLAY=/d' ~/.zshrc - echo "export DISPLAY=\$(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}'):0.0 #GWSL" >> ~/.zshrc + echo "export DISPLAY=\$(ip route show | grep default | awk '{print $3}'):0.0 #GWSL" >> ~/.zshrc elif [ $wsl_shell == "bash" ] then # Configure Bash sed -i.bak '/DISPLAY=/d' ~/.profile - echo "export DISPLAY=\$(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}'):0.0 #GWSL" >> ~/.profile + echo "export DISPLAY=\$(ip route show | grep default | awk '{print $3}'):0.0 #GWSL" >> ~/.profile sed -i.bak '/DISPLAY=/d' ~/.bashrc - echo "export DISPLAY=\$(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}'):0.0 #GWSL" >> ~/.bashrc + echo "export DISPLAY=\$(ip route show | grep default | awk '{print $3}'):0.0 #GWSL" >> ~/.bashrc fi fi @@ -91,19 +91,19 @@ then then # Configure Fish sed -i.bak '/PULSE_SERVER /d' ~/.config/fish/config.fish - echo "set -gx PULSE_SERVER tcp:(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}') #GWSL" >> ~/.config/fish/config.fish + echo "set -gx PULSE_SERVER tcp:(ip route show | grep default | awk '{print $3}') #GWSL" >> ~/.config/fish/config.fish elif [ $wsl_shell == "zsh" ] then # Configure Zsh sed -i.bak '/PULSE_SERVER=/d' ~/.zshrc - echo "export PULSE_SERVER=tcp:\$(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}') #GWSL" >> ~/.zshrc + echo "export PULSE_SERVER=tcp:\$(ip route show | grep default | awk '{print $3}') #GWSL" >> ~/.zshrc elif [ $wsl_shell == "bash" ] then # Configure Bash sed -i.bak '/PULSE_SERVER=/d' ~/.profile - echo "export PULSE_SERVER=tcp:\$(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}') #GWSL" >> ~/.profile + echo "export PULSE_SERVER=tcp:\$(ip route show | grep default | awk '{print $3}') #GWSL" >> ~/.profile sed -i.bak '/PULSE_SERVER=/d' ~/.bashrc - echo "export PULSE_SERVER=tcp:\$(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}') #GWSL" >> ~/.bashrc + echo "export PULSE_SERVER=tcp:\$(ip route show | grep default | awk '{print $3}') #GWSL" >> ~/.bashrc fi fi @@ -227,4 +227,4 @@ then else echo "Not recognized" -fi \ No newline at end of file +fi