From ef153eeae3807982e6f694ade20a2b841e11496f Mon Sep 17 00:00:00 2001 From: Ruzicka Pavel Date: Thu, 1 Jun 2017 20:31:26 +0200 Subject: [PATCH] push-cardids.sh update --- brmdoor-rpi/push-cardids.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 brmdoor-rpi/push-cardids.sh diff --git a/brmdoor-rpi/push-cardids.sh b/brmdoor-rpi/push-cardids.sh new file mode 100644 index 0000000..47291f3 --- /dev/null +++ b/brmdoor-rpi/push-cardids.sh @@ -0,0 +1,22 @@ +#!/bin/bash +MSG_SUCCESS="Seznam brmkaret byl aktualizovan" + +cat - > /tmp/cards.tmp + +cf=/home/brmdoor/brmdoor/brmdoor-rpi/allowed.list + +if [ `cat /tmp/cards.tmp | wc -l` -le 20 -o `cat /tmp/cards.tmp | wc -l` -ge 100 ]; then + echo "Sanity check error: file length mismatch" + exit 1 +fi + +if [ `diff /tmp/cards.tmp /root/brmdoor/allowed.list | wc -l` -ge 20 ]; then + echo "Sanity check error: too many changes" + exit 1 +fi + +CARDS_COUNT="$(wc -l /tmp/cards.tmp)" +MSG_SUCCESS="${MSG_SUCCESS} (${CARDS_COUNT} cards)" + +cp /tmp/cards.tmp "$cf" && logger "${MSG_SUCCESS}" && echo "${HOSTNAME}: ${MSG_SUCCESS}" +