Update provision info, readme stuffs

This commit is contained in:
Shaba Abhiram
2015-02-04 09:57:10 -08:00
parent 867206af53
commit 9fc4e48389
2 changed files with 53 additions and 17 deletions

View File

@@ -12,24 +12,43 @@ This project broadly follows these [instructions](http://www.maketecheasier.com/
## Install
#### Pre-requisites:
Install hostapd and isc-dhcp-server:
```sh
$sudo apt-get update
$sudo apt-get install hostapd isc-dhcp-server
```
#### Fetch raspberry-wifi-conf
```sh
$git clone git@github.com:sabhiram/rpi-connect-to-wifi.git
$cd rpi-connect-to-wifi
$npm update
$npm start
$sudo npm run-script provision
$sudo npm start
```
#### Gotchas
The `hostapd` application does not like to behave itself on some wifi adapters (RTL8192CU et al). This link does a good job explaining the issue and the remedy: [Edimax Wifi Issues](http://willhaley.com/blog/raspberry-pi-hotspot-ew7811un-rtl8188cus/). The gist of what you need to do is as follows:
```
# run iw to detect if you have a non nl80211 driver
$iw list
```
If the above says `nl80211 not found.` - then you probably need to update the `hostapd` binary as follows:
```
$wget http://www.adafruit.com/downloads/adafruit_hostapd.zip
$unzip hostapd.zip
$sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.OLD
$sudo mv hostapd /usr/sbin/hostapd
$sudo chmod 755 /usr/sbin/hostapd
```
Also note that since I run the `rtl871xdrv`, I have this value hard-coded into the `/assets/etc/hostapd/hostapd.conf.template`. For the `nl80211` devices, change the conf template as so:
```
interface={{ wifi_interface }}
driver=nl80211
#driver=rtl871xdrv
```
TODO: Make the server smarter: once dependency checks and provisioning is built into the app, we can do the `iwlist` check and copy the appropriate version of `hostapd`.
## Usage
This is approximately what occurs when we run this app:
@@ -39,12 +58,29 @@ This is approximately what occurs when we run this app:
3. Convert RPI to act as a AP (with a configurable SSID)
4. Host a lightweight HTTP server which allows for the user to connect and configure the RPIs wifi connection. The interfaces exposed are RESTy so other applications can similarly implement their own UIs around the data returned.
5. Once the RPI is successfully configured, reset it to act as a wifi device (not AP anymore), and setup its wifi network based on what the user picked.
6. At this stage, the RPI is named, and has a valid wifi connection which its bound to, reboot the pi and re-run this script on startup.
6. At this stage, the RPI is named, and has a valid wifi connection which its bound to.
Typically, I have the following line in my `/etc/rc.local` file:
```
cd /home/pi/raspberry-wifi-conf
sudo /usr/bin/node server.js
```
Note that this is run in a blocking fashion, in that this script will have to exit before we can proceed with others defined in `rc.local`. This way I can guarantee that other services which might rely on wifi will have said connection before being run. If this is not the case for you, and you just want this to run (if needed) in the background, then you can do:
```
cd /home/pi/raspberry-wifi-conf
sudo /usr/bin/node server.js < /dev/null &
```
## Testing
TODO: Write simple tests for external libs
TODO: Enable TravisCI, Coveralls
```sh
$npm test
```
## TODO
1. Automate the deployment of alternate `hostapd` application
2. Automate provisioning of the application dependencies
3. Make the running of scripts cleaner and more easy to read
4. ifup should never be allowed to fail... same w/ the "start" pieces of various services. Perhaps we need to tease the restart into stop and start and allow the stop to fail.

View File

@@ -5,7 +5,7 @@
"main": "server.js",
"scripts": {
"test": "npm test",
"provision": "apt-get install isc-dhcp-server hostapd -y",
"provision": "apt-get update -y && apt-get install isc-dhcp-server hostapd iw -y",
"bootstrap": "wget http://treebeard.home.net:1234/bootstrap/pifi-conf -O bootstrap.sh && chmod u+x bootstrap.sh && ./bootstrap.sh"
},
"repository": {