Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Variables
- GPIONUMBER=27
- COUNT=0
- STARTUPTIME=1
- LEDBLINK=100
- ###############
- # Exports pin 27
- echo "Exporting pin 27"
- gpio export 27 out
- # Forces LED off
- echo "Forcing LED off"
- gpio -g write 27 0
- # Sleeps until startup is finished
- echo "Sleeping for $STARTUPTIME second(s) until system is started up..."
- sleep $STARTUPTIME
- # Command to grep ps for 'node'. If found, returns 0, else returns 1.
- echo "Grepping 8th row of 'ps -ef' for 'node'. If found running, returns 0, else returns 1."
- #ps ax | grep node | grep -q -v grep ; echo $?
- ps -ef | awk '{print $8}' | grep node ; echo $?
- ###############
- # Conditional code (If 0; ON, If 1; BLINK)
- if [ $? -gt 0 ]
- then
- echo "Node.js was found to be running. Powering LED on pin 27"
- gpio -g write 27 1
- else
- echo "Node.js was not found to be running. Blinking LED $LEDBLINK times on pin 27"
- # Code to blink LED $LEDBLINK times
- while [ $COUNT -lt $LEDBLINK ]; do
- gpio -g write 27 1
- sleep 0.05
- gpio -g write 27 0
- sleep 0.05
- COUNT++
- done
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement