Advertisement
Guest User

Untitled

a guest
Aug 29th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. # Variables
  2. GPIONUMBER=27
  3. COUNT=0
  4. STARTUPTIME=1
  5. LEDBLINK=100
  6.  
  7. ###############
  8. # Exports pin 27
  9. echo "Exporting pin 27"
  10. gpio export 27 out
  11.  
  12. # Forces LED off
  13. echo "Forcing LED off"
  14. gpio -g write 27 0
  15.  
  16. # Sleeps until startup is finished
  17. echo "Sleeping for $STARTUPTIME second(s) until system is started up..."
  18. sleep $STARTUPTIME
  19.  
  20. # Command to grep ps for 'node'. If found, returns 0, else returns 1.
  21. echo "Grepping 8th row of 'ps -ef' for 'node'. If found running, returns 0, else returns 1."
  22. #ps ax | grep node | grep -q -v grep ; echo $?
  23. ps -ef | awk '{print $8}' | grep node ; echo $?
  24. ###############
  25.  
  26. # Conditional code (If 0; ON, If 1; BLINK)
  27. if [ $? -gt 0 ]
  28. then
  29. echo "Node.js was found to be running. Powering LED on pin 27"
  30. gpio -g write 27 1
  31.  
  32. else
  33. echo "Node.js was not found to be running. Blinking LED $LEDBLINK times on pin 27"
  34. # Code to blink LED $LEDBLINK times
  35. while [ $COUNT -lt $LEDBLINK ]; do
  36. gpio -g write 27 1
  37. sleep 0.05
  38. gpio -g write 27 0
  39. sleep 0.05
  40. COUNT++
  41. done
  42. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement