Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Otgether Enhancements #31

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions otgether/otgEther.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,22 @@ then
done
fi

# Add the static IP to /etc/dhcpcd.conf
echo -e "interface usb0 \nstatic ip_address=$1" | tee -a /etc/dhcpcd.conf
# Add the static IP to /etc/dhcpcd.conf, if one is set
# This is optional because on Windows in case there is
# a DHCP on the other end
if [ ! -z "$1" ]
then
echo -e "interface usb0 \nstatic ip_address=$1" | tee -a /etc/dhcpcd.conf

# If a second argument is specified, add it as a router
if [ ! -z "$2" ]
then
echo -e "static routers=$2" | tee -a /etc/dhcpcd.conf

# If a third argument is specified, add it as a nameserver
if [ ! -z "$3" ]
then
echo -e "static domain_name_servers=$3"| tee -a /etc/dhcpcd.conf
fi
fi
fi
16 changes: 13 additions & 3 deletions otgether/otgether.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
{
"name": "otgether",
"text": "Set Pi Zero OTG Mode to Ethernet\\nWith Static IP: %1\\nRequires restart to take effect",
"text": "Set Pi Zero OTG Mode to Ethernet\\nStatic IP (optional): %1\\nGateway (optional): %2\\nNameserver (optional): %3\\nRequires restart to take effect",
"script": "otgEther.sh",
"args": [
{
"type": "text",
"default": "169.254.64.64",
"maxLength":19
},
{
"type": "text",
"default": "",
"maxLength":16
},
{
"type": "text",
"default": "",
"maxLength":16
}
],
Expand All @@ -17,6 +27,6 @@
"raspbian-pibakery.img",
"raspbian-lite-pibakery.img"
],
"shortDescription":"Set the Pi Zero to use Ethernet over OTG, with a static IP address.",
"longDescription":"The Raspberry Pi Zero has the ability to support OTG gadget mode over it's DATA usb port. This block enables the Ethernet gadget, allowing your Raspberry Pi to be networked to a computer over USB. You need to specify an IP address for your Raspberr Pi, so that you'll be able to connect to it."
"shortDescription":"Set the Pi Zero to use Ethernet over OTG, optionally with a static IP address. Also optionally set the gateway and nameserver.",
"longDescription":"The Raspberry Pi Zero has the ability to support OTG gadget mode over it's DATA usb port. This block enables the Ethernet gadget, allowing your Raspberry Pi to be networked to a computer over USB. You may specify an IP address (and optionally a netmask in the form XXX.XXX.XXX.XXX/YY) for your Raspberry Pi, so that you'll be able to connect to it. If one is not set, you must have DHCP on the other end. You can also set optional IP addresses for the gateway and nameserver, to enable outbound networking (for example IP Masquerading.) NOTE: in order to set a gateway, a static IP must be set, and in order to set a nameserver, both a static IP and gateway must be set."
}