Page 1 of 1
Could Someone Help Me Reversing What This Script Does Please?
Posted: Mon Feb 12, 2024 7:39 pm
by TLoMatt
Hi there because Groovy Mister appeared I immediately wanted to try it when I was trying to make it work i've noticed that groovy mister needed a static ip for the ethernet port at first i couln't find useful information , then I finally found a mister forum post viewtopic.php?t=1602 in which someone made a script that user says that you only have to open and fill the script ip with the ip you'd like to use so i did , after doing that and opened that script from the scripts folder everything worked like a charm but i've noticed my mister can no longer connect to the wifi network like before so I wanna know how can I reverse this script in order to make my mister work normally like before and also I wanna know which is the best method to set a static ip to the mister ethernet port and if there's a way to have wifi adapter working and if plugged an ethernet using a static ip that script seems to force me using only ethernet port, thanks in advance the script is this:
network_ip_static_eth0.sh
Code: Select all
#!/bin/sh
set -a
# set ip address, subnet mask, standard gateway, dns server and mac address
SIA_IP=192.168.0.77
SIA_SM=255.255.255.0
SIA_GW=192.168.0.1
SIA_NS=8.8.8.8
SIA_MA=02:03:04:05:06:01
# display ip address, subnet mask, standard gateway, dns server and mac address
echo -----------------------------------------
echo Set static IP address for interface wlan0
echo -----------------------------------------
echo "IP address $SIA_IP"
echo "Subnet mask $SIA_SM"
echo "Std gateway $SIA_GW"
echo "DNS server $SIA_NS"
echo "MAC address $SIA_MA"
echo -----------------------------------------
# check if /etc is writeable
if [ ! -w /etc/network/interfaces ]; then
echo
echo ERROR : File /etc/network/interfaces not writeable, run script via ssh shell
echo
exit
fi
# set eth0 static ip address
cat << EOF > /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address $SIA_IP
netmask $SIA_SM
gateway $SIA_GW
dns-nameservers $SIA_NS
EOF
# set dns server
cat << EOF > /etc/init.d/S99staticip
#!/bin/sh
echo 'nameserver $SIA_NS' > /etc/resolv.conf
EOF
chmod 755 /etc/init.d/S99staticip
# disable dhcp client daemon
if [ -f /etc/init.d/S41dhcpcd ]; then
mv /etc/init.d/S41dhcpcd /etc/init.d/disabled.S41dhcpcd
fi
# set eth0 mac address
if [ -f /media/fat/linux/u-boot.txt ]; then
perl -pi -e 'eof && s!$!\nethaddr=$ENV{SIA_MA}! unless s!(ethaddr=)\S+!${1}$ENV{SIA_MA}!;' /media/fat/linux/u-boot.txt
else
echo "ethaddr=$SIA_MA" > /media/fat/linux/u-boot.txt
fi
# power off message
echo
echo POWER MISTER DEVICE OFF + ON
echo
Re: Could Someone Help Me Reversing What This Script Does Please?
Posted: Mon Feb 12, 2024 9:46 pm
by bbond007
Code: Select all
rm /etc/init.d/S99staticip
mv /etc/init.d/disabled.S41dhcpcd /etc/init.d/S41dhcpcd
edit/change it to:
- Untitled.png (12.93 KiB) Viewed 3915 times
ctrl-k x (to save)
Re: Could Someone Help Me Reversing What This Script Does Please?
Posted: Tue Feb 13, 2024 12:36 am
by TLoMatt
Hi bbond007 thanks for the reply I decompressed the file changed it's format to '.sh' , putted in the scripts folder and run it through mister but even though I get this message:
- Whats-App-Image-2024-02-12-at-8-34-25-PM.jpg (77.8 KiB) Viewed 2550 times
Re: Could Someone Help Me Reversing What This Script Does Please?
Posted: Tue Feb 13, 2024 12:56 am
by bbond007
TLoMatt wrote: ↑Tue Feb 13, 2024 12:36 am
Hi bbond007 thanks for the reply I decompressed the file changed it's format to '.sh' , putted in the scripts folder and run it through mister but even though I get this message:
Its not a script but a config file.
I provided the stock /etc/network/interfaces for your reference. You need to edit your file to match with the joe command.
rather than edit (with joe), you could also put it in /media/fat and copy it:
Code: Select all
cp /media/fat/interfaces /etc/network/interfaces
chmod 644 /media/fat/interfaces
Please connect via putty(SSH) or use the F9 console and follow the above instructions implicitly to reverse what this script did --> viewtopic.php?p=83375#p83375
Re: Could Someone Help Me Reversing What This Script Does Please?
Posted: Tue Feb 13, 2024 1:39 am
by bbond007
Honestly,
I think if you really need the ethernet IP to be static, I think it is better to make your changes to the DHCP config in your router. It should allow you to tie a specific MAC address (probably 02:03:04:05:06:01) to a specific IP address. My router is a ASUS RT-N66R, your options may look slightly different. Otherwise when the linux.img updates you'll be no longer be static.
- Untitled.png (19.6 KiB) Viewed 3832 times
I've made mine always 192.168.1.75 (and it worked) in this example:
- Untitled2.png (22.18 KiB) Viewed 3819 times
Your WiFi should have a different MAC address so you can follow the same procedure to make that one static too. If you want.
Hope that helps...
Re: Could Someone Help Me Reversing What This Script Does Please?
Posted: Tue Feb 13, 2024 10:49 am
by yoshi41
There are 3 scripts in the zip file here viewtopic.php?p=49700#p49700.
Code: Select all
network_ip_dhcp.sh (config eth0 and wlan0 with dhcp)
network_ip_static_eth0.sh (config eth0 with static ip)
network_ip_static_wlan0.sh (config wlan0 with static ip)
Setting up static ip for both would require to configure the routing table (the script doesn't do that). Therefore it's necessary to run the corresponding script when switching between static wlan and eth.
To "reverse" the changes (static ip config), just run the dhcp script.
Re: Could Someone Help Me Reversing What This Script Does Please?
Posted: Wed Feb 14, 2024 6:50 pm
by MiSTer Consoles
bbond007 wrote: ↑Tue Feb 13, 2024 1:39 am
Honestly,
I think if you really need the ethernet IP to be static, I think it is better to make your changes to the DHCP config in your router. It should allow you to tie a specific MAC address (probably 02:03:04:05:06:01) to a specific IP address. My router is a ASUS RT-N66R, your options may look slightly different. Otherwise when the linux.img updates you'll be no longer be static.
Untitled.png
I've made mine always 192.168.1.75 (and it worked) in this example:
Untitled2.png
Your WiFi should have a different MAC address so you can follow the same procedure to make that one static too. If you want.
Hope that helps...
To minimize latency when streaming from a PC to Groovy MiSTer it is recommended to set static IPs on both devices and connect them directly thru their ethernet ports bypassing a router altogether. Whenever the MiSTer has to connect to the internet (for updates and such) the ethernet cable would have to be removed from the PC and connected to the router. This is what I do. Unfortunately I'm not sure how a WiFi dongle work work in this type of setup.