aggiunto sistema di invio identificativo installazione per uso statistico

This commit is contained in:
lejubila
2017-06-09 01:59:04 +02:00
parent ced5ba83e8
commit 5a28d129f5
3 changed files with 35 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
Add credentials support to socket server (define TCPSERVER_USER and TCPSERVER_PWD in your config file)
Add management lock/unlock for prevent concurrente call to open/close solenoid
Added the ability to enter an open / close schedule in disabled mode
Add send statistic information to remote server
## 0.3.1 - 13/05/2017
Add experimental support for monostable solenoid valve:

View File

@@ -117,3 +117,7 @@ TCPSERVER_PORT="8084"
# Utente e password che i clients devono utilizzare per stabilire una connessione tramite socket server
TCPSERVER_USER=""
TCPSERVER_PWD=""
# Con impostato il valore 1 non invia l'identificativi per statistiche di utilizzo
NO_SEND_IDENTIFIER=0

View File

@@ -1441,6 +1441,34 @@ function lock {
}
function send_identifier {
if [ "$NO_SEND_IDENTIFIER" == "1" ]; then
return
fi
local FILE_ID="/tmp/pigarden.id"
if [ -f "$FILE_ID" ]; then
# Se il file è più vecchio di un giorno esce
local max_age_file=86400
local time_file=`$STAT -c %Y "$FILE_ID"`
local age_file=$((`date +"%s"` - $time_file ))
if [ "$age_file" -lt "$max_age_file" ]; then
return
fi
else
local ID=`ifconfig | $GREP --color=never -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' | head -1 | md5sum | $CUT -d" " -f 1`
if [ -z "$ID" ]; then
return;
fi
echo "$ID" > "$FILE_ID"
fi
#$CURL https://www.lejubila.net/statistic/usage/piGarden/$ID/$VERSION/$SUB_VERSION/$RELEASE_VERSION > /dev/null
}
#
# Chidue un lock
#
@@ -1487,6 +1515,7 @@ LAST_WARNING_FILE="$STATUS_DIR/last_worning"
LAST_SUCCESS_FILE="$STATUS_DIR/last_success"
# Elimina il file di lock se più vecchio di 11 secondi
if [ -f "$LOCK_FILE" ]; then
max_age_lock_file=11
time_lock_file=`$STAT -c %Y "$LOCK_FILE"`
@@ -1496,6 +1525,7 @@ if [ -f "$LOCK_FILE" ]; then
fi
fi
send_identifier &
case "$1" in
init)