From 54697a551cd755e51bfc10cc399820176bf3896a Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Mon, 10 Aug 2015 13:29:29 +0200 Subject: [PATCH] [IMP] point_of_sale: migrate the script that sets the rpi leds When the server is answering HTTP requests, the status led (green one) of the Raspberry Pi will turn on. Contrary to the previous script this will not exit and keep running every 5 seconds. This way we can easily troubleshoot connection issues (if led is on and we can't connect it's a network issue, otherwise it's an issue with Odoo). --- .../posbox/overwrite_after_init/etc/rc.local | 2 ++ .../home/pi/led_status.sh | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100755 addons/point_of_sale/tools/posbox/overwrite_before_init/home/pi/led_status.sh diff --git a/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/rc.local b/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/rc.local index 08ca9c555c0..065b6a05f77 100755 --- a/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/rc.local +++ b/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/rc.local @@ -20,4 +20,6 @@ fi mkdir -p /var/run/odoo chown pi:pi /var/run/odoo +/home/pi/led_status.sh & + exit 0 diff --git a/addons/point_of_sale/tools/posbox/overwrite_before_init/home/pi/led_status.sh b/addons/point_of_sale/tools/posbox/overwrite_before_init/home/pi/led_status.sh new file mode 100755 index 00000000000..8d272d7de2b --- /dev/null +++ b/addons/point_of_sale/tools/posbox/overwrite_before_init/home/pi/led_status.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set_brightness() { + echo "${1}" > /sys/class/leds/led0/brightness +} + +check_status_loop() { + while true ; do + if wget --quiet localhost:8069/hw_proxy/hello -O /dev/null ; then + set_brightness 255 + else + set_brightness 0 + fi + sleep 5 + done +} + +echo none > /sys/class/leds/led0/trigger +check_status_loop