Skip to content

Commit

Permalink
Fixes to prepare-base.sh for the merged wifi setup (#1242)
Browse files Browse the repository at this point in the history
* Fixes to prepare-base.sh for the merged wifi setup

* Updated to use HERE documents

* Final tweaks for 0.5.0
  • Loading branch information
dhylands authored Aug 2, 2018
1 parent f7618a3 commit 287d1ed
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 73 deletions.
5 changes: 5 additions & 0 deletions image/add-gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ main() {
sudo mv "${ADDONS_DIR}/package" "${ADDONS_DIR}/thing-url-adapter"
rm -rf "${tempdir}"

# Create the .post_upgrade_complete file so that it doesn't try
# to upgrade on the first boot.

sudo touch ${MOZILLA_IOT_DIR}/gateway/.post_upgrade_complete

# Setup things so that the filesystem gets resized
# on the next boot.

Expand Down
52 changes: 0 additions & 52 deletions image/config/dnsmasq.conf

This file was deleted.

6 changes: 0 additions & 6 deletions image/config/hostapd.conf

This file was deleted.

75 changes: 62 additions & 13 deletions image/prepare-base-root.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
#!/bin/bash -e

NVM_VERSION="v0.33.8"
NODE_VERSION="--lts=carbon"

# first we install nvm
cd $HOME
curl -o- https://github.com/raw/creationix/nvm/${NVM_VERSION}/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh" # This loads nvm
nvm install ${NODE_VERSION}
nvm use ${NODE_VERSION}

# Allow node and python3 to use the Bluetooth adapter
setcap cap_net_raw+eip $(eval readlink -f `which node`)
setcap cap_net_raw+eip $(eval readlink -f `which python3`)
Expand All @@ -20,6 +9,66 @@ systemctl disable hostapd.service
systemctl disable dnsmasq.service

# install hostapd and dnsmasq config files
cp config/hostapd.conf /etc/hostapd/hostapd.conf
cp config/dnsmasq.conf /etc/dnsmasq.conf

cat > /etc/hostapd/hostapd.conf <<END
interface=wlan0
driver=nl80211
ssid=Mozilla IoT Gateway
hw_mode=g
# or 1 or 11
channel=6
END
echo 'DAEMON_CONF="/etc/hostapd/hostapd.conf"' >> /etc/default/hostapd

cat > /etc/dnsmasq.conf <<END
# Never forward addresses in the non-routed address spaces.
bogus-priv
# Add other name servers here, with domain specs if they are for
# non-public domains.
server=/local/192.168.220.1
address=/#/192.168.220.1
# Add local-only domains here, queries in these domains are answered
# from /etc/hosts or DHCP only.
local=/local/
# If you want dnsmasq to listen for DHCP and DNS requests only on
# specified interfaces (and the loopback) give the name of the
# interface (eg eth0) here.
# Repeat the line for more than one interface.
interface=wlan0
# Set the domain for dnsmasq. this is optional, but if it is set, it
# does the following things.
# 1) Allows DHCP hosts to have fully qualified domain names, as long
# as the domain part matches this setting.
# 2) Sets the "domain" DHCP option thereby potentially setting the
# domain of all systems configured by DHCP
# 3) Provides the domain part for "expand-hosts"
domain=local
# Uncomment this to enable the integrated DHCP server, you need
# to supply the range of addresses available for lease and optionally
# a lease time. If you have more than one network, you will need to
# repeat this for each network on which you want to supply DHCP
# service.
dhcp-range=192.168.220.2,192.168.220.10,2h
# Override the default route supplied by dnsmasq, which assumes the
# router is the same machine as the one running dnsmasq.
dhcp-option=3,192.168.220.1
#DNS Server
dhcp-option=6,192.168.220.1
# Set the DHCP server to authoritative mode. In this mode it will barge in
# and take over the lease for any client which broadcasts on the network,
# whether it has a record of the lease or not. This avoids long timeouts
# when a machine wakes up on a new network. DO NOT enable this if there's
# the slightest chance that you might end up accidentally configuring a DHCP
# server for your campus/company accidentally. The ISC server uses
# the same option, and this URL provides more information:
# http://www.isc.org/files/auth.html
dhcp-authoritative
END
2 changes: 0 additions & 2 deletions image/prepare-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,4 @@ END
sudo chmod +x /etc/init.d/gateway-iptables.sh
sudo update-rc.d gateway-iptables.sh defaults

../tools/post-upgrade.sh

echo "Done"

0 comments on commit 287d1ed

Please sign in to comment.