pass by reference fixed [3]
[brisk.git] / bin / brisk_explain_update.sh
1 #!/bin/bash
2 # set -x
3 export PATH=/home/nastasi/bin:/usr/local/bin:/usr/bin:/bin:/usr/games
4
5 CONFIG_FILE="$HOME/.brisk_install"
6
7 # default values
8 web_url="http://localhost/brisk"
9 admin_password=""
10 if [ -f "$CONFIG_FILE" ]; then
11    source "$CONFIG_FILE"
12    conffile_in="$CONFIG_FILE"
13 fi
14
15 tty -s
16 is_a_tty=$?
17 if [ -z "$admin_password" ]; then
18     if [ "$is_a_tty" -eq 0 ]; then
19         read -s -p "Please insert admin password (no echo): " admin_password
20     else
21         echo "Incomplete configuration"
22         exit 1
23     fi
24 fi
25
26 # now="$(date -d '2014-01-21 23:56:00' +%s)"
27 now="$(date +%s)"
28 delta="86400"
29
30 to="$(date +"%Y-%m-%d+%H:%M:%S" -d @$(echo "($now / 86400) * 86400 + 7200 + $delta" | bc))"
31 from="$(date +"%Y-%m-%d+%H:%M:%S" -d @$(echo "($now / 86400) * 86400 + 7200 - (86400) + $delta" | bc))"
32 # to="$(date +"%Y-%m-%d+%H:%M:%S" -d @$(echo "$now + 7200 + $delta" | bc))"
33 # from="$(date +"%Y-%m-%d+%H:%M:%S" -d @$(echo "$now - 9200 + $delta" | bc))"
34
35 curl -d "pazz=$admin_password" "$web_url/briskin5/stat-day.php?from=$from&to=$to"