add service to allow for start / stop / on boot starting of the wifi conf app

This commit is contained in:
Shaba Abhiram
2015-02-07 22:26:06 -08:00
parent ffdde8af5c
commit 119c4d7022
2 changed files with 40 additions and 0 deletions

View File

@@ -20,6 +20,16 @@ $sudo npm run-script provision
$sudo npm start
```
## Setup the app as a service
There is a startup script included to make the server starting and stopping easier. Do remember that the application is assumed to be installed under `/home/pi/raspberry-wifi-conf`. Feel free to change this in the `assets/init.d/raspberry-wifi-conf` file.
```sh
$sudo cp assets/init.d/raspberry-wifi-conf /etc/init.d/raspberry-wifi-conf
$sudo chmod +x /etc/init.d/raspberry-wifi-conf
$sudo update-rc.d raspberry-wifi-conf defaults
```
#### 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:

View File

@@ -0,0 +1,30 @@
#! /bin/sh
# /etc/init.d/raspberry-wifi-conf
### BEGIN INIT INFO
# Provides: raspberry-wifi-conf
# Required-Start: $local_fs $syslog $network
# Required-Stop: $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Script to ensure wifi connectivity
# Description: A NodeJS application to ensure Wifi connectivity by setting the RPI as an AP if needed
### END INIT INFO
# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting raspberry-wifi-conf service"
cd /home/pi/raspberry-wifi-conf
sudo /usr/bin/node server.js > service.log
;;
stop)
echo "Stopping raspberry-wifi-conf service"
;;
*)
echo "Usage: /etc/init.d/raspberry-wifi-conf {start|stop}"
exit 1
;;
esac
exit 0