...
Open a terminal application on your Revolution Pi or connect via SSH.
Navigate to the desired directory where you want to create the script using the
cd <directory path>
command. For example:Code Block language bash cd /home/pi/
Create a new empty file with your desired name and the ".sh" file extension using a text editor of your choice. For example:
Code Block language bash nano static_pibridge_mac.sh
Copy the script code into nano text editor.
Code Block language bash #!/bin/bash if [[ $(id -u) != 0 ]]; then echo "usage: sudo $(basename $0)" exit 1 fi pibridge_static_mac() { interface=$1 if [[ $interface != "pileft" && $interface != "piright" ]]; then echo 2>&1 "interface is not a PiBridge interface: ${interface}" exit 3 elif [[ ! -e /sys/class/net/${interface} ]]; then echo 2>&1 "warning: network interface does not exists: ${interface}" fi mac=$(ip l show $interface | grep ether | xargs | cut -f 2 -d ' ' | sed -e 's/://g') mac_hi=${mac:0:8} mac_lo=${mac:8:12} grep -q dtparam=${interface}_mac_hi /boot/config.txt || echo "dtparam=${interface}_mac_hi=0x$mac_hi" >> /boot/config.txt grep -q dtparam=${interface}_mac_lo /boot/config.txt || echo "dtparam=${interface}_mac_lo=0x$mac_lo" >> /boot/config.txt } pibridge_static_mac pileft pibridge_static_mac piright
Save the script by pressing ⌨️ "Ctrl + X", followed by "Y" to save the file and "Enter" to exit the nano Nano text editor.
Enter the following command to make the script executable:
Code Block language bash sudo codechmod +x static_pibridge_mac.sh
This grants the script execution permission.
To run the script, enter the following command:
Code Block code language bash ./static_pibridge_mac.sh
This will start the script and execute the code.
...