mirror of
https://github.com/netfun2000/raspberry-wifi-conf.git
synced 2026-02-27 09:45:16 +08:00
Add run scripts
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
"body-parser": "^1.18.2",
|
||||
"ejs": "^1.0.0",
|
||||
"express": "^4.10.8",
|
||||
"underscore": "^1.7.0"
|
||||
"moment": "^2.19.2",
|
||||
"underscore": "^1.7.0",
|
||||
"wifi-control": "^2.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
47
run.js
Normal file
47
run.js
Normal file
@@ -0,0 +1,47 @@
|
||||
var async = require("async"),
|
||||
wifi_manager = require("./app/wifi_manager")(),
|
||||
dependency_manager = require("./app/dependency_manager")(),
|
||||
config = require("./config.json");
|
||||
wifi_control = require("wifi-control");
|
||||
|
||||
/*****************************************************************************\
|
||||
1. Check for dependencies
|
||||
2. Check to see if we are connected to a wifi AP
|
||||
3. If connected to a wifi, do nothing -> exit
|
||||
4. Convert RPI to act as a AP (with a configurable SSID)
|
||||
5. 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.
|
||||
6. 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.
|
||||
7. 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.
|
||||
\*****************************************************************************/
|
||||
async.series([
|
||||
|
||||
// 1. Check if we have the required dependencies installed
|
||||
function test_deps(next_step) {
|
||||
dependency_manager.check_deps({
|
||||
"binaries": ["dhcpd", "hostapd", "iw"],
|
||||
"files": ["/etc/init.d/isc-dhcp-server"]
|
||||
}, function(error) {
|
||||
if (error) console.log(" * Dependency error, did you run `sudo npm run-script provision`?");
|
||||
next_step(error);
|
||||
});
|
||||
},
|
||||
|
||||
// 4. Host HTTP server while functioning as AP, the "api.js"
|
||||
// file contains all the needed logic to get a basic express
|
||||
// server up. It uses a small angular application which allows
|
||||
// us to choose the wifi of our choosing.
|
||||
function start_http_server(next_step) {
|
||||
console.log("\nHTTP server running...");
|
||||
require("./app/api.js")(wifi_manager, next_step);
|
||||
}
|
||||
], function(error) {
|
||||
if (error) {
|
||||
console.log("ERROR: " + error);
|
||||
}
|
||||
});
|
||||
30
setup.sh
Normal file
30
setup.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
#TODO: read wlan0 instead of hardcode
|
||||
|
||||
#install nodejs9
|
||||
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
|
||||
sudo apt-get install -y nodejs
|
||||
|
||||
#install bower
|
||||
sudo npm install -g bower
|
||||
|
||||
#Create virtual wlan
|
||||
sudo
|
||||
|
||||
#install raspberry-wifi-conf
|
||||
#cd /home/pi/raspberry-wifi-conf
|
||||
npm update
|
||||
bower install
|
||||
sudo npm run-script provision
|
||||
|
||||
#Shutdown dhcpcd for wlan0. TODO: Run this only when necessary
|
||||
#echo "denyinterfaces wlan0" | cat - /etc/dhcpcd.conf > /tmp/out && sudo mv /tmp/out /etc/dhcpcd.conf
|
||||
|
||||
sudo iw dev wlan0 interface add vwlan0 type master
|
||||
|
||||
#TODO: Generate random MAC address
|
||||
sudo ip link set dev vwlan0 address 12:34:56:78:90:12
|
||||
|
||||
#Turn on new vwlan
|
||||
sudo ip link set dev vwlan0 up
|
||||
Reference in New Issue
Block a user