diff --git a/README.md b/README.md index faad098..1135145 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/assets/init.d/raspberry-wifi-conf b/assets/init.d/raspberry-wifi-conf new file mode 100644 index 0000000..b6a8236 --- /dev/null +++ b/assets/init.d/raspberry-wifi-conf @@ -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