Skip to content

Instantly share code, notes, and snippets.

@wincentbalin
Created January 14, 2019 21:07
Show Gist options
  • Save wincentbalin/83749d46ea5aadec6c3dcfd3ff672d21 to your computer and use it in GitHub Desktop.
Save wincentbalin/83749d46ea5aadec6c3dcfd3ff672d21 to your computer and use it in GitHub Desktop.
Mode switcher for USB armory
#!/bin/sh
#
# Function switcher for USB armory
if [ $# -eq 0 -o $# -eq 1 -a \( "$1" != "stick" -a "$1" != "stick-win" -a "$1" != "stick-mac" -a "$1" != "host" \) ]
then
echo "Usage: $0 stick|stick-win|stick-mac|host"
exit 1
fi
if [ `id -u` -ne 0 ]
then
sudo bash $0 "$@"
exit
fi
if [ $1 = "stick" ]
then
echo Switching to stick
ln -sf /boot/imx53-usbarmory-default-4.14.52-0.dtb /boot/imx53-usbarmory.dtb
sed -i -e 's/\(.*\)address .*$/\1address 10.0.0.1/' /etc/network/interfaces
sed -i -e 's/\(.*\)gateway .*$/\1gateway 10.0.0.2/' /etc/network/interfaces
elif [ $1 = "stick-win" ]
then
echo Switching to stick for Windows
ln -sf /boot/imx53-usbarmory-default-4.14.52-0.dtb /boot/imx53-usbarmory.dtb
sed -i -e 's/\(.*\)address .*$/\1address 192.168.137.200/' /etc/network/interfaces
sed -i -e 's/\(.*\)gateway .*$/\1gateway 192.168.137.1/' /etc/network/interfaces
elif [ $1 = "stick-mac" ]
then
echo Switching to stick for MacOSX
ln -sf /boot/imx53-usbarmory-default-4.14.52-0.dtb /boot/imx53-usbarmory.dtb
sed -i -e 's/\(.*\)address .*$/\1address 192.168.2.200/' /etc/network/interfaces
sed -i -e 's/\(.*\)gateway .*$/\1gateway 192.168.2.1/' /etc/network/interfaces
elif [ $1 = "host" ]
then
echo Switching to host
ln -sf /boot/imx53-usbarmory-host-4.14.52-0.dtb /boot/imx53-usbarmory.dtb
sed -i -e 's/\(.*\)wpa-ssid .*$/\1wpa-ssid SSID_of_a_wifi_network' /etc/network/interfaces
sed -i -e 's/\(.*\)wpa-psk .*$/\1wpa-psk PASSWORD_of_a_wifi_network' /etc/network/interfaces
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment