check for errors on startup in init scripts
check for errors on startup in init scripts

file:a/app.js -> file:b/app.js
--- a/app.js
+++ b/app.js
@@ -21,7 +21,7 @@
 } else if ( app.DEVICES == undefined || app.DEVICES == "" ) {
 	throw new Error('Please fill in DEVICES in /etc/default/piBeacon');
 } else if ( app.DEVICES > 4 ) {
-	throw new Error('Raspberry Pi has only 4 usb ports so maximul 4 devices');
+	throw new Error('Raspberry Pi has only 4 usb ports so maximum 4 devices');
 } else if ( app.MACADDRESS == undefined || app.MACADDRESS == "" ) {
 	throw new Error('Cannot get device eth0 mac address');
 }

--- a/default/piBeacon
+++ b/default/piBeacon
@@ -2,4 +2,3 @@
 NAME="piBeacon demo"
 SERVER=http://demo.razvi.ro/piBeacon/index.php?type=eddystone-url
 INTERVAL=60
-

--- a/init/common
+++ b/init/common
@@ -35,6 +35,20 @@
 start_it() {
 	mkdir -p "$PID_DIR"
 	mkdir -p "$LOG_DIR"
+
+	if [ -z "$DEVICES" ]
+	then
+		log_daemon_msg "Cannot start piBeacon. Please fill in DEVICES in /etc/default/piBeacon"
+		log_end_msg 1
+	elif [ -z "$NAME" ]
+	then
+		log_daemon_msg "Cannot start piBeacon. Please fill in NAME in /etc/default/piBeacon"
+		log_end_msg 1
+	elif [ -z "$INTERVAL" ]
+	then
+		log_daemon_msg "Cannot start piBeacon. Please fill in INTERVAL in /etc/default/piBeacon"
+		log_end_msg 1
+	fi
 
 	if [ $DEVICES -gt "0" ] && [ "$DEVICE_ID" -lt "$DEVICES" ]
 	then

comments