# Resin Wifi Connect only works if I plug in ethernet first

**URL:** <https://forums.balena.io/t/resin-wifi-connect-only-works-if-i-plug-in-ethernet-first/2771>\
**Category:** Product support\
**Tags:** wifi\
**Created:** [March 21, 2018, 10:31am UTC](https://forums.balena.io/t/resin-wifi-connect-only-works-if-i-plug-in-ethernet-first/2771 "2018-03-21T10:31:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rcullen](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/rcullen/32/859_2.png) [@rcullen](https://forums.balena.io/u/rcullen)\
**Post date:** [March 21, 2018, 10:31am UTC](https://forums.balena.io/t/resin-wifi-connect-only-works-if-i-plug-in-ethernet-first/2771/1 "2018-03-21T10:31:50Z")

</div>

Hey guys, I’ve been working with resin for about a week and am LOVING it. I’ve built out our prototype and am preparing to have them test it back at HQ.

My ideal workflow would be:

1. Send them an \*img.zip file that they can burn to the SD using Etcher
2. Have it boot to [https://github.com/resin-io/resin-wifi-connect](https://github.com/resin-io/resin-wifi-connect) and have them enter SSID/PSK

Right now I’ve been downloading the IMG file from the dashboard but it doesn’t seem to boot the portal until I connect it to wifi and it downloads a bunch of other stuff. These are the first few lines from the logs when it provisions for the first time:

```
27.02.18 18:44:26 (+0100) Applying configuration change {"RESIN_SUPERVISOR_NATIVE_LOGGER":"false"}
27.02.18 18:44:27 (+0100) Creating network 'default'
27.02.18 18:44:27 (+0100) Creating volume 'resin-data'
27.02.18 18:44:27 (+0100) Downloading image 'registry2.resin.io/v2/yadayada@sha256:yadayada'

```

I’ve tried combinations on the cli of `resin init, resin-build, resin-deploy` but it still hasn’t booted as I was hoping.

I have a feeling I’m fundamentally misunderstanding how the code/build/deploy process works and need to build the host and container images first locally so I can burn that IMG to an SD card but I’m a little stuck and hoping you guys can help.

Thanks in advance!

**Dockerfile.template**

```
FROM resin/%%RESIN_MACHINE_NAME%%-node:6-slim

RUN apt-get update && apt-get install -yq --no-install-recommends \
    curl cron iperf3 jq bc speedtest-cli python git wireless-tools vim dnsmasq \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

#switch on systemd init system in container
ENV INITSYSTEM on

COPY . /usr/src/app
COPY package.json package.json
WORKDIR /usr/src/app

# pip install python deps from requirements.txt on the resin.io build server
RUN JOBS=MAX npm install --production --unsafe-perm && npm cache clean && rm -rf /tmp/*
RUN curl https://bootstrap.pypa.io/get-pip.py | python
RUN pip install git+https://github.com/sivel/speedtest-cli.git
RUN pip install pingparsing

# -- Start of resin-wifi-connect section -- #

# Set the device type environment variable using Dockerfile templates
ENV DEVICE_TYPE=%%RESIN_MACHINE_NAME%%

RUN curl https://api.github.com/repos/resin-io/resin-wifi-connect/releases/latest -s \
    | grep -hoP 'browser_download_url": "\K.*%%RESIN_ARCH%%\.tar\.gz' \
    | xargs -n1 curl -Ls \
    | tar -xvz -C /usr/src/app/

# -- End of resin-wifi-connect section -- #

# Provision device to Rails App

RUN sh provision.sh

# Load environment variables into crontab (not working - WIP)
# RUN (crontab -l ; cat /etc/docker.env)| crontab -

# Load cronjobs from crontab file
RUN (crontab -l; cat cronjobs)| crontab -

# start.sh will run when container starts up on the device

CMD ["bash", "start.sh"]

```

**start.sh**

```
#!/usr/bin/env bash

export DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket

# Choose a condition for running WiFi Connect according to your use case:

# 1. Is there a default gateway?
# ip route | grep default

# 2. Is there Internet connectivity?
# nmcli -t g | grep full

# 3. Is there Internet connectivity via a google ping?
# wget --spider http://google.com 2>&1

# 4. Is there an active WiFi connection?
iwgetid -r

if [$? -eq 0]; then
    printf 'Skipping WiFi Connect\n'
else
    printf 'Starting WiFi Connect\n'
    ./wifi-connect --portal-ssid sec-perfmon
fi

npm start
```

---

<div class="post-metadata">

**Author:** ![rcullen](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/rcullen/32/859_2.png) [@rcullen](https://forums.balena.io/u/rcullen)\
**Post date:** [March 21, 2018, 12:53pm UTC](https://forums.balena.io/t/resin-wifi-connect-only-works-if-i-plug-in-ethernet-first/2771/4 "2018-03-21T12:53:43Z")

</div>

Props to @shaunmulligan - I shot him an email with this link and he suggested the following:

```
resin preload resin-perfmon-2.12.3+rev1-dev-v7.1.14.img

```

I then burnt the same file “resin preload resin-perfmon-2.12.3+rev1-dev-v7.1.14.img” to my SD card and it booted as I was hoping!

Perhaps it would make sense to update the instructions on [https://github.com/resin-io/resin-wifi-connect](https://github.com/resin-io/resin-wifi-connect) so complete noobs can get this up and running!

Thanks guys 🙂

---

<div class="post-metadata">

**Author:** ![lucianbuzzo](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/lucianbuzzo/32/615_2.png) [@lucianbuzzo](https://forums.balena.io/u/lucianbuzzo)\
**Post date:** [March 21, 2018, 12:58pm UTC](https://forums.balena.io/t/resin-wifi-connect-only-works-if-i-plug-in-ethernet-first/2771/5 "2018-03-21T12:58:00Z")

</div>

@majorz Perhaps we want to mention this use case on the wifi-connect repo?

---

<div class="post-metadata">

**Author:** ![majorz](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/majorz/32/639_2.png) [@majorz](https://forums.balena.io/u/majorz)\
**Post date:** [March 21, 2018, 3:37pm UTC](https://forums.balena.io/t/resin-wifi-connect-only-works-if-i-plug-in-ethernet-first/2771/7 "2018-03-21T15:37:58Z")

</div>

I included this forum thread in a pending WiFi Connect ticket about improving the docs for running on top of resinOS.
